1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Issue #4336 and tests for e107::plugLan() (e107::lan()) . Error message will be displayed in debug mode when a LAN file failed to load.

This commit is contained in:
Cameron
2021-01-08 09:56:33 -08:00
parent eb2cb9a7cb
commit 452f594ad2
4 changed files with 64 additions and 10 deletions

View File

@@ -3530,10 +3530,9 @@ class e107
}
elseif($fname === true) // admin file.
{
//$fname = "admin/".e_LANGUAGE;
$fname = e_LANGUAGE."_admin";
}
elseif($fname === null)
elseif($fname === null) // BC usage. English.php
{
$fname = e_LANGUAGE;
}
@@ -3567,7 +3566,14 @@ class e107
self::setRegistry($cstring, true);
return self::includeLan($path);
$ret = self::includeLan($path);
if(($ret === false) && defset('E107_DEBUG_LEVEL') > 0)
{
self::getMessage()->addError("Couldn't load: ".$path);
}
return $ret;
}
/**
@@ -3661,7 +3667,7 @@ class e107
* @example e107::lan('gallery', true, true); // Loads e_PLUGIN."gallery/languages/English/English_admin.php (if English is the current language)
* @example e107::lan('gallery', false, true); // Loads e_PLUGIN."gallery/languages/English/English_front.php (if English is the current language)
*/
public static function lan($type, $fname = null, $options = null)
public static function lan($type, $fname = '', $options = null)
{
$options = $options ? true : false;
switch ($type)

View File

@@ -442,13 +442,15 @@ class news {
*/
function render_newsgrid($parm=null)
{
$cacheString = 'nq_news_grid_menu_'.md5(serialize($parm));
$cached = e107::getCache()->retrieve($cacheString);
if(false === $cached)
{
e107::plugLan('news');
e107::plugLan('news', null);
if(is_string($parm))
{

View File

@@ -10,7 +10,14 @@ $tp = e107::getParser();
$template = e107::getCoreTemplate('page','panel');
//TODO Limits and cache etc.
$data = $sql->retrieve("SELECT * FROM #page WHERE page_class IN (".USERCLASS_LIST.") AND FIND_IN_SET('panel', page_template) LIMIT 3", true);
if(!$data = $sql->retrieve("SELECT * FROM #page WHERE page_class IN (".USERCLASS_LIST.") AND FIND_IN_SET('panel', page_template) LIMIT 3", true))
{
if(ADMIN)
{
echo "<div class='alert alert-danger'>There are no page items assigned to the 'panel' template.</div>";
}
return null;
}
//TODO Use shortcodes and template.
foreach($data as $row)

View File

@@ -780,13 +780,52 @@ class e107Test extends \Codeception\Test\Unit
$res = null;
$this->assertTrue($res);
}
*/
public function testPlugLan()
{
$res = null;
$this->assertTrue($res);
}
// Make sure nothing else loaded the language files.
$this->assertFalse(defined('BANNERLAN_19'), 'BANNERLAN_19 is already defined!');
// $this->assertFalse(defined('LAN_FORUM_0002'), 'LAN_FORUM_0002 is already defined!');
$this->assertFalse(defined('LAN_GALLERY_ADMIN_01'), 'LAN_GALLERY_ADMIN_01 is already defined!');
$this->assertFalse(defined('CM_L1'), 'Comment Menu English file already defined');
$this->assertFalse(defined('LAN_FORUM_MENU_001'),'LAN_FORUM_MENU_001 is already defined!');
$this->assertFalse(defined('BNRLAN_11'),'BNRLAN_11 is already defined!');
$this->assertFalse(defined('CHATBOX_L1'),'CHATBOX_L1 is already defined!');
$this->assertTrue(defined('LAN_PLUGIN_GALLERY_SEF_01')); // global so it is defined already.
$e107 = $this->e107;
// Test 1
$e107::plugLan('banner'); // languages/English_front.php
$this->assertTrue(defined('BANNERLAN_19'), 'plugLan() test #1 failed');
// Test 2 - conflict with shortcode testing.
// $e107::plugLan('forum', 'front', true); // languages/English/English_front.php
// $this->assertTrue(defined('LAN_FORUM_0002'),'plugLan() test #2 failed');
// Test 3
$e107::plugLan('gallery', true, true); // languages/English/English_admin.php
$this->assertTrue(defined('LAN_GALLERY_ADMIN_01'),'plugLan() test #3 failed');
// Test 4
$e107::plugLan('forum','menu', true); // languages/English/English_menu.php
$this->assertTrue(defined('LAN_FORUM_MENU_001'),'plugLan() test #4 failed');
// Test 5
$e107::plugLan('banner', true); // languages/English_admin.php
$this->assertTrue(defined('BNRLAN_11'),'plugLan() test #5 failed');
// Test 6
$e107::plugLan('chatbox_menu', e_LANGUAGE); // languages/English/English.php
$this->assertTrue(defined('CHATBOX_L1'),'plugLan() test #6 failed');
// Test 7
$e107::plugLan('comment_menu', null); // languages/English.php - BC path.
$this->assertTrue(defined('CM_L1'), 'plugLan() test #7 failed');
}
/*
public function testThemeLan()
{
$res = null;