From b7e6837e345a4d83a16001ed7a4d2a65e8fa784c Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 1 Apr 2015 23:01:04 -0700 Subject: [PATCH] Code cleanup --- e107_admin/menus.php | 4 +-- e107_handlers/menumanager_class.php | 32 ++++++++++++++++------ e107_plugins/blogcalendar_menu/archive.php | 4 +-- e107_plugins/blogcalendar_menu/config.php | 19 ++++--------- e107_plugins/log/admin_config.php | 5 +++- 5 files changed, 37 insertions(+), 27 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 9630d01f1..9703a786f 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -1348,7 +1348,7 @@ if($_POST) $text .= $men->menuVisibilityOptions(); $text .= $men->menuInstanceParameters(); $text .= $men->menuRenderIframe(); - $ns -> tablerender(ADLAN_6.SEP.LAN_MENULAYOUT, $text, 'menus_config'); + $ns -> tablerender(ADLAN_6.SEP.LAN_MENULAYOUT, e107::getMessage()->render(). $text, 'menus_config'); } else // Within the IFrame. { @@ -1407,7 +1407,7 @@ require_once("footer.php"); function menus_adminmenu() { - // See admin_shortcodes_class.php - get_admin_menumanager() + // See admin_shortcodes.php - sc_admin_menumanager() // required there so it can be shared by plugins. } diff --git a/e107_handlers/menumanager_class.php b/e107_handlers/menumanager_class.php index 5617a5ba4..bb00f6ed8 100644 --- a/e107_handlers/menumanager_class.php +++ b/e107_handlers/menumanager_class.php @@ -1594,37 +1594,51 @@ class e_menuManager { function menuSetConfigList() { + e107::getMessage()->addDebug("Scanning for Menu config files"); + $sql = e107::getDb(); $pref = e107::getPref(); + $prev_name = ''; + $search = array('_menu','_'); $sql -> select("menus", "*", "menu_location != 0 ORDER BY menu_path,menu_name"); while($row = $sql-> fetch()) { $link = ""; - extract($row); - $id = substr($menu_path,0,-1); + $id = substr($row['menu_path'],0,-1); - if (file_exists(e_PLUGIN."{$menu_path}{$menu_name}_menu_config.php")) + if (file_exists(e_PLUGIN."{$row['menu_path']}{$row['menu_name']}_menu_config.php")) { - $link = "{$menu_path}{$menu_name}_menu_config.php"; + $link = $row['menu_path'].$row['menu_name']."_menu_config.php"; } - if(file_exists(e_PLUGIN."{$menu_path}config.php")) + if($row['menu_path'] == 'news/') { - $link = "{$menu_path}config.php"; + $row['menu_path'] = "blogcalendar_menu/"; } + if(file_exists(e_PLUGIN.$row['menu_path']."config.php")) + { + $link = $row['menu_path']."config.php"; + } + + + if($link) { - $tmp[$id]['name'] = ucwords(str_replace("_menu","",$menu_name)); - if(vartrue($prev) == $id && ($tmp[$id]['name']!=$prev_name)) + + + $tmp[$id]['name'] = ucwords(str_replace($search,"",$row['menu_name'])); // remove _ + + if(vartrue($prev) == $id && ($tmp[$id]['name'] != $prev_name)) { $tmp[$id]['name'] .= ":".$prev_name; } $tmp[$id]['link'] = $link; $prev = $id; + $prev_name = $tmp[$id]['name']; } } @@ -1632,6 +1646,6 @@ class e_menuManager { $pref['menuconfig_list'] = vartrue($tmp); e107::getConfig()->setPref($pref)->save(false,true,false); - // save_prefs(); + } } // end of Class. diff --git a/e107_plugins/blogcalendar_menu/archive.php b/e107_plugins/blogcalendar_menu/archive.php index 9b3f444b2..fc7de5d93 100644 --- a/e107_plugins/blogcalendar_menu/archive.php +++ b/e107_plugins/blogcalendar_menu/archive.php @@ -35,8 +35,8 @@ $marray = e107::getDate()->terms('month'); // if nr of rows per month is not set, default to 3 -$months_per_row = $pref['blogcal_mpr']?$pref['blogcal_mpr']: -"3"; +$months_per_row = (!empty($pref['blogcal_mpr'])) ? $pref['blogcal_mpr']: "3"; + $pref['blogcal_ws'] = "monday"; // ------------------------------------- diff --git a/e107_plugins/blogcalendar_menu/config.php b/e107_plugins/blogcalendar_menu/config.php index 76a78b129..9107f6897 100644 --- a/e107_plugins/blogcalendar_menu/config.php +++ b/e107_plugins/blogcalendar_menu/config.php @@ -24,20 +24,13 @@ require_once(e_ADMIN."auth.php"); $frm = e107::getForm(); $mes = e107::getMessage(); -if (isset($_POST['update_menu'])) +if(!empty($_POST['update_menu'])) { - $temp = array(); - while (list($key, $value) = each($_POST)) - { - if ($value != LAN_UPDATE) // ??? - { - $temp[$key] = $value; - } - } - if ($admin_log->logArrayDiffs($temp,$pref,'MISC_06')) - { - save_prefs(); - } + $cfg = e107::getConfig(); + $cfg->set('blogcal_mpr', intval($_POST['blogcal_mpr'])); + $cfg->set('blogcal_padding', intval($_POST['blogcal_padding'])); + $cfg->save(true,true,true); + } $ns->tablerender($caption, $mes->render() . $text); diff --git a/e107_plugins/log/admin_config.php b/e107_plugins/log/admin_config.php index 0b3172ba3..3b77ca33f 100644 --- a/e107_plugins/log/admin_config.php +++ b/e107_plugins/log/admin_config.php @@ -11,6 +11,7 @@ */ require_once('../../class2.php'); + if (!getperms('P') || !e107::isInstalled('log')) { header('Location: '.e_BASE.'index.php'); @@ -19,6 +20,7 @@ if (!getperms('P') || !e107::isInstalled('log')) require_once(e_ADMIN.'auth.php'); + require_once(e_HANDLER.'userclass_class.php'); $frm = e107::getForm(); $mes = e107::getMessage(); @@ -240,7 +242,7 @@ if (isset($_POST['updatesettings'])) e107::getLog()->add('STAT_02',ADSTAT_L82.$logStr,''); } -$ns->tablerender($caption, $mes->render() . $text); +echo $mes->render() ; function gen_select($prompt,$name,$value) { @@ -337,6 +339,7 @@ switch ($action) "; + $ns->tablerender(ADSTAT_L16, $text); break; // case config