mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 12:48:24 +01:00
Closes #4141 - Upgraded theme specification for v2.3.0+. See bootstrap3/theme.php for details. Use 'theme' class.
This commit is contained in:
parent
8d73a79427
commit
568d8feb77
41
class2.php
41
class2.php
@ -943,7 +943,8 @@ if (!class_exists('e107table', false))
|
||||
public $eMenuArea;
|
||||
public $eMenuTotal = array();
|
||||
public $eSetStyle;
|
||||
private $themeClass = '';
|
||||
private $themeClass = 'theme'; // v2.3.0+
|
||||
private $legacyThemeClass = '';
|
||||
private $adminThemeClass = '';
|
||||
public $frontend = null;
|
||||
private $uniqueId = null;
|
||||
@ -954,7 +955,7 @@ if (!class_exists('e107table', false))
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->themeClass = 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.
|
||||
}
|
||||
|
||||
@ -1170,6 +1171,22 @@ if (!class_exists('e107table', false))
|
||||
}
|
||||
|
||||
|
||||
private function hasLegacyCode()
|
||||
{
|
||||
$legacy = ['VIEWPORT','THEME_DISCLAIMER', 'IMODE', 'BODYTAG', 'COMMENTLINK', 'OTHERNEWS_LIMIT',
|
||||
'PRE_EXTENDEDSTRING', 'COMMENTOFFSTRING', 'e_SEARCH'];
|
||||
|
||||
foreach($legacy as $const)
|
||||
{
|
||||
if(defined($const))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1181,15 +1198,33 @@ if (!class_exists('e107table', false))
|
||||
private function tablestyle($caption, $text, $mode)
|
||||
{
|
||||
|
||||
|
||||
if(class_exists($this->adminThemeClass) && ($this->frontend == false))
|
||||
{
|
||||
/** @var e_theme_render $thm */
|
||||
$thm = new $this->adminThemeClass();
|
||||
}
|
||||
elseif(class_exists($this->themeClass)) // disabled at the moment.
|
||||
elseif(class_exists($this->themeClass)) // v2.3.0+
|
||||
{
|
||||
|
||||
if(ADMIN && $this->hasLegacyCode()) // debug - no translation needed.
|
||||
{
|
||||
echo "<div class='alert alert-danger'>Please place all theme code inside the <b>theme</b> class. </div>";
|
||||
}
|
||||
|
||||
/** @var e_theme_render $thm */
|
||||
$thm = new $this->themeClass();
|
||||
|
||||
if(ADMIN && !$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>";
|
||||
}
|
||||
}
|
||||
elseif(class_exists($this->legacyThemeClass)) // legacy v2.x
|
||||
{
|
||||
/** @var e_theme_render $thm */
|
||||
$thm = new $this->legacyThemeClass();
|
||||
}
|
||||
|
||||
// Automatic list detection .
|
||||
|
@ -124,7 +124,10 @@ e107::coreLan('admin', true);
|
||||
|
||||
if(e_MENUMANAGER_ACTIVE === true || vartrue($_GET['enc']))
|
||||
{
|
||||
|
||||
if(class_exists('theme')) // v2.3.0+
|
||||
{
|
||||
$tmpTemp = new theme; // load __construct() in case it contains CSS etc.
|
||||
}
|
||||
|
||||
$JSMODAL = <<<TEMPL
|
||||
$(function() {
|
||||
@ -763,6 +766,8 @@ class e_layout
|
||||
$theme = e107::getPref('sitetheme');
|
||||
require_once(e_THEME.$theme."/theme.php");
|
||||
|
||||
|
||||
|
||||
$this->HEADER = $HEADER;
|
||||
$this->FOOTER = $FOOTER;
|
||||
$this->CUSTOMHEADER = $CUSTOMHEADER;
|
||||
|
@ -628,12 +628,19 @@ echo "</head>\n";
|
||||
|
||||
$def = THEME_LAYOUT; // The active layout based on custompage matches.
|
||||
$noBody = false;
|
||||
// v2.2.2 --- Experimental --
|
||||
|
||||
// v2.2.2
|
||||
if($tmp = e_theme::loadLayout(THEME_LAYOUT))
|
||||
{
|
||||
$LAYOUT = $tmp;
|
||||
$noBody = true;
|
||||
unset($tmp);
|
||||
|
||||
if(!class_exists('theme') && ADMIN) // 2.3.0+ required class.
|
||||
{
|
||||
// debug - no translation needed.
|
||||
echo "<div class='alert alert-danger'>Required class <b>theme</b> is missing. See <b>".e_THEME."bootstrap3/theme.php</b> for an example.</div>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -81,7 +81,7 @@ class e_theme
|
||||
|
||||
/**
|
||||
* Load theme layout from html files
|
||||
* Required theme.html file in the theme root directory.
|
||||
* Requires theme.html file in the theme root directory.
|
||||
* @param string $key layout name
|
||||
* @return array|bool
|
||||
*/
|
||||
@ -2042,6 +2042,12 @@ class themeHandler
|
||||
{
|
||||
$this->themeConfigObj = new theme_config();
|
||||
|
||||
if(!$this->themeConfigObj instanceof e_theme_config)
|
||||
{
|
||||
// debug - no need to translate.
|
||||
e107::getMessage()->addWarning("class <b>theme_config</b> is missing 'implements e_theme_config'");
|
||||
}
|
||||
|
||||
if(class_exists('theme_config_form')) // new v2.1.7
|
||||
{
|
||||
$this->themeConfigFormObj = new theme_config_form();
|
||||
@ -3278,11 +3284,12 @@ interface e_theme_config
|
||||
|
||||
/**
|
||||
* Interface e_theme_render
|
||||
* @see e107_themes/bootstrap3/theme.php
|
||||
* @see e107_themes/bootstrap3/admin_theme.php
|
||||
*/
|
||||
interface e_theme_render
|
||||
{
|
||||
public function tablestyle($caption, $text, $mode, $data);
|
||||
public function tablestyle($caption, $text, $mode='', $data=array());
|
||||
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ if(!defined("OTHERNEWS2_THUMB")){
|
||||
}
|
||||
|
||||
if(!defined("OTHERNEWS2_COLS")){
|
||||
// define("OTHERNEWS2_COLS","1");
|
||||
define("OTHERNEWS2_COLS",false);
|
||||
}
|
||||
|
||||
if(!defined("OTHERNEWS2_CELL")){
|
||||
|
@ -64,7 +64,7 @@ $(function() {
|
||||
// e107::js("inline","$('.dropdown-toggle').toggle('slow');");
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if(defined('TEXTDIRECTION') && file_exists(THEME.'/menu/menu_'.strtolower(TEXTDIRECTION).'.css'))
|
||||
{
|
||||
// e107::css('theme','menu/menu_'.strtolower(TEXTDIRECTION).'.css');
|
||||
@ -72,7 +72,7 @@ if(defined('TEXTDIRECTION') && file_exists(THEME.'/menu/menu_'.strtolower(TEXTDI
|
||||
else
|
||||
{
|
||||
// e107::css('theme','menu/menu.css');
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// $register_sc[]='FS_ADMIN_ALT_NAV';
|
||||
@ -82,7 +82,7 @@ $no_core_css = TRUE;
|
||||
class bootstrap3_admintheme implements e_theme_render
|
||||
{
|
||||
|
||||
function tablestyle($caption, $text, $mode, $data)
|
||||
function tablestyle($caption, $text, $mode='', $data=array())
|
||||
{
|
||||
// global $style;
|
||||
|
||||
@ -93,12 +93,12 @@ class bootstrap3_admintheme implements e_theme_render
|
||||
echo "\n\n<!-- UniqueID: ".$data['uniqueId']." -->\n\n";
|
||||
echo "<!-- Style: ".$style." -->\n\n";
|
||||
echo "<!-- Mode: ".(string) $mode." -->";
|
||||
$class = '';
|
||||
/* $class = '';
|
||||
|
||||
if(is_string($mode) && $mode == 'admin_help')
|
||||
{
|
||||
$class = ' ' . str_replace('_', '-', $mode);
|
||||
}
|
||||
}*/
|
||||
|
||||
if($mode == 'core-infopanel_latest' || $mode == 'core-infopanel_status')
|
||||
{
|
||||
@ -280,4 +280,3 @@ $NEWSSTYLE = '
|
||||
';
|
||||
|
||||
*/
|
||||
?>
|
@ -8,7 +8,7 @@
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* @file
|
||||
* Bootstrap 3 Theme for e107 v2.x.
|
||||
* Bootstrap 3 Theme for e107 v2.3.x+.
|
||||
*/
|
||||
|
||||
if(!defined('e107_INIT'))
|
||||
@ -17,7 +17,14 @@ if(!defined('e107_INIT'))
|
||||
}
|
||||
|
||||
|
||||
define('VIEWPORT', "width=device-width, initial-scale=1.0");
|
||||
|
||||
class theme implements e_theme_render
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
|
||||
e107::meta('viewport',"width=device-width, initial-scale=1.0");
|
||||
|
||||
// Load CDN provider for Bootswatch.
|
||||
if($bootswatch = e107::pref('theme', 'bootswatch', false))
|
||||
@ -25,38 +32,22 @@ if($bootswatch = e107::pref('theme', 'bootswatch', false))
|
||||
e107::css('url', 'https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/' . $bootswatch . '/bootstrap.min.css');
|
||||
}
|
||||
|
||||
e107::js("footer-inline", "$('.e-tip').tooltip({container: 'body'});"); // activate bootstrap tooltips.
|
||||
|
||||
/* @example prefetch */
|
||||
//e107::link(array('rel'=>'prefetch', 'href'=>THEME.'images/browsers.png'));
|
||||
|
||||
e107::js("footer-inline", "$('.e-tip').tooltip({container: 'body'});"); // activate bootstrap tooltips.
|
||||
}
|
||||
|
||||
// Legacy Stuff.
|
||||
define('OTHERNEWS_COLS',false); // no tables, only divs.
|
||||
define('OTHERNEWS_LIMIT', 3); // Limit to 3.
|
||||
define('OTHERNEWS2_COLS',false); // no tables, only divs.
|
||||
define('OTHERNEWS2_LIMIT', 3); // Limit to 3.
|
||||
// define('COMMENTLINK', e107::getParser()->toGlyph('fa-comment'));
|
||||
define('COMMENTOFFSTRING', '');
|
||||
|
||||
define('PRE_EXTENDEDSTRING', '<br />');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class bootstrap3_theme
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $caption
|
||||
* @param string $text
|
||||
* @param string $id : id of the current render
|
||||
* @param array $info : current style and other menu data.
|
||||
* @return null
|
||||
*/
|
||||
function tablestyle($caption, $text, $id='', $info=array())
|
||||
public function tablestyle($caption, $text, $id='', $info=array())
|
||||
{
|
||||
|
||||
|
||||
@ -162,24 +153,4 @@ class bootstrap3_theme
|
||||
}
|
||||
|
||||
|
||||
$NEWSCAT = "\n\n\n\n<!-- News Category -->\n\n\n\n
|
||||
<div style='padding:2px;padding-bottom:12px'>
|
||||
<div class='newscat_caption'>
|
||||
{NEWSCATEGORY}
|
||||
</div>
|
||||
<div style='width:100%;text-align:left'>
|
||||
{NEWSCAT_ITEM}
|
||||
</div>
|
||||
</div>
|
||||
";
|
||||
|
||||
|
||||
$NEWSCAT_ITEM = "\n\n\n\n<!-- News Category Item -->\n\n\n\n
|
||||
<div style='width:100%; display:block'>
|
||||
<table style='width:100%'>
|
||||
<tr><td style='width:2px;vertical-align:middle'>• </td>
|
||||
<td style='text-align:left;height:10px'>
|
||||
{NEWSTITLELINK}
|
||||
</td></tr></table></div>
|
||||
";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user