1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 03:10:50 +02:00

Test all e_shortcode.php files in core. PHP8 Fix for featurebox.

This commit is contained in:
Cameron
2021-01-14 10:30:22 -08:00
parent aa3c267ef6
commit e51dfa1fc8
11 changed files with 127 additions and 22 deletions

View File

@@ -722,20 +722,20 @@ class e_news_tree extends e_front_tree_model
/** /**
* Load tree by category id * Load tree by category id
* *
* @param integer $category_id * @param integer $id
* @param boolean $force * @param boolean $force
* @param array $params DB query parameters * @param array $params DB query parameters
* @return e_news_tree * @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); $id = intval($id);
if(!$this->hasCurrentCategoryId() || $force) $this->setCurrentCategoryId($category_id); if(!$this->hasCurrentCategoryId() || $force) $this->setCurrentCategoryId($id);
$this->setParam('model_class', 'e_news_item') $this->setParam('model_class', 'e_news_item')
->setParam('db_order', vartrue($params['db_order'], 'news_datestamp DESC')) ->setParam('db_order', vartrue($params['db_order'], 'news_datestamp DESC'))
->setParam('db_limit', vartrue($params['db_limit'], '0,10')) ->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); ->setParam('noCacheStringModify', false);
return parent::load($force); return parent::load($force);

View File

@@ -288,7 +288,7 @@ class featurebox_shortcodes// must match the plugin's folder name. ie. [PLUGIN_F
* @param string $parm parameters * @param string $parm parameters
* @param string $mod category template * @param string $mod category template
*/ */
function sc_featurebox_items($parm, $mod = '') function sc_featurebox_items($parm=null, $mod = '')
{ {
// TODO cache // TODO cache
if(!e107::isInstalled('featurebox')) //just in case if(!e107::isInstalled('featurebox')) //just in case
@@ -305,7 +305,10 @@ class featurebox_shortcodes// must match the plugin's folder name. ie. [PLUGIN_F
$ctemplate = $mod; $ctemplate = $mod;
} }
parse_str($parm, $parm); if(!empty($parm))
{
parse_str($parm, $parm);
}
$category = clone $this->getCategoryModel($ctemplate); $category = clone $this->getCategoryModel($ctemplate);
if(!$category->hasData()) if(!$category->hasData())

View File

@@ -21,12 +21,12 @@ class plugin_featurebox_tree extends e_tree_model
* Load tree data * Load tree data
* TODO - system cache * TODO - system cache
* *
* @param integer $category_id * @param integer $id
* @param array $options * @param array $options
* @param boolean $force * @param boolean $force
* @return plugin_featurebox_tree * @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()) if(!$force && !$this->isEmpty())
{ {
@@ -36,13 +36,13 @@ class plugin_featurebox_tree extends e_tree_model
$this->setParam('model_class', 'plugin_featurebox_item') $this->setParam('model_class', 'plugin_featurebox_item')
->setParam('model_message_stack', 'featurebox'); ->setParam('model_message_stack', 'featurebox');
$this->updateParams($options); // $this->updateParams($options);
$order = $this->getParam('random') ? ' ORDER BY rand()' : ' ORDER BY fb_order ASC'; $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')) : ''; $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')) : ''; $ids = $this->getParam('ids') ? preg_replace('/[^0-9,]/', '', $this->getParam('ids')) : '';
$where = $ids ? ' AND fb_id IN('.$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); $this->setParam('db_query', $qry);
parent::loadBatch($force); parent::loadBatch($force);

View File

@@ -22,8 +22,8 @@ class hero_shortcodes extends e_shortcode
{ {
parent::__construct(); parent::__construct();
$pref = e107::pref('hero'); $visibility = e107::pref('hero', 'visibility');
$this->active = check_class($pref['visibility']); $this->active = check_class($visibility);
} }

View File

@@ -467,7 +467,8 @@ class logConsolidate
if($logQry == false) if($logQry == false)
{ {
list($pageName,$tmp) = explode("?",$pageName); $tmp = explode("?",$pageName);
$pageName = $tmp[0];
} }
if(empty($pageName)) if(empty($pageName))

View File

@@ -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); //print_a($this->dbPageInfo);

View File

@@ -38,7 +38,7 @@ class pm_shortcodes extends e_shortcode
{ {
$tp = e107::getParser(); $tp = e107::getParser();
if(!check_class($this->prefs['pm_class'])) if(!isset($this->prefs['pm_class']) || !check_class($this->prefs['pm_class']))
{ {
return null; return null;
} }
@@ -94,7 +94,7 @@ class pm_shortcodes extends e_shortcode
$pm_prefs = e107::getPlugPref('pm'); $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"); 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']; $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')) if(deftrue('FONTAWESOME') && deftrue('BOOTSTRAP'))
{ {

View File

@@ -20,7 +20,7 @@ class siteinfo_shortcodes // must match the folder name of the plugin.
$path = (strpos(SITEBUTTON, 'http:') !== false ? SITEBUTTON : e_IMAGE.SITEBUTTON); $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; $h = !empty($parm['h']) ? $parm['h'] : 100;
@@ -213,7 +213,7 @@ class siteinfo_shortcodes // must match the folder name of the plugin.
return $image; return $image;
} }
function sc_theme_disclaimer($parm) function sc_theme_disclaimer($parm=null)
{ {
$pref = e107::getPref(); $pref = e107::getPref();
return (defined('THEME_DISCLAIMER') && $pref['displaythemeinfo'] ? THEME_DISCLAIMER : ''); return (defined('THEME_DISCLAIMER') && $pref['displaythemeinfo'] ? THEME_DISCLAIMER : '');

View File

@@ -426,7 +426,7 @@ class social_shortcodes extends e_shortcode
/** /**
* @example {TWITTER_TIMELINE: id=xxxxxxx&theme=light} * @example {TWITTER_TIMELINE: id=xxxxxxx&theme=light}
*/ */
function sc_twitter_timeline($parm) function sc_twitter_timeline($parm=null)
{ {
$ns = e107::getRender(); $ns = e107::getRender();

View File

@@ -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();
}
}
} }

View File

@@ -12,6 +12,7 @@
try try
{ {
/** @var userlogin lg */
$this->lg = $this->make('userlogin'); $this->lg = $this->make('userlogin');
} }