Esempio n. 1
0
 function cacheGetContent($cache_id, $cache_group = 'global', $time = false)
 {
     global $cms_db_tables;
     global $mw_cache_storage;
     if ($cache_group === null) {
         $cache_group = 'global';
     }
     if ($cache_id === null) {
         return false;
     }
     $cache_id = trim($cache_id);
     //$_ENV['cache_storage'][$cache_id];
     //$memory = $this->cache_storage [$cache_id];
     //	p($mw_cache_storage);
     $memory = $mw_cache_storage["{$cache_id}"];
     //var_dump ( $memory );
     if ($memory != false) {
         $this->cache_storage_hits[$cache_id]++;
         //	print 'mem';
         return $memory;
     } else {
         //print 'nomem';
     }
     $cache_group = $cache_group . '/';
     $cache_group = reduce_double_slashes($cache_group);
     $cache_file = $this->_getCacheFile($cache_id, $cache_group);
     if ($time != false) {
         if (is_file($cache_file)) {
             $time_limit = strtotime($time);
             $last_modified = filemtime($cache_file);
             if (time() - $last_modified > $time_limit) {
                 unlink($cache_file);
             }
             return false;
         }
     }
     if (!in_array($cache_file, $this->path_list)) {
         $this->path_list[] = $cache_file;
         try {
             $cache = cache_file_memory_storage($cache_file);
         } catch (Exception $e) {
             $cache = false;
         }
     } else {
         try {
             $cache = file_get_contents($cache_file);
         } catch (Exception $e) {
             $cache = false;
         }
     }
     if (strval($cache) != '') {
         $search = CACHE_CONTENT_PREPEND;
         $replace = '';
         $count = 1;
         $cache = str_replace($search, $replace, $cache, $count);
         $mw_cache_storage["{$cache_id}"] = $cache;
         $this->cache_storage_hits[$cache_id]++;
     } else {
         //$this->cache_storage_not_found [$cache_file] ;
         //print 'no cache file'.$cache_file;
         //$this->cache_storage [$cache_id] = false;
         $mw_cache_storage["{$cache_id}"] = false;
         return false;
     }
     if ($cache != '') {
         //print 'put in mem';
         //	$this->cache_storage [$cache_id] = $cache;
         $mw_cache_storage["{$cache_id}"] = $cache;
         return $cache;
     } else {
         //clean
         $mw_cache_storage["{$cache_id}"] = false;
         //$this->cache_storage [$cache_id] = false;
         return false;
     }
     return false;
 }
Esempio n. 2
0
 /**
  * @desc  Get the template layouts styles fom the $layout_name/styles dir
  * @param string dir name under the layouts subdir on your active template
  * @return string
  * @author	Microweber Dev Team
  * @version 1.0
  * @since Version 1.0
  */
 function stylesList($layout_name)
 {
     CI::helper('directory');
     //$path = BASEPATH . 'content/templates/';
     $the_active_site_template = CI::model('core')->optionsGetByKey('curent_template');
     $path = TEMPLATEFILES . '' . $the_active_site_template . DIRECTORY_SEPARATOR . 'layouts' . DIRECTORY_SEPARATOR . $layout_name . DIRECTORY_SEPARATOR . 'styles' . DIRECTORY_SEPARATOR;
     //int $path;
     //exit;
     //	$map = directory_map ( $path, TRUE );
     //r_dump($map);
     $map = directory_map($path, TRUE, TRUE);
     //var_dump($map);
     $to_return = array();
     foreach ($map as $file) {
         $filename = $path . $file;
         //var_dump($filename);
         if (is_file($filename)) {
             $ext = file_extension($filename);
             $filename_no_ext = basename($filename, "." . $ext);
             $txt_file = $path . $dir . DIRECTORY_SEPARATOR . $filename_no_ext . '.txt';
             $img_file = $path . $dir . DIRECTORY_SEPARATOR . $filename_no_ext . '.jpg';
             $ext = end(explode(".", $filename));
             //var_dump($filename_no_ext);
             if ($ext == 'css') {
                 $filename2 = $txt_file;
                 if (is_file($filename2)) {
                     $fin = cache_file_memory_storage($filename2);
                     $to_return_temp = array();
                     $to_return_temp['filename'] = $file;
                     if (is_file($img_file)) {
                         $screens_file = pathToURL($img_file);
                         $to_return_temp['screenshot'] = trim($screens_file);
                     }
                     if (preg_match('/description:.+/', $fin, $regs)) {
                         $result = $regs[0];
                         $result = str_ireplace('description:', '', $result);
                         $to_return_temp['description'] = trim($result);
                     }
                     if (preg_match('/name:.+/', $fin, $regs)) {
                         $result = $regs[0];
                         $result = str_ireplace('name:', '', $result);
                         $to_return_temp['name'] = trim($result);
                     }
                     if (preg_match('/type:.+/', $fin, $regs)) {
                         $result = $regs[0];
                         $result = str_ireplace('type:', '', $result);
                         $to_return_temp['type'] = trim($result);
                     }
                     //if ($to_return_temp ['type'] == 'layout') {
                     if ($to_return_temp['name'] != false) {
                         $to_return[] = $to_return_temp;
                     }
                     //}
                 }
             }
         }
     }
     return $to_return;
 }