Caching of themes (fully supported) and admin menu (experimental!) now configurable
authorRoland Häder <roland@mxchange.org>
Tue, 16 Sep 2008 14:42:04 +0000 (14:42 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 16 Sep 2008 14:42:04 +0000 (14:42 +0000)
inc/databases.php
inc/extensions/ext-cache.php
inc/language/cache_de.php
inc/libs/cache_functions.php
inc/modules/admin/admin-inc.php
inc/modules/admin/what-config_cache.php
templates/de/html/admin/admin_config_cache.tpl

index 102465d..2cb23a8 100644 (file)
@@ -113,7 +113,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
-define('CURR_SVN_REVISION', "338");
+define('CURR_SVN_REVISION', "339");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index cc8114c..b5c5977 100644 (file)
@@ -39,13 +39,13 @@ if (!defined('__SECURITY')) {
 }
 
 // Version number
-$EXT_VERSION = "0.1.8";
+$EXT_VERSION = "0.1.9";
 
 // Auto-set extension version
 if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION;
 
 // Version history array (add more with , "0.1" and so on)
-$EXT_VER_HISTORY = array("0.0", "0.0.1", "0.0.2", "0.0.3", "0.0.4", "0.0.5", "0.0.6", "0.0.7", "0.0.8", "0.0.9", "0.1.0", "0.1.1", "0.1.2", "0.1.3", "0.1.4", "0.1.5", "0.1.6", "0.1.7", "0.1.8");
+$EXT_VER_HISTORY = array("0.0", "0.0.1", "0.0.2", "0.0.3", "0.0.4", "0.0.5", "0.0.6", "0.0.7", "0.0.8", "0.0.9", "0.1.0", "0.1.1", "0.1.2", "0.1.3", "0.1.4", "0.1.5", "0.1.6", "0.1.7", "0.1.8", "0.1.9");
 
 switch ($EXT_LOAD_MODE)
 {
@@ -178,11 +178,18 @@ case "update": // Update an extension
                break;
 
        case "0.1.8": // SQL queries for v0.1.8
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_theme ENUM('Y','N') NOT NULL DEFAULT 'Y'";
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_themes ENUM('Y','N') NOT NULL DEFAULT 'Y'";
 
                // Update notes (these will be set as task text!)
                $UPDATE_NOTES = "Daten von installierten Themes werden nun gecacht.";
                break;
+
+       case "0.1.9": // SQL queries for v0.1.9
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_admin_menu ENUM('Y','N') NOT NULL DEFAULT 'N'";
+
+               // Update notes (these will be set as task text!)
+               $UPDATE_NOTES = "Administratormen&uuml; experimentell gecacht.";
+               break;
        }
        break;
 
@@ -191,7 +198,7 @@ default: // Do stuff when extension is loaded
        if ($cacheMode != "init") {
                // Initialize cache system only when it's needed
                $cacheInstance = new mxchange_cache($_CONFIG['cache_update'], PATH."inc/".$_CONFIG['cache_path'], $_CONFIG['cache_tested']);
-               if ($cacheInstance->ret != "done") {
+               if ($cacheInstance->getStatus() != "done") {
                        // Failed to initialize cache sustem
                        ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_INITIALIZE);
                }
index 3dcf19a..20bdf2c 100644 (file)
@@ -32,8 +32,7 @@
  ************************************************************************/
 
 // Some security stuff...
-if (basename($_SERVER['PHP_SELF']) == basename(__FILE__))
-{
+if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
 }
@@ -61,6 +60,8 @@ define('ADMIN_CACHE_CONFIG', "Soll der Zugriff auf die Tabelle <STRONG>"._MYSQL_
 define('ADMIN_CACHE_MODREG', "Soll der Zugriff auf die Tabelle <STRONG>"._MYSQL_PREFIX."_mod_reg</STRONG> beschleunigt werden?");
 define('ADMIN_CACHE_REFDEPTH', "Soll der Zugriff auf die Tabelle <STRONG>"._MYSQL_PREFIX."_refdepths</STRONG> beschleunigt werden?");
 define('ADMIN_CACHE_REFSYS', "Soll der Zugriff auf die Tabelle <STRONG>"._MYSQL_PREFIX."_refsystem</STRONG> beschleunigt werden?");
+define('ADMIN_CACHE_THEMES', "Soll der Zugriff auf die Tabelle <STRONG>"._MYSQL_PREFIX."_themes</STRONG> beschleunigt werden?");
+define('ADMIN_CACHE_ADMIN_MENU', "Soll der Aufbau des Administratormen&uuml;s beschleunigt werden (EXPERIMENTELL!)?");
 define('ADMIN_CACHE_PATH', "Relativer Pfad f&uuml;r alle Cache-Dateien zum Pfad <STRONG>inc</STRONG>");
 
 //
index 81b65c4..44df62b 100644 (file)
@@ -52,11 +52,14 @@ class mxchange_cache
 
        // Constructor
        function mxchange_cache($interval, $path, $tested) {
+               // Failed is the default
+               $this->ret = "failed";
+
                // Remember interval in class
-               $this->update_interval=$interval;
+               $this->update_interval = $interval;
 
                // Remeber path
-               $this->cache_path=$path;
+               $this->cache_path = $path;
 
                // Check if path exists
                if ((is_dir($path)) && (!$tested)) {
@@ -72,22 +75,16 @@ class mxchange_cache
                                        UPDATE_CONFIG("cache_tested", 1);
 
                                        // All done!
-                                       return "done";
+                                       $this->ret = "done";
                                } else {
                                        // Stop! Set a .htaccess file first
-                                       $this->ret="htaccess";
-                                       return "htaccess";
+                                       $this->ret = "htaccess";
                                }
                        }
                } elseif ($tested) {
                        // System already tested
-                       $this->ret="done";
-                       return "done";
+                       $this->ret = "done";
                }
-
-               // Something goes wrong here!
-               $this->ret="failed";
-               return "failed";
        }
 
        function cache_file($file, $ignore_ctime=false) {
@@ -390,6 +387,10 @@ class mxchange_cache
                // Return line
                return $line;
        }
+
+       function getStatus () {
+               return $this->ret;
+       }
 }
 //
 ?>
index 8060c15..ebf2b0e 100644 (file)
@@ -390,7 +390,7 @@ LIMIT 1", array($act, $wht, $wht), __FILE__, __LINE__);
 }
 //
 function ADD_ADMIN_MENU($act, $wht, $return=false) {
-       global $menuDesription, $menuTitle, $cacheInstance;
+       global $menuDesription, $menuTitle, $cacheInstance, $_CONFIG;
 
        // Init variables
        $SUB = false;
@@ -401,7 +401,7 @@ function ADD_ADMIN_MENU($act, $wht, $return=false) {
        $menuTitle = array();
 
        // Is there a cache instance?
-       if (is_object($cacheInstance)) {
+       if ((is_object($cacheInstance)) && (isset($_CONFIG['cache_admin_menu'])) && ($_CONFIG['cache_admin_menu'] == "Y")) {
                // Create cache name
                $cacheName = "admin_".$act."_".$wht."_".GET_LANGUAGE()."_".strtolower(get_session('admin_login'));
 
@@ -555,7 +555,7 @@ function ADD_ADMIN_MENU($act, $wht, $return=false) {
        eval($eval);
 
        // Is there a cache instance again?
-       if (is_object($cacheInstance)) {
+       if ((is_object($cacheInstance)) && (isset($_CONFIG['cache_admin_menu'])) && ($_CONFIG['cache_admin_menu'] == "Y")) {
                // Init cache
                $cacheInstance->cache_init($cacheName);
 
index 4f90be0..6f0a5f4 100644 (file)
@@ -88,41 +88,42 @@ if (isset($_POST['ok']))
  else
 {
        // Prepare data
-       switch ($_CONFIG['cache_admins'])
-       {
+       switch ($_CONFIG['cache_admins']) {
                case 'Y': define('__ADMINS_Y', " checked"); define('__ADMINS_N', "");         break;
                case 'N': define('__ADMINS_Y', "");         define('__ADMINS_N', " checked"); break;
        }
-       switch ($_CONFIG['cache_acls'])
-       {
+       switch ($_CONFIG['cache_acls']) {
                case 'Y': define('__ACLS_Y', " checked"); define('__ACLS_N', "");         break;
                case 'N': define('__ACLS_Y', "");         define('__ACLS_N', " checked"); break;
        }
-       switch ($_CONFIG['cache_exts'])
-       {
+       switch ($_CONFIG['cache_exts']) {
                case 'Y': define('__EXTS_Y', " checked"); define('__EXTS_N', "");         break;
                case 'N': define('__EXTS_Y', "");         define('__EXTS_N', " checked"); break;
        }
-       switch ($_CONFIG['cache_config'])
-       {
+       switch ($_CONFIG['cache_config']) {
                case 'Y': define('__CONFIG_Y', " checked"); define('__CONFIG_N', "");         break;
                case 'N': define('__CONFIG_Y', "");         define('__CONFIG_N', " checked"); break;
        }
-       switch ($_CONFIG['cache_modreg'])
-       {
+       switch ($_CONFIG['cache_modreg']) {
                case 'Y': define('__MODREG_Y', " checked"); define('__MODREG_N', "");         break;
                case 'N': define('__MODREG_Y', "");         define('__MODREG_N', " checked"); break;
        }
-       switch ($_CONFIG['cache_refdepth'])
-       {
+       switch ($_CONFIG['cache_refdepth']) {
                case 'Y': define('__REFDEPTH_Y', " checked"); define('__REFDEPTH_N', "");         break;
                case 'N': define('__REFDEPTH_Y', "");         define('__REFDEPTH_N', " checked"); break;
        }
-       switch ($_CONFIG['cache_refsys'])
-       {
+       switch ($_CONFIG['cache_refsys']) {
                case 'Y': define('__REFSYS_Y', " checked"); define('__REFSYS_N', "");         break;
                case 'N': define('__REFSYS_Y', "");         define('__REFSYS_N', " checked"); break;
        }
+       switch ($_CONFIG['cache_themes']) {
+               case 'Y': define('__THEMES_Y', " checked"); define('__THEMES_N', "");         break;
+               case 'N': define('__THEMES_Y', "");         define('__THEMES_N', " checked"); break;
+       }
+       switch ($_CONFIG['cache_admin_menu']) {
+               case 'Y': define('__ADMIN_MENU_Y', " checked"); define('__ADMIN_MENU_N', "");         break;
+               case 'N': define('__ADMIN_MENU_Y', "");         define('__ADMIN_MENU_N', " checked"); break;
+       }
        define('__PATH', $_CONFIG['cache_path']);
 
        // Load template
index 356d39e..15c7654 100644 (file)
        <TR>
                <TD colspan="2" class="seperator" height="10">&nbsp;</TD>
        </TR>
+       <TR>
+               <TD align="right" width="350" height="20">
+               {--ADMIN_CACHE_THEMES--}</TD>
+               <TD width="150" style="padding-left: 10px"><INPUT type="radio"
+                       name="cache_themes" value="Y" class="admin_normal"{!__THEMES_Y!}>&nbsp;{--YES--}
+               <INPUT type="radio" name="cache_themes" value="N" class="admin_normal"{!__THEMES_N!}>&nbsp;{--NO--}&nbsp;
+               </TD>
+       </TR>
+       <TR>
+               <TD colspan="2" class="seperator" height="10">&nbsp;</TD>
+       </TR>
+       <TR>
+               <TD align="right" width="350" height="20">
+               {--ADMIN_CACHE_ADMIN_MENU--}</TD>
+               <TD width="150" style="padding-left: 10px"><INPUT type="radio"
+                       name="cache_admin_menu" value="Y" class="admin_normal"{!__ADMIN_MENU_Y!}>&nbsp;{--YES--}
+               <INPUT type="radio" name="cache_admin_menu" value="N" class="admin_normal"{!__ADMIN_MENU_N!}>&nbsp;{--NO--}&nbsp;
+               </TD>
+       </TR>
+       <TR>
+               <TD colspan="2" class="seperator" height="10">&nbsp;</TD>
+       </TR>
        <TR>
                <TD align="right" width="350" height="20">
                {--ADMIN_CACHE_PATH--}:</TD>