• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの


Commit MetaInfo

Revisione1f038c45e496247bd86657fb2ceed3b321fff7e (tree)
Time2009-03-20 03:08:27
Authorshizuki <shizuki@1ca2...>
Commitershizuki

Log Message

Event 'TemplateExtraFields' is indispensable.
No depend. any plugins.
Add <%openidform%> tag.This tag for OpenID login form.

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@988 1ca29b6e-896d-4ea0-84a5-967f57386b96

Change Summary

Incremental Difference

--- a/NP_EzComment2/trunk/NP_EzComment2.php
+++ b/NP_EzComment2/trunk/NP_EzComment2.php
@@ -129,8 +129,8 @@ class NP_EzComment2 extends NucleusPlugin
129129 function getPluginDep()
130130 {
131131 return array(
132- 'NP_OpenId',
133- 'NP_znSpecialTemplateParts',
132+// 'NP_OpenId',
133+// 'NP_znSpecialTemplateParts',
134134 );
135135 }
136136
@@ -195,6 +195,7 @@ class NP_EzComment2 extends NucleusPlugin
195195 'PostAddComment',
196196 'PostDeleteComment',
197197 'PreComment',
198+ 'TemplateExtraFields',
198199 );
199200 }
200201
@@ -296,6 +297,33 @@ class NP_EzComment2 extends NucleusPlugin
296297 }
297298
298299 // }}}
300+ // {{{ event_TemplateExtraFields($data)
301+
302+ /**
303+ * Extra template parts for plugin specified
304+ *
305+ * @param array
306+ * fields array
307+ * 'PLUGIN_NAME' array
308+ * 'TEMPLATE_PARTS_NAME'
309+ * 'TEMPLATE_PARTS_NAME'
310+ * 'TEMPLATE_PARTS_NAME'...
311+ * @return void
312+ */
313+ function event_TemplateExtraFields($data)
314+ {
315+ $data['fields']['NP_EzComment2'] = array(
316+ '_NP_EZCOMMENT2_FORM_LOGGEDIN_IDX' => _NP_EZCOMMENT2_FORM_LOGGEDIN_IDX,
317+ '_NP_EZCOMMENT2_FORM_NOTLOGGEDIN_IDX' => _NP_EZCOMMENT2_FORM_NOTLOGGEDIN_IDX,
318+ '_NP_EZCOMMENT2_FORM_LOGGEDIN_ITM' => _NP_EZCOMMENT2_FORM_LOGGEDIN_ITM,
319+ '_NP_EZCOMMENT2_FORM_NOTLOGGEDIN_ITM' => _NP_EZCOMMENT2_FORM_NOTLOGGEDIN_ITM,
320+ 'COMMENTS_BODY_IDX' => _NP_EZCOMMENT2_COMMENTS_BODY_IDX,
321+ 'COMMENTS_FOOTER_IDX' => _NP_EZCOMMENT2_COMMENTS_FOOTER_IDX,
322+ 'COMMENTS_HEADER_IDX' => _NP_EZCOMMENT2_COMMENTS_HEADER_IDX,
323+ );
324+ }
325+
326+ // }}}
299327 // {{{ event_PostAddComment($data)
300328
301329 /**
@@ -370,9 +398,9 @@ class NP_EzComment2 extends NucleusPlugin
370398 echo '<br /><input type="checkbox" value="1" name="EzComment2_Secret" id="EzComment2_Secret_' . $this->numcalled . '" />';
371399 echo '<label for="EzComment2_Secret_' . $this->numcalled . '">'.$this->getBlogOption($bid, 'secLabel').'</label><br />';
372400 }
373- if ($this->authOpenID) {
374- $this->plugOpenIDdoSkinVar($this->commentSkinType, $this->commentItemId);
375- }
401+// if ($this->authOpenID) {
402+// $this->plugOpenIDdoSkinVar($this->commentSkinType, $this->commentItemId);
403+// }
376404 }
377405
378406 // }}}
@@ -551,7 +579,7 @@ class NP_EzComment2 extends NucleusPlugin
551579 * @param string
552580 * @param integer
553581 * @return void.
554- */
582+ *
555583 function plugOpenIDdoSkinVar($skinType, $iid = 0)
556584 {
557585 global $CONF, $manager, $member;
@@ -597,7 +625,7 @@ class NP_EzComment2 extends NucleusPlugin
597625 }
598626 }
599627
600- // }}}
628+ // }}}*/
601629 // {{{ checkDestinationurl($destinationurl)
602630
603631 /**
@@ -702,20 +730,20 @@ class NP_EzComment2 extends NucleusPlugin
702730 $formFlg = '_IDX';
703731 }
704732 if ($member && $member->isLoggedIn()) {
705- $formType = 'FORM_LOGGEDIN' . $formFlg;
733+ $formType = '_NP_EZCOMMENT2_FORM_LOGGEDIN' . $formFlg;
706734 $loginMember = $member->createFromID($member->getID());
707735 $formdata['membername'] = $this->_hsc($loginMember->getDisplayName());
708736 } else {
709- $formType = 'FORM_NOTLOGGEDIN' . $formFlg;
710- }
711- if ($this->authOpenID && ($skinType == 'item' || $this->numcalled == 0)) {
712- $this->plugOpenIDdoSkinVar($skinType, intval($commentItem->itemid));
737+ $formType = '_NP_EZCOMMENT2_FORM_NOTLOGGEDIN' . $formFlg;
713738 }
739+// if ($this->authOpenID && ($skinType == 'item' || $this->numcalled == 0)) {
740+// $this->plugOpenIDdoSkinVar($skinType, intval($commentItem->itemid));
741+// }
714742 $this->commentItemId = intval($commentItem->itemid);
715743 $this->commentSkinType = $skinType;
716744 $contents = $template[$formType];
717745 include_once($this->getDirectory() . 'EzCommentActions.php');
718- $formAction =& new EzCommentFormActions($commentItem, $formdata, $loginMember);
746+ $formAction =& new EzCommentFormActions($skinType, $commentItem, $formdata, $loginMember);
719747 $parser =& new PARSER($formAction->getAllowedActions(), $formAction);
720748 $parser->parse(&$contents);
721749 }
@@ -948,7 +976,7 @@ class NP_EzComment2 extends NucleusPlugin
948976 * Comment form/list template via NP_znSpecialTemplateParts
949977 *
950978 * @return array
951- */
979+ *
952980 function getTemplateParts()
953981 {
954982 $this->languageInclude();
--- a/NP_EzComment2/trunk/ezcomment2/EzCommentActions.php
+++ b/NP_EzComment2/trunk/ezcomment2/EzCommentActions.php
@@ -1,5 +1,28 @@
11 <?php
2-
2+/**
3+ * SHOW Comment Form/List PLUG-IN FOR NucleusCMS
4+ * PHP versions 5
5+ *
6+ * Form and List template parser
7+ *
8+ * This program is free software; you can redistribute it and/or
9+ * modify it under the terms of the GNU General Public License
10+ * as published by the Free Software Foundation; either version 2
11+ * of the License, or (at your option) any later version.
12+ * (see nucleus/documentation/index.html#license for more info)
13+ *
14+ * @author shizuki
15+ * @copyright 2008 shizuki
16+ * @license http://www.gnu.org/licenses/gpl.txt GNU GENERAL PUBLIC LICENSE Version 2, June 1991
17+ * @version $Date$ $Revision$
18+ * @link http://japan.nucleuscms.org/wiki/plugins:ezcomment2
19+ * @since File available since Release 1.0
20+ */
21+/**
22+ * version history
23+ *
24+ * $Log$
25+ */
326 class EzCommentFormActions extends ACTIONS
427 {
528
@@ -7,12 +30,21 @@ var $commentItem;
730
831 var $loginMember;
932
10- function EzCommentFormActions(&$item, $formdata, $member)
33+var $numcalled;
34+
35+var $authOpenID;
36+
37+ function EzCommentFormActions($skinType, &$item, $formdata, $member)
1138 {
12- $this->ACTIONS('item');
39+ global $manager;
40+ $this->ACTIONS($skinType);
1341 $this->commentItem =& $item;
1442 $this->formdata = $formdata;
1543 $this->loginMember = $member;
44+ $this->numcalled = 0;
45+ if ($manager->pluginInstalled('NP_OpenId')) {
46+ $this->authOpenID = $manager->getPlugin('NP_OpenId');
47+ }
1648 }
1749
1850 function getAllowedActions()
@@ -29,6 +61,7 @@ var $loginMember;
2961 'itemtitle',
3062 'membername',
3163 'memberurl',
64+ 'openidform',
3265 );
3366 }
3467
@@ -72,11 +105,92 @@ var $loginMember;
72105 echo $this->_hsc($this->loginMember->getURL());
73106 }
74107
108+ /**
109+ * Parse callback
110+ */
111+ function parse_callback($eventName, $type)
112+ {
113+ global $manager;
114+ $subscriver =& $manager->subscriptions['FormExtra'];
115+ foreach ($subscriver as $key => $value) {
116+ if (strtoupper($value) == 'NP_OPENID') {
117+ unset($subscriver[$key]);
118+ break;
119+ }
120+ }
121+ $this->numcalled++;
122+ $manager->notify($eventName, array('type' => $type));
123+ }
124+
75125 function _hsc($str)
76126 {
77127 return htmlspecialchars($str, ENT_QUOTES, _CHARSET);
78128 }
79129
130+ function parse_openidform()
131+ {
132+ global $manager;
133+ if ($manager->pluginInstalled('NP_OpenId')) {
134+ $this->plugOpenIDdoSkinVar($this->skintype, $this->commentItem->itemid);
135+ }
136+ }
137+
138+ // {{{ plugOpenIDdoSkinVar()
139+
140+ /**
141+ * Overwride NP_OpenId's doSkinVar()
142+ *
143+ * @param string
144+ * @param integer
145+ * @return void.
146+ */
147+ function plugOpenIDdoSkinVar($skinType, $iid = 0)
148+ {
149+ global $CONF, $manager, $member;
150+ if ($member->isLoggedIn()) return;
151+ if (!($authOpenID = $this->authOpenID)) return;
152+ $ezComment = $manager->getPlugin('NP_EzComment2');
153+ $externalauth = array ( 'source' => $authOpenID->getName() );
154+ $manager->notify('ExternalAuth', array ('externalauth' => &$externalauth));
155+ if (isset($externalauth['result']) && $externalauth['result'] == true) return;
156+ $templateEngine = $authOpenID->_getTemplateEngine();
157+ $aVars = array();
158+ $aVars['PluginURL'] = $CONF['PluginURL'];
159+ if ($authOpenID->isLoggedin()) {
160+ // Loggedin
161+ if ($skinType == 'template') {
162+ require_once 'cles/Template.php';
163+ $templateDirectory = rtrim($ezComment->getDirectory(), '/');
164+ $templateEngine =& new cles_Template($templateDirectory);
165+ $templateEngine->defaultLang = 'english';
166+ $aVars['itemid'] = intval($iid);
167+ }
168+ $nowURL = 'http://' . serverVar("HTTP_HOST")
169+ . serverVar("REQUEST_URI");
170+ $aVars['url'] = $authOpenID->getAdminURL() . 'rd.php?action=rd'
171+ . '&url=' . urlencode($nowURL);
172+ $aVars['nick'] = $authOpenID->loggedinUser['nick'];
173+ $aVars['email'] = $authOpenID->loggedinUser['email'];
174+ $aVars['ts'] = $authOpenID->loggedinUser['ts'];
175+ $aVars['identity'] = $authOpenID->loggedinUser['identity'];
176+ $aVars['visible'] = $aVars['nick'] ? 'false' : 'true' ;
177+ $actionUrl = parse_url($CONF['ActionURL']);
178+ $aVars['updateUrl'] = $actionUrl['path'];
179+ if ($skinType == 'item' || ($skinType == 'template' && $this->numcalled == 0)) {
180+ echo $templateEngine->fetchAndFill('yui', $aVars, 'np_openid');
181+ echo $templateEngine->fetchAndFill('form', $aVars, 'np_openid');
182+ }
183+ echo $templateEngine->fetchAndFill('loggedin', $aVars, 'np_openid');
184+ } elseif (!$authOpenID->isLoggedin()) {
185+ // Not loggedin
186+ $aVars['url'] = $authOpenID->getAdminURL() . 'rd.php?action=doauth'
187+ . '&return_url=' . urlencode(createItemLink(intval($iid)));
188+ echo $templateEngine->fetchAndFill('notloggedin', $aVars, 'np_openid');
189+ }
190+ }
191+
192+ // }}}
193+
80194 }
81195
82196 class EzCommentActions extends COMMENTACTIONS
Show on old repository browser