1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 21:27:25 +02:00

Bad menu parsing problem in Administration area leading to duplicate/wrong menu area numbers/layout

This commit is contained in:
secretr
2010-02-13 16:37:35 +00:00
parent f254307d76
commit 778cbf9e86

View File

@@ -877,6 +877,7 @@ class e_menuManager {
// $tmp = explode("\n", $LAYOUT); // $tmp = explode("\n", $LAYOUT);
// Split up using the same function as the shortcode handler // Split up using the same function as the shortcode handler
$tmp = preg_split('#(\{\S[^\x02]*?\S\})#', $LAYOUT, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $tmp = preg_split('#(\{\S[^\x02]*?\S\})#', $LAYOUT, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
$str = array();
for($c = 0; $c < count($tmp); $c++) for($c = 0; $c < count($tmp); $c++)
{ {
if(preg_match("/[\{|\}]/", $tmp[$c])) if(preg_match("/[\{|\}]/", $tmp[$c]))
@@ -885,12 +886,15 @@ class e_menuManager {
{ {
if(strstr($tmp[$c], "{MENU=")) if(strstr($tmp[$c], "{MENU="))
{ {
$str[] = preg_replace("/\{MENU=(.*?)(:.*?)?\}/si", "\\1", $tmp[$c]); $matches = array();
// Match all menu areas, menu number is limited to tinyint(3)
preg_match_all("/\{MENU=([\d]{1,3})(:[\w\d]*)?\}/", $tmp[$c], $matches);
$this->menuSetCode($matches, $str);
} }
} }
else else
{ {
$this->checklayout($tmp[$c],$this->curLayout); $this->checklayout($tmp[$c]);
} }
} }
else else
@@ -907,6 +911,19 @@ class e_menuManager {
} }
} }
function menuSetCode($matches, &$ret)
{
if(!$matches || !varsettrue($matches[1]))
{
return;
}
foreach ($matches[1] as $match)
{
$ret[] = $match;
}
}
function checklayout($str) function checklayout($str)
{ // Displays a basic representation of the theme { // Displays a basic representation of the theme
global $pref, $ns, $PLUGINS_DIRECTORY, $rs, $sc_style, $tp, $menu_order; global $pref, $ns, $PLUGINS_DIRECTORY, $rs, $sc_style, $tp, $menu_order;
@@ -959,7 +976,11 @@ class e_menuManager {
} }
else if(strstr($str, "MENU")) else if(strstr($str, "MENU"))
{ {
// $ns = new e107table; $matches = array();
if(preg_match_all("/\{MENU=([\d]{1,3})(:[\w\d]*)?\}/", $str, $matches))
{
foreach($matches[1] as $menu)
{
$menu = preg_replace("/\{MENU=(.*?)(:.*?)?\}/si", "\\1", $str); $menu = preg_replace("/\{MENU=(.*?)(:.*?)?\}/si", "\\1", $str);
if(isset($sc_style['MENU']['pre']) && strpos($str, 'ret') !== false) if(isset($sc_style['MENU']['pre']) && strpos($str, 'ret') !== false)
{ {
@@ -972,7 +993,7 @@ class e_menuManager {
<div class='forumheader'><b>" . MENLAN_14 . " " . $menu . "</b></div></div><br />"; <div class='forumheader'><b>" . MENLAN_14 . " " . $menu . "</b></div></div><br />";
$text = "&nbsp;"; $text = "&nbsp;";
$sql9 = new db; $sql9 = new db();
if($sql9->db_Count("menus", "(*)", " WHERE menu_location='$menu' AND menu_layout = '" . $this->dbLayout . "' ")) if($sql9->db_Count("menus", "(*)", " WHERE menu_location='$menu' AND menu_layout = '" . $this->dbLayout . "' "))
{ {
unset($text); unset($text);
@@ -995,21 +1016,25 @@ class e_menuManager {
echo "\n\n\n<!-- Menu end -->\n\n\n"; echo "\n\n\n<!-- Menu end -->\n\n\n";
echo "<div><br /></div>"; echo "<div><br /></div>";
} }
echo $rs->form_close(); echo $rs->form_close();
} }
echo "</div>"; echo "</div>";
if(isset($sc_style['MENU']['post']) && strpos($str, 'ret') !== false) { if(isset($sc_style['MENU']['post']) && strpos($str, 'ret') !== false)
{
echo $sc_style['MENU']['post']; echo $sc_style['MENU']['post'];
} }
} }
else if (strstr($str, "SETSTYLE")) { }
}
else if(strstr($str, "SETSTYLE"))
{
$tmp = explode("=", $str); $tmp = explode("=", $str);
$style = preg_replace("/\{SETSTYLE=(.*?)\}/si", "\\1", $str); $style = preg_replace("/\{SETSTYLE=(.*?)\}/si", "\\1", $str);
} }
else if (strstr($str, "SITEDISCLAIMER")) { else if(strstr($str, "SITEDISCLAIMER"))
{
echo "[Sitedisclaimer]"; echo "[Sitedisclaimer]";
} }
} }