mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 03:40:37 +02:00
CustomPage settings working correctly now. The constant THEME_LAYOUT added. (Will be used by menus later)
This commit is contained in:
38
class2.php
38
class2.php
@@ -9,8 +9,8 @@
|
||||
* General purpose file
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/class2.php,v $
|
||||
* $Revision: 1.99 $
|
||||
* $Date: 2009-07-06 08:45:19 $
|
||||
* $Revision: 1.100 $
|
||||
* $Date: 2009-07-07 16:04:39 $
|
||||
* $Author: e107coders $
|
||||
*
|
||||
*/
|
||||
@@ -925,6 +925,40 @@ if (isset($_COOKIE['e107_tzOffset']))
|
||||
|
||||
define('TIMEOFFSET', $e_deltaTime);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
if(!defined("THEME_LAYOUT"))
|
||||
{
|
||||
$def = ""; // no custom pages found yet.
|
||||
|
||||
if(is_array($pref['sitetheme_custompages'])) // check if we match a page in layout custompages.
|
||||
{
|
||||
foreach($pref['sitetheme_custompages'] as $layout=>$cusPageArray)
|
||||
{
|
||||
foreach($cusPageArray as $kpage)
|
||||
{
|
||||
if ($kpage && (strstr(e_SELF, $kpage) || strstr(e_SELF."?".e_QUERY,$kpage)))
|
||||
{
|
||||
$def = ($layout) ? $layout : "no_array";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($def) // custom-page layout.
|
||||
{
|
||||
define("THEME_LAYOUT",$def);
|
||||
}
|
||||
else // default layout.
|
||||
{
|
||||
define("THEME_LAYOUT",varset($pref['sitetheme_deflayout'])); // default layout.
|
||||
}
|
||||
unset($def);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
$sql->db_Mark_Time('Start: Get menus');
|
||||
if(!isset($_E107['no_menus']))
|
||||
{
|
||||
|
@@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_admin/menus.php,v $
|
||||
| $Revision: 1.17 $
|
||||
| $Date: 2009-07-07 12:54:44 $
|
||||
| $Revision: 1.18 $
|
||||
| $Date: 2009-07-07 16:04:42 $
|
||||
| $Author: e107coders $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -147,7 +147,7 @@ function menuActivate()
|
||||
global $sql, $admin_log, $pref;
|
||||
|
||||
$location = key($_POST['menuActivate']);
|
||||
echo "LAYOUT= ".$_POST['curLayout'] ;
|
||||
|
||||
$layout = ($_POST['curLayout'] != $pref['sitetheme_deflayout']) ? $_POST['curLayout'] : "";
|
||||
|
||||
$menu_count = $sql->db_Count("menus", "(*)", " WHERE menu_location=".$location." AND menu_layout = '$layout' ");
|
||||
@@ -160,14 +160,14 @@ function menuActivate()
|
||||
$row=$sql->db_Fetch();
|
||||
//If menu is not already activated in that area, add the record.
|
||||
|
||||
if(!$sql->db_Update('menus', "menu_order='{$menu_count}', menu_location = ".$location." WHERE menu_name='".$row['menu_name']."' AND menu_layout = '$layout' LIMIT 1 ",TRUE))
|
||||
if(!$sql->db_Update('menus', "menu_order='{$menu_count}', menu_location = ".$location." WHERE menu_name='".$row['menu_name']."' AND menu_layout = '$layout' LIMIT 1 "))
|
||||
{
|
||||
$qry = "
|
||||
INSERT into #menus
|
||||
(`menu_name`, `menu_location`, `menu_order`, `menu_pages`, `menu_path`, `menu_layout`)
|
||||
VALUES ('{$row['menu_name']}', {$location}, {$menu_count}, '', '{$row['menu_path']}', '{$layout}')
|
||||
";
|
||||
$sql->db_Select_gen($qry,TRUE);
|
||||
$sql->db_Select_gen($qry);
|
||||
$admin_log->log_event('MENU_01',$row['menu_name'].'[!br!]'.$location.'[!br!]'.$menu_count.'[!br!]'.$row['menu_path'],E_LOG_INFORMATIVE,'');
|
||||
$menu_count++;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ function menuSetCustomPages($array)
|
||||
{
|
||||
global $pref;
|
||||
$key = key($array);
|
||||
$pref['sitetheme_custompages'][$key] = $array[$key];
|
||||
$pref['sitetheme_custompages'][$key] = array_filter(explode(" ",$array[$key]));
|
||||
save_prefs();
|
||||
}
|
||||
|
||||
@@ -656,7 +656,7 @@ function layout_list()
|
||||
if($curLayout && ($curLayout != $pref['sitetheme_deflayout']))
|
||||
{
|
||||
|
||||
if(!$pref['sitetheme_custompages'][$curLayout])
|
||||
if(!isset($pref['sitetheme_custompages'][$curLayout]))
|
||||
{
|
||||
if(isset($pref['sitetheme_layouts'][$curLayout]['customPages']))
|
||||
{
|
||||
@@ -679,7 +679,7 @@ function layout_list()
|
||||
$custPages = $pref['sitetheme_custompages'][$curLayout];
|
||||
}
|
||||
|
||||
$text .= "<div style='padding:10px'>Displays on these pages: <input type='text' style='width:80%;color:black;background-color:white' name='custompages[".$curLayout."]' value=\"".$custPages."\" />
|
||||
$text .= "<div style='padding:10px'>Displays on these pages: <input type='text' style='width:80%;color:black;background-color:white' name='custompages[".$curLayout."]' value=\"".implode(" ",$custPages)."\" />
|
||||
<input type='submit' name='menuSetCustomPages' value='".LAN_SAVE."' />
|
||||
</div>";
|
||||
}
|
||||
|
@@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/theme_handler.php,v $
|
||||
| $Revision: 1.24 $
|
||||
| $Date: 2009-07-07 02:25:05 $
|
||||
| $Revision: 1.25 $
|
||||
| $Date: 2009-07-07 16:04:45 $
|
||||
| $Author: e107coders $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -525,10 +525,10 @@ class themeHandler{
|
||||
if(!$pref['sitetheme_deflayout'])
|
||||
{
|
||||
$pref['sitetheme_deflayout'] = ($val['@attributes']['default']=='true') ? $key : "";
|
||||
// echo "------------- NODEFAULT";
|
||||
}
|
||||
}
|
||||
$itext .= "<td style='vertical-align:top width:auto;text-align:center'>\n";
|
||||
|
||||
$itext .= "
|
||||
<td style='vertical-align:top width:auto;text-align:center'>
|
||||
<input type='radio' name='layout_default' value='{$key}' ".($pref['sitetheme_deflayout']==$key ? " checked='checked'" : "")." />
|
||||
</td>";
|
||||
}
|
||||
@@ -706,15 +706,16 @@ class themeHandler{
|
||||
|
||||
function setTheme()
|
||||
{
|
||||
global $pref, $e107cache, $ns;
|
||||
global $pref, $e107cache, $ns, $sql;
|
||||
$themeArray = $this -> getThemes("id");
|
||||
|
||||
$pref['sitetheme'] = $themeArray[$this -> id];
|
||||
$pref['themecss'] ='style.css';
|
||||
$pref['sitetheme_deflayout'] = $this->findDefault($themeArray[$this -> id]);
|
||||
$pref['sitetheme_layouts'] = is_array($this->themeArray[$pref['sitetheme']]['layouts']) ? $this->themeArray[$pref['sitetheme']]['layouts'] : array();
|
||||
$pref['sitetheme_custompages'] = $this->themeArray[$pref['sitetheme']]['custompages'];
|
||||
|
||||
|
||||
$sql -> db_Delete("menus", "menu_layout !='' ");
|
||||
|
||||
$e107cache->clear_sys();
|
||||
save_prefs();
|
||||
@@ -725,12 +726,14 @@ class themeHandler{
|
||||
|
||||
function findDefault($theme)
|
||||
{
|
||||
|
||||
if(varset($_POST['layout_default']))
|
||||
{
|
||||
return $_POST['layout_default'];
|
||||
}
|
||||
|
||||
$l = $this->themeArray[$theme];
|
||||
|
||||
foreach($l['layouts'] as $key=>$val)
|
||||
{
|
||||
if(isset($val['@attributes']['default']) && ($val['@attributes']['default'] == "true"))
|
||||
@@ -755,7 +758,7 @@ class themeHandler{
|
||||
|
||||
function setStyle()
|
||||
{
|
||||
global $pref, $e107cache, $ns;
|
||||
global $pref, $e107cache, $ns, $sql;
|
||||
$pref['themecss'] = $_POST['themecss'];
|
||||
$pref['image_preload'] = $_POST['image_preload'];
|
||||
$pref['sitetheme_deflayout'] = $_POST['layout_default'];
|
||||
@@ -818,10 +821,36 @@ class themeHandler{
|
||||
$css = strtolower($match[2]);
|
||||
$themeArray['csscompliant'] = ($css == "true" ? true : false);
|
||||
|
||||
/* preg_match('/CUSTOMPAGES(\s*?=\s*?)("|\')(.*?)("|\');/si', $themeContents, $match);
|
||||
$themeArray['custompages'] = array_filter(explode(" ",$match[3]));*/
|
||||
|
||||
$themeContentsArray = explode("\n",$themeContents);
|
||||
|
||||
if (!$themeArray['name'])
|
||||
{
|
||||
unset($themeArray);
|
||||
}
|
||||
// echo " <hr>".$path."<hr>";
|
||||
|
||||
foreach($themeContentsArray as $line)
|
||||
{
|
||||
if(strstr($line,"CUSTOMPAGES"))
|
||||
{
|
||||
eval(str_replace("$","\\$",$line));
|
||||
}
|
||||
}
|
||||
if(is_array($CUSTOMPAGES))
|
||||
{
|
||||
foreach($CUSTOMPAGES as $key=>$val)
|
||||
{
|
||||
$themeArray['custompages'][$key] = explode(" ",$val);
|
||||
}
|
||||
}
|
||||
elseif($CUSTOMPAGES)
|
||||
{
|
||||
$themeArray['custompages']['no_array'] = explode(" ",$CUSTOMPAGES);
|
||||
}
|
||||
|
||||
$themeArray['path'] = $path;
|
||||
|
||||
return $themeArray;
|
||||
@@ -867,6 +896,10 @@ class themeHandler{
|
||||
$name = $val['@attributes']['name'];
|
||||
unset($val['@attributes']['name']);
|
||||
$lays[$name] = $val;
|
||||
if(isset($val['customPages']))
|
||||
{
|
||||
$custom[$name] = array_filter(explode(" ",$val['customPages']));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -874,11 +907,17 @@ class themeHandler{
|
||||
$name = $layout['@attributes']['name'];
|
||||
unset($layout['@attributes']['name']);
|
||||
$lays[$name] = $layout;
|
||||
if(isset($val['customPages']))
|
||||
{
|
||||
$custom[$name] = array_filter(explode(" ",$layout['customPages']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$vars['layouts'] = $lays;
|
||||
$vars['path'] = $path;
|
||||
$vars['custompages'] = $custom;
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<area id='1' >
|
||||
<menu name='login' />
|
||||
<menu name='compliance' />
|
||||
<menu name='online' userclass='E_UC_MEMBER' />
|
||||
<menu name='online' userclass='e_UC_MEMBER' />
|
||||
</area>
|
||||
<area id='2'>
|
||||
<menu name='poll' />
|
||||
@@ -28,6 +28,7 @@
|
||||
<menu name='powered_by' />
|
||||
</area>
|
||||
</menuPresets>
|
||||
<customPages>news.php usersettings.php</customPages>
|
||||
</layout>
|
||||
</layouts>
|
||||
</e107Theme>
|
@@ -6,8 +6,8 @@
|
||||
| Released under the terms and conditions of the GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_themes/templates/header_default.php,v $
|
||||
| $Revision: 1.31 $
|
||||
| $Date: 2009-07-07 12:54:47 $
|
||||
| $Revision: 1.32 $
|
||||
| $Date: 2009-07-07 16:04:51 $
|
||||
| $Author: e107coders $
|
||||
+-----------------------------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -447,56 +447,28 @@ if ($e107_popup != 1) {
|
||||
//
|
||||
|
||||
// ---------- New in 0.8 -------------------------------------------------------
|
||||
$def = ""; // no custom pages found yet.
|
||||
|
||||
function checkCustomPages($urlBits) // Function for checking URL matches.
|
||||
$def = THEME_LAYOUT;
|
||||
|
||||
// echo "DEF = ".$def;
|
||||
|
||||
if(($def == 'no_array') && (isset($CUSTOMHEADER) || isset($CUSTOMFOOTER)) ) // 0.6 themes.
|
||||
{
|
||||
if(is_array($urlBits)) return FALSE;
|
||||
|
||||
$tpages = explode(" ",$urlBits);
|
||||
foreach($tpages as $kpage)
|
||||
{
|
||||
if ($kpage && (strstr(e_SELF, $kpage) || strstr(e_SELF."?".e_QUERY,$kpage)))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(is_array($pref['sitetheme_custompages'])) // check if we match a page in layout custompages.
|
||||
{
|
||||
foreach($pref['sitetheme_custompages'] as $layout=>$cusPages)
|
||||
{
|
||||
if(checkCustomPages($cusPages))
|
||||
{
|
||||
$def = ($layout) ? $layout : "no_array";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$def) // no custompage match, so load the default.
|
||||
{
|
||||
$def = varset($pref['sitetheme_deflayout']); // default layout.
|
||||
}
|
||||
|
||||
// The Above should be put into Class2, so it can interact with the menu loading.
|
||||
|
||||
|
||||
if($def && is_array($HEADER) && isset($HEADER[$def]) && isset($FOOTER[$def])) // 0.8 themes - we always use $HEADER and $FOOTER.
|
||||
{
|
||||
$HEADER = $HEADER[$def];
|
||||
$FOOTER = $FOOTER[$def];
|
||||
// echo " MODE 0.6";
|
||||
$HEADER = ($CUSTOMHEADER) ? $CUSTOMHEADER : $HEADER;
|
||||
$FOOTER = ($CUSTOMFOOTER) ? $CUSTOMFOOTER : $FOOTER;
|
||||
}
|
||||
elseif($def && $def != "no_array" && (isset($CUSTOMHEADER[$def]) || isset($CUSTOMHEADER[$def]))) // 0.7 themes
|
||||
{
|
||||
// echo " MODE 0.7";
|
||||
$HEADER = ($CUSTOMHEADER[$def]) ? $CUSTOMHEADER[$def] : $HEADER;
|
||||
$FOOTER = ($CUSTOMFOOTER[$def]) ? $CUSTOMFOOTER[$def] : $FOOTER;
|
||||
}
|
||||
elseif($def && (isset($CUSTOMHEADER) || isset($CUSTOMFOOTER)) ) // 0.6 themes.
|
||||
elseif($def && isset($HEADER[$def]) && isset($FOOTER[$def])) // 0.8 themes - we use only $HEADER and $FOOTER arrays.
|
||||
{
|
||||
$HEADER = ($CUSTOMHEADER) ? $CUSTOMHEADER : $HEADER;
|
||||
$FOOTER = ($CUSTOMFOOTER) ? $CUSTOMFOOTER : $FOOTER;
|
||||
// echo " MODE 0.8";
|
||||
$HEADER = $HEADER[$def];
|
||||
$FOOTER = $FOOTER[$def];
|
||||
}
|
||||
|
||||
if (e_PAGE == 'news.php' && isset($NEWSHEADER))
|
||||
@@ -508,7 +480,6 @@ if ($e107_popup != 1) {
|
||||
parseheader($HEADER);
|
||||
}
|
||||
|
||||
|
||||
unset($def);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user