本文整理汇总了PHP中rex_path::cache方法的典型用法代码示例。如果您正苦于以下问题:PHP rex_path::cache方法的具体用法?PHP rex_path::cache怎么用?PHP rex_path::cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rex_path
的用法示例。
在下文中一共展示了rex_path::cache方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkFilesystem
/**
* checks permissions of all required filesystem resources.
*
* @return array An array of error messages
*/
public static function checkFilesystem()
{
// -------------------------- SCHREIBRECHTE
$writables = [rex_path::media(), rex_path::assets(), rex_path::cache(), rex_path::data(), rex_path::src()];
$func = function ($dir) use(&$func) {
if (!rex_dir::isWritable($dir)) {
return ['setup_304' => [$dir]];
}
$res = [];
foreach (rex_finder::factory($dir) as $path => $file) {
if ($file->isDir()) {
$res = array_merge_recursive($res, $func($path));
} elseif (!$file->isWritable()) {
$res['setup_305'][] = $path;
}
}
return $res;
};
$res = [];
foreach ($writables as $dir) {
if (@is_dir($dir)) {
$res = array_merge_recursive($res, $func($dir));
} else {
$res['setup_306'][] = $dir;
}
}
return $res;
}
示例2: rex_delete_cache
/**
* Deletes the cache.
*
* @package redaxo\core
*/
function rex_delete_cache()
{
// close logger, so the logfile can also be deleted
rex_logger::close();
$finder = rex_finder::factory(rex_path::cache())->recursive()->childFirst()->ignoreFiles(['.htaccess', '.redaxo'], false)->ignoreSystemStuff(false);
rex_dir::deleteIterator($finder);
rex_clang::reset();
// ----- EXTENSION POINT
return rex_extension::registerPoint(new rex_extension_point('CACHE_DELETED', rex_i18n::msg('delete_cache_message')));
}
示例3: register
/**
* Register rex_autoload in spl autoloader.
*/
public static function register()
{
if (self::$registered) {
return;
}
ini_set('unserialize_callback_func', 'spl_autoload_call');
if (!self::$composerLoader) {
self::$composerLoader = (require rex_path::core('vendor/autoload.php'));
// Unregister Composer Autoloader because we call self::$composerLoader->loadClass() manually
self::$composerLoader->unregister();
}
if (false === spl_autoload_register([__CLASS__, 'autoload'])) {
throw new Exception(sprintf('Unable to register %s::autoload as an autoloading method.', __CLASS__));
}
self::$cacheFile = rex_path::cache('autoload.cache');
self::loadCache();
register_shutdown_function([__CLASS__, 'saveCache']);
self::$registered = true;
}
示例4: foreach
if ($error != '') {
$message .= rex_view::error($error);
}
$content .= '
<table class="table table-hover">
<thead>
<tr>
<th>' . rex_i18n::msg('syslog_timestamp') . '</th>
<th>' . rex_i18n::msg('syslog_type') . '</th>
<th>' . rex_i18n::msg('syslog_message') . '</th>
<th>' . rex_i18n::msg('syslog_file') . '</th>
<th class="rex-table-number">' . rex_i18n::msg('syslog_line') . '</th>
</tr>
</thead>
<tbody>';
if ($file = new rex_log_file(rex_path::cache('system.log'))) {
foreach (new LimitIterator($file, 0, 30) as $entry) {
/* @var rex_log_entry $entry */
$data = $entry->getData();
$class = strtolower($data[0]);
$class = $class == 'notice' || $class == 'warning' ? $class : 'error';
$content .= '
<tr class="rex-state-' . $class . '">
<td data-title="' . rex_i18n::msg('syslog_timestamp') . '">' . $entry->getTimestamp('%d.%m.%Y %H:%M:%S') . '</td>
<td data-title="' . rex_i18n::msg('syslog_type') . '">' . $data[0] . '</td>
<td data-title="' . rex_i18n::msg('syslog_message') . '">' . $data[1] . '</td>
<td data-title="' . rex_i18n::msg('syslog_file') . '"><span class="rex-truncate rex-truncate-left">' . (isset($data[2]) ? $data[2] : '') . '</span></td>
<td class="rex-table-number" data-title="' . rex_i18n::msg('syslog_line') . '">' . (isset($data[3]) ? $data[3] : '') . '</td>
</tr>';
}
}
示例5: open
/**
* Prepares the logifle for later use.
*/
public static function open()
{
// check if already opened
if (!self::$file) {
$file = rex_path::cache('system.log');
self::$file = new rex_log_file($file, 2000000);
}
}
示例6: 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;
}
示例7: rex_fragment
echo $headline;
$fragment = new rex_fragment();
$fragment->setVar('title', rex_i18n::msg('setup_606'), false);
$fragment->setVar('body', $content, false);
$fragment->setVar('buttons', $buttons, false);
$content = $fragment->parse('core/page/section.php');
echo '<form class="rex-js-createadminform" action="' . rex_url::backendController() . '" method="post" autocomplete="off">' . $content . '</form>';
}
// ---------------------------------- step 7 . thank you . setup false
if ($step == 7) {
$configFile = rex_path::data('config.yml');
$config = array_merge(rex_file::getConfig(rex_path::core('default.config.yml')), rex_file::getConfig($configFile));
$config['setup'] = false;
if (rex_file::putConfig($configFile, $config)) {
$errmsg = '';
rex_file::delete(rex_path::cache('config.yml.cache'));
} else {
$errmsg = rex_i18n::msg('setup_701');
}
$headline = rex_view::title(rex_i18n::msg('setup_700'));
$content = '<h3>' . rex_i18n::msg('setup_703') . '</h3>';
$content .= rex_i18n::rawMsg('setup_704', '<a href="' . rex_url::backendController() . '">', '</a>');
$content .= '<p>' . rex_i18n::msg('setup_705') . '</p>';
$buttons = '<a class="btn btn-setup" href="' . rex_url::backendController() . '">' . rex_i18n::msg('setup_706') . '</a>';
echo $headline;
$fragment = new rex_fragment();
$fragment->setVar('heading', rex_i18n::msg('setup_702'), false);
$fragment->setVar('body', $content, false);
$fragment->setVar('buttons', $buttons, false);
echo $fragment->parse('core/page/section.php');
}
示例8: 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;
}
示例9: 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::cache('clang.cache');
if (rex_file::putCache($file, $clangs) === false) {
throw new rex_exception('Clang cache file could not be generated');
}
}
示例10: rex_timer
rex_autoload::addDirectory(rex_path::core('lib'));
rex_url::init($REX['HTDOCS_PATH'], $REX['BACKEND_FOLDER']);
// start timer at the very beginning
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()) {
示例11: 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::cache('.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
if ($installAddon->getConfig('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());
}
}
}
//.........这里部分代码省略.........
示例12: getCompiledFile
/**
* Get the path to the compiled version of a fragment.
*
* @param string $path
*
* @return string
*/
public function getCompiledFile($file)
{
return rex_path::cache($file);
}
示例13: init
/**
* initilizes the rex_config class.
*/
protected static function init()
{
if (self::$initialized) {
return;
}
define('REX_CONFIG_FILE_CACHE', rex_path::cache('config.cache'));
// take care, so we are able to write a cache file on shutdown
// (check here, since exceptions in shutdown functions are not visible to the user)
if (!is_writable(dirname(REX_CONFIG_FILE_CACHE))) {
throw new rex_exception('rex-config: cache dir "' . dirname(REX_CONFIG_FILE_CACHE) . '" is not writable!');
}
// save cache on shutdown
register_shutdown_function([__CLASS__, 'save']);
self::load();
self::$initialized = true;
}