1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 21:27:25 +02:00

PHP8 fixes and shortcode tests for forum, gallery, hero and login_menu. admin-shortcode time fix.

This commit is contained in:
Cameron
2021-01-07 13:24:55 -08:00
parent a908ce82b6
commit 3f5d3786b2
10 changed files with 1442 additions and 1080 deletions

View File

@@ -108,7 +108,9 @@ class admin_shortcodes
function sc_admin_docs() function sc_admin_docs()
{ {
if (!ADMIN) { return ''; } if (!ADMIN) { return ''; }
global $ns;
$helplist = array();
$i=1; $i=1;
if (!$handle=opendir(e_DOCS.e_LANGUAGE.'/')) if (!$handle=opendir(e_DOCS.e_LANGUAGE.'/'))
{ {
@@ -125,6 +127,7 @@ class admin_shortcodes
closedir($handle); closedir($handle);
unset($e107_var); unset($e107_var);
$e107_var = array();
foreach ($helplist as $key => $value) foreach ($helplist as $key => $value)
{ {
$e107_var['x'.$key]['text'] = str_replace('_', ' ', $value); $e107_var['x'.$key]['text'] = str_replace('_', ' ', $value);
@@ -136,7 +139,7 @@ class admin_shortcodes
if(function_exists('show_admin_menu')) if(function_exists('show_admin_menu'))
{ {
$text = show_admin_menu(FOOTLAN_14, $act, $e107_var, FALSE, TRUE, TRUE); $text = show_admin_menu(FOOTLAN_14, $act, $e107_var, FALSE, TRUE, TRUE);
return $ns -> tablerender(FOOTLAN_14,$text, array('id' => 'admin_docs', 'style' => 'button_menu'), TRUE); return e107::getRender()->tablerender(FOOTLAN_14,$text, array('id' => 'admin_docs', 'style' => 'button_menu'), TRUE);
} }
} }
@@ -1009,6 +1012,7 @@ class admin_shortcodes
$xml->filter = array('@attributes' => FALSE, 'administration' => FALSE); // .. and they're all going to need the same filter $xml->filter = array('@attributes' => FALSE, 'administration' => FALSE); // .. and they're all going to need the same filter
$nav_sql = new db; $nav_sql = new db;
$tmp = array();
if ($nav_sql ->select('plugin', '*', 'plugin_installflag=1')) if ($nav_sql ->select('plugin', '*', 'plugin_installflag=1'))
{ {
$tmp = array(); $tmp = array();
@@ -1038,9 +1042,9 @@ class admin_shortcodes
} }
// Links Plugins // Links Plugins
if ($eplug_conffile) if(!empty($eplug_conffile))
{ {
$tmp['plug_'.$plugin_id]['text'] = $eplug_caption; $tmp['plug_'.$plugin_id]['text'] = varset($eplug_caption);
$tmp['plug_'.$plugin_id]['link'] = e_PLUGIN.$plugin_path.'/'.$eplug_conffile; $tmp['plug_'.$plugin_id]['link'] = e_PLUGIN.$plugin_path.'/'.$eplug_conffile;
$tmp['plug_'.$plugin_id]['perm'] = 'P'.$plugin_id; $tmp['plug_'.$plugin_id]['perm'] = 'P'.$plugin_id;
} }
@@ -1171,16 +1175,20 @@ class admin_shortcodes
function sc_admin_siteinfo($parm='') function sc_admin_siteinfo($parm='')
{ {
if($parm == 'creditsonly' && e_PAGE != "credits.php" && e_PAGE != "phpinfo.php" && e_PAGE != 'e107_update.php') if($parm == 'creditsonly' && e_PAGE !== "credits.php" && e_PAGE !== "phpinfo.php" && e_PAGE !== 'e107_update.php')
{ {
return null; return null;
} }
if (ADMIN) if (!ADMIN)
{ {
global $ns, $pref, $themename, $themeversion, $themeauthor, $themedate, $themeinfo, $mySQLdefaultdb; return null;
}
global $themename, $themeversion, $themeauthor, $themedate, $themeinfo, $mySQLdefaultdb;
$pref = e107::getPref();
$ns = e107::getRender();
// if (file_exists(e_ADMIN.'ver.php')) // if (file_exists(e_ADMIN.'ver.php'))
{ {
// include(e_ADMIN.'ver.php'); // include(e_ADMIN.'ver.php');
@@ -1191,8 +1199,7 @@ class admin_shortcodes
return e_VERSION; return e_VERSION;
} }
$obj = e107::getDateConvert(); $install_date = e107::getDate()->convert_date($pref['install_date'], '%A %d %B %Y - %H:%M');
$install_date = $obj->convert_date($pref['install_date'], 'long');
if(is_readable(THEME."theme.xml")) if(is_readable(THEME."theme.xml"))
{ {
@@ -1267,7 +1274,7 @@ class admin_shortcodes
"<br />"; "<br />";
return e107::getRender()->tablerender(FOOTLAN_13, $text, '', TRUE); return e107::getRender()->tablerender(FOOTLAN_13, $text, '', TRUE);
}
} }
private function getLastGitUpdate() private function getLastGitUpdate()

View File

@@ -143,9 +143,15 @@
return FALSE; return FALSE;
} }
if ($parms[1] == 'value') if ($parms[1] === 'value')
{ {
$uVal = isset($parms[0]) && isset($udata['user_'.$parms[0]]) ? str_replace(chr(1), '', $udata['user_'.$parms[0]]) : ''; $uVal = isset($parms[0]) && isset($udata['user_'.$parms[0]]) ? str_replace(chr(1), '', $udata['user_'.$parms[0]]) : '';
if(!isset($parms[0]) || !isset($ueStruct["user_".$parms[0]]) || !isset($ueStruct["user_".$parms[0]]['user_extended_struct_type']))
{
return null;
}
switch ($ueStruct["user_".$parms[0]]['user_extended_struct_type']) switch ($ueStruct["user_".$parms[0]]['user_extended_struct_type'])
{ {

View File

@@ -1744,7 +1744,7 @@ class e107
/** /**
* Retrieve date handler singleton object * Retrieve date handler singleton object
* * @deprecated Use e107::getDate();
* @return convert * @return convert
*/ */
public static function getDateConvert() public static function getDateConvert()
@@ -3495,6 +3495,9 @@ class e107
* // import defeinitions from /e107_plugins/myplug/languages/[CurrentLanguage]_admin.php * // import defeinitions from /e107_plugins/myplug/languages/[CurrentLanguage]_admin.php
* e107::plugLan('myplug', true); * e107::plugLan('myplug', true);
* *
* // import defeinitions from /e107_plugins/myplug/languages/[CurrentLanguage].php // FOR BC only.
* e107::plugLan('myplug', null);
*
* // import defeinitions from /e107_plugins/myplug/languages/[CurrentLanguage]/[CurrentLanguage]_front.php * // import defeinitions from /e107_plugins/myplug/languages/[CurrentLanguage]/[CurrentLanguage]_front.php
* e107::plugLan('myplug', 'front', true); * e107::plugLan('myplug', 'front', true);
* *
@@ -3530,6 +3533,10 @@ class e107
//$fname = "admin/".e_LANGUAGE; //$fname = "admin/".e_LANGUAGE;
$fname = e_LANGUAGE."_admin"; $fname = e_LANGUAGE."_admin";
} }
elseif($fname === null)
{
$fname = e_LANGUAGE;
}
else else
{ {
// $fname = e_LANGUAGE; // $fname = e_LANGUAGE;

View File

@@ -1449,7 +1449,8 @@ class e_parse_shortcode
*/ */
private function makeWrapper($ret, $code, $fullShortcodeKey, $sc_mode) private function makeWrapper($ret, $code, $fullShortcodeKey, $sc_mode)
{ {
$pre = $post = ''; $pre = '';
$post = '';
if(!empty($fullShortcodeKey) && !empty($this->wrappers[$fullShortcodeKey]) ) // eg: $NEWS_WRAPPER['view']['item']['NEWSIMAGE: item=1'] if(!empty($fullShortcodeKey) && !empty($this->wrappers[$fullShortcodeKey]) ) // eg: $NEWS_WRAPPER['view']['item']['NEWSIMAGE: item=1']
{ {
@@ -1505,6 +1506,7 @@ class e_parse_shortcode
$this->nowrap = false; $this->nowrap = false;
} }
return $pre.$ret.$post; return $pre.$ret.$post;
} }

View File

@@ -1942,6 +1942,11 @@ class e107forum
function forumGetAllowed($type='view') function forumGetAllowed($type='view')
{ {
if(empty($this->permList[$type]))
{
return array();
}
$sql = e107::getDb(); $sql = e107::getDb();
$forumList = implode(',', $this->permList[$type]); $forumList = implode(',', $this->permList[$type]);
$qry = " $qry = "

File diff suppressed because it is too large Load Diff

View File

@@ -312,7 +312,7 @@ class gallery_shortcodes extends e_shortcode
* limit - (optional) total limit of pcitures to be shown * limit - (optional) total limit of pcitures to be shown
* template - (optional) template - name of template to be used for parsing the slideshow item * template - (optional) template - name of template to be used for parsing the slideshow item
*/ */
function sc_gallery_slides($parm) function sc_gallery_slides($parm=null)
{ {
$plugPrefs = e107::getPlugConfig('gallery')->getPref(); $plugPrefs = e107::getPlugConfig('gallery')->getPref();
$orderBy = varset($plugPrefs['orderby'], 'media_id DESC'); $orderBy = varset($plugPrefs['orderby'], 'media_id DESC');
@@ -359,7 +359,7 @@ class gallery_shortcodes extends e_shortcode
} }
function sc_gallery_jumper($parm) function sc_gallery_jumper($parm=null)
{ {
// echo "SlideCount=".$this->slideCount; // echo "SlideCount=".$this->slideCount;
if($this->slideCount == 1 && deftrue('E107_DBG_BASIC')) if($this->slideCount == 1 && deftrue('E107_DBG_BASIC'))

View File

@@ -7,7 +7,7 @@ if (!defined('e107_INIT')) { exit; }
class plugin_hero_hero_shortcodes extends e_shortcode class plugin_hero_hero_shortcodes extends e_shortcode
{ {
public $count; public $count =0;
/** /**
* {hero_ID} * {hero_ID}
@@ -52,7 +52,7 @@ class plugin_hero_hero_shortcodes extends e_shortcode
{ {
$target = !empty($parm['target']) ? $parm['target'] : 'carousel-hero'; $target = !empty($parm['target']) ? $parm['target'] : 'carousel-hero';
$class = !empty($parm['class']) ? $parm['class'] : ''; $class = !empty($parm['class']) ? $parm['class'] : '';
$total = (int) $this->var['hero_total_slides']; $total = (int) vartrue($this->var['hero_total_slides'], 0);
if(empty($total)) if(empty($total))
{ {
@@ -81,7 +81,7 @@ class plugin_hero_hero_shortcodes extends e_shortcode
public function sc_hero_slide_active($parm=null) public function sc_hero_slide_active($parm=null)
{ {
return $this->var['hero_slide_active']; return varset($this->var['hero_slide_active']);
} }
public function sc_hero_slide_interval($parm=null) public function sc_hero_slide_interval($parm=null)
@@ -135,7 +135,8 @@ class plugin_hero_hero_shortcodes extends e_shortcode
public function sc_hero_text() public function sc_hero_text()
{ {
return e107::getParser()->toHTML($this->var['hero_bullets'][$this->count]['text'],true,'BODY'); $count = (int) $this->count;
return e107::getParser()->toHTML($this->var['hero_bullets'][$count]['text'],true,'BODY');
} }
@@ -209,12 +210,12 @@ class plugin_hero_hero_shortcodes extends e_shortcode
/** /**
* {HERO_BULLETS} * {HERO_BULLETS}
*/ *//*
public function sc_hero_bullets($parm=null) public function sc_hero_bullets($parm=null)
{ {
return $this->var['hero_bullets']; return $this->var['hero_bullets'];
} }
*/
/** /**
* {hero_BUTTON1_xxxx} * {hero_BUTTON1_xxxx}

View File

@@ -17,6 +17,7 @@
if (!defined('e107_INIT')) { exit(); } if (!defined('e107_INIT')) { exit(); }
global $tp; global $tp;
e107::plugLan('login_menu', null);
// BC LAN Fix. // BC LAN Fix.
@@ -190,7 +191,7 @@ e107::getLanguage()->bcDefs($bcDefs);
if($parm == "hidden"){ if($parm == "hidden"){
return "<input type='hidden' name='autologin' id='autologin' value='1' />"; return "<input type='hidden' name='autologin' id='autologin' value='1' />";
} }
if($pref['user_tracking'] != "session") if(varset($pref['user_tracking']) !== "session")
{ {
return "<label for='autologin'><input type='checkbox' name='autologin' id='autologin' value='1' checked='checked' />".($parm ? $parm : "".LAN_LOGINMENU_6."</label>"); return "<label for='autologin'><input type='checkbox' name='autologin' id='autologin' value='1' checked='checked' />".($parm ? $parm : "".LAN_LOGINMENU_6."</label>");
} }
@@ -252,9 +253,11 @@ e107::getLanguage()->bcDefs($bcDefs);
{ {
if(ADMIN) if(ADMIN)
{ {
$data = e107::getRegistry('login_menu_data'); if($data = e107::getRegistry('login_menu_data'))
{
return $parm == 'src' ? $data['link_bullet_src'] : $data['link_bullet']; return $parm == 'src' ? $data['link_bullet_src'] : $data['link_bullet'];
} }
}
return ''; return '';
} }
@@ -276,7 +279,11 @@ e107::getLanguage()->bcDefs($bcDefs);
function sc_lm_bullet($parm='') function sc_lm_bullet($parm='')
{ {
$data = e107::getRegistry('login_menu_data'); if(!$data = e107::getRegistry('login_menu_data'))
{
return null;
}
return $parm == 'src' ? $data['link_bullet_src'] : $data['link_bullet']; return $parm == 'src' ? $data['link_bullet_src'] : $data['link_bullet'];
} }
@@ -323,6 +330,7 @@ e107::getLanguage()->bcDefs($bcDefs);
global $menu_pref, $login_menu_shortcodes, $LOGIN_MENU_EXTERNAL_LINK; global $menu_pref, $login_menu_shortcodes, $LOGIN_MENU_EXTERNAL_LINK;
$tp = e107::getParser(); $tp = e107::getParser();
require_once(e_PLUGIN."login_menu/login_menu_class.php");
$lmc = new login_menu_class; $lmc = new login_menu_class;
if(!vartrue($menu_pref['login_menu']['external_links'])) if(!vartrue($menu_pref['login_menu']['external_links']))
@@ -361,6 +369,12 @@ e107::getLanguage()->bcDefs($bcDefs);
function sc_lm_external_link($parm='') function sc_lm_external_link($parm='')
{ {
$lbox_item = e107::getRegistry('login_menu_linkdata'); $lbox_item = e107::getRegistry('login_menu_linkdata');
if(empty($lbox_item['link_url']))
{
return null;
}
return $parm == 'href' ? $lbox_item['link_url'] : '<a href="'.$lbox_item['link_url'].'" class="login_menu_link external" id="login_menu_link_external_'.$lbox_item['link_id'].'">'.vartrue($lbox_item['link_label'], '['.LAN_LOGINMENU_44.']').'</a>'; return $parm == 'href' ? $lbox_item['link_url'] : '<a href="'.$lbox_item['link_url'].'" class="login_menu_link external" id="login_menu_link_external_'.$lbox_item['link_id'].'">'.vartrue($lbox_item['link_label'], '['.LAN_LOGINMENU_44.']').'</a>';
} }
@@ -372,11 +386,17 @@ e107::getLanguage()->bcDefs($bcDefs);
function sc_lm_stats($parm='') function sc_lm_stats($parm='')
{ {
$tp = e107::getParser(); $tp = e107::getParser();
global $LOGIN_MENU_STATS; global $LOGIN_MENU_STATS;
$data = e107::getRegistry('login_menu_data'); $data = e107::getRegistry('login_menu_data');
if(!$data['enable_stats']) return '';
return $tp -> parseTemplate($LOGIN_MENU_STATS, true, $this); if(empty($data['enable_stats']) || empty($LOGIN_MENU_STATS))
{
return '';
}
return $tp->parseTemplate($LOGIN_MENU_STATS, true, $this);
} }
function sc_lm_new_news($parm='') function sc_lm_new_news($parm='')
@@ -439,7 +459,7 @@ e107::getLanguage()->bcDefs($bcDefs);
global $tp, $menu_pref, $new_total, $LOGIN_MENU_STATITEM, $LM_STATITEM_SEPARATOR; global $tp, $menu_pref, $new_total, $LOGIN_MENU_STATITEM, $LM_STATITEM_SEPARATOR;
if(!vartrue($menu_pref['login_menu']['external_stats'])) return ''; if(!vartrue($menu_pref['login_menu']['external_stats'])) return '';
require_once(e_PLUGIN."login_menu/login_menu_class.php");
$lm = new login_menu_class; $lm = new login_menu_class;
$lbox_infos = $lm->parse_external_list(true, false); $lbox_infos = $lm->parse_external_list(true, false);
@@ -483,11 +503,20 @@ e107::getLanguage()->bcDefs($bcDefs);
} }
function sc_lm_listnew_link($parm='') function sc_lm_listnew_link($parm = '')
{ {
$data = e107::getRegistry('login_menu_data');
if($parm == 'href') return $data['listnew_link']; if(!$data = e107::getRegistry('login_menu_data'))
return $data['listnew_link'] ? '<a href="'.$data['listnew_link'].'" class="login_menu_link listnew" id="login_menu_link_listnew">'.LAN_LOGINMENU_24.'</a>' : ''; {
return null;
}
if($parm === 'href')
{
return $data['listnew_link'];
}
return $data['listnew_link'] ? '<a href="' . $data['listnew_link'] . '" class="login_menu_link listnew" id="login_menu_link_listnew">' . LAN_LOGINMENU_24 . '</a>' : '';
} }

View File

@@ -907,31 +907,236 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit
} }
public function testForumViewShortcodes()
{
require_once(e_PLUGIN."forum/shortcodes/batch/view_shortcodes.php");
try
{
/** @var plugin_forum_view_shortcodes $sc */
$sc = $this->make('plugin_forum_view_shortcodes');
}
catch (Exception $e)
{
$this->fail($e->getMessage());
}
$vars = array(
'forum_id' => '2',
'forum_name' => 'Parent Number Two',
'forum_description' => 'Forum Description',
'forum_parent' => '0',
'forum_sub' => '0',
'forum_datestamp' => '1367304545',
'forum_moderators' => '248',
'forum_threads' => '0',
'forum_replies' => '0',
'forum_lastpost_user' => '0',
'forum_lastpost_user_anon' => NULL,
'forum_lastpost_info' => '',
'forum_class' => '253',
'forum_order' => '300',
'forum_postclass' => '253',
'forum_threadclass' => '0',
'forum_options' => '',
'forum_sef' => 'parent-number-two',
'forum_image' => NULL,
'forum_icon' => NULL,
'thread_id' => '1',
'thread_name' => '3 Duis tempus enim vitae magna placerat vel dapibus tellus feugiat.',
'thread_forum_id' => '4',
'thread_views' => '53',
'thread_active' => '1',
'thread_lastpost' => '1434584999',
'thread_sticky' => '0',
'thread_datestamp' => '1367307189',
'thread_user' => '2',
'thread_user_anon' => NULL,
'thread_lastuser' => '1',
'thread_lastuser_anon' => NULL,
'thread_total_replies' => '7',
'thread_options' => NULL,
'post_id' => '1',
'post_entry' => '4 Morbi eleifend auctor quam, ac consequat ipsum dictum vitae. Curabitur egestas lacinia mi, in venenatis mi euismod eu.',
'post_thread' => '1',
'post_forum' => '4',
'post_status' => '0',
'post_datestamp' => '1367307189',
'post_user' => '2',
'post_edit_datestamp' => NULL,
'post_edit_user' => NULL,
'post_ip' => NULL,
'post_user_anon' => NULL,
'post_attachments' => NULL,
'post_options' => NULL
);
$sc->__construct();
$sc->setVars($vars);
$this->processShortcodeMethods($sc);
}
public function testGalleryShortcodes()
{
require_once(e_PLUGIN."gallery/e_shortcode.php");
try
{
/** @var gallery_shortcodes $sc */
$sc = $this->make('gallery_shortcodes');
}
catch (Exception $e)
{
$this->fail($e->getMessage());
}
$vars = array(
'media_id' => '227',
'media_type' => 'image/jpeg',
'media_name' => 'gasmask.jpg',
'media_caption' => 'gasmask.jpg',
'media_description' => '',
'media_category' => '_common_image',
'media_datestamp' => '1464646050',
'media_author' => '1',
'media_url' => '{e_THEME}voux/install/gasmask.jpg',
'media_size' => '91054',
'media_dimensions' => '1200 x 830',
'media_userclass' => '0',
'media_usedby' => '',
'media_tags' => '',
'media_cat_id' => '1',
'media_cat_owner' => '_common',
'media_cat_category' => '_common_image',
'media_cat_title' => '(Common Images)',
'media_cat_sef' => '',
'media_cat_diz' => 'Media in this category will be available in all areas of admin.',
'media_cat_class' => '253',
'media_cat_image' => '',
'media_cat_order' => '0'
);
$sc->setVars($vars);
$exclude = array('sc_gallery_slides'); // uses a counter.
$this->processShortcodeMethods($sc, $exclude);
}
public function testHeroShortcodes()
{
require_once(e_PLUGIN."hero/hero_shortcodes.php");
try
{
/** @var plugin_hero_hero_shortcodes $sc */
$sc = $this->make('plugin_hero_hero_shortcodes');
}
catch (Exception $e)
{
$this->fail($e->getMessage());
}
$vars = array(
'hero_id' => '1',
'hero_title' => 'A [powerful] &amp; [free] hero area',
'hero_description' => '[Easy] to Use',
'hero_bg' => '{e_MEDIA_IMAGE}2020-12/4.sm.webp',
'hero_media' => '{e_MEDIA_IMAGE}2020-12/horse.jpg',
'hero_bullets' => e107::unserialize('[
{
"icon": "fa-sun-o.glyph",
"icon_style": "warning",
"text": "Add some bullet text",
"animation": "fadeInRight",
"animation_delay": "15"
},
{
"icon": "fa-font-awesome.glyph",
"icon_style": "success",
"text": "Select an Icon from FontAwesome or others",
"animation": "fadeInRight",
"animation_delay": "25"
},
{
"icon": "fa-adjust.glyph",
"icon_style": "danger",
"text": "Choose a Style from Bootstrap",
"animation": "fadeInRight",
"animation_delay": "35"
},
{
"icon": "",
"icon_style": "",
"text": "",
"animation": "",
"animation_delay": "0"
},
{
"icon": "",
"icon_style": "",
"text": "",
"animation": "",
"animation_delay": "0"
}
]'),
'hero_button1' => e107::unserialize('{
"icon": "fa-",
"label": "",
"url": "",
"class": ""
}'),
'hero_button2' => e107::unserialize('{
"icon": "fa-",
"label": "",
"url": "",
"class": ""
}'),
'hero_order' => '1',
'hero_class' => '0'
);
$sc->setVars($vars);
// $exclude = array('sc_gallery_slides'); // uses a counter.
$this->processShortcodeMethods($sc);
}
public function testLoginMenuShortcodes()
{
require_once(e_PLUGIN."login_menu/login_menu_shortcodes.php");
try
{
/** @var login_menu_shortcodes $sc */
$sc = $this->make('login_menu_shortcodes');
}
catch (Exception $e)
{
$this->fail($e->getMessage());
}
$this->processShortcodeMethods($sc);
}
/* /*
e107_plugins\faqs/
faqs_shortcodes.php (1 usage found)
1 <?php
e107_plugins\forum\shortcodes\batch (4 usages found)
forum_shortcodes.php (1 usage found)
1 <?php
post_shortcodes.php (1 usage found)
1 <?php
view_shortcodes.php (1 usage found)
1 <?php
viewforum_shortcodes.php (1 usage found)
1 <?php
e107_plugins\forum\todelete (2 usages found)
forum_post_shortcodes.php (1 usage found)
1 <?php
forum_shortcodes.php (1 usage found)
1 <?php
e107_plugins\gallery\shortcodes\batch (1 usage found)
gallery_shortcodes.php (1 usage found)
1 <?php
e107_plugins\hero (1 usage found)
hero_shortcodes.php (1 usage found)
1 <?php
e107_plugins\links_page (1 usage found) e107_plugins\links_page (1 usage found)
links_page_shortcodes.php (1 usage found) links_page_shortcodes.php (1 usage found)
1 <?php 1 <?php