From f2c7bad663b9e8d70c018510b1c376933b3c21bf Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Fri, 2 Nov 2012 00:23:59 +0000 Subject: [PATCH] Updated FAQs plugin to use the right shortcode methods. --- e107_handlers/comment_class.php | 4 +-- e107_handlers/ren_help.php | 2 +- e107_handlers/shortcode_handler.php | 12 +++++++- e107_plugins/faqs/faqs.php | 35 ++++++++++++++-------- e107_plugins/faqs/faqs_shortcodes.php | 32 ++++++++++---------- e107_plugins/faqs/faqs_template.php | 4 +-- e107_plugins/gallery/controllers/index.php | 2 +- page.php | 8 ++--- usersettings.php | 2 +- 9 files changed, 60 insertions(+), 41 deletions(-) diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php index 0d8568e5a..c493ebe38 100644 --- a/e107_handlers/comment_class.php +++ b/e107_handlers/comment_class.php @@ -275,7 +275,7 @@ class comment 'rate' => $rating ); - e107::getScBatch('comment')->setParserVars($data); + e107::getScBatch('comment')->setVars($data); e107::getScBatch('comment')->setMode('edit'); @@ -395,7 +395,7 @@ class comment $row['rating_enabled'] = true; // Toggles rating shortcode. //TODO add pref - e107::getScBatch('comment')->setParserVars($row); + e107::getScBatch('comment')->setVars($row); $COMMENT_TEMPLATE = $this->template; diff --git a/e107_handlers/ren_help.php b/e107_handlers/ren_help.php index 9e6d50776..2726cf35b 100644 --- a/e107_handlers/ren_help.php +++ b/e107_handlers/ren_help.php @@ -114,7 +114,7 @@ function display_help($tagid="helpb", $mode = 1, $addtextfunc = "addtext", $help 'size' => $helpsize ); - $sc->setParserVars($data); + $sc->setVars($data); return "
".$tp->parseTemplate($BBCODE_TEMPLATE)."
"; } diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index b92f22673..ec6ae9c69 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -292,6 +292,12 @@ class e_parse_shortcode $path = ($pluginName ? e_PLUGIN.$pluginName.'/shortcodes/batch/' : e_CORE.'shortcodes/batch/').$_class_fname.'.php'; + $pathBC = e_PLUGIN.$pluginName.'/'.$_class_fname.'.php'; + + if(is_readable($pathBC)) // BC - required. + { + $path = $pathBC; + } if (is_readable($path)) { @@ -914,16 +920,20 @@ class e_shortcode /** * Set external array data to be used in the batch + * Use setVars() - preferred. * * @param array $eVars * @return e_shortcode */ - public function setParserVars($eVars) + public function setParserVars($eVars) //XXX will soon become private. Use setVars() instead. { $this->var = $eVars; return $this; } + /** + * Alias of setParserVars - Preferred use by Plugins. + */ public function setVars($eVars) // Alias of setParserVars(); { return $this->setParserVars($eVars); diff --git a/e107_plugins/faqs/faqs.php b/e107_plugins/faqs/faqs.php index 9473a9e46..18c7eb092 100644 --- a/e107_plugins/faqs/faqs.php +++ b/e107_plugins/faqs/faqs.php @@ -179,15 +179,20 @@ class faq global $FAQ_START, $FAQ_END, $FAQ_LISTALL_START,$FAQ_LISTALL_LOOP,$FAQ_LISTALL_END; - require_once (e_PLUGIN."faqs/faqs_shortcodes.php"); + //require_once (e_PLUGIN."faqs/faqs_shortcodes.php"); $query = "SELECT f.*,cat.* FROM #faqs AS f LEFT JOIN #faqs_info AS cat ON f.faq_parent = cat.faq_info_id WHERE cat.faq_info_class IN (".USERCLASS_LIST.") ORDER BY cat.faq_info_order,f.faq_order "; $sql->db_Select_gen($query); $text = $tp->parseTemplate($FAQ_START, true); $prevcat = ""; + $sc = e107::getScBatch('faqs',TRUE); + + // var_dump($sc); + while ($rw = $sql->db_Fetch()) { - setScVar('faqs_shortcodes', 'row', $rw); + // setScVar('faqs_shortcodes', 'row', $rw); + $sc->setVars($rw); if($rw['faq_info_order'] != $prevcat) { @@ -222,20 +227,20 @@ class faq { global $ns,$row,$FAQ_LIST_START,$FAQ_LIST_LOOP,$FAQ_LIST_END; - $tp = e107::getParser(); - $sql = e107::getDb(); - require_once (e_PLUGIN."faqs/faqs_shortcodes.php"); + $tp = e107::getParser(); + $sql = e107::getDb(); + $sc = e107::getScBatch('faqs',TRUE); $query = "SELECT f.*,cat.* FROM #faqs AS f LEFT JOIN #faqs_info AS cat ON f.faq_parent = cat.faq_info_id WHERE f.faq_parent = '$id' "; $sql->db_Select_gen($query); - - setScVar('faqs_shortcodes', 'row', $row); + $sc->setVars($row); $text = $tp->parseTemplate($FAQ_LIST_START, true); while ($rw = $sql->db_Fetch()) { - setScVar('faqs_shortcodes', 'row', $rw); + // setScVar('faqs_shortcodes', 'var', $rw); + $sc->setVars($rw); $text .= $tp->parseTemplate($FAQ_LIST_LOOP, true); $caption = " Category: ".$rw['faq_info_title'].""; @@ -258,7 +263,8 @@ class faq // ##### Display scrolling list of existing FAQ items --------------------------------------------------------------------------------------------------------- global $FAQ_CAT_START,$FAQ_CAT_PARENT,$FAQ_CAT_CHILD,$FAQ_CAT_END; - require_once (e_PLUGIN."faqs/faqs_shortcodes.php"); + // require_once (e_PLUGIN."faqs/faqs_shortcodes.php"); + $sc = e107::getScBatch('faqs',TRUE); $text = "
"; @@ -278,8 +284,8 @@ class faq $sql->db_Select_gen($qry); while ($row = $sql->db_Fetch()) { - - setScVar('faqs_shortcodes', 'row', $row); + $sc->setVars($row); + // setScVar('faqs_shortcodes', 'row', $row); if ($row['faq_info_parent'] == '0') // { @@ -313,11 +319,14 @@ class faq { global $ns,$row,$sql,$aj,$pref,$cobj,$id,$tp,$FAQ_VIEW_TEMPLATE; - require_once (e_PLUGIN."faqs/faqs_shortcodes.php"); + //require_once (e_PLUGIN."faqs/faqs_shortcodes.php"); + + $sc = e107::getScBatch('faqs',TRUE); $sql->db_Select("faqs", "*", "faq_id='$idx' LIMIT 1"); $row = $sql->db_Fetch(); - setScVar('faqs_shortcodes', 'row', $row); + + $sc->setVars($row); $caption = " FAQ #".$row['faq_id']; $text = $tp->parseTemplate($FAQ_VIEW_TEMPLATE, true); diff --git a/e107_plugins/faqs/faqs_shortcodes.php b/e107_plugins/faqs/faqs_shortcodes.php index 1390216ca..a8fdfeda0 100644 --- a/e107_plugins/faqs/faqs_shortcodes.php +++ b/e107_plugins/faqs/faqs_shortcodes.php @@ -17,12 +17,12 @@ */ if (!defined('e107_INIT')) { exit; } -register_shortcode('faqs_shortcodes', true); -initShortcodeClass('faqs_shortcodes'); +// register_shortcode('faqs_shortcodes', true); +// initShortcodeClass('faqs_shortcodes'); -class faqs_shortcodes +class faqs_shortcodes extends e_shortcode { - var $row; + // var $var; function sc_faq_question($parm='') { @@ -30,13 +30,13 @@ class faqs_shortcodes if($parm == 'expand') { - $id = "faq_".$this->row['faq_id']; - $text = "".$tp->toHtml($this->row['faq_question'])." -
".$tp->toHTML($this->row['faq_answer'],TRUE)."
"; + $id = "faq_".$this->var['faq_id']; + $text = "".$tp->toHtml($this->var['faq_question'])." +
".$tp->toHTML($this->var['faq_answer'],TRUE)."
"; } else { - $text = $tp->toHtml($this->row['faq_question']); + $text = $tp->toHtml($this->var['faq_question']); } return $text; } @@ -44,47 +44,47 @@ class faqs_shortcodes function sc_faq_question_link($parm='') { $tp = e107::getParser(); - return "row['faq_id']."' >".$tp -> toHtml($this->row['faq_question']).""; + return "var['faq_id']."' >".$tp -> toHtml($this->var['faq_question']).""; } function sc_faq_answer() { $tp = e107::getParser(); - return "
".$tp -> toHtml($this->row['faq_answer'])."
"; + return "
".$tp -> toHtml($this->var['faq_answer'])."
"; } function sc_faq_edit() { $tp = e107::getParser(); $faqpref = e107::getPlugConfig('faqs')->getPref(); - if(($faqpref['add_faq'] && $this->row['faq_author'] == USERID) || ADMIN ) + if(($faqpref['add_faq'] && $this->var['faq_author'] == USERID) || ADMIN ) { - return "[ row['faq_id']."'>Edit ]"; + return "[ var['faq_id']."'>Edit ]"; } } function sc_faq_category() { $tp = e107::getParser(); - return "".$tp->toHtml($this->row['faq_info_title']).""; + return "".$tp->toHtml($this->var['faq_info_title']).""; } function sc_faq_catlink() { $tp = e107::getParser(); - return "".($this->row['faq_info_title'] ? $tp -> toHtml($this->row['faq_info_title']) : "[".NWSLAN_42."]").""; + return "".($this->var['faq_info_title'] ? $tp -> toHtml($this->var['faq_info_title']) : "[".NWSLAN_42."]").""; } function sc_faq_count() { $tp = e107::getParser(); - return $this->row['f_count']; + return $this->var['f_count']; } function sc_faq_cat_diz() { $tp = e107::getParser(); - return $tp->toHtml($this->row['faq_info_about'])." "; + return $tp->toHtml($this->var['faq_info_about'])." "; } function sc_faq_icon() diff --git a/e107_plugins/faqs/faqs_template.php b/e107_plugins/faqs/faqs_template.php index de11950ef..7c8af3323 100644 --- a/e107_plugins/faqs/faqs_template.php +++ b/e107_plugins/faqs/faqs_template.php @@ -85,7 +85,7 @@ if(!defined("USER_WIDTH"))
- + {FAQ_QUESTION} @@ -94,7 +94,7 @@ if(!defined("USER_WIDTH"))
- +
{FAQ_ANSWER}
diff --git a/e107_plugins/gallery/controllers/index.php b/e107_plugins/gallery/controllers/index.php index b4ad2d0de..957be86e0 100644 --- a/e107_plugins/gallery/controllers/index.php +++ b/e107_plugins/gallery/controllers/index.php @@ -86,7 +86,7 @@ class plugin_gallery_index_controller extends eControllerFront $text = ""; foreach($this->catList as $val) { - $sc->setParserVars($val); + $sc->setVars($val); $text .= e107::getParser()->parseTemplate($template['CAT_ITEM'],TRUE); } $text = $template['CAT_START'].$text.$template['CAT_END']; diff --git a/page.php b/page.php index be5ee98e6..a45897dc8 100644 --- a/page.php +++ b/page.php @@ -207,7 +207,7 @@ class pageClass $ret['cachecontrol'] = false; $this->authorized = 'nf'; $this->template = e107::getCoreTemplate('page', 'default'); - $this->batch = e107::getScBatch('page')->setParserVars(new e_vars($ret))->setScVar('page', array()); + $this->batch = e107::getScBatch('page')->setVars(new e_vars($ret))->setScVar('page', array()); define("e_PAGETITLE", $ret['title']); return; @@ -248,7 +248,7 @@ class pageClass $ret['err'] = FALSE; $ret['cachecontrol'] = (isset($this->page['page_password']) && !$this->page['page_password'] && $this->authorized === true); // Don't cache password protected pages - $this->batch->setParserVars(new e_vars($ret))->setScVar('page', $this->page); + $this->batch->setVars(new e_vars($ret))->setScVar('page', $this->page); define('e_PAGETITLE', eHelper::formatMetaTitle($ret['title'])); define('META_DESCRIPTION', $this->page['page_metadscr']); @@ -286,7 +286,7 @@ class pageClass if($this->cacheData['COMMENT_FLAG']) { $vars = new e_vars(array('comments' => $this->pageComment(true))); - $comments = e107::getScBatch('page')->setParserVars($vars)->cpagecomments(); + $comments = e107::getScBatch('page')->setVars($vars)->cpagecomments(); } define('e_PAGETITLE', eHelper::formatMetaTitle($this->cacheData['TITLE'])); define('META_DESCRIPTION', $this->cacheData['META_DSCR']); @@ -326,7 +326,7 @@ class pageClass $vars = $this->batch->getParserVars(); // reset batch data - $this->batch->setParserVars(null)->setScVar('page', array()); + $this->batch->setVars(null)->setScVar('page', array()); // copy some data $extend->title = $vars->title; diff --git a/usersettings.php b/usersettings.php index c9a9a1cbd..3960b7cdb 100644 --- a/usersettings.php +++ b/usersettings.php @@ -697,7 +697,7 @@ if (e_QUERY == "update") $text .= "

".str_replace("*", "*", LAN_USET_9)."
".LAN_USET_10."

"; } -// $sc->setParserVars($val); + e107::getScBatch('usersettings')->setVars($curVal); $text .= $tp->parseTemplate($USERSETTINGS_EDIT, TRUE, $usersettings_shortcodes);