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


PHP rex_file::getCache方法代码示例

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


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

示例1: get

 /**
  * @param string $name
  *
  * @return null|self
  */
 public static function get($name)
 {
     if (!$name) {
         return null;
     }
     return self::getInstance($name, function ($name) {
         $media_path = rex_path::addonCache('mediapool', $name . '.media');
         if (!file_exists($media_path)) {
             rex_media_cache::generate($name);
         }
         if (file_exists($media_path)) {
             $cache = rex_file::getCache($media_path);
             $aliasMap = ['filename' => 'name', 'filetype' => 'type', 'filesize' => 'size'];
             $media = new self();
             foreach ($cache as $key => $value) {
                 if (array_key_exists($key, $aliasMap)) {
                     $var_name = $aliasMap[$key];
                 } else {
                     $var_name = $key;
                 }
                 $media->{$var_name} = $value;
             }
             $media->category = null;
             return $media;
         }
         return null;
     });
 }
开发者ID:DECAF,项目名称:redaxo,代码行数:33,代码来源:media.php

示例2: 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

示例3: 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

示例4: execute

 public function execute()
 {
     if (!rex::getUser()->isAdmin()) {
         throw new rex_api_exception('You do not have the permission!');
     }
     $installAddon = rex_addon::get('install');
     $versions = self::getVersions();
     $versionId = rex_request('version_id', 'int');
     if (!isset($versions[$versionId])) {
         return null;
     }
     $version = $versions[$versionId];
     if (!rex_string::versionCompare($version['version'], rex::getVersion(), '>')) {
         throw new rex_api_exception(sprintf('Existing version of Core (%s) is newer than %s', rex::getVersion(), $version['version']));
     }
     try {
         $archivefile = rex_install_webservice::getArchive($version['path']);
     } catch (rex_functional_exception $e) {
         throw new rex_api_exception($e->getMessage());
     }
     $message = '';
     $temppath = rex_path::coreCache('.new.core/');
     try {
         if ($version['checksum'] != md5_file($archivefile)) {
             throw new rex_functional_exception($installAddon->i18n('warning_zip_wrong_checksum'));
         }
         if (!rex_install_archive::extract($archivefile, $temppath)) {
             throw new rex_functional_exception($installAddon->i18n('warning_core_zip_not_extracted'));
         }
         if (!is_dir($temppath . 'core')) {
             throw new rex_functional_exception($installAddon->i18n('warning_zip_wrong_format'));
         }
         $coreAddons = [];
         /** @var rex_addon[] $updateAddons */
         $updateAddons = [];
         if (is_dir($temppath . 'addons')) {
             foreach (rex_finder::factory($temppath . 'addons')->dirsOnly() as $dir) {
                 $addonkey = $dir->getBasename();
                 $addonPath = $dir->getRealPath() . '/';
                 if (!file_exists($addonPath . rex_package::FILE_PACKAGE)) {
                     continue;
                 }
                 $config = rex_file::getConfig($addonPath . rex_package::FILE_PACKAGE);
                 if (!isset($config['version']) || rex_addon::exists($addonkey) && rex_string::versionCompare($config['version'], rex_addon::get($addonkey)->getVersion(), '<')) {
                     continue;
                 }
                 $coreAddons[$addonkey] = $addonkey;
                 if (rex_addon::exists($addonkey)) {
                     $updateAddons[$addonkey] = rex_addon::get($addonkey);
                     $updateAddonsConfig[$addonkey] = $config;
                 }
             }
         }
         //$config = rex_file::getConfig($temppath . 'core/default.config.yml');
         //foreach ($config['system_addons'] as $addonkey) {
         //    if (is_dir($temppath . 'addons/' . $addonkey) && rex_addon::exists($addonkey)) {
         //        $updateAddons[$addonkey] = rex_addon::get($addonkey);
         //    }
         //}
         $this->checkRequirements($temppath, $version['version'], $updateAddonsConfig);
         if (file_exists($temppath . 'core/update.php')) {
             include $temppath . 'core/update.php';
         }
         foreach ($updateAddons as $addonkey => $addon) {
             if ($addon->isInstalled() && file_exists($file = $temppath . 'addons/' . $addonkey . '/' . rex_package::FILE_UPDATE)) {
                 try {
                     $addon->includeFile($file);
                     if ($msg = $addon->getProperty('updatemsg', '')) {
                         throw new rex_functional_exception($msg);
                     }
                     if (!$addon->getProperty('update', true)) {
                         throw new rex_functional_exception(rex_i18n::msg('package_no_reason'));
                     }
                 } catch (rex_functional_exception $e) {
                     throw new rex_functional_exception($addonkey . ': ' . $e->getMessage(), $e);
                 } catch (rex_sql_exception $e) {
                     throw new rex_functional_exception($addonkey . ': SQL error: ' . $e->getMessage(), $e);
                 }
             }
         }
         // create backup
         $installConfig = rex_file::getCache($installAddon->getDataPath('config.json'));
         if (isset($installConfig['backups']) && $installConfig['backups']) {
             rex_dir::create($installAddon->getDataPath());
             $archive = $installAddon->getDataPath(strtolower(preg_replace('/[^a-z0-9-_.]/i', '_', rex::getVersion())) . '.zip');
             rex_install_archive::copyDirToArchive(rex_path::core(), $archive);
             foreach ($updateAddons as $addonkey => $addon) {
                 rex_install_archive::copyDirToArchive($addon->getPath(), $archive, 'addons/' . $addonkey);
             }
         }
         // copy plugins to new addon dirs
         foreach ($updateAddons as $addonkey => $addon) {
             foreach ($addon->getRegisteredPlugins() as $plugin) {
                 $pluginPath = $temppath . 'addons/' . $addonkey . '/plugins/' . $plugin->getName();
                 if (!is_dir($pluginPath)) {
                     rex_dir::copy($plugin->getPath(), $pluginPath);
                 } elseif ($plugin->isInstalled() && is_dir($pluginPath . '/assets')) {
                     rex_dir::copy($pluginPath . '/assets', $plugin->getAssetsPath());
                 }
             }
//.........这里部分代码省略.........
开发者ID:VIEWSION,项目名称:redaxo,代码行数:101,代码来源:api_core_update.php

示例5: getChildElements

 /**
  * @param int    $parentId
  * @param string $listType
  * @param bool   $ignoreOfflines
  * @param int    $clang
  *
  * @return static[]
  */
 protected static function getChildElements($parentId, $listType, $ignoreOfflines = false, $clang = null)
 {
     $parentId = (int) $parentId;
     // for $parentId=0 root elements will be returned, so abort here for $parentId<0 only
     if (0 > $parentId) {
         return [];
     }
     if (!$clang) {
         $clang = rex_clang::getCurrentId();
     }
     $class = get_called_class();
     return static::getInstanceList([$parentId, $listType], function ($id) use($class, $ignoreOfflines, $clang) {
         if ($instance = $class::get($id, $clang)) {
             return !$ignoreOfflines || $instance->isOnline() ? $instance : null;
         }
         return null;
     }, function ($parentId, $listType) {
         $listFile = rex_path::addonCache('structure', $parentId . '.' . $listType);
         if (!file_exists($listFile)) {
             rex_article_cache::generateLists($parentId);
         }
         return rex_file::getCache($listFile);
     });
 }
开发者ID:skerbis,项目名称:redaxo,代码行数:32,代码来源:structure_element.php

示例6: loadCache

 private static function loadCache()
 {
     if (self::$cache === null) {
         foreach ((array) rex_file::getCache(rex_path::addonCache('install', 'webservice.cache')) as $path => $cache) {
             if ($cache['stamp'] > time() - self::REFRESH_CACHE) {
                 self::$cache[$path] = $cache;
             }
         }
     }
 }
开发者ID:eaCe,项目名称:redaxo4,代码行数:10,代码来源:webservice.php

示例7: checkCache

 /**
  * Loads the cache if not already loaded.
  */
 private static function checkCache()
 {
     if (self::$cacheLoaded) {
         return;
     }
     $file = rex_path::cache('clang.cache');
     if (!file_exists($file)) {
         rex_clang_service::generateCache();
     }
     foreach (rex_file::getCache($file) as $id => $clang) {
         self::$clangs[$id] = new self($id, $clang['code'], $clang['name'], $clang['priority']);
     }
     self::$cacheLoaded = true;
 }
开发者ID:staabm,项目名称:redaxo,代码行数:17,代码来源:clang.php

示例8: rex_timer

rex::setProperty('timer', new rex_timer($_SERVER['REQUEST_TIME_FLOAT']));
// add backend flag to rex
rex::setProperty('redaxo', $REX['REDAXO']);
// 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
开发者ID:skerbis,项目名称:redaxo,代码行数:31,代码来源:boot.php

示例9: loadFromFile

 /**
  * load the config-data from a file-cache.
  *
  * @return bool Returns TRUE, if the data was successfully loaded from the file-cache, otherwise FALSE.
  */
 private static function loadFromFile()
 {
     // delete cache-file, will be regenerated on next request
     if (file_exists(REX_CONFIG_FILE_CACHE)) {
         self::$data = rex_file::getCache(REX_CONFIG_FILE_CACHE);
         return true;
     }
     return false;
 }
开发者ID:VIEWSION,项目名称:redaxo,代码行数:14,代码来源:config.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: sendMedia

 public function sendMedia()
 {
     $headerCacheFilename = $this->getHeaderCacheFilename();
     $CacheFilename = $this->getCacheFilename();
     if ($this->isCached()) {
         $header = rex_file::getCache($headerCacheFilename);
         if (isset($header['Last-Modified'])) {
             rex_response::sendLastModified(strtotime($header['Last-Modified']));
         }
         foreach ($header as $t => $c) {
             header($t . ': ' . $c);
         }
         readfile($CacheFilename);
     } else {
         $this->media->sendMedia($CacheFilename, $headerCacheFilename, $this->use_cache);
     }
     exit;
 }
开发者ID:skerbis,项目名称:redaxo,代码行数:18,代码来源:media_manager.php

示例12: getMedia

 /**
  * @return rex_media[]
  */
 public function getMedia()
 {
     return self::getInstanceList([$this->getId(), 'media'], 'rex_media::get', function ($id) {
         $list_path = rex_path::addonCache('mediapool', $id . '.mlist');
         if (!file_exists($list_path)) {
             rex_media_cache::generateList($id);
         }
         return rex_file::getCache($list_path);
     });
 }
开发者ID:staabm,项目名称:redaxo,代码行数:13,代码来源:media_category.php

示例13: doAction

 public function doAction()
 {
     $path = rex_path::addon($this->addonkey);
     $temppath = rex_path::addon('.new.' . $this->addonkey);
     if (($msg = $this->extractArchiveTo($temppath)) !== true) {
         return $msg;
     }
     // ---- check package.yml
     $packageFile = $temppath . rex_package::FILE_PACKAGE;
     if (!file_exists($packageFile)) {
         return rex_i18n::msg('package_missing_yml_file');
     }
     try {
         $config = rex_file::getConfig($packageFile);
     } catch (rex_yaml_parse_exception $e) {
         return rex_i18n::msg('package_invalid_yml_file') . ' ' . $e->getMessage();
     }
     if ($this->addon->isAvailable() && ($msg = $this->checkRequirements($config)) !== true) {
         return $msg;
     }
     // ---- include update.php
     if ($this->addon->isInstalled() && file_exists($temppath . rex_package::FILE_UPDATE)) {
         try {
             $this->addon->includeFile('../.new.' . $this->addonkey . '/' . rex_package::FILE_UPDATE);
         } catch (rex_functional_exception $e) {
             return $e->getMessage();
         } catch (rex_sql_exception $e) {
             return 'SQL error: ' . $e->getMessage();
         }
         if (($msg = $this->addon->getProperty('updatemsg', '')) != '') {
             return $msg;
         }
         if (!$this->addon->getProperty('update', true)) {
             return rex_i18n::msg('package_no_reason');
         }
     }
     // ---- backup
     $assets = $this->addon->getAssetsPath();
     $installConfig = rex_file::getCache(rex_addon::get('install')->getDataPath('config.json'));
     if (isset($installConfig['backups']) && $installConfig['backups']) {
         $archivePath = rex_path::addonData('install', $this->addonkey . '/');
         rex_dir::create($archivePath);
         $archive = $archivePath . strtolower(preg_replace('/[^a-z0-9-_.]/i', '_', $this->addon->getVersion('0'))) . '.zip';
         rex_install_archive::copyDirToArchive($path, $archive);
         if (is_dir($assets)) {
             rex_install_archive::copyDirToArchive($assets, $archive, 'assets');
         }
     }
     // ---- copy plugins to new addon dir
     foreach ($this->addon->getRegisteredPlugins() as $plugin) {
         $pluginPath = $temppath . '/plugins/' . $plugin->getName();
         if (!is_dir($pluginPath)) {
             rex_dir::copy($plugin->getPath(), $pluginPath);
         } elseif ($plugin->isInstalled() && is_dir($pluginPath . '/assets')) {
             rex_dir::copy($pluginPath . '/assets', $plugin->getAssetsPath());
         }
     }
     // ---- update main addon dir
     rex_dir::delete($path);
     rename($temppath, $path);
     // ---- update assets
     $origAssets = $this->addon->getPath('assets');
     if ($this->addon->isInstalled() && is_dir($origAssets)) {
         rex_dir::copy($origAssets, $assets);
     }
     // ---- update package order
     if ($this->addon->isAvailable()) {
         $this->addon->loadProperties();
         foreach ($this->addon->getAvailablePlugins() as $plugin) {
             $plugin->loadProperties();
         }
         rex_package_manager::generatePackageOrder();
     }
     $this->addon->setProperty('version', $this->file['version']);
     rex_install_packages::updatedPackage($this->addonkey, $this->fileId);
 }
开发者ID:DECAF,项目名称:redaxo,代码行数:76,代码来源:api_package_update.php

示例14: array_merge

<?php

/** @var rex_addon $this */
$panel = '';
$configFile = $this->getDataPath('config.json');
$config = array_merge(['backups' => false, 'api_login' => null, 'api_key' => null], rex_file::getCache($configFile));
$newConfig = rex_post('settings', [['backups', 'bool', false], ['api_login', 'string'], ['api_key', 'string']], null);
if (is_array($newConfig)) {
    $config = $newConfig;
    rex_file::putCache($configFile, $config);
    echo rex_view::success($this->i18n('settings_saved'));
    rex_install_webservice::deleteCache();
}
$panel .= '
            <fieldset>
                <legend>' . $this->i18n('settings_general') . '</legend>';
$formElements = [];
$n = [];
$n['reverse'] = true;
$n['label'] = '<label>' . $this->i18n('settings_backups') . '</label>';
$n['field'] = '<input type="checkbox"  name="settings[backups]" value="1" ' . ($config['backups'] ? 'checked="checked" ' : '') . '/>';
$formElements[] = $n;
$fragment = new rex_fragment();
$fragment->setVar('elements', $formElements, false);
$panel .= $fragment->parse('core/form/checkbox.php');
$panel .= '
            </fieldset>
            <fieldset>
                <legend>' . $this->i18n('settings_myredaxo_account') . '</legend>';
$formElements = [];
$n = [];
开发者ID:DECAF,项目名称:redaxo,代码行数:31,代码来源:settings.php

示例15: readPathFile

 public static function readPathFile()
 {
     if (!file_exists(self::$pathfile)) {
         self::generatePathFile([]);
     }
     self::$paths = rex_file::getCache(self::$pathfile);
 }
开发者ID:tzfrs,项目名称:redaxo_yrewrite,代码行数:7,代码来源:yrewrite.php


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