diff --git a/e107_handlers/news_class.php b/e107_handlers/news_class.php index 42cf3080e..18b38c11e 100644 --- a/e107_handlers/news_class.php +++ b/e107_handlers/news_class.php @@ -722,20 +722,20 @@ class e_news_tree extends e_front_tree_model /** * Load tree by category id * - * @param integer $category_id + * @param integer $id * @param boolean $force * @param array $params DB query parameters * @return e_news_tree */ - public function load($category_id = 0, $force = false, $params = array()) + public function load($id = 0, $force = false, $params = array()) { - $category_id = intval($category_id); - if(!$this->hasCurrentCategoryId() || $force) $this->setCurrentCategoryId($category_id); + $id = intval($id); + if(!$this->hasCurrentCategoryId() || $force) $this->setCurrentCategoryId($id); $this->setParam('model_class', 'e_news_item') ->setParam('db_order', vartrue($params['db_order'], 'news_datestamp DESC')) ->setParam('db_limit', vartrue($params['db_limit'], '0,10')) - ->setParam('db_where', $category_id ? 'news_category='.$category_id : '') + ->setParam('db_where', $id ? 'news_category='.$id : '') ->setParam('noCacheStringModify', false); return parent::load($force); diff --git a/e107_plugins/featurebox/e_shortcode.php b/e107_plugins/featurebox/e_shortcode.php index 066088df2..4b089792f 100644 --- a/e107_plugins/featurebox/e_shortcode.php +++ b/e107_plugins/featurebox/e_shortcode.php @@ -288,7 +288,7 @@ class featurebox_shortcodes// must match the plugin's folder name. ie. [PLUGIN_F * @param string $parm parameters * @param string $mod category template */ - function sc_featurebox_items($parm, $mod = '') + function sc_featurebox_items($parm=null, $mod = '') { // TODO cache if(!e107::isInstalled('featurebox')) //just in case @@ -304,8 +304,11 @@ class featurebox_shortcodes// must match the plugin's folder name. ie. [PLUGIN_F { $ctemplate = $mod; } - - parse_str($parm, $parm); + + if(!empty($parm)) + { + parse_str($parm, $parm); + } $category = clone $this->getCategoryModel($ctemplate); if(!$category->hasData()) diff --git a/e107_plugins/featurebox/includes/tree.php b/e107_plugins/featurebox/includes/tree.php index 22aa3c3ed..96e0385e5 100644 --- a/e107_plugins/featurebox/includes/tree.php +++ b/e107_plugins/featurebox/includes/tree.php @@ -21,12 +21,12 @@ class plugin_featurebox_tree extends e_tree_model * Load tree data * TODO - system cache * - * @param integer $category_id + * @param integer $id * @param array $options * @param boolean $force * @return plugin_featurebox_tree */ - public function load($category_id, $options = array(), $force = false) + public function load($id=null, $force = false, $options=array()) { if(!$force && !$this->isEmpty()) { @@ -36,13 +36,13 @@ class plugin_featurebox_tree extends e_tree_model $this->setParam('model_class', 'plugin_featurebox_item') ->setParam('model_message_stack', 'featurebox'); - $this->updateParams($options); + // $this->updateParams($options); $order = $this->getParam('random') ? ' ORDER BY rand()' : ' ORDER BY fb_order ASC'; $limit = $this->getParam('limit') ? ' LIMIT '.intval($this->getParam('from'), 0).','.intval($this->getParam('limit')) : ''; $ids = $this->getParam('ids') ? preg_replace('/[^0-9,]/', '', $this->getParam('ids')) : ''; $where = $ids ? ' AND fb_id IN('.$ids.')' : ''; - $qry = 'SELECT SQL_CALC_FOUND_ROWS * FROM #featurebox WHERE fb_category='.intval($category_id).' AND fb_class IN('.USERCLASS_LIST.')'.$where.$order.$limit; + $qry = 'SELECT SQL_CALC_FOUND_ROWS * FROM #featurebox WHERE fb_category='.intval($id).' AND fb_class IN('.USERCLASS_LIST.')'.$where.$order.$limit; $this->setParam('db_query', $qry); parent::loadBatch($force); diff --git a/e107_plugins/hero/e_shortcode.php b/e107_plugins/hero/e_shortcode.php index 32fe32a28..d1266e724 100644 --- a/e107_plugins/hero/e_shortcode.php +++ b/e107_plugins/hero/e_shortcode.php @@ -22,8 +22,8 @@ class hero_shortcodes extends e_shortcode { parent::__construct(); - $pref = e107::pref('hero'); - $this->active = check_class($pref['visibility']); + $visibility = e107::pref('hero', 'visibility'); + $this->active = check_class($visibility); } diff --git a/e107_plugins/log/consolidate.php b/e107_plugins/log/consolidate.php index 6f0800a7d..d71ef6007 100644 --- a/e107_plugins/log/consolidate.php +++ b/e107_plugins/log/consolidate.php @@ -467,7 +467,8 @@ class logConsolidate if($logQry == false) { - list($pageName,$tmp) = explode("?",$pageName); + $tmp = explode("?",$pageName); + $pageName = $tmp[0]; } if(empty($pageName)) diff --git a/e107_plugins/log/e_shortcode.php b/e107_plugins/log/e_shortcode.php index 481049be0..c9df94041 100644 --- a/e107_plugins/log/e_shortcode.php +++ b/e107_plugins/log/e_shortcode.php @@ -82,7 +82,7 @@ class log_shortcodes extends e_shortcode } - function sc_log_pagecounter($parm) + function sc_log_pagecounter($parm=null) { //print_a($this->dbPageInfo); diff --git a/e107_plugins/pm/e_shortcode.php b/e107_plugins/pm/e_shortcode.php index ff50d92c6..8ed2160a9 100644 --- a/e107_plugins/pm/e_shortcode.php +++ b/e107_plugins/pm/e_shortcode.php @@ -38,7 +38,7 @@ class pm_shortcodes extends e_shortcode { $tp = e107::getParser(); - if(!check_class($this->prefs['pm_class'])) + if(!isset($this->prefs['pm_class']) || !check_class($this->prefs['pm_class'])) { return null; } @@ -94,7 +94,7 @@ class pm_shortcodes extends e_shortcode $pm_prefs = e107::getPlugPref('pm'); - $url = e107::url('pm','index').'?send.'.$parm['user']; + $url = e107::url('pm','index').'?send.'.varset($parm['user']); require_once(e_PLUGIN."pm/pm_class.php"); @@ -104,7 +104,7 @@ class pm_shortcodes extends e_shortcode $class = empty($parm['class']) ? 'sendpm btn btn-sm btn-default btn-secondary' : $parm['class']; - if(check_class($pm_prefs['pm_class']) && $pm->canSendTo($parm['user'])) // check $this->pmPrefs['send_to_class']. + if(isset($pm_prefs['pm_class']) && check_class($pm_prefs['pm_class']) && $pm->canSendTo($parm['user'])) // check $this->pmPrefs['send_to_class']. { if(deftrue('FONTAWESOME') && deftrue('BOOTSTRAP')) { diff --git a/e107_plugins/siteinfo/e_shortcode.php b/e107_plugins/siteinfo/e_shortcode.php index 46f8bc3ab..84a918a34 100644 --- a/e107_plugins/siteinfo/e_shortcode.php +++ b/e107_plugins/siteinfo/e_shortcode.php @@ -20,7 +20,7 @@ class siteinfo_shortcodes // must match the folder name of the plugin. $path = (strpos(SITEBUTTON, 'http:') !== false ? SITEBUTTON : e_IMAGE.SITEBUTTON); } - if($parm['type'] == 'email' || $parm == 'email') // (retain {} constants ) + if(varset($parm['type']) == 'email' || $parm == 'email') // (retain {} constants ) { $h = !empty($parm['h']) ? $parm['h'] : 100; @@ -213,7 +213,7 @@ class siteinfo_shortcodes // must match the folder name of the plugin. return $image; } - function sc_theme_disclaimer($parm) + function sc_theme_disclaimer($parm=null) { $pref = e107::getPref(); return (defined('THEME_DISCLAIMER') && $pref['displaythemeinfo'] ? THEME_DISCLAIMER : ''); diff --git a/e107_plugins/social/e_shortcode.php b/e107_plugins/social/e_shortcode.php index 7bcbd5270..2568d67b8 100644 --- a/e107_plugins/social/e_shortcode.php +++ b/e107_plugins/social/e_shortcode.php @@ -426,7 +426,7 @@ class social_shortcodes extends e_shortcode /** * @example {TWITTER_TIMELINE: id=xxxxxxx&theme=light} */ - function sc_twitter_timeline($parm) + function sc_twitter_timeline($parm=null) { $ns = e107::getRender(); diff --git a/e107_tests/tests/unit/e_parse_shortcodeTest.php b/e107_tests/tests/unit/e_parse_shortcodeTest.php index 7bbbf36f8..50588e9d7 100644 --- a/e107_tests/tests/unit/e_parse_shortcodeTest.php +++ b/e107_tests/tests/unit/e_parse_shortcodeTest.php @@ -1503,6 +1503,106 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit } + } + + + public function testAddonShortcodes() + { + $vars = array( + 'gallery' => array( + 'media_caption' => 'caption', + 'media_url' => '{e_IMAGE}logo.png', + 'media_description' => 'diz', + 'media_cat_title' => 'category', + 'media_cat_diz' => 'category description', + 'media_cat_image' => '', + 'media_cat_sef' => 'gallery-cat-sef', + ), + 'pm'=> array( + 'pm_id' => 5, + 'pm_sent' => time(), + 'pm_read' => 0, + 'pm_from' => 1, + 'from_name' => 'admin', + 'pm_to' => 1, + 'pm_block_datestamp' => time(), + 'pm_block_from'=> 2, + 'pm_class' => '0', + ), + + + + + + ); + + + + + + $list = e107::getPlug()->getCorePluginList(); + + foreach($list as $plug) + { + $path = e_PLUGIN.$plug."/e_shortcode.php"; + + if(!file_exists($path) || $plug ==='page' || $plug === 'news') // news/page have their own test for this. + { + continue; + } + + require_once($path); + + try + { + $sc = $this->make($plug.'_shortcodes'); + } + catch (Exception $e) + { + $this->fail($e->getMessage()); + } + + $methods = get_class_methods($sc); + + if(empty($methods)) + { + continue; + } + + if(isset($vars[$plug])) + { + $sc->setVars($vars[$plug]); + } + + foreach($methods as $meth) + { + if(strpos($meth, 'sc_') !== 0) + { + continue; + } + + if(in_array('__construct', $methods)) + { + $sc->__construct(); + } + + $result = $sc->$meth(); + } + + + + + + + + } + + + + + + + } diff --git a/e107_tests/tests/unit/userloginTest.php b/e107_tests/tests/unit/userloginTest.php index 8e0e937d8..8fa32de48 100644 --- a/e107_tests/tests/unit/userloginTest.php +++ b/e107_tests/tests/unit/userloginTest.php @@ -12,6 +12,7 @@ try { + /** @var userlogin lg */ $this->lg = $this->make('userlogin'); }