1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 04:38:27 +01:00

Issue #4350 theme.php class must now use init() and tablestyle() (not __construct() )

This commit is contained in:
Cameron 2021-01-17 07:27:28 -08:00
parent 06888f1fcf
commit f97dd307af
5 changed files with 25 additions and 8 deletions

View File

@ -815,7 +815,7 @@ if (!class_exists('e107table', false))
private $thm;
public function init()
public function _init()
{
$this->legacyThemeClass = e107::getPref('sitetheme'). '_theme'; // disabled at the moment.
$this->adminThemeClass = e107::getPref('admintheme'). '_admintheme'; // Check for a class.
@ -823,6 +823,19 @@ if (!class_exists('e107table', false))
$this->load();
}
// Called in header.
public function init()
{
if(empty($this->thm) || !method_exists($this->thm, 'init'))
{
return null;
}
ob_start(); // don't allow init() to echo.
$this->thm->init();
ob_end_clean();
}
/**
* Load theme class if necessary.
* @return null
@ -853,7 +866,7 @@ if (!class_exists('e107table', false))
if(ADMIN && !$this->thm instanceof e_theme_render)
{
// debug - no need to translate.
echo "<div class='alert alert-danger'>class <b>".$this->themeClass."</b> is missing 'implements e_theme_render'</div>";
echo "<div class='alert alert-danger'>class <b>".$this->themeClass."</b> is missing 'implements e_theme_render'. Make sure there is an init() method also!</div>";
}
}
elseif(class_exists($this->legacyThemeClass)) // legacy v2.x
@ -1406,7 +1419,7 @@ if(!isset($_E107['no_theme']))
}
}
$dbg->logTime("Init Theme Class");
e107::getRender()->init(); // initialize theme class.
e107::getRender()->_init(); // initialize theme class.
if ($pref['anon_post'])
{

View File

@ -16,13 +16,13 @@ if(!defined('USER_AREA'))
//overload is now possible, prevent warnings
define('USER_AREA',TRUE);
}
define('ADMIN_AREA',FALSE);
define('ADMIN_AREA', FALSE);
$e107 = e107::getInstance();
$sql = e107::getDb();
e107::getDebug()->logTime('(Header Top)');
e107::getRender()->init();
//e107::js('core', 'bootstrap/js/bootstrap-tooltip.js','jquery');

View File

@ -3394,6 +3394,8 @@ interface e_theme_config
*/
interface e_theme_render
{
public function init();
public function tablestyle($caption, $text, $mode='', $data=array());
}

View File

@ -27,7 +27,7 @@
$this->assertTrue(false, "Couldn't load e107table object");
}
$this->ns->init();
$this->ns->_init();
}
/*

View File

@ -17,11 +17,10 @@ if(!defined('e107_INIT'))
}
class theme implements e_theme_render
{
function __construct()
public function init()
{
e107::meta('viewport',"width=device-width, initial-scale=1.0");
@ -40,6 +39,8 @@ class theme implements e_theme_render
}
/**
* @param string $caption
* @param string $text
@ -51,6 +52,7 @@ class theme implements e_theme_render
{
$style = is_string($info['setStyle']) ? $info['setStyle'] : ''; // global $style; // no longer needed.
echo "<!-- tablestyle: style=".$style." id=".$id." -->\n\n";