本文整理汇总了PHP中rex_i18n::translateArray方法的典型用法代码示例。如果您正苦于以下问题:PHP rex_i18n::translateArray方法的具体用法?PHP rex_i18n::translateArray怎么用?PHP rex_i18n::translateArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rex_i18n
的用法示例。
在下文中一共展示了rex_i18n::translateArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}