public function populate($current_cache = array())
 {
     $enabled = true;
     if (isset($current_cache['frontend']['core']['caching'])) {
         $enabled = $current_cache['frontend']['core']['caching'];
     }
     $this->getElement('enable')->setValue($enabled);
     $backend = Engine_Cache::getDefaultBackend();
     if (isset($current_cache['backend'])) {
         $backend = array_keys($current_cache['backend']);
         $backend = $backend[0];
     }
     $this->getElement('type')->setValue($backend);
     $file_path = $current_cache['default_file_path'];
     if (isset($current_cache['backend']['File']['cache_dir'])) {
         $file_path = $current_cache['backend']['File']['cache_dir'];
     }
     $this->getElement('file_path')->setValue($file_path);
     $file_locking = 1;
     if (isset($current_cache['backend']['File']['file_locking'])) {
         $file_locking = $current_cache['backend']['File']['file_locking'];
     }
     $this->getElement('file_locking')->setValue($file_locking);
     if (isset($current_cache['frontend']['core']['lifetime'])) {
         $lifetime = $current_cache['frontend']['core']['lifetime'];
     } else {
         $lifetime = 300;
         // 5 minutes
     }
     if (isset($current_cache['frontend']['core']['options']['lifetime'])) {
         $lifetime = $current_cache['frontend']['core']['options']['lifetime'];
     }
     $this->getElement('lifetime')->setValue($lifetime);
     $memcache_host = '127.0.0.1';
     $memcache_port = '11211';
     if (isset($current_cache['backend']['Memcache']['servers'][0]['host'])) {
         $memcache_host = $current_cache['backend']['Memcached']['servers'][0]['host'];
     }
     if (isset($current_cache["backend"]["Memcached"]["servers"][0]["port"])) {
         $memcache_port = $current_cache["backend"]["Memcached"]["servers"][0]["port"];
     }
     $this->getElement('memcache_host')->setValue($memcache_host);
     $this->getElement('memcache_port')->setValue($memcache_port);
     // Set Existing Value for Translation Performance checkbox
     $db = Engine_Db_Table::getDefaultAdapter();
     $initialTranslateAdapter = $db->select()->from('engine4_core_settings', 'value')->where('`name` = ?', 'core.translate.adapter')->query()->fetchColumn();
     if ($initialTranslateAdapter == 'array') {
         $translate_array = 1;
     } else {
         $translate_array = 0;
     }
     $this->getElement('translate_array')->setValue($translate_array);
     // Set Value for HTML Compression
     $gzip = FALSE;
     if (isset($current_cache['frontend']['core']['gzip'])) {
         $gzip = $current_cache['frontend']['core']['gzip'];
     }
     $this->getElement('gzip_html')->setValue($gzip);
 }
Example #2
0
 public function populate($current_cache = array())
 {
     $enabled = true;
     if (isset($current_cache['frontend']['core']['caching'])) {
         $enabled = $current_cache['frontend']['core']['caching'];
     }
     $this->getElement('enable')->setValue($enabled);
     $backend = Engine_Cache::getDefaultBackend();
     if (isset($current_cache['backend'])) {
         $backend = array_keys($current_cache['backend']);
         $backend = $backend[0];
     }
     $this->getElement('type')->setValue($backend);
     $file_path = $current_cache['default_file_path'];
     if (isset($current_cache['backend']['File']['cache_dir'])) {
         $file_path = $current_cache['backend']['File']['cache_dir'];
     }
     $this->getElement('file_path')->setValue($file_path);
     $file_locking = 1;
     if (isset($current_cache['backend']['File']['file_locking'])) {
         $file_locking = $current_cache['backend']['File']['file_locking'];
     }
     $this->getElement('file_locking')->setValue($file_locking);
     $lifetime = 300;
     // 5 minutes
     if (isset($current_cache['frontend']['core']['options']['lifetime'])) {
         $lifetime = $current_cache['frontend']['core']['options']['lifetime'];
     }
     $this->getElement('lifetime')->setValue($lifetime);
     $memcache_host = '127.0.0.1';
     $memcache_port = '11211';
     if (isset($current_cache['backend']['Memcache']['servers'][0]['host'])) {
         $memcache_host = $current_cache['backend']['Memcache']['servers'][0]['host'];
     }
     if (isset($current_cache['backend']['Memcache']['servers'][0]['port'])) {
         $memcache_port = $current_cache['backend']['Memcache']['servers'][0]['port'];
     }
     $this->getElement('memcache_host')->setValue($memcache_host);
     $this->getElement('memcache_port')->setValue($memcache_port);
 }
Example #3
0
 protected function _initCache()
 {
     // Get configurations
     $file = APPLICATION_PATH . '/application/settings/cache.php';
     // @todo cache config in database
     if (file_exists($file)) {
         // Manual config
         $options = (include $file);
     } else {
         if (is_writable(APPLICATION_PATH . '/temporary/cache') || !@is_dir(APPLICATION_PATH . '/temporary/cache') && @mkdir(APPLICATION_PATH . '/temporary/cache', 0777, true)) {
             // Auto default config
             $options = array('default_backend' => 'File', 'frontend' => array('core' => array('automatic_serialization' => true, 'cache_id_prefix' => 'Engine4_', 'lifetime' => '300', 'caching' => true)), 'backend' => array('File' => array('cache_dir' => APPLICATION_PATH . '/temporary/cache')));
         } else {
             // Failure
             return null;
         }
     }
     // Create cache
     $frontend = key($options['frontend']);
     $backend = key($options['backend']);
     Engine_Cache::setConfig($options);
     $cache = Engine_Cache::factory($frontend, $backend);
     // Disable caching in development mode
     if (APPLICATION_ENV == 'development') {
         $cache->setOption('caching', false);
     }
     // Save in registry
     Zend_Registry::set('Zend_Cache', $cache);
     // Use cache helper?
     Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-1, new Engine_Controller_Action_Helper_Cache());
     // Add cache to database
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     // Save in bootstrap
     return $cache;
 }
 /**
  * Set default backend
  *
  * @param string|Zend_Cache_Backend $backend
  */
 public static function setDefaultBackend($backend)
 {
     self::$_defaultBackend = $backend;
 }