]> git.mxchange.org Git - mailer.git/commitdiff
Admin menu prepared for AJAX requests:
authorRoland Häder <roland@mxchange.org>
Tue, 16 Aug 2011 20:46:22 +0000 (20:46 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 16 Aug 2011 20:46:22 +0000 (20:46 +0000)
- Admin menu system prepared for later updates (e.g. AJAX-driven) by adding ids to li-tags
- 2 internal TODOs closed to rewrite to SQL_FETCHARRAY()
- TODOs.txt updated

DOCS/TODOs.txt
inc/modules/admin.php
inc/modules/admin/admin-inc.php

index 5d45fbe32bcfa5eeff966347a5c80be2ca0912d0..26b1617efc4817af162d61a4b79f2b8eadd202d7 100644 (file)
 ./inc/mails/doubler_mails.php:53:// @TODO Can this be rewritten to a filter?
 ./inc/module-functions.php:267:                        // @TODO Nothing helped???
 ./inc/module-functions.php:308:                        // @TODO Rewrite this to a filter
-./inc/modules/admin/admin-inc.php:1423:                                // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided
+./inc/modules/admin/admin-inc.php:1426:                                // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided
 ./inc/modules/admin/admin-inc.php:171:         // @TODO This and the next getCurrentAdminId() call might be moved into the templates?
 ./inc/modules/admin/admin-inc.php:242:         // @TODO This can be rewritten into a filter
-./inc/modules/admin/admin-inc.php:274:         // @TODO Rewrite this to $content = SQL_FETCHARRAY()
-./inc/modules/admin/admin-inc.php:342:                                 // @TODO Rewrite this to $content = SQL_FETCHARRAY()
-./inc/modules/admin/admin-inc.php:487:// @TODO Try to rewrite this to adminAddMenuSelectionBox()
+./inc/modules/admin/admin-inc.php:490:// @TODO Try to rewrite this to adminAddMenuSelectionBox()
 ./inc/modules/admin/overview-inc.php:162:                              // @TODO Rewrite this to a filter
 ./inc/modules/admin/overview-inc.php:275:                              // @TODO Rewrite this to something with include files and/or filter
 ./inc/modules/admin/overview-inc.php:309:                                              // @TODO This may also be rewritten to include files
 ./inc/loader/load_cache-revision.php:2:// @DEPRECATED
 ./inc/loader/load_cache-them.php:2:// @DEPRECATED
 ./inc/loader/load-extensions.php:2:// @DEPRECATED
-./inc/modules/admin/admin-inc.php:488:// @DEPRECATED
+./inc/modules/admin/admin-inc.php:491:// @DEPRECATED
 ./inc/modules/admin/what-chk_regs.php:2:// @DEPRECATED
 ./inc/modules/admin/what-config_admins.php:2:// @DEPRECATED
 ./inc/modules/admin/what-config_email.php:2:// @DEPRECATED
index 518ed798387313497f067cb986f463ccfa188ae1..2aa70e1b6b2cff24506a8b93326e84001b2d3a0d 100644 (file)
@@ -361,7 +361,9 @@ if (!isAdminRegistered()) {
                                $area = 'entrance';
 
                                // Check for similar URL variable
-                               if (isGetRequestElementSet('area')) $area = getRequestElement('area');
+                               if (isGetRequestElementSet('area')) {
+                                       $area = getRequestElement('area');
+                               } // END - if
 
                                // Load logical-area menu-system file
                                loadIncludeOnce('inc/modules/admin/lasys-inc.php');
@@ -369,8 +371,10 @@ if (!isAdminRegistered()) {
                                // Create new-style menu system will logical areas
                                doAdminLogicalArea($area, $action, getWhat());
                        } else {
-                               // This little call constructs the whole default old and lacky menu system
-                               // on left side. It also renders the content on right side
+                               /*
+                                * This little call constructs the whole default old and lacky menu system
+                                * on left side. It also renders the content on right side
+                                */
                                doAdminAction();
                        }
                        break;
index bcc4c3c16334030989c6cc12e64d9e7cb3085ba4..44bd7de7abc40dbc25acdc2edb2b98c9bfb4cb06 100644 (file)
@@ -248,18 +248,20 @@ function isAdminAllowedAccessMenu ($action, $what = NULL) {
 }
 
 // Adds an admin menu
-function addAdminMenu ($action, $what, $return = false) {
+function addAdminMenu ($action, $what) {
        // Init variables
        $SUB = false;
        $OUT = '';
 
        // Menu descriptions
        $GLOBALS['menu']['description'] = array();
-       $GLOBALS['menu']['title'] = array();
+       $GLOBALS['menu']['title']       = array();
 
        // Build main menu
        $result_main = SQL_QUERY("SELECT
-       `action`,`title`,`descr`
+       `action` AS `main_action`,
+       `title` AS `main_title`,
+       `descr` AS `main_descr`
 FROM
        `{?_MYSQL_PREFIX?}_admin_menu`
 WHERE
@@ -271,38 +273,39 @@ ORDER BY
        // Do we have entries?
        if (!SQL_HASZERONUMS($result_main)) {
                $OUT .= '<ul class="admin_menu_main">';
-               // @TODO Rewrite this to $content = SQL_FETCHARRAY()
-               while (list($menu, $title, $descr) = SQL_FETCHROW($result_main)) {
+
+               // Load all 'action' menus
+               while ($mainContent = SQL_FETCHARRAY($result_main)) {
                        // Filename
-                       $inc = sprintf("inc/modules/admin/action-%s.php", $menu);
+                       $inc = sprintf("inc/modules/admin/action-%s.php", $mainContent['main_action']);
 
                        // Is the file readable?
                        $readable = isIncludeReadable($inc);
 
                        // Is the current admin allowed to access this 'action' menu?
-                       if (isAdminAllowedAccessMenu($menu)) {
+                       if (isAdminAllowedAccessMenu($mainContent['main_action'])) {
                                if ($SUB === false) {
                                        // Insert compiled menu title and description
-                                       $GLOBALS['menu']['title'][$menu]      = $title;
-                                       $GLOBALS['menu']['description'][$menu] = $descr;
+                                       $GLOBALS['menu']['title'][$mainContent['main_action']]       = $mainContent['main_title'];
+                                       $GLOBALS['menu']['description'][$mainContent['main_action']] = $mainContent['main_descr'];
                                } // END - if
                                $OUT .= '<li class="admin_menu">
 <div class="nobr"><strong>&middot;</strong>&nbsp;';
 
                                if ($readable === true) {
-                                       if (($menu == $action) && (empty($what))) {
+                                       if (($mainContent['main_action'] == $action) && (empty($what))) {
                                                $OUT .= '<strong>';
                                        } else {
-                                               $OUT .= '[<a href="{%url=modules.php?module=admin&amp;action=' . $menu . '%}">';
+                                               $OUT .= '[<a href="{%url=modules.php?module=admin&amp;action=' . $mainContent['main_action'] . '%}">';
                                        }
                                } else {
-                                       $OUT .= '<span class="bad" style="cursor:help" title="{%message,ADMIN_MENU_ACTION_404_TITLE=' . $menu . '%}">';
+                                       $OUT .= '<span class="bad" style="cursor:help" title="{%message,ADMIN_MENU_ACTION_404_TITLE=' . $mainContent['main_action'] . '%}">';
                                }
 
-                               $OUT .= $title;
+                               $OUT .= $mainContent['main_title'];
 
                                if ($readable === true) {
-                                       if (($menu == $action) && (empty($what))) {
+                                       if (($mainContent['main_action'] == $action) && (empty($what))) {
                                                $OUT .= '</strong>';
                                        } else {
                                                $OUT .= '</a>]';
@@ -316,9 +319,9 @@ ORDER BY
 
                                // Check for menu entries
                                $result_what = SQL_QUERY_ESC("SELECT
-       `what`,
-       `title`,
-       `descr`
+       `what` AS `sub_what`,
+       `title` AS `sub_title`,
+       `descr` AS `sub_descr`
 FROM
        `{?_MYSQL_PREFIX?}_admin_menu`
 WHERE
@@ -328,46 +331,49 @@ WHERE
 ORDER BY
        `sort` ASC,
        `id` DESC",
-                                       array($menu), __FUNCTION__, __LINE__);
+                                       array($mainContent['main_action']), __FUNCTION__, __LINE__);
 
                                // Remember the count for later checks
-                               setAdminMenuHasEntries($menu, ((!SQL_HASZERONUMS($result_what)) && ($action == $menu)));
+                               setAdminMenuHasEntries($mainContent['main_action'], ((!SQL_HASZERONUMS($result_what)) && ($action == $mainContent['main_action'])));
+
+                               // Start li-tag for sub menu content
+                               $OUT .= '<li class="admin_menu_sub" id="action_menu_' . $mainContent['main_action'] . '">';
 
                                // Do we have entries?
-                               if ((ifAdminMenuHasEntries($menu)) && (!SQL_HASZERONUMS($result_what))) {
-                                       $GLOBALS['menu']['description'] = array();
-                                       $GLOBALS['menu']['title'] = array();
+                               if (ifAdminMenuHasEntries($mainContent['main_action'])) {
+                                       // Sub menu has been called
                                        $SUB = true;
-                                       $OUT .= '<li class="admin_menu_sub"><ul class="admin_menu_sub">';
-                                       // @TODO Rewrite this to $content = SQL_FETCHARRAY()
-                                       while (list($what_sub, $title_what, $desc_what) = SQL_FETCHROW($result_what)) {
+                                       $OUT .= '<ul class="admin_menu_sub">';
+
+                                       // Load all entries
+                                       while ($subContent = SQL_FETCHARRAY($result_what)) {
                                                // Filename
-                                               $inc = sprintf("inc/modules/admin/what-%s.php", $what_sub);
+                                               $inc = sprintf("inc/modules/admin/what-%s.php", $subContent['sub_what']);
 
                                                // Is the file readable?
                                                $readable = isIncludeReadable($inc);
 
                                                // Is the current admin allowed to access this 'what' menu?
-                                               if (isAdminAllowedAccessMenu(null, $what_sub)) {
+                                               if (isAdminAllowedAccessMenu(NULL, $subContent['sub_what'])) {
                                                        // Insert compiled title and description
-                                                       $GLOBALS['menu']['title'][$what_sub]      = $title_what;
-                                                       $GLOBALS['menu']['description'][$what_sub] = $desc_what;
+                                                       $GLOBALS['menu']['title'][$subContent['sub_what']]       = $subContent['sub_title'];
+                                                       $GLOBALS['menu']['description'][$subContent['sub_what']] = $subContent['sub_descr'];
                                                        $OUT .= '<li class="admin_menu">
 <div class="nobr"><strong>--&gt;</strong>&nbsp;';
                                                        if ($readable === true) {
-                                                               if ($what == $what_sub) {
+                                                               if ($what == $subContent['sub_what']) {
                                                                        $OUT .= '<strong>';
                                                                } else {
-                                                                       $OUT .= '[<a href="{%url=modules.php?module=admin&amp;what=' . $what_sub . '%}">';
+                                                                       $OUT .= '[<a href="{%url=modules.php?module=admin&amp;what=' . $subContent['sub_what'] . '%}">';
                                                                }
                                                        } else {
-                                                               $OUT .= '<span class="bad" style="cursor:help" title="{%message,ADMIN_MENU_WHAT_404_TITLE=' . $what_sub . '%}">';
+                                                               $OUT .= '<span class="bad" style="cursor:help" title="{%message,ADMIN_MENU_WHAT_404_TITLE=' . $subContent['sub_what'] . '%}">';
                                                        }
 
-                                                       $OUT .= $title_what;
+                                                       $OUT .= $subContent['sub_title'];
 
                                                        if ($readable === true) {
-                                                               if ($what == $what_sub) {
+                                                               if ($what == $subContent['sub_what']) {
                                                                        $OUT .= '</strong>';
                                                                } else {
                                                                        $OUT .= '</a>]';
@@ -382,9 +388,11 @@ ORDER BY
 
                                        // Free memory
                                        SQL_FREERESULT($result_what);
-                                       $OUT .= '</ul>
-</li>';
+                                       $OUT .= '</ul>';
                                } // END - if
+
+                               // Close li-tag
+                               $OUT .= '</li>';
                        } // END - if
                } // END - while
 
@@ -393,13 +401,8 @@ ORDER BY
                $OUT .= '</ul>';
        } // END - if
 
-       // Is there a cache instance again?
-       // Return or output content?
-       if ($return === true) {
-               return $OUT;
-       } else {
-               outputHtml($OUT);
-       }
+       // Return content
+       return $OUT;
 }
 
 // Create an admin selection box form