本文整理匯總了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;
}