A lot while() conditions rewritten to SQL_FETCHARRAY(), see bug #107, @TODO tags...
[mailer.git] / inc / modules / admin / what-theme_check.php
index 53ef7809ca23f50bc7c6e975c54b043d3ef47c1a..c538c9fbd0291e96a800db681e95d8942b5abe67 100644 (file)
@@ -40,8 +40,6 @@ if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
 // Add description as navigation point
 ADD_DESCR("admin", __FILE__);
 
-global $cacheInstance, $cacheArray, $cacheMode;
-
 // Normally we want the overview of all registered theme_check
 $mode = "overview";
 $SEL = 0;
@@ -50,8 +48,7 @@ $SEL = 0;
 $response = GET_URL("check-themes.php");
 
 // Are theme_check found?
-if (($response[sizeof($response) - 1] == "[EOF]") && ($response[0] != "[EOF]"))
-{
+if (($response[count($response) - 1] == "[EOF]") && ($response[0] != "[EOF]")) {
        // Ok, mark found and create the array
        $THEMES = array(
                'fname'  => array(), // File names
@@ -63,21 +60,21 @@ if (($response[sizeof($response) - 1] == "[EOF]") && ($response[0] != "[EOF]"))
        );
 
        // Get count of theme_check for validation
-       $count = trim($response[sizeof($response) - 2]);
+       $count = trim($response[count($response) - 2]);
        foreach ($response as $idx => $value) {
                $value = str_replace("\n", "", $value); $ver = "";
 
                // Leave loop when data is invalid or EOF?
                if ((substr($value, 0, 6) == "theme-") && (substr($value, -4) == ".zip")) {
+                       // Extract name and version
                        $name = substr($value, 6, -4);
-                       $file = sprintf("%sthemes/%s/theme.php", PATH, $name);
                        $ver  = trim(substr($response[$idx + 3], 4));
 
                        // Load version
                        $cver = THEME_GET_VERSION($name);
 
-                       // Is the extension already installed or not?
-                       if (((SQL_NUMROWS($result) == 0) && (!FILE_READABLE($file))) || ($ver != $cver)) {
+                       // Is the theme already installed or not?
+                       if (($ver != $cver) && ($cver != "?") && ($cver != "!")) {
                                // No, it isn't. So let's add this one!
                                $THEMES['fname'][]  = $name;
                                $THEMES['fsize'][]  = $response[$idx + 1];
@@ -85,9 +82,10 @@ if (($response[sizeof($response) - 1] == "[EOF]") && ($response[0] != "[EOF]"))
                                $THEMES['ver'][]    = $ver;
                                $THEMES['cver'][]   = $cver;
 
+                               // Extract language strings from reponse
                                $LANG_DUMMY = explode("[nl]", $response[$idx + 4]);
                                $LANG = array();
-                               $INFO = ADMIN_EXT_NO_INFO_FOUND;
+                               $INFO = getMessage('ADMIN_EXT_NO_INFO_FOUND');
 
                                // Trim every data line
                                foreach ($LANG_DUMMY as $k => $v) {
@@ -110,34 +108,36 @@ if (($response[sizeof($response) - 1] == "[EOF]") && ($response[0] != "[EOF]"))
        } // END - foreach
 
        // Ok, themes are on our server but maybe you have already installed them?
-       if (sizeof($THEMES['fname']) > 0) {
+       if (count($THEMES['fname']) > 0) {
                // Sort array (I missed ver and cver here)
                array_pk_sort($THEMES, array("cver", "fname"), 0, 1);
 
                // Extensions where found which are not downloaded and installed
-               $SW = 2; $OUT = ""; $TSIZE = 0;
+               $OUT = ""; $SW = 2; $TSIZE = 0;
                foreach ($THEMES['fname'] as $idx => $name) {
                        // Generate download link
                        $LINK = SERVER_URL."/themes/theme-".$name.".zip";
-                       $OUT .= "<TR>
-  <TD align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".($idx + 1).".</TD>
-  <TD align=\"center\" class=\"switch_sw".$SW." bottom2 right2\"><A href=\"".$LINK."\">".$name."</A></TD>
-  <TD align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".MAKE_DATETIME($THEMES['fctime'][$idx], "2")."</TD>
-  <TD align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".TRANSLATE_COMMA(round($THEMES['fsize'][$idx] / 1.024) / 1000)." ".KBYTES."</TD>
-  <TD align=\"center\" class=\"switch_sw".$SW." bottom2\">".$THEMES['ver'][$idx]." (".$THEMES['cver'][$idx].")</TD>
-</TR>
-<TR>
-  <TD class=\"switch_sw".$SW." bottom2\">&nbsp;</TD>
-  <TD colspan=\"4\" class=\"switch_sw".$SW." bottom2\">
-    <FONT class=\"tiny\">".$THEMES['infos'][$idx]."</FONT>
-  </TD>
-</TR>\n";
+
+                       // @TODO Move this HTML code to a template "admin_theme_row"
+                       $OUT .= "<tr>
+  <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".($idx + 1).".</td>
+  <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\"><a href=\"".$LINK."\">".$name."</a></td>
+  <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".MAKE_DATETIME($THEMES['fctime'][$idx], "2")."</td>
+  <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".TRANSLATE_COMMA(round($THEMES['fsize'][$idx] / 1.024) / 1000)." ".KBYTES."</td>
+  <td align=\"center\" class=\"switch_sw".$SW." bottom2\">".$THEMES['ver'][$idx]." (".$THEMES['cver'][$idx].")</td>
+</tr>
+<tr>
+  <td class=\"switch_sw".$SW." bottom2\">&nbsp;</td>
+  <td colspan=\"4\" class=\"switch_sw".$SW." bottom2\">
+    <div class=\"tiny\">".$THEMES['infos'][$idx]."</div>
+  </td>
+</tr>\n";
                        $TSIZE += $THEMES['fsize'][$idx];
                        $SW = 3 - $SW;
                }
                define('__THEMES_ROWS', $OUT);
                define('__TKBYTES_VALUE', TRANSLATE_COMMA(round($TSIZE / 1.024) / 1000));
-               define('__TTHEME_VALUE', sizeof($THEMES['fname']));
+               define('__TTHEME_VALUE', count($THEMES['fname']));
 
                // Load template
                LOAD_TEMPLATE("admin_theme_list");
@@ -147,7 +147,7 @@ if (($response[sizeof($response) - 1] == "[EOF]") && ($response[0] != "[EOF]"))
        }
 } else {
        // No theme where found
-       LOAD_TEMPLATE("admin_theme_404");
+       LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_THEME_NOTHING_FOUND'));
 }
 
 //