diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 27a57972a..f4d616de2 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -708,312 +708,6 @@ if($_SERVER['E_DEV_MENU'] == 'true') } //} -// new v2.1.4 -class e_menu_layout -{ - function __construct() - { - - } - - static function getLayouts($theme=null) - { - if(empty($theme)) - { - $theme = e107::pref('core','sitetheme'); - } - - $sql = e107::getDb(); - $tp = e107::getParser(); - - $HEADER = null; - $FOOTER = null; - $LAYOUT = null; - $CUSTOMHEADER = null; - $CUSTOMFOOTER = null; - - - $file = e_THEME.$theme."/theme.php"; - - if(!is_readable($file)) - { - return false; - } - - e107::set('css_enabled',false); - e107::set('js_enabled',false); - - $themeFileContent = file_get_contents($file); - - $srch = array(''); - - $themeFileContent = preg_replace('/\(\s?THEME\s?\./', '( e_THEME. "'.$theme.'/" .', str_replace($srch, '', $themeFileContent)); - - try - { - @eval($themeFileContent); - } - catch (ParseError $e) - { - echo "
Couldn't parse theme.php: ". $e->getMessage()."
"; - } - - - // @eval($themeFileContent); - - e107::set('css_enabled',true); - e107::set('js_enabled',true); - - $head = array(); - $foot = array(); - - if(isset($LAYOUT) && (isset($HEADER) || isset($FOOTER))) - { - $fallbackLan = "This theme is using deprecated elements. All [x]HEADER and [x]FOOTER variables should be removed from theme.php."; // DO NOT TRANSLATE! - $warningLan = $tp->lanVars(deftrue('MENLAN_60',$fallbackLan),'$'); - echo "
".$warningLan."
"; - - } - - - - if(isset($LAYOUT) && is_array($LAYOUT)) // $LAYOUT is a combined $HEADER,$FOOTER. - { - foreach($LAYOUT as $key=>$template) - { - if($key == '_header_' || $key == '_footer_' || $key == '_modal_') - { - continue; - } - - if(strpos($template,'{---}') !==false) - { - list($hd,$ft) = explode("{---}",$template); - $head[$key] = isset($LAYOUT['_header_']) ? $LAYOUT['_header_'] . $hd : $hd; - $foot[$key] = isset($LAYOUT['_footer_']) ? $ft . $LAYOUT['_footer_'] : $ft ; - } - else - { - e107::getMessage()->addDebug('Missing "{---}" in $LAYOUT["'.$key.'"] '); - } - } - unset($hd,$ft); - } - - - if(is_string($CUSTOMHEADER)) - { - $head['legacyCustom'] = $CUSTOMHEADER; - } - elseif(is_array($CUSTOMHEADER)) - { - foreach($CUSTOMHEADER as $k=>$v) - { - $head[$k] = $v; - } - } - - if(is_string($HEADER)) - { - $head['legacyDefault'] = $HEADER; - } - elseif(is_array($HEADER)) - { - foreach($HEADER as $k=>$v) - { - $head[$k] = $v; - } - - } - - if(is_string($CUSTOMFOOTER)) - { - $foot['legacyCustom'] = $CUSTOMFOOTER; - } - elseif(is_array($CUSTOMFOOTER)) - { - foreach($CUSTOMFOOTER as $k=>$v) - { - $foot[$k] = $v; - } - } - - - if(is_string($FOOTER)) - { - $foot['legacyDefault'] = $FOOTER; - } - elseif(is_array($FOOTER)) - { - foreach($FOOTER as $k=>$v) - { - $foot[$k] = $v; - } - } - - $layout = array(); - - foreach($head as $k=>$v) - { - $template = $head[$k]."\n{---}".$foot[$k]; - $layout['templates'][$k] = $template; - $layout['menus'][$k] = self::countMenus($template, $k); - } - - - return $layout; - - - } - - - private static function countMenus($template, $name) - { - if(preg_match_all("/\{MENU=([\d]{1,3})(:[\w\d]*)?\}/", $template, $matches)) - { - sort($matches[1]); - return $matches[1]; - } - - e107::getDebug()->log("No Menus Found in Template:".$name." with strlen: ".strlen($template)); - - return array(); - } - - - - static function menuSelector() - { - - // $p = e107::getPref('e_menu_list'); // new storage for xxxxx_menu.php list. - $sql = e107::getDb(); - $frm = e107::getForm(); - - $done = array(); - - $pageMenu = array(); - $pluginMenu = array(); - - $sql->select("menus", "menu_name, menu_id, menu_pages, menu_path", "1 ORDER BY menu_name ASC"); - while ($row = $sql->fetch()) - { - - if(in_array($row['menu_name'],$done)) - { - continue; - } - - $done[] = $row['menu_name']; - - if(is_numeric($row['menu_path'])) - { - $pageMenu[] = $row; - } - else - { - $pluginMenu[] = $row; - } - - } - - $tab1 = ''; - - $tab2 = ''; - - $tabs = array( - 'custom' => array('caption'=>'', 'text'=>$tab1), - 'plugin' => array('caption'=>'', 'text'=>$tab2) - - ); - - - $defLayout =e107::getRegistry('core/e107/menu-manager/curLayout');; - - $text = '
'; - - $text .= ""; - - - //TODO FIXME parse the theme file (or store it somewhere) to get the number of menu areas for each layout. ie. $menu_areas below. - - $layouts = self::getLayouts(); - $tp = e107::getParser(); - - // $text .= print_a($layouts['menus'],true); - - - $text .= ' - - '; - - - $text .= $frm->tabs($tabs); - - - - - - $text .= '
'; - - $tp = e107::getParser(); - - $caption = MENLAN_22; - - ; - - - - - return array('caption'=>$caption,'text'=>$text); - - - - - - - } - - - -} - // XXX Menu Manager Re-Write with drag and drop and multi-dimensional array as storage. ($pref) diff --git a/e107_handlers/menumanager_class.php b/e107_handlers/menumanager_class.php index 288832767..83bd394c2 100644 --- a/e107_handlers/menumanager_class.php +++ b/e107_handlers/menumanager_class.php @@ -1954,3 +1954,317 @@ class e_menuManager { } } // end of Class. + + + + + + + +// new v2.1.4 +class e_menu_layout +{ + function __construct() + { + + } + + static function getLayouts($theme=null) + { + if(empty($theme)) + { + $theme = e107::pref('core','sitetheme'); + } + + $sql = e107::getDb(); + $tp = e107::getParser(); + + $HEADER = null; + $FOOTER = null; + $LAYOUT = null; + $CUSTOMHEADER = null; + $CUSTOMFOOTER = null; + + + $file = e_THEME.$theme."/theme.php"; + + if(!is_readable($file)) + { + return false; + } + + e107::set('css_enabled',false); + e107::set('js_enabled',false); + + $themeFileContent = file_get_contents($file); + + $srch = array(''); + + $themeFileContent = preg_replace('/\(\s?THEME\s?\./', '( e_THEME. "'.$theme.'/" .', str_replace($srch, '', $themeFileContent)); + + $themeFileContent = str_replace('tablestyle', $theme."_tablestyle",$themeFileContent); // rename function to avoid conflicts while parsing. + + try + { + @eval($themeFileContent); + } + catch (ParseError $e) + { + echo "
Couldn't parse theme.php: ". $e->getMessage()."
"; + } + + + // @eval($themeFileContent); + + e107::set('css_enabled',true); + e107::set('js_enabled',true); + + $head = array(); + $foot = array(); + + if(isset($LAYOUT) && (isset($HEADER) || isset($FOOTER))) + { + $fallbackLan = "This theme is using deprecated elements. All [x]HEADER and [x]FOOTER variables should be removed from theme.php."; // DO NOT TRANSLATE! + $warningLan = $tp->lanVars(deftrue('MENLAN_60',$fallbackLan),'$'); + echo "
".$warningLan."
"; + + } + + + + if(isset($LAYOUT) && is_array($LAYOUT)) // $LAYOUT is a combined $HEADER,$FOOTER. + { + foreach($LAYOUT as $key=>$template) + { + if($key == '_header_' || $key == '_footer_' || $key == '_modal_') + { + continue; + } + + if(strpos($template,'{---}') !==false) + { + list($hd,$ft) = explode("{---}",$template); + $head[$key] = isset($LAYOUT['_header_']) ? $LAYOUT['_header_'] . $hd : $hd; + $foot[$key] = isset($LAYOUT['_footer_']) ? $ft . $LAYOUT['_footer_'] : $ft ; + } + else + { + e107::getMessage()->addDebug('Missing "{---}" in $LAYOUT["'.$key.'"] '); + } + } + unset($hd,$ft); + } + + + if(is_string($CUSTOMHEADER)) + { + $head['legacyCustom'] = $CUSTOMHEADER; + } + elseif(is_array($CUSTOMHEADER)) + { + foreach($CUSTOMHEADER as $k=>$v) + { + $head[$k] = $v; + } + } + + if(is_string($HEADER)) + { + $head['legacyDefault'] = $HEADER; + } + elseif(is_array($HEADER)) + { + foreach($HEADER as $k=>$v) + { + $head[$k] = $v; + } + + } + + if(is_string($CUSTOMFOOTER)) + { + $foot['legacyCustom'] = $CUSTOMFOOTER; + } + elseif(is_array($CUSTOMFOOTER)) + { + foreach($CUSTOMFOOTER as $k=>$v) + { + $foot[$k] = $v; + } + } + + + if(is_string($FOOTER)) + { + $foot['legacyDefault'] = $FOOTER; + } + elseif(is_array($FOOTER)) + { + foreach($FOOTER as $k=>$v) + { + $foot[$k] = $v; + } + } + + $layout = array(); + + foreach($head as $k=>$v) + { + $template = $head[$k]."\n{---}".$foot[$k]; + $layout['templates'][$k] = $template; + $layout['menus'][$k] = self::countMenus($template, $k); + } + + + return $layout; + + + } + + + private static function countMenus($template, $name) + { + if(preg_match_all("/\{MENU=([\d]{1,3})(:[\w\d]*)?\}/", $template, $matches)) + { + sort($matches[1]); + return $matches[1]; + } + + e107::getDebug()->log("No Menus Found in Template:".$name." with strlen: ".strlen($template)); + + return array(); + } + + + + static function menuSelector() + { + + // $p = e107::getPref('e_menu_list'); // new storage for xxxxx_menu.php list. + $sql = e107::getDb(); + $frm = e107::getForm(); + + $done = array(); + + $pageMenu = array(); + $pluginMenu = array(); + + $sql->select("menus", "menu_name, menu_id, menu_pages, menu_path", "1 ORDER BY menu_name ASC"); + while ($row = $sql->fetch()) + { + + if(in_array($row['menu_name'],$done)) + { + continue; + } + + $done[] = $row['menu_name']; + + if(is_numeric($row['menu_path'])) + { + $pageMenu[] = $row; + } + else + { + $pluginMenu[] = $row; + } + + } + + $tab1 = ''; + + $tab2 = ''; + + $tabs = array( + 'custom' => array('caption'=>'', 'text'=>$tab1), + 'plugin' => array('caption'=>'', 'text'=>$tab2) + + ); + + + $defLayout =e107::getRegistry('core/e107/menu-manager/curLayout');; + + $text = '
'; + + $text .= ""; + + + //TODO FIXME parse the theme file (or store it somewhere) to get the number of menu areas for each layout. ie. $menu_areas below. + + $layouts = self::getLayouts(); + $tp = e107::getParser(); + + // $text .= print_a($layouts['menus'],true); + + + $text .= ' + + '; + + + $text .= $frm->tabs($tabs); + + + + + + $text .= '
'; + + $tp = e107::getParser(); + + $caption = MENLAN_22; + + ; + + + + + return array('caption'=>$caption,'text'=>$text); + + + + + + + } + + + +}