]> git.mxchange.org Git - mailer.git/blobdiff - inc/classes/cachesystem.class.php
Introduced some wrapper functions, the extension for cache files is now .cache.php...
[mailer.git] / inc / classes / cachesystem.class.php
index df3c14578cd5f107ab04269dba99f960aeb1fe99..a5ea7261d17157cb62921364226888ab37f7c4fe 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -62,13 +62,16 @@ class CacheSystem {
        var $rebuilt = array();
 
        // File extension
-       var $extension = '.cache';
+       var $extension = '';
        var $status = array();
        var $readable = array();
        var $fullPath = '';
 
        // Constructor
        function CacheSystem () {
+               // Set extension
+               $this->extension = getCacheExtension();
+
                // Construct full path
                $this->fullPath = getPath() . getCachePath();
 
@@ -138,7 +141,7 @@ class CacheSystem {
                // Is the pointer a valid resource?
                if (is_resource($this->pointer)) {
                        // Write the line
-                       fwrite($this->pointer, $line . chr(10));
+                       fwrite($this->pointer, $line . PHP_EOL);
                } else {
                        // Something bad happened
                        reportBug(__METHOD__, __LINE__, 'Pointer type is ' . gettype($this->pointer) . ', expected is resource.');
@@ -152,6 +155,7 @@ class CacheSystem {
                unset($this->status[$this->name]);
        }
 
+       // Adds a data row (array) to cache file and global cache array
        function addRow ($data) {
                // Is the pointe rvalid?
                if (is_resource($this->pointer)) {
@@ -172,9 +176,9 @@ class CacheSystem {
                                        $GLOBALS['cache_array']['config'][$data['config']][$k] = $v;
                                } elseif ($this->name == 'filter') {
                                        // Filter
-                                       $GLOBALS['cache_array']['filter']['chains'][$data['filter_name']][$data['filter_function']] = $data['filter_active'];
+                                       $GLOBALS['cache_array']['filter']['chains'][$data['filter_name']][$data['filter_function']]  = $data['filter_active'];
                                        $GLOBALS['cache_array']['filter']['counter'][$data['filter_name']][$data['filter_function']] = $data['filter_counter'];
-                                       $GLOBALS['cache_array']['filter']['loaded'][$data['filter_name']][$data['filter_function']] = TRUE;
+                                       $GLOBALS['cache_array']['filter']['loaded'][$data['filter_name']][$data['filter_function']]  = TRUE;
                                } elseif ($this->name == 'modules') {
                                        // Modules
                                        $GLOBALS['cache_array']['modules'][$k][$data['module']] = $v;
@@ -239,6 +243,7 @@ class CacheSystem {
                }
        }
 
+       // Closes cache file with closing PHP tag
        function finalize () {
                // Quit function when no pointer is set
                if (is_resource($this->pointer)) {
@@ -264,6 +269,7 @@ class CacheSystem {
                } // END - if
        }
 
+       // Loads cache file and returns an array of the cached data
        function getArrayFromCache () {
                // Is the cache already loaded?
                if (isset($this->data[$this->name])) {
@@ -315,7 +321,7 @@ class CacheSystem {
                $this->resetCacheReadStatus();
 
                // Debug message
-               //* DEBUG: */ logDebugMessage(__METHOD__, __LINE__, sprintf("%s should be removed.", $this->name));
+               //* DEBUG: */ logDebugMessage(__METHOD__, __LINE__, sprintf('%s should be removed.', $this->name));
 
                // Is the cache file not yet rebuilt?
                if ((!isset($this->rebuilt[$this->name])) && ($this->isCacheReadable())) {
@@ -488,10 +494,10 @@ class CacheSystem {
                                // Debug messages
                                if (isset($this->version[$this->name][$ext_name])) {
                                        // Does it match?
-                                       $GLOBALS[__METHOD__][$ext_name] = ((isset($this->version[$this->name][$ext_name])) && ($this->version[$this->name][$ext_name] == $ext_ver));
+                                       $GLOBALS[__METHOD__][$ext_name] = ($this->version[$this->name][$ext_name] == $ext_ver);
                                } elseif ($this->isCacheReadable()) {
                                        // No cache version found
-                                       logDebugMessage(__METHOD__, __LINE__, 'Cache ' . $this->name . ' has missing version entry for extension ' . $ext_name . '! Purging cache...');
+                                       logDebugMessage(__METHOD__, __LINE__, 'Cache ' . $this->name . ' has missing version entry for extension ext-' . $ext_name . '! Purging cache...');
        
                                        // Remove the cache file
                                        $this->removeCacheFile(TRUE);