From 76a9758447c15182852ed1a739482b3611450771 Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 3 Dec 2012 02:21:51 -0800 Subject: [PATCH] More admin links cleanup and moving of arrays to e_navigation class --- e107_admin/admin.php | 32 ++------ e107_admin/includes/beginner.php | 2 +- e107_admin/includes/cascade.php | 2 +- e107_admin/includes/categories.php | 6 +- e107_admin/includes/classis.php | 2 +- e107_admin/includes/combo.php | 2 +- e107_admin/includes/compact.php | 2 +- e107_admin/includes/infopanel.php | 4 +- e107_admin/includes/tabbed.php | 2 +- e107_handlers/sitelinks_class.php | 128 +++++++++++++++++++++++++++-- 10 files changed, 142 insertions(+), 40 deletions(-) diff --git a/e107_admin/admin.php b/e107_admin/admin.php index c9f79ab81..9d4106551 100644 --- a/e107_admin/admin.php +++ b/e107_admin/admin.php @@ -161,9 +161,14 @@ if(!defined("ADLINK_COLS")) define("ADLINK_COLS",5); } - +// DEPRECATED function render_links($link, $title, $description, $perms, $icon = FALSE, $mode = FALSE) { + + return e107::getNav()->renderAdminButton($link, $title, $description, $perms, $icon, $mode); + + + /* global $td,$tp; $text = ''; if (getperms($perms)) @@ -230,6 +235,8 @@ function render_links($link, $title, $description, $perms, $icon = FALSE, $mode } } return $text; + + */ } @@ -248,32 +255,9 @@ function render_clean() } -$newarray = asortbyindex($array_functions, 1); -$array_functions_assoc = convert_core_icons($newarray); -function convert_core_icons($newarray) // Put core button array in the same format as plugin button array. -{ - foreach($newarray as $key=>$val) - { - if(varset($val[0])) - { - $key = "e-".basename($val[0],".php"); - $val['icon'] = $val[5]; - $val['icon_32'] = $val[6]; - $val['title'] = $val[1]; - $val['link'] = $val[0]; - $val['caption'] = $val['2']; - $val['perms'] = $val['3']; - $array_functions_assoc[$key] = $val; - } - } - - return $array_functions_assoc; -} - - require_once(e_ADMIN.'includes/'.$pref['adminstyle'].'.php'); diff --git a/e107_admin/includes/beginner.php b/e107_admin/includes/beginner.php index 7e96b5c6f..79d1aa534 100644 --- a/e107_admin/includes/beginner.php +++ b/e107_admin/includes/beginner.php @@ -35,7 +35,7 @@ if($_GET['mode'] == "e_advanced"){ // $selection = array(21,11,17,24,5,19,7,27,28,25); foreach($selection as $id) { - $buts .= render_links($newarray[$id][0],$newarray[$id][1],$newarray[$id][2],$newarray[$id][3],$newarray[$id][6],'beginner'); + $buts .= e107::renderAdminButton($newarray[$id][0],$newarray[$id][1],$newarray[$id][2],$newarray[$id][3],$newarray[$id][6],'beginner'); } $text .= $buts; diff --git a/e107_admin/includes/cascade.php b/e107_admin/includes/cascade.php index bef9bdab0..14a58c7ec 100644 --- a/e107_admin/includes/cascade.php +++ b/e107_admin/includes/cascade.php @@ -24,7 +24,7 @@ $text = "
while (list($key, $funcinfo) = each($newarray)) { - $text .= render_links($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[5], 'adminb'); + $text .= e107::renderAdminButton($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[5], 'adminb'); } $text .= " diff --git a/e107_admin/includes/categories.php b/e107_admin/includes/categories.php index f88fda548..b1805efe5 100644 --- a/e107_admin/includes/categories.php +++ b/e107_admin/includes/categories.php @@ -36,7 +36,7 @@ foreach ($admin_cat['id'] as $cat_key => $cat_id) { if ($funcinfo[4] == $cat_key) { - $text_rend = render_links($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[5], 'default'); + $text_rend = e107::renderAdminButton($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[5], 'default'); if ($text_rend) { $text_check = TRUE; @@ -47,7 +47,7 @@ foreach ($admin_cat['id'] as $cat_key => $cat_id) } else { - $text_rend = render_links(e_ADMIN."plugin.php", ADLAN_98, ADLAN_99, "Z", E_16_PLUGMANAGER, 'default'); + $text_rend = e107::renderAdminButton(e_ADMIN."plugin.php", ADLAN_98, ADLAN_99, "Z", E_16_PLUGMANAGER, 'default'); $xml = e107::getXml(); $xml->filter = array('@attributes' => FALSE,'administration' => FALSE); // .. and they're all going to need the same filter @@ -94,7 +94,7 @@ foreach ($admin_cat['id'] as $cat_key => $cat_id) ksort($plugin_array, SORT_STRING); foreach ($plugin_array as $plug_key => $plug_value) { - $text_cat .= render_links($plug_value['link'], $plug_value['title'], $plug_value['caption'], $plug_value['perms'], $plug_value['icon'], 'default'); + $text_cat .= e107::renderAdminButton($plug_value['link'], $plug_value['title'], $plug_value['caption'], $plug_value['perms'], $plug_value['icon'], 'default'); } } $text_cat .= render_clean(); diff --git a/e107_admin/includes/classis.php b/e107_admin/includes/classis.php index 1ee01a019..8a9cb4471 100644 --- a/e107_admin/includes/classis.php +++ b/e107_admin/includes/classis.php @@ -23,7 +23,7 @@ $buts = ""; while (list($key, $funcinfo) = each($newarray)) { - $buts .= render_links($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[6], "classis"); + $buts .= e107::renderAdminButton($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[6], "classis"); } if($buts != "") { diff --git a/e107_admin/includes/combo.php b/e107_admin/includes/combo.php index 1cb34f81c..0df5de0b3 100644 --- a/e107_admin/includes/combo.php +++ b/e107_admin/includes/combo.php @@ -23,7 +23,7 @@ $text = "
"; $buts = ""; while (list($key, $funcinfo) = each($newarray)) { - $buts .= render_links($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[5], 'default'); + $buts .= e107::renderAdminButton($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[5], 'default'); } $text .= $buts; while ($td <= 5) { diff --git a/e107_admin/includes/compact.php b/e107_admin/includes/compact.php index 1dab6495a..31428a0c7 100644 --- a/e107_admin/includes/compact.php +++ b/e107_admin/includes/compact.php @@ -24,7 +24,7 @@ $text = "
"; while (list($key, $funcinfo) = each($newarray)) { - $buts .= render_links($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[5], 'default'); + $buts .= e107::renderAdminButton($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[5], 'default'); } $text .= $buts; diff --git a/e107_admin/includes/infopanel.php b/e107_admin/includes/infopanel.php index 05bfb50dd..88af0a855 100644 --- a/e107_admin/includes/infopanel.php +++ b/e107_admin/includes/infopanel.php @@ -43,6 +43,8 @@ if (isset($_POST['submit-mye107']) || varset($_POST['submit-mymenus'])) { $user_pref['core-infopanel-mye107'] = $pref['core-infopanel-default']; } + + $array_functions_assoc = e107::getNav()->adminLinks('assoc'); $iconlist = array_merge($array_functions_assoc, e107::getNav()->pluginLinks(E_16_PLUGMANAGER, "array")); @@ -62,7 +64,7 @@ if (isset($_POST['submit-mye107']) || varset($_POST['submit-mymenus'])) { if (!vartrue($user_pref['core-infopanel-mye107']) || in_array($key, $user_pref['core-infopanel-mye107'])) { - $mainPanel .= render_links($val['link'], $val['title'], $val['caption'], $val['perms'], $val['icon_32'], "div-icon-only"); + $mainPanel .= e107::getNav()->renderAdminButton($val['link'], $val['title'], $val['caption'], $val['perms'], $val['icon_32'], "div-icon-only"); } } diff --git a/e107_admin/includes/tabbed.php b/e107_admin/includes/tabbed.php index 086f4439c..89af1569c 100644 --- a/e107_admin/includes/tabbed.php +++ b/e107_admin/includes/tabbed.php @@ -49,7 +49,7 @@ foreach ($admin_cat['id'] as $cat_key => $cat_id) { if ($funcinfo[4] == $cat_key) { - $text_rend = render_links($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[6], 'classis'); + $text_rend = e107::renderAdminButton($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[6], 'classis'); if ($text_rend) { $text_check = TRUE; diff --git a/e107_handlers/sitelinks_class.php b/e107_handlers/sitelinks_class.php index 77b5ecb1a..df34a02ec 100644 --- a/e107_handlers/sitelinks_class.php +++ b/e107_handlers/sitelinks_class.php @@ -617,11 +617,11 @@ class e_navigation } - - function adminLinks($sub=false) + // Previously $array_functions variable. + function adminLinks($mode=false) { - if($sub==true) + if($mode=='sub') { //FIXME array structure suitable for e_admin_menu - see shortcodes/admin_navigation.php @@ -694,19 +694,45 @@ class e_navigation 38 => array(e_ADMIN.'comment.php', LAN_COMMENTMAN, LAN_COMMENTMAN, 'B', 5, E_16_COMMENT, E_32_COMMENT) ); + if($mode == 'assoc') + { + $newarray = asortbyindex($array_functions, 1); + $array_functions_assoc = $this->convert_core_icons($newarray); + return $array_functions_assoc; + } return $array_functions; } - + function convert_core_icons($newarray) // Put core button array in the same format as plugin button array. + { + foreach($newarray as $key=>$val) + { + if(varset($val[0])) + { + $key = "e-".basename($val[0],".php"); + $val['icon'] = $val[5]; + $val['icon_32'] = $val[6]; + $val['title'] = $val[1]; + $val['link'] = $val[0]; + $val['caption'] = $val['2']; + $val['perms'] = $val['3']; + $array_functions_assoc[$key] = $val; + } + } + + return $array_functions_assoc; + } // Function renders all the plugin links according to the required icon size and layout style // - common to the various admin layouts such as infopanel, classis etc. function pluginLinks($iconSize = E_16_PLUGMANAGER, $linkStyle = 'adminb') { - - global $sql, $tp; + + $sql = e107::getDb(); + $tp = e107::getParser(); + $plug_id = array(); $plugin_array = array(); @@ -1041,6 +1067,96 @@ class e_navigation return ''; } + + + + // Previously admin.php -> render_links(); + function renderAdminButton($link, $title, $description, $perms, $icon = FALSE, $mode = FALSE) + { + global $td,$tp; + $tp = e107::getParser(); + + + + $text = ''; + if (getperms($perms)) + { + $description = strip_tags($description); + if ($mode == 'adminb') + { + $text = ""; + } + else + { + + if($mode != "div" && $mode != 'div-icon-only') + { + if ($td == (ADLINK_COLS+1)) + { + $text .= ''; + $td = 1; + } + if ($td == 1) + { + $text .= ''; + } + } + + + switch ($mode) + { + case 'default': + $text .= ""; + break; + + case 'classis': + $text .= ""; + break; + + case 'beginner': + $text .= ""; + break; + + case 'div': + $text .= ""; + break; + + case 'div-icon-only': + $text .= ""; + break; + + default: + + break; + } + + $td++; + } + } +else +{ + echo "no Perms"; +} + + return $text; + } + + + + + + + + function frontend() //TODO equivalent for front-end sitelinks etc.
+
+ ".$icon." ".$title." ".($description ? "[ ".$description." ]" : "")."
".$icon." ".$tp->toHTML($title,FALSE,"defs, emotes_off")."".$icon."
+ ".$tp->toHTML($title,FALSE,"defs, emotes_off")."

".$icon." +