当前位置: 首页>>代码示例>>PHP>>正文


PHP Smarty::getCacheDir方法代码示例

本文整理汇总了PHP中Smarty::getCacheDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::getCacheDir方法的具体用法?PHP Smarty::getCacheDir怎么用?PHP Smarty::getCacheDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Smarty的用法示例。


在下文中一共展示了Smarty::getCacheDir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initTemplateEngine

 /**
  * Initialise Twig
  *
  * @return void
  */
 protected function initTemplateEngine()
 {
     $this->loader = new \Smarty();
     $this->loader->muteExpectedErrors();
     $this->loader->setTemplateDir($this->getTemplateDir());
     $this->loader->addPluginsDir(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'SmartyPlugins');
     $this->initSmartyCache();
     Logger::debug("Smarty Cache: " . $this->loader->getCacheDir());
 }
开发者ID:chrisnoden,项目名称:synergy,代码行数:14,代码来源:SmartyTemplate.php

示例2: testInstall


//.........这里部分代码省略.........
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['plugins_dir'] = $message;
             }
         } elseif (!is_readable($plugin_dir)) {
             $status = false;
             $message = "FAILED: {$plugin_dir} is not readable";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['plugins_dir'] = $message;
             }
         } elseif ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) {
             $_core_plugins_available = true;
         } else {
             if ($errors === null) {
                 echo "{$plugin_dir} is OK.\n";
             }
         }
     }
     if (!$_core_plugins_available) {
         $status = false;
         $message = "WARNING: Smarty's own libs/plugins is not available";
         if ($errors === null) {
             echo $message . ".\n";
         } elseif (!isset($errors['plugins_dir'])) {
             $errors['plugins_dir'] = $message;
         }
     }
     if ($errors === null) {
         echo "Testing cache directory...\n";
     }
     $_cache_dir = $smarty->getCacheDir();
     // test if all registered cache_dir is accessible
     if (!is_dir($_cache_dir)) {
         $status = false;
         $message = "FAILED: {$_cache_dir} is not a directory";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['cache_dir'] = $message;
         }
     } elseif (!is_readable($_cache_dir)) {
         $status = false;
         $message = "FAILED: {$_cache_dir} is not readable";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['cache_dir'] = $message;
         }
     } elseif (!is_writable($_cache_dir)) {
         $status = false;
         $message = "FAILED: {$_cache_dir} is not writable";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['cache_dir'] = $message;
         }
     } else {
         if ($errors === null) {
             echo "{$_cache_dir} is OK.\n";
         }
     }
     if ($errors === null) {
         echo "Testing configs directory...\n";
开发者ID:harmofwk,项目名称:harmofwk,代码行数:67,代码来源:smarty_internal_utility.php

示例3: clear

 public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
 {
     $_cache_id = isset($cache_id) ? preg_replace('![^\\w\\|]+!', '_', $cache_id) : null;
     $_compile_id = isset($compile_id) ? preg_replace('![^\\w\\|]+!', '_', $compile_id) : null;
     $_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
     $_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
     $_dir = $smarty->getCacheDir();
     $_dir_length = strlen($_dir);
     if (isset($_cache_id)) {
         $_cache_id_parts = explode('|', $_cache_id);
         $_cache_id_parts_count = count($_cache_id_parts);
         if ($smarty->use_sub_dirs) {
             foreach ($_cache_id_parts as $id_part) {
                 $_dir .= $id_part . DS;
             }
         }
     }
     if (isset($resource_name)) {
         $_save_stat = $smarty->caching;
         $smarty->caching = true;
         $tpl = new $smarty->template_class($resource_name, $smarty);
         $smarty->caching = $_save_stat;
         $tpl->source;
         if ($smarty->allow_ambiguous_resources) {
             $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
         } else {
             $_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
         }
         if (isset($_templateId[150])) {
             $_templateId = sha1($_templateId);
         }
         unset($smarty->template_objects[$_templateId]);
         if ($tpl->source->exists) {
             $_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath));
         } else {
             return 0;
         }
     }
     $_count = 0;
     $_time = time();
     if (file_exists($_dir)) {
         $_cacheDirs = new RecursiveDirectoryIterator($_dir);
         $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
         foreach ($_cache as $_file) {
             if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
                 continue;
             }
             if ($_file->isDir()) {
                 if (!$_cache->isDot()) {
                     @rmdir($_file->getPathname());
                 }
             } else {
                 $_parts = explode($_dir_sep, str_replace('\\', '/', substr((string) $_file, $_dir_length)));
                 $_parts_count = count($_parts);
                 if (isset($resource_name)) {
                     if ($_parts[$_parts_count - 1] != $_resourcename_parts) {
                         continue;
                     }
                 }
                 if (isset($_compile_id) && (!isset($_parts[$_parts_count - 2 - $_compile_id_offset]) || $_parts[$_parts_count - 2 - $_compile_id_offset] != $_compile_id)) {
                     continue;
                 }
                 if (isset($_cache_id)) {
                     $_parts_count = isset($_compile_id) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset;
                     if ($_parts_count < $_cache_id_parts_count) {
                         continue;
                     }
                     for ($i = 0; $i < $_cache_id_parts_count; $i++) {
                         if ($_parts[$i] != $_cache_id_parts[$i]) {
                             continue 2;
                         }
                     }
                 }
                 if (isset($exp_time) && $_time - @filemtime($_file) < $exp_time) {
                     continue;
                 }
                 $_count += @unlink((string) $_file) ? 1 : 0;
             }
         }
     }
     return $_count;
 }
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:82,代码来源:smarty_internal_cacheresource_file.php

示例4: clear

 /**
  * Empty cache for a specific template
  *
  * @param Smarty  $smarty
  * @param string  $resource_name template name
  * @param string  $cache_id      cache id
  * @param string  $compile_id    compile id
  * @param integer $exp_time      expiration time (number of seconds, not timestamp)
  *
  * @return integer number of cache files deleted
  */
 public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
 {
     $_cache_id = isset($cache_id) ? preg_replace('![^\\w\\|]+!', '_', $cache_id) : null;
     $_compile_id = isset($compile_id) ? preg_replace('![^\\w\\|]+!', '_', $compile_id) : null;
     $_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
     $_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
     if (($_dir = realpath($smarty->getCacheDir())) === false) {
         return 0;
     }
     $_dir .= '/';
     $_dir_length = strlen($_dir);
     if (isset($_cache_id)) {
         $_cache_id_parts = explode('|', $_cache_id);
         $_cache_id_parts_count = count($_cache_id_parts);
         if ($smarty->use_sub_dirs) {
             foreach ($_cache_id_parts as $id_part) {
                 $_dir .= $id_part . DS;
             }
         }
     }
     if (isset($resource_name)) {
         $_save_stat = $smarty->caching;
         $smarty->caching = true;
         $tpl = new $smarty->template_class($resource_name, $smarty);
         $smarty->caching = $_save_stat;
         // remove from template cache
         $tpl->source;
         // have the template registered before unset()
         if ($smarty->allow_ambiguous_resources) {
             $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
         } else {
             $_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
         }
         if (isset($_templateId[150])) {
             $_templateId = sha1($_templateId);
         }
         unset($smarty->template_objects[$_templateId]);
         if ($tpl->source->exists) {
             $_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath));
         } else {
             return 0;
         }
     }
     $_count = 0;
     $_time = time();
     if (file_exists($_dir)) {
         $_cacheDirs = new RecursiveDirectoryIterator($_dir);
         $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
         foreach ($_cache as $_file) {
             if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
                 continue;
             }
             // directory ?
             if ($_file->isDir()) {
                 if (!$_cache->isDot()) {
                     // delete folder if empty
                     @rmdir($_file->getPathname());
                 }
             } else {
                 $_parts = explode($_dir_sep, str_replace('\\', '/', substr((string) $_file, $_dir_length)));
                 $_parts_count = count($_parts);
                 // check name
                 if (isset($resource_name)) {
                     if ($_parts[$_parts_count - 1] != $_resourcename_parts) {
                         continue;
                     }
                 }
                 // check compile id
                 if (isset($_compile_id) && (!isset($_parts[$_parts_count - 2 - $_compile_id_offset]) || $_parts[$_parts_count - 2 - $_compile_id_offset] != $_compile_id)) {
                     continue;
                 }
                 // check cache id
                 if (isset($_cache_id)) {
                     // count of cache id parts
                     $_parts_count = isset($_compile_id) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset;
                     if ($_parts_count < $_cache_id_parts_count) {
                         continue;
                     }
                     for ($i = 0; $i < $_cache_id_parts_count; $i++) {
                         if ($_parts[$i] != $_cache_id_parts[$i]) {
                             continue 2;
                         }
                     }
                 }
                 // expired ?
                 if (isset($exp_time)) {
                     if ($exp_time < 0) {
                         preg_match('#\'cache_lifetime\' =>\\s*(\\d*)#', file_get_contents($_file), $match);
                         if ($_time < @filemtime($_file) + $match[1]) {
//.........这里部分代码省略.........
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:101,代码来源:smarty_internal_cacheresource_file.php

示例5: clear

 /**
  * Empty cache for a specific template
  *
  * @param Smarty  $smarty
  * @param string  $resource_name template name
  * @param string  $cache_id      cache id
  * @param string  $compile_id    compile id
  * @param integer $exp_time      expiration time (number of seconds, not timestamp)
  *
  * @return integer number of cache files deleted
  */
 public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
 {
     $_cache_id = isset($cache_id) ? preg_replace('![^\\w\\|]+!', '_', $cache_id) : null;
     $_compile_id = isset($compile_id) ? preg_replace('![^\\w]+!', '_', $compile_id) : null;
     $_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
     $_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
     $_dir = $smarty->getCacheDir();
     if ($_dir == '/') {
         //We should never want to delete this!
         return 0;
     }
     $_dir_length = strlen($_dir);
     if (isset($_cache_id)) {
         $_cache_id_parts = explode('|', $_cache_id);
         $_cache_id_parts_count = count($_cache_id_parts);
         if ($smarty->use_sub_dirs) {
             foreach ($_cache_id_parts as $id_part) {
                 $_dir .= $id_part . $smarty->ds;
             }
         }
     }
     if (isset($resource_name)) {
         $_save_stat = $smarty->caching;
         $smarty->caching = true;
         $tpl = new $smarty->template_class($resource_name, $smarty);
         $smarty->caching = $_save_stat;
         // remove from template cache
         $tpl->source;
         // have the template registered before unset()
         if ($tpl->source->exists) {
             $_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath));
         } else {
             return 0;
         }
     }
     $_count = 0;
     $_time = time();
     if (file_exists($_dir)) {
         $_cacheDirs = new RecursiveDirectoryIterator($_dir);
         $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
         foreach ($_cache as $_file) {
             if (substr(basename($_file->getPathname()), 0, 1) == '.') {
                 continue;
             }
             $_filepath = (string) $_file;
             // directory ?
             if ($_file->isDir()) {
                 if (!$_cache->isDot()) {
                     // delete folder if empty
                     @rmdir($_file->getPathname());
                 }
             } else {
                 // delete only php files
                 if (substr($_filepath, -4) !== '.php') {
                     continue;
                 }
                 $_parts = explode($_dir_sep, str_replace('\\', '/', substr($_filepath, $_dir_length)));
                 $_parts_count = count($_parts);
                 // check name
                 if (isset($resource_name)) {
                     if ($_parts[$_parts_count - 1] != $_resourcename_parts) {
                         continue;
                     }
                 }
                 // check compile id
                 if (isset($_compile_id) && (!isset($_parts[$_parts_count - 2 - $_compile_id_offset]) || $_parts[$_parts_count - 2 - $_compile_id_offset] != $_compile_id)) {
                     continue;
                 }
                 // check cache id
                 if (isset($_cache_id)) {
                     // count of cache id parts
                     $_parts_count = isset($_compile_id) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset;
                     if ($_parts_count < $_cache_id_parts_count) {
                         continue;
                     }
                     for ($i = 0; $i < $_cache_id_parts_count; $i++) {
                         if ($_parts[$i] != $_cache_id_parts[$i]) {
                             continue 2;
                         }
                     }
                 }
                 // expired ?
                 if (isset($exp_time)) {
                     if ($exp_time < 0) {
                         preg_match('#\'cache_lifetime\' =>\\s*(\\d*)#', file_get_contents($_file), $match);
                         if ($_time < @filemtime($_file) + $match[1]) {
                             continue;
                         }
                     } else {
//.........这里部分代码省略.........
开发者ID:jimjag,项目名称:smarty,代码行数:101,代码来源:smarty_internal_runtime_cacheresourcefile.php

示例6: clear

 /**
  * Empty cache for a specific template
  *
  * @param Smarty  $_template     template object
  * @param string  $resource_name template name
  * @param string  $cache_id      cache id
  * @param string  $compile_id    compile id
  * @param integer $exp_time      expiration time (number of seconds, not timestamp)
  * @return integer number of cache files deleted
  */
 public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
 {
     $_cache_id = isset($cache_id) ? preg_replace('![^\\w\\|]+!', '_', $cache_id) : null;
     $_compile_id = isset($compile_id) ? preg_replace('![^\\w\\|]+!', '_', $compile_id) : null;
     $_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
     $_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
     $_dir = $smarty->getCacheDir();
     $_dir_length = strlen($_dir);
     if (isset($_cache_id)) {
         $_cache_id_parts = explode('|', $_cache_id);
         $_cache_id_parts_count = count($_cache_id_parts);
         if ($smarty->use_sub_dirs) {
             foreach ($_cache_id_parts as $id_part) {
                 $_dir .= $id_part . DS;
             }
         }
     }
     if (isset($resource_name)) {
         $_save_stat = $smarty->caching;
         $smarty->caching = true;
         $tpl = new $smarty->template_class($resource_name, $smarty);
         $smarty->caching = $_save_stat;
         if ($tpl->source->exists) {
             $_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath));
             // remove from template cache
             unset($smarty->template_objects[sha1(join(DIRECTORY_SEPARATOR, $smarty->getTemplateDir()) . $tpl->template_resource . $tpl->cache_id . $tpl->compile_id)]);
         } else {
             // remove from template cache
             unset($smarty->template_objects[sha1(join(DIRECTORY_SEPARATOR, $smarty->getTemplateDir()) . $tpl->template_resource . $tpl->cache_id . $tpl->compile_id)]);
             return 0;
         }
     }
     $_count = 0;
     $_time = time();
     if (file_exists($_dir)) {
         $_cacheDirs = new RecursiveDirectoryIterator($_dir);
         $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
         foreach ($_cache as $_file) {
             if (substr($_file->getBasename(), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
                 continue;
             }
             // directory ?
             if ($_file->isDir()) {
                 if (!$_cache->isDot()) {
                     // delete folder if empty
                     @rmdir($_file->getPathname());
                 }
             } else {
                 $_parts = explode($_dir_sep, str_replace('\\', '/', substr((string) $_file, $_dir_length)));
                 $_parts_count = count($_parts);
                 // check name
                 if (isset($resource_name)) {
                     if ($_parts[$_parts_count - 1] != $_resourcename_parts) {
                         continue;
                     }
                 }
                 // check compile id
                 if (isset($_compile_id) && (!isset($_parts[$_parts_count - 2 - $_compile_id_offset]) || $_parts[$_parts_count - 2 - $_compile_id_offset] != $_compile_id)) {
                     continue;
                 }
                 // check cache id
                 if (isset($_cache_id)) {
                     // count of cache id parts
                     $_parts_count = isset($_compile_id) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset;
                     if ($_parts_count < $_cache_id_parts_count) {
                         continue;
                     }
                     for ($i = 0; $i < $_cache_id_parts_count; $i++) {
                         if ($_parts[$i] != $_cache_id_parts[$i]) {
                             continue 2;
                         }
                     }
                 }
                 // expired ?
                 if (isset($exp_time) && $_time - @filemtime($_file) < $exp_time) {
                     continue;
                 }
                 $_count += @unlink((string) $_file) ? 1 : 0;
             }
         }
     }
     return $_count;
 }
开发者ID:harmofwk,项目名称:harmofwk,代码行数:93,代码来源:smarty_internal_cacheresource_file.php


注:本文中的Smarty::getCacheDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。