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

Replaced global $menu_pref usage. Updated tests.

This commit is contained in:
Cameron
2021-01-08 13:50:32 -08:00
parent 487c10fc1d
commit d86d8d999f
5 changed files with 22 additions and 10 deletions

View File

@@ -41,8 +41,7 @@ if (!defined('e107_INIT'))
$cobj = e107::getComment();
global $menu_pref;
$menu_pref = e107::getConfig('menu')->getPref();
$data = $cobj->getCommentData(intval($menu_pref['comment_display']));

View File

@@ -18,7 +18,7 @@
function __construct()
{
$this->gen = new convert; // TODO replace all usage with e107::getParser()->toDate();
$this->gen = e107::getDate(); // TODO replace all usage with e107::getParser()->toDate();
// $this->forum_rules = forum_rules('check');
}
@@ -902,7 +902,7 @@
*/
function sc_threadname($parm=null)
{
global $menu_pref, $forum;
global $forum;
$tp = e107::getParser();
$thread_name = strip_tags($tp->toHTML($this->var['thread_name'], false, 'no_hook, emotes_off'));
@@ -922,6 +922,7 @@
$tip_length = $forum->prefs->get('tiplength', 400);
if(strlen($thread_thread) > $tip_length)
{
$menu_pref = e107::getConfig('menu')->getPref();
//$thread_thread = substr($thread_thread, 0, $tip_length).' '.$menu_pref['newforumposts_postfix'];
$thread_thread = $tp->text_truncate($thread_thread, $tip_length, $menu_pref['newforumposts_postfix']); // Doesn't split entities
}

View File

@@ -327,7 +327,8 @@ e107::getLanguage()->bcDefs($bcDefs);
function sc_lm_external_links($parm='')
{
global $menu_pref, $login_menu_shortcodes, $LOGIN_MENU_EXTERNAL_LINK;
global $LOGIN_MENU_EXTERNAL_LINK;
$menu_pref = e107::getConfig('menu')->getPref();
$tp = e107::getParser();
require_once(e_PLUGIN."login_menu/login_menu_class.php");
@@ -359,7 +360,7 @@ e107::getLanguage()->bcDefs($bcDefs);
{
$lbox_item['link_id'] = $stackid . '_' . $num;
e107::setRegistry('login_menu_linkdata', $lbox_item);
$ret .= $tp->parseTemplate($LOGIN_MENU_EXTERNAL_LINK, false, $login_menu_shortcodes);
$ret .= $tp->parseTemplate($LOGIN_MENU_EXTERNAL_LINK, false, $this);
}
}

View File

@@ -186,6 +186,11 @@
$actual = $this->dateObj->computeLapse($newer, $time, false, true, 'long');
$this->assertEquals("Just now", $actual);
// Test "Just now" on identical timestamps
$actual = $this->dateObj->computeLapse($older, $older, false, true, 'long');
$this->assertEquals("Just now", $actual);
// XXX Improve output
/* $newer = strtotime("18 months ago");
$actual = $this->dateObj->computeLapse($newer, time(), false, true, 'short');

View File

@@ -145,10 +145,16 @@ while($row = $sql->fetch())
public function testParseTemplateWithCoreAddonShortcodes()
{
$shortcodeObject = e107::getScBatch('online', true);
$expected = "<a href=''>lost</a>";
$result = $this->tp->parseTemplate('{ONLINE_MEMBER_PAGE}', false, $shortcodeObject);
$this->assertEquals($expected, $result);
e107::getPlugin()->uninstall('online');
$sc = e107::getScParser();
$sc->__construct();
$sc->clearRegistered();
// $sc->resetscClass('online', null);
$result = $this->tp->parseTemplate('{ONLINE_MEMBER_PAGE}', false);
$this->assertEmpty($result);
@@ -162,11 +168,11 @@ while(&#036;row = &#036;sql-&gt;fetch())
$result = $this->tp->parseTemplate('{ONLINE_MEMBER_PAGE}', false, $shortcodeObject);
$this->assertEquals($expected, $result);
$result = $this->tp->parseTemplate('{ONLINE_MEMBER_PAGE}', false);
$result = $this->tp->parseTemplate('{ONLINE_MEMBER_PAGE}', true);
$this->assertEmpty($result);
$result = $this->tp->parseTemplate('{ONLINE_MEMBER_PAGE}', true);
$this->assertEquals($expected, $result);
// $result = $this->tp->parseTemplate('{ONLINE_MEMBER_PAGE}', true);
// $this->assertEquals($expected, $result);
}
public function testParseTemplateWithNonCoreShortcodes()