1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 05:07:27 +02: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; private $thm;
public function init() public function _init()
{ {
$this->legacyThemeClass = e107::getPref('sitetheme'). '_theme'; // disabled at the moment. $this->legacyThemeClass = e107::getPref('sitetheme'). '_theme'; // disabled at the moment.
$this->adminThemeClass = e107::getPref('admintheme'). '_admintheme'; // Check for a class. $this->adminThemeClass = e107::getPref('admintheme'). '_admintheme'; // Check for a class.
@@ -823,6 +823,19 @@ if (!class_exists('e107table', false))
$this->load(); $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. * Load theme class if necessary.
* @return null * @return null
@@ -853,7 +866,7 @@ if (!class_exists('e107table', false))
if(ADMIN && !$this->thm instanceof e_theme_render) if(ADMIN && !$this->thm instanceof e_theme_render)
{ {
// debug - no need to translate. // 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 elseif(class_exists($this->legacyThemeClass)) // legacy v2.x
@@ -1406,7 +1419,7 @@ if(!isset($_E107['no_theme']))
} }
} }
$dbg->logTime("Init Theme Class"); $dbg->logTime("Init Theme Class");
e107::getRender()->init(); // initialize theme class. e107::getRender()->_init(); // initialize theme class.
if ($pref['anon_post']) if ($pref['anon_post'])
{ {

View File

@@ -22,7 +22,7 @@ $e107 = e107::getInstance();
$sql = e107::getDb(); $sql = e107::getDb();
e107::getDebug()->logTime('(Header Top)'); e107::getDebug()->logTime('(Header Top)');
e107::getRender()->init();
//e107::js('core', 'bootstrap/js/bootstrap-tooltip.js','jquery'); //e107::js('core', 'bootstrap/js/bootstrap-tooltip.js','jquery');

View File

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

View File

@@ -27,7 +27,7 @@
$this->assertTrue(false, "Couldn't load e107table object"); $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 class theme implements e_theme_render
{ {
function __construct() public function init()
{ {
e107::meta('viewport',"width=device-width, initial-scale=1.0"); 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 $caption
* @param string $text * @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. $style = is_string($info['setStyle']) ? $info['setStyle'] : ''; // global $style; // no longer needed.
echo "<!-- tablestyle: style=".$style." id=".$id." -->\n\n"; echo "<!-- tablestyle: style=".$style." id=".$id." -->\n\n";