From d4475ede389d56c870911171f554729a1fc27cc1 Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Tue, 7 Jul 2009 16:04:51 +0000 Subject: [PATCH] CustomPage settings working correctly now. The constant THEME_LAYOUT added. (Will be used by menus later) --- class2.php | 38 ++++++++++++++- e107_admin/menus.php | 16 +++---- e107_handlers/theme_handler.php | 55 ++++++++++++++++++---- e107_themes/e107v4a/theme.xml | 3 +- e107_themes/templates/header_default.php | 59 ++++++------------------ 5 files changed, 108 insertions(+), 63 deletions(-) diff --git a/class2.php b/class2.php index 518d95c0a..b2e849631 100644 --- a/class2.php +++ b/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'])) { diff --git a/e107_admin/menus.php b/e107_admin/menus.php index c6a080a0d..44eec1dce 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -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 .= "
Displays on these pages: + $text .= "
Displays on these pages:
"; } diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index cbe786656..8f23e4b52 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -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 .= "\n"; + $itext .= " - "; } @@ -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 "
".$path."
"; + + 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; } diff --git a/e107_themes/e107v4a/theme.xml b/e107_themes/e107v4a/theme.xml index 57331dc42..bc4804e05 100644 --- a/e107_themes/e107v4a/theme.xml +++ b/e107_themes/e107v4a/theme.xml @@ -9,7 +9,7 @@ - + @@ -28,6 +28,7 @@ + news.php usersettings.php \ No newline at end of file diff --git a/e107_themes/templates/header_default.php b/e107_themes/templates/header_default.php index f82a4ed06..a0f3d95b8 100644 --- a/e107_themes/templates/header_default.php +++ b/e107_themes/templates/header_default.php @@ -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); // -----------------------------------------------------------------------------