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


PHP rex_file::putCache方法代码示例

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


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

示例1: testPutGetCache

 public function testPutGetCache()
 {
     $file = $this->getPath('putgetcache.txt');
     $content = ['test', 'key' => 'value'];
     $this->assertTrue(rex_file::putCache($file, $content), 'putCache() returns true on success');
     $this->assertEquals($content, rex_file::getCache($file), 'getCache() returns content of file');
 }
开发者ID:staabm,项目名称:redaxo,代码行数:7,代码来源:file_test.php

示例2: loadProperties

 /**
  * Loads the properties of package.yml.
  */
 private function loadProperties()
 {
     static $cache = null;
     if (is_null($cache)) {
         $cache = rex_file::getCache(rex_path::cache('packages.cache'));
     }
     $id = $this->getPackageId();
     $file = $this->getPath(self::FILE_PACKAGE);
     if (!file_exists($file)) {
         $this->propertiesLoaded = true;
         return;
     }
     if (isset($cache[$id]) && (!rex::isBackend() || !($user = rex::getUser()) || !$user->isAdmin() || $cache[$id]['timestamp'] >= filemtime($file))) {
         $properties = $cache[$id]['data'];
     } else {
         $properties = rex_file::getConfig($file);
         $cache[$id]['timestamp'] = filemtime($file);
         $cache[$id]['data'] = $properties;
         static $registeredShutdown = false;
         if (!$registeredShutdown) {
             $registeredShutdown = true;
             register_shutdown_function(function () use(&$cache) {
                 foreach ($cache as $package => $_) {
                     if (!rex_package::exists($package)) {
                         unset($cache[$package]);
                     }
                 }
                 rex_file::putCache(rex_path::cache('packages.cache'), $cache);
             });
         }
     }
     foreach ($properties as $key => $value) {
         if (!isset($this->properties[$key])) {
             $this->properties[$key] = rex_i18n::translateArray($value, false, [$this, 'i18n']);
         }
     }
     $this->propertiesLoaded = true;
 }
开发者ID:staabm,项目名称:redaxo,代码行数:41,代码来源:package.php

示例3: generateCache

 /**
  * Schreibt Spracheigenschaften in die Datei include/clang.php.
  *
  * @throws rex_exception
  */
 public static function generateCache()
 {
     $lg = rex_sql::factory();
     $lg->setQuery('select * from ' . rex::getTablePrefix() . 'clang order by priority');
     $clangs = [];
     foreach ($lg as $lang) {
         $id = $lang->getValue('id');
         foreach ($lg->getFieldnames() as $field) {
             $clangs[$id][$field] = $lang->getValue($field);
         }
     }
     $file = rex_path::coreCache('clang.cache');
     if (rex_file::putCache($file, $clangs) === false) {
         throw new rex_exception('Clang cache file could not be generated');
     }
 }
开发者ID:VIEWSION,项目名称:redaxo,代码行数:21,代码来源:service.php

示例4: setCache

 private static function setCache($path, $data)
 {
     self::$cache[$path]['stamp'] = time();
     self::$cache[$path]['data'] = $data;
     rex_file::putCache(rex_path::addonCache('install', 'webservice.cache'), self::$cache);
 }
开发者ID:eaCe,项目名称:redaxo4,代码行数:6,代码来源:webservice.php

示例5: generateCategoryList

 /**
  * Generiert eine Liste mit den Kindkategorien einer Kategorie.
  *
  * @param int $category_id Id der Kategorie
  *
  * @return bool TRUE bei Erfolg, sonst FALSE
  */
 public static function generateCategoryList($category_id)
 {
     // sanity check
     if ($category_id < 0) {
         return false;
     }
     $query = 'SELECT id, cast( name AS SIGNED ) AS sort FROM ' . rex::getTable('media_category') . ' WHERE parent_id = ' . $category_id . ' ORDER BY sort, name';
     $sql = rex_sql::factory();
     //$sql->setDebug();
     $sql->setQuery($query);
     $cacheArray = [];
     for ($i = 0; $i < $sql->getRows(); ++$i) {
         $cacheArray[] = $sql->getValue('id');
         $sql->next();
     }
     $list_file = rex_path::addonCache('mediapool', $category_id . '.mclist');
     if (rex_file::putCache($list_file, $cacheArray)) {
         return true;
     }
     return false;
 }
开发者ID:staabm,项目名称:redaxo,代码行数:28,代码来源:cache_media.php

示例6: array_merge

// add core lang directory to rex_i18n
rex_i18n::addDirectory(rex_path::core('lang'));
// add core base-fragmentpath to fragmentloader
rex_fragment::addDirectory(rex_path::core('fragments/'));
// ----------------- FUNCTIONS
require_once rex_path::core('functions/function_rex_globals.php');
require_once rex_path::core('functions/function_rex_other.php');
// ----------------- VERSION
rex::setProperty('version', '5.0.0-alpha7');
$cacheFile = rex_path::cache('config.yml.cache');
$configFile = rex_path::data('config.yml');
if (file_exists($cacheFile) && file_exists($configFile) && filemtime($cacheFile) >= filemtime($configFile)) {
    $config = rex_file::getCache($cacheFile);
} else {
    $config = array_merge(rex_file::getConfig(rex_path::core('default.config.yml')), rex_file::getConfig($configFile));
    rex_file::putCache($cacheFile, $config);
}
foreach ($config as $key => $value) {
    if (in_array($key, ['fileperm', 'dirperm'])) {
        $value = octdec($value);
    }
    rex::setProperty($key, $value);
}
date_default_timezone_set(rex::getProperty('timezone', 'Europe/Berlin'));
if (!rex::isSetup()) {
    rex_error_handler::register();
}
// ----------------- REX PERMS
rex_complex_perm::register('clang', 'rex_clang_perm');
// ----- SET CLANG
if (!rex::isSetup()) {
开发者ID:skerbis,项目名称:redaxo,代码行数:31,代码来源:boot.php

示例7: generateCache

 /**
  * save config to file-cache.
  */
 private static function generateCache()
 {
     if (rex_file::putCache(REX_CONFIG_FILE_CACHE, self::$data) <= 0) {
         throw new rex_exception('rex-config: unable to write cache file ' . REX_CONFIG_FILE_CACHE);
     }
 }
开发者ID:VIEWSION,项目名称:redaxo,代码行数:9,代码来源:config.php

示例8: saveCache

 /**
  * Saves the cache.
  */
 public static function saveCache()
 {
     if (!self::$cacheChanged) {
         return;
     }
     if (!is_writable(dirname(self::$cacheFile))) {
         throw new Exception("Unable to write autoload cachefile '" . self::$cacheFile . "'!");
     }
     // remove obsolete dirs from cache
     foreach (self::$dirs as $dir => $files) {
         if (!in_array($dir, self::$addedDirs)) {
             unset(self::$dirs[$dir]);
         }
     }
     rex_file::putCache(self::$cacheFile, [self::$classes, self::$dirs]);
     self::$cacheChanged = false;
 }
开发者ID:staabm,项目名称:redaxo,代码行数:20,代码来源:autoload.php

示例9: sendMedia

 public function sendMedia($sourceCacheFilename, $headerCacheFilename, $save = false)
 {
     if ($this->asImage) {
         $src = $this->getImageSource();
     } else {
         $src = rex_file::get($this->getMediapath());
     }
     $this->setHeader('Content-Length', rex_string::size($src));
     $header = $this->getHeader();
     if (!array_key_exists('Content-Type', $header)) {
         $finfo = finfo_open(FILEINFO_MIME_TYPE);
         $content_type = finfo_file($finfo, $this->getMediapath());
         if ($content_type != '') {
             $this->setHeader('Content-Type', $content_type);
         }
     }
     if (!array_key_exists('Content-Disposition', $header)) {
         $this->setHeader('Content-Disposition', 'inline; filename="' . $this->getMediaFilename() . '";');
     }
     if (!array_key_exists('Last-Modified', $header)) {
         $this->setHeader('Last-Modified', gmdate('D, d M Y H:i:s T'));
     }
     rex_response::cleanOutputBuffers();
     foreach ($this->header as $t => $c) {
         header($t . ': ' . $c);
     }
     echo $src;
     if ($save) {
         rex_file::putCache($headerCacheFilename, $this->header);
         rex_file::put($sourceCacheFilename, $src);
     }
 }
开发者ID:DECAF,项目名称:redaxo,代码行数:32,代码来源:managed_media.php

示例10: loadProperties

 /**
  * Loads the properties of package.yml.
  */
 public function loadProperties()
 {
     static $cache = null;
     if (is_null($cache)) {
         $cache = rex_file::getCache(rex_path::coreCache('packages.cache'));
     }
     $id = $this->getPackageId();
     $file = $this->getPath(self::FILE_PACKAGE);
     if (!file_exists($file)) {
         $this->propertiesLoaded = true;
         return;
     }
     if (isset($cache[$id]) && (!rex::isBackend() || !($user = rex::getUser()) || !$user->isAdmin() || $cache[$id]['timestamp'] >= filemtime($file))) {
         $properties = $cache[$id]['data'];
     } else {
         try {
             $properties = rex_file::getConfig($file);
             $cache[$id]['timestamp'] = filemtime($file);
             $cache[$id]['data'] = $properties;
             static $registeredShutdown = false;
             if (!$registeredShutdown) {
                 $registeredShutdown = true;
                 register_shutdown_function(function () use(&$cache) {
                     foreach ($cache as $package => $_) {
                         if (!rex_package::exists($package)) {
                             unset($cache[$package]);
                         }
                     }
                     rex_file::putCache(rex_path::coreCache('packages.cache'), $cache);
                 });
             }
         } catch (rex_yaml_parse_exception $exception) {
             if ($this->isInstalled()) {
                 throw $exception;
             }
             $properties = [];
         }
     }
     $this->properties = array_intersect_key($this->properties, ['install' => null, 'status' => null]);
     if ($properties) {
         foreach ($properties as $key => $value) {
             if (isset($this->properties[$key])) {
                 continue;
             }
             if ('supportpage' !== $key) {
                 $value = rex_i18n::translateArray($value, false, [$this, 'i18n']);
             } elseif (!preg_match('@^https?://@i', $value)) {
                 $value = 'http://' . $value;
             }
             $this->properties[$key] = $value;
         }
     }
     $this->propertiesLoaded = true;
 }
开发者ID:DECAF,项目名称:redaxo,代码行数:57,代码来源:package.php

示例11: generateLists

 /**
  * Generiert alle *.alist u. *.clist Dateien einer Kategorie/eines Artikels.
  *
  * @param int $parent_id KategorieId oder ArtikelId, die erneuert werden soll
  *
  * @return bool TRUE wenn der Artikel gelöscht wurde, sonst eine Fehlermeldung
  */
 public static function generateLists($parent_id)
 {
     // sanity check
     if ($parent_id < 0) {
         return false;
     }
     // --------------------------------------- ARTICLE LIST
     $GC = rex_sql::factory();
     // $GC->setDebug();
     $GC->setQuery('select * from ' . rex::getTablePrefix() . 'article where clang_id=:clang AND ((parent_id=:id and startarticle=0) OR (id=:id and startarticle=1)) order by priority,name', ['id' => $parent_id, 'clang' => rex_clang::getStartId()]);
     $cacheArray = [];
     foreach ($GC as $row) {
         $cacheArray[] = (int) $row->getValue('id');
     }
     $article_list_file = rex_path::addonCache('structure', $parent_id . '.alist');
     if (rex_file::putCache($article_list_file, $cacheArray) === false) {
         return rex_i18n::msg('article_could_not_be_generated') . ' ' . rex_i18n::msg('check_rights_in_directory') . rex_path::addonCache('structure');
     }
     // --------------------------------------- CAT LIST
     $GC = rex_sql::factory();
     $GC->setQuery('select * from ' . rex::getTablePrefix() . 'article where parent_id=:id and clang_id=:clang and startarticle=1 order by catpriority,name', ['id' => $parent_id, 'clang' => rex_clang::getStartId()]);
     $cacheArray = [];
     foreach ($GC as $row) {
         $cacheArray[] = (int) $row->getValue('id');
     }
     $article_categories_file = rex_path::addonCache('structure', $parent_id . '.clist');
     if (rex_file::putCache($article_categories_file, $cacheArray) === false) {
         return rex_i18n::msg('article_could_not_be_generated') . ' ' . rex_i18n::msg('check_rights_in_directory') . rex_path::addonCache('structure');
     }
     return true;
 }
开发者ID:staabm,项目名称:redaxo,代码行数:38,代码来源:cache_article.php

示例12:

<?php

/** @var rex_addon $this */
if (rex_string::versionCompare($this->getVersion(), '2.0.1', '<') && rex_config::has('install')) {
    rex_file::putCache($this->getDataPath('config.json'), rex_config::get('install'));
    rex_config::removeNamespace('install');
}
开发者ID:DECAF,项目名称:redaxo,代码行数:7,代码来源:update.php

示例13: generatePathFile

 public static function generatePathFile($params)
 {
     $setDomain = function (rex_yrewrite_domain &$domain, &$path, rex_structure_element $element) {
         $id = $element->getId();
         $clang = $element->getClang();
         if (isset(rex_yrewrite::$domainsByMountId[$id][$clang])) {
             $domain = rex_yrewrite::$domainsByMountId[$id][$clang];
             $path = rex_yrewrite::$scheme->getClang($clang, $domain);
         }
     };
     $setPath = function (rex_yrewrite_domain $domain, $path, rex_article $art) use($setDomain) {
         $setDomain($domain, $path, $art);
         if (($redirection = rex_yrewrite::$scheme->getRedirection($art, $domain)) instanceof rex_structure_element) {
             rex_yrewrite::$paths['redirections'][$art->getId()][$art->getClang()] = ['id' => $redirection->getId(), 'clang' => $redirection->getClang()];
             unset(rex_yrewrite::$paths['paths'][$domain->getName()][$art->getId()][$art->getClang()]);
             return;
         }
         unset(rex_yrewrite::$paths['redirections'][$art->getId()][$art->getClang()]);
         $url = rex_yrewrite::$scheme->getCustomUrl($art, $domain);
         if (!is_string($url)) {
             $url = rex_yrewrite::$scheme->appendArticle($path, $art, $domain);
         }
         rex_yrewrite::$paths['paths'][$domain->getName()][$art->getId()][$art->getClang()] = ltrim($url, '/');
     };
     $generatePaths = function (rex_yrewrite_domain $domain, $path, rex_category $cat) use(&$generatePaths, $setDomain, $setPath) {
         $path = rex_yrewrite::$scheme->appendCategory($path, $cat, $domain);
         $setDomain($domain, $path, $cat);
         foreach ($cat->getChildren() as $child) {
             $generatePaths($domain, $path, $child);
         }
         foreach ($cat->getArticles() as $art) {
             $setPath($domain, $path, $art);
         }
     };
     $ep = isset($params['extension_point']) ? $params['extension_point'] : '';
     switch ($ep) {
         // clang and id specific update
         case 'CAT_DELETED':
         case 'ART_DELETED':
             foreach (self::$paths['paths'] as $domain => $c) {
                 unset(self::$paths['paths'][$domain][$params['id']]);
             }
             unset(self::$paths['redirections'][$params['id']]);
             if (0 == $params['re_id']) {
                 break;
             }
             $params['id'] = $params['re_id'];
             // no break
         // no break
         case 'CAT_ADDED':
         case 'CAT_UPDATED':
         case 'CAT_STATUS':
         case 'ART_ADDED':
         case 'ART_UPDATED':
         case 'ART_STATUS':
             rex_article_cache::delete($params['id']);
             $domain = self::$domainsByMountId[0][$params['clang']];
             $path = self::$scheme->getClang($params['clang'], $domain);
             $art = rex_article::get($params['id'], $params['clang']);
             $tree = $art->getParentTree();
             if ($art->isStartArticle()) {
                 $cat = array_pop($tree);
             }
             foreach ($tree as $parent) {
                 $path = self::$scheme->appendCategory($path, $parent, $domain);
                 $setDomain($domain, $path, $parent);
                 $setPath($domain, $path, rex_article::get($parent->getId(), $parent->getClang()));
             }
             if ($art->isStartArticle()) {
                 $generatePaths($domain, $path, $cat);
             } else {
                 $setPath($domain, $path, $art);
             }
             break;
             // update all
         // update all
         case 'CLANG_DELETED':
         case 'CLANG_ADDED':
         case 'CLANG_UPDATED':
             //case 'ALL_GENERATED':
         //case 'ALL_GENERATED':
         default:
             self::$paths = ['paths' => [], 'redirections' => []];
             foreach (rex_clang::getAllIds() as $clangId) {
                 $domain = self::$domainsByMountId[0][$clangId];
                 $path = self::$scheme->getClang($clangId, $domain);
                 foreach (rex_category::getRootCategories(false, $clangId) as $cat) {
                     $generatePaths($domain, $path, $cat);
                 }
                 foreach (rex_article::getRootArticles(false, $clangId) as $art) {
                     $setPath($domain, $path, $art);
                 }
             }
             break;
     }
     rex_file::putCache(self::$pathfile, self::$paths);
 }
开发者ID:tzfrs,项目名称:redaxo_yrewrite,代码行数:97,代码来源:yrewrite.php


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