]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-config_cats.php
A lot while() conditions rewritten to SQL_FETCHARRAY(), see bug #107, @TODO tags...
[mailer.git] / inc / modules / admin / what-config_cats.php
index b8ebcf8b04bb5483580e8993139443db767ad2b4..4b84498ec36ae0b3c8b343f6058262ae747b6bcd 100644 (file)
@@ -105,7 +105,7 @@ if (REQUEST_ISSET_POST(('add'))) {
        }
 } elseif ((REQUEST_ISSET_POST('del')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) {
        // Delete categories
-       $SW = 2; $OUT = "";
+       $OUT = ""; $SW = 2;
        foreach (REQUEST_POST('sel') as $id => $value) {
                // Load data of category
                $result = SQL_QUERY_ESC("SELECT cat FROM `{!_MYSQL_PREFIX!}_cats` WHERE id=%s LIMIT 1",
@@ -130,7 +130,7 @@ if (REQUEST_ISSET_POST(('add'))) {
        LOAD_TEMPLATE("admin_del_cats");
 } elseif ((REQUEST_ISSET_POST('edit')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) {
        // Edit categories
-       $SW = 2; $OUT = "";
+       $OUT = ""; $SW = 2;
        foreach (REQUEST_POST('sel') as $id => $value)
        {
                // Load data from the category
@@ -156,29 +156,25 @@ if (REQUEST_ISSET_POST(('add'))) {
 
        // Load main template
        LOAD_TEMPLATE("admin_edit_cats");
-}
- else
-{
+} else {
+       // Init variable here
+       $CATS = "";
+
        // Load all categories
        $result = SQL_QUERY("SELECT id, cat, visible, sort FROM `{!_MYSQL_PREFIX!}_cats` ORDER BY `sort`", __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) > 0)
-       {
+       if (SQL_NUMROWS($result) > 0) {
+               // Init variables
+               $OUT = ""; $SW = 2;
+
                // List already existing categories for editing
-               $SW = 2; $OUT = ""; $CATS = "";
-               while (list($id, $cat, $visible, $sort) = SQL_FETCHROW($result))
-               {
+               while ($content = SQL_FETCHARRAY($result)) {
                        // Prepare data for the row template
-                       $content = array(
-                               'sw'   => $SW,
-                               'id'   => $id,
-                               'cat'  => $cat,
-                               'vis'  => TRANSLATE_YESNO($visible),
-                               'sort' => $sort,
-                       );
+                       $content['sw']  = $SW;
+                       $content['vis'] = TRANSLATE_YESNO($content['visible']);
 
                        // Put cat descriptions into variable for the selection box
-                       if (strlen($cat) > 20) $cat = substr($cat, 0, 17)."...";
-                       $CATS .= "      <option value=\"".$sort."\">".$cat."</option>\n";
+                       if (strlen($content['cat']) > 20) $content['cat'] = substr($content['cat'], 0, 17)."...";
+                       $CATS .= "      <option value=\"".$content['sort']."\">".$content['cat']."</option>\n";
 
                        // Load row template and switch color
                        $OUT .= LOAD_TEMPLATE("admin_config_cats_row", true, $content);
@@ -187,12 +183,15 @@ if (REQUEST_ISSET_POST(('add'))) {
 
                // Free memory
                SQL_FREERESULT($result);
+
+               // @TODO Rewrite this constant
                define('__CAT_ROWS', $OUT);
 
                // Load main template
                LOAD_TEMPLATE("admin_config_cats");
        }
 
+       // @TODO Rewrite this constant
        define('CATS', $CATS);
 
        // Form to add a new category