本文整理汇总了PHP中Tygh\Registry::cacheLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::cacheLevel方法的具体用法?PHP Registry::cacheLevel怎么用?PHP Registry::cacheLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tygh\Registry
的用法示例。
在下文中一共展示了Registry::cacheLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLangVar
/**
* Gets language variable by name
*
* @param string $var_name Language variable name
* @param string $lang_code 2-letter language code
*
* @return string Language variable value; in case the value is absent, language variable name with "_" prefix is returned
*/
public static function getLangVar($var_name, $lang_code = CART_LANGUAGE)
{
Registry::registerCache('lang_cache', array('language_values', 'ult_language_values'), Registry::cacheLevel('dispatch'), true);
if (empty($var_name)) {
return '';
}
$values = Registry::get('lang_cache.' . $lang_code);
if (empty($values)) {
$values = array();
}
$var_name = strtolower($var_name);
if (!isset($values[$var_name])) {
$params = array();
$left_join = array();
$fields = array('lang.value' => true);
$tables = array('?:language_values lang');
$condition = array(db_quote('lang.lang_code = ?s', $lang_code), db_quote('lang.name = ?s', $var_name));
fn_set_hook('get_lang_var', $fields, $tables, $left_join, $condition, $params);
$joins = !empty($left_join) ? ' LEFT JOIN ' . implode(', ', $left_join) : '';
$values[$var_name] = db_get_field('SELECT ' . implode(', ', array_keys($fields)) . ' FROM ' . implode(', ', $tables) . $joins . ' WHERE ' . implode(' AND ', $condition));
if (!db_get_found_rows()) {
unset($values[$var_name]);
}
Registry::set('lang_cache.' . $lang_code, $values);
}
if (!isset($values[$var_name])) {
return '_' . $var_name;
}
if (Registry::get('runtime.customization_mode.live_editor')) {
return '[lang name=' . $var_name . (preg_match('/\\[[\\w]+\\]/', $values[$var_name]) ? ' cm-pre-ajax' : '') . ']' . $values[$var_name] . '[/lang]';
}
return $values[$var_name];
}
示例2: init
public static function init($reinit = false, $config = array())
{
self::$active_debug_mode = false;
self::$allow_backtrace_sql = isset($_REQUEST['sql_backtrace']);
self::$debugger_cookie = !empty($_COOKIE['debugger']) ? $_COOKIE['debugger'] : '';
if ($reinit) {
Registry::registerCache('debugger', SESSION_ALIVE_TIME, Registry::cacheLevel('time'), true);
self::$actives = fn_get_storage_data('debugger_active');
self::$actives = !empty(self::$actives) ? unserialize(self::$actives) : array();
$active_in_registry = !empty(self::$actives[self::$debugger_cookie]) && time() - self::$actives[self::$debugger_cookie] < 0 ? true : false;
}
$debugger_token = !empty($config) ? $config['debugger_token'] : Registry::get('config.debugger_token');
switch (true) {
case defined('AJAX_REQUEST') && substr($_REQUEST['dispatch'], 0, 8) !== 'debugger':
break;
case defined('DEBUG_MODE') && DEBUG_MODE == true:
case !$reinit && (!empty(self::$debugger_cookie) || isset($_REQUEST[$debugger_token])):
self::$active_debug_mode = true;
break;
case !$reinit:
break;
// next if reinit
// next if reinit
case !empty(self::$debugger_cookie) && !empty($active_in_registry):
self::$active_debug_mode = true;
break;
case isset($_REQUEST[$debugger_token]):
$salt = '';
if ($_SESSION['auth']['user_type'] == 'A' && $_SESSION['auth']['is_root'] == 'Y') {
$user_admin = db_get_row('SELECT email, password FROM ?:users WHERE user_id = ?i', $_SESSION['auth']['user_id']);
$salt = $user_admin['email'] . $user_admin['password'];
}
if ($debugger_token != self::DEFAULT_TOKEN || !empty($salt)) {
// for non-default token allow full access
self::$debugger_cookie = substr(md5(SESSION::getId() . $salt), 0, 8);
$active_in_registry = true;
self::$active_debug_mode = true;
}
if (AREA == 'C' && !empty($_REQUEST[$debugger_token])) {
if (!empty(self::$actives[$_REQUEST[$debugger_token]]) && time() - self::$actives[$_REQUEST[$debugger_token]] < 0) {
$active_in_registry = true;
self::$debugger_cookie = $_REQUEST[$debugger_token];
self::$active_debug_mode = true;
}
}
fn_set_cookie('debugger', self::$debugger_cookie, SESSION_ALIVE_TIME);
break;
}
if ($reinit && self::$active_debug_mode && !empty(self::$debugger_cookie)) {
self::$actives[self::$debugger_cookie] = time() + self::EXPIRE_DEBUGGER;
fn_set_storage_data('debugger_active', serialize(self::$actives));
$active_in_registry = true;
}
if ($reinit && !empty(self::$debugger_cookie) && empty($active_in_registry)) {
fn_set_cookie('debugger', '', 0);
unset(self::$actives[self::$debugger_cookie]);
fn_set_storage_data('debugger_active', serialize(self::$actives));
}
return self::$active_debug_mode;
}
示例3: get
public function get($name, $cache_level = NULL)
{
$data = $this->query('hGet', $this->mapTags($name), $cache_level);
if (!empty($data)) {
if (!empty($data) && ($cache_level != Registry::cacheLevel('time') || $cache_level == Registry::cacheLevel('time') && $data['expiry'] > TIME)) {
return array($data['data']);
} else {
// clean up the cache
$this->query('del', $this->mapTags($name));
}
}
return false;
}
示例4: get
public function get($name, $cache_level = NULL)
{
$fname = $this->_mapTags($name) . '/' . $cache_level;
if (!empty($name) && is_readable($fname)) {
$_cache_data = @unserialize(fn_get_contents($fname));
if (!empty($_cache_data) && ($cache_level != Registry::cacheLevel('time') || $cache_level == Registry::cacheLevel('time') && $_cache_data['expiry'] > TIME)) {
return array($_cache_data['data']);
} else {
// clean up the cache
fn_rm($fname);
}
}
return false;
}
示例5: get
public function get($name, $cache_level = NULL)
{
$fname = $name . '.' . $cache_level;
$expiry_condition = $cache_level == Registry::cacheLevel('time') ? db_quote(" AND expiry > ?i", TIME) : '';
$res = $this->_dbFetch("SELECT data, expiry FROM cache WHERE name = '{$fname}' AND company_id = " . $this->_company_id . $expiry_condition);
if (!empty($name) && !empty($res)) {
$_cache_data = !empty($res['data']) ? @unserialize($res['data']) : false;
if ($_cache_data !== false) {
return array($_cache_data);
}
// clean up the cache
$this->db->query("DELETE FROM cache WHERE name = '{$fname}' AND company_id = " . $this->_company_id);
}
return false;
}
示例6: get
public function get($name, $cache_level = NULL)
{
$fname = $name . '.' . $cache_level;
$expiry_condition = $cache_level == Registry::cacheLevel('time') ? db_quote(" AND expiry > ?i", TIME) : '';
Db::$raw = true;
$res = Db::getRow("SELECT data, expiry FROM ?:cache WHERE name = ?s AND company_id = ?i ?p", $fname, $this->_company_id, $expiry_condition);
if (!empty($name) && !empty($res)) {
$_cache_data = !empty($res['data']) ? @unserialize($res['data']) : false;
if ($_cache_data !== false) {
return array($_cache_data);
}
// clean up the cache
Db::$raw = true;
Db::query("DELETE FROM ?:cache WHERE name = ?s AND company_id = ?i", $fname, $this->_company_id);
}
return false;
}
示例7: preloadLangVars
/**
* Loads received language variables into language cache
*
* @param array $var_names Language variable that to be loaded
* @param string $lang_code 2-letter language code
*
* @return boolean True if any of received language variables were added into cache; false otherwise
*/
public static function preloadLangVars($var_names, $lang_code = CART_LANGUAGE)
{
Registry::registerCache('lang_cache', array('language_values', 'ult_language_values'), Registry::cacheLevel('dispatch'), true);
$values = Registry::get('lang_cache.' . $lang_code);
if (empty($values)) {
$values = array();
}
$var_names = array_diff($var_names, array_keys($values));
if ($var_names) {
foreach ($var_names as $index => $var_name) {
$var_names[$index] = strtolower($var_name);
if (isset($values[$var_name])) {
unset($var_names[$index]);
}
}
if (empty($var_names)) {
return true;
}
$fields = array('lang.name' => true, 'lang.value' => true);
$tables = array('?:language_values lang');
$left_join = array();
$condition = array(db_quote('lang.lang_code = ?s', $lang_code), db_quote('lang.name IN (?a)', $var_names));
$params = array();
fn_set_hook('get_lang_var', $fields, $tables, $left_join, $condition, $params);
$joins = !empty($left_join) ? ' LEFT JOIN ' . implode(', ', $left_join) : '';
$new_values = db_get_hash_single_array('SELECT ' . implode(', ', array_keys($fields)) . ' FROM ' . implode(', ', $tables) . $joins . ' WHERE ' . implode(' AND ', $condition), array('name', 'value'));
foreach ($var_names as $var_name) {
if (!isset($new_values[$var_name])) {
$new_values[$var_name] = '_' . $var_name;
}
}
$values = fn_array_merge($values, $new_values);
Registry::set('lang_cache.' . $lang_code, $values);
return true;
}
return false;
}
示例8: fn_get_schema
/**
* Get all schema files (e.g. exim schemas, admin area menu)
*
* @param string $schema_dir schema name (subdirectory in /schema directory)
* @param string $name file name/prefix
* @param string $type schema type (php/xml)
* @param bool $force_addon_init initialize disabled addons also
* @return array schema definition (if exists)
*/
function fn_get_schema($schema_dir, $name, $type = 'php', $force_addon_init = false)
{
Registry::registerCache(array('schemas', 'schema_' . $schema_dir . '_' . $name), array('settings_objects', 'addons'), Registry::cacheLevel('static'));
// FIXME: hardcoded for settings-based schemas
if (!Registry::isExist('schema_' . $schema_dir . '_' . $name)) {
$files = array();
$path_name = Registry::get('config.dir.schemas') . $schema_dir . '/' . $name;
if (file_exists($path_name . '.' . $type)) {
$files[] = $path_name . '.' . $type;
}
if (file_exists($path_name . '_' . fn_strtolower(PRODUCT_EDITION) . '.' . $type)) {
$files[] = $path_name . '_' . fn_strtolower(PRODUCT_EDITION) . '.' . $type;
}
$addons = Registry::get('addons');
if (!empty($addons)) {
foreach ($addons as $k => $v) {
if ($force_addon_init && $v['status'] == 'D' && file_exists(Registry::get('config.dir.addons') . $k . '/func.php')) {
// force addon initialization
include_once Registry::get('config.dir.addons') . $k . '/func.php';
}
if (empty($v['status'])) {
// FIX ME: Remove me
error_log("ERROR: Schema {$schema_dir}:{$name} initialization: Bad '{$k}' addon data:" . serialize($v) . " Addons Registry:" . serialize(Registry::get('addons')));
}
if (!empty($v['status']) && $v['status'] == 'A' || $force_addon_init) {
$path_name = Registry::get('config.dir.addons') . $k . '/schemas/' . $schema_dir . '/' . $name;
if (file_exists($path_name . '_' . fn_strtolower(PRODUCT_EDITION) . '.' . $type)) {
array_unshift($files, $path_name . '_' . fn_strtolower(PRODUCT_EDITION) . '.' . $type);
}
if (file_exists($path_name . '.' . $type)) {
array_unshift($files, $path_name . '.' . $type);
}
if (file_exists($path_name . '.post.' . $type)) {
$files[] = $path_name . '.post.' . $type;
}
if (file_exists($path_name . '_' . fn_strtolower(PRODUCT_EDITION) . '.post.' . $type)) {
$files[] = $path_name . '_' . fn_strtolower(PRODUCT_EDITION) . '.post.' . $type;
}
}
}
}
Registry::set('schema_' . $schema_dir . '_' . $name, $files);
}
$schema = '';
$include_once = strpos($name, '.functions') !== false;
foreach (Registry::get('schema_' . $schema_dir . '_' . $name) as $file) {
if ($type == 'php') {
$schema = $include_once ? include_once $file : (include $file);
} else {
$schema .= file_get_contents($file);
}
}
return $schema;
}
示例9: isExist
/**
* Checks if file exists
*
* @param string $file file to check
* @param string $in_cache indicates that file existance should be checked in cache only (useful for non-local storages)
* @return boolean true if exists, false - otherwise
*/
public function isExist($file, $in_cache = false)
{
$file = $this->prefix($file);
$cache_name = 's3_' . $this->getOption('bucket');
Registry::registerCache($cache_name, array(), Registry::cacheLevel('static'), true);
$is_exist = Registry::get($cache_name . '.' . md5($file));
if ($in_cache == false && $is_exist == false && ($is_exist = $this->s3()->if_object_exists($this->getOption('bucket'), $file))) {
Registry::set($cache_name . '.' . md5($file), true);
}
return $is_exist;
}
示例10: fn_seo_get_cache_name
/**
* Gets cached SEO name
* @param string $name cached object (name or path)
* @param string $object_type object type
* @param mixed $object_id object_id/dispatch
* @param integer $company_id company ID
* @param string $lang_code language code
* @param string $area current working area
* @return string cached name
*/
function fn_seo_get_cache_name($name, $object_type, $object_id, $company_id, $lang_code, $area = AREA)
{
static $init_cache = false;
if ($area != 'C') {
return null;
}
$cache_name = $object_type == 's' ? 'seo_cache_static' : 'seo_cache';
if ($object_type == 's' && !$init_cache) {
Registry::registerCache($cache_name, array('seo_names'), Registry::cacheLevel('static') . $lang_code, true);
}
$key = $lang_code . '_' . $object_id . '_' . $object_type . '_' . $company_id;
return Registry::get($cache_name . '.' . $key . '.' . $name);
}
示例11: _registerBlockCache
/**
* Registers block cache
* @param string $cache_name Cache name
* @param array $block_scheme Block scheme data
*/
private static function _registerBlockCache($cache_name, $block_scheme)
{
if (isset($block_scheme['cache'])) {
$additional_level = '';
$default_handlers = fn_get_schema('block_manager', 'block_cache_properties');
if (isset($block_scheme['cache']['update_handlers']) && is_array($block_scheme['cache']['update_handlers'])) {
$handlers = $block_scheme['cache']['update_handlers'];
} else {
$handlers = array();
}
$cookie_data = fn_get_session_data();
$cookie_data['all'] = $cookie_data;
$additional_level .= self::_generateAdditionalCacheLevel($block_scheme['cache'], 'request_handlers', $_REQUEST);
$additional_level .= self::_generateAdditionalCacheLevel($block_scheme['cache'], 'session_handlers', $_SESSION);
$additional_level .= self::_generateAdditionalCacheLevel($block_scheme['cache'], 'cookie_handlers', $cookie_data);
$additional_level .= self::_generateAdditionalCacheLevel($block_scheme['cache'], 'auth_handlers', $_SESSION['auth']);
$additional_level .= '|path=' . Registry::get('config.current_path');
$additional_level .= Embedded::isEnabled() ? '|embedded' : '';
$additional_level = !empty($additional_level) ? md5($additional_level) : '';
$handlers = array_merge($handlers, $default_handlers['update_handlers']);
$cache_level = isset($block_scheme['cache']['cache_level']) ? $block_scheme['cache']['cache_level'] : Registry::cacheLevel('html_blocks');
Registry::registerCache($cache_name, $handlers, $cache_level . '__' . $additional_level);
}
}
示例12: fn_get_filters_products_count
/**
* Gets product filters with ranges
*
* @param array $params Products filter search params
* @return array Products and filters data
* array $filters - Product filters data
* array $view_all - All ranges filters
*/
function fn_get_filters_products_count($params = array())
{
/**
* Change parameters for getting product filters count
*
* @param array $params Products filter search params
*/
fn_set_hook('get_filters_products_count_pre', $params);
$key = 'pfilters_' . md5(serialize($params));
Registry::registerCache($key, array('products', 'product_features', 'product_filters', 'product_features_values', 'categories'), Registry::cacheLevel('user'));
if (Registry::isExist($key) == false) {
if (!empty($params['check_location'])) {
// FIXME: this is bad style, should be refactored
$valid_locations = array('index.index', 'products.search', 'categories.view', 'product_features.view');
if (!in_array($params['dispatch'], $valid_locations)) {
return array();
}
if ($params['dispatch'] == 'categories.view') {
$params['simple_link'] = true;
// this parameter means that extended filters on this page should be displayed as simple
$params['filter_custom_advanced'] = true;
// this parameter means that extended filtering should be stayed on the same page
} else {
if ($params['dispatch'] == 'product_features.view') {
$params['simple_link'] = true;
$params['features_hash'] = (!empty($params['features_hash']) ? $params['features_hash'] . '.' : '') . 'V' . $params['variant_id'];
//$params['exclude_feature_id'] = db_get_field("SELECT feature_id FROM ?:product_features_values WHERE variant_id = ?i", $params['variant_id']);
}
$params['get_for_home'] = 'Y';
}
}
// hide filters block on the advanced search page
if (!empty($params['skip_if_advanced']) && !empty($params['advanced_filter']) && $params['advanced_filter'] == 'Y') {
return array();
}
// Base fields for the SELECT queries
$values_fields = array('?:product_features_values.feature_id', 'COUNT(DISTINCT ?:products.product_id) as products', '?:product_features_values.variant_id as range_id', '?:product_feature_variant_descriptions.variant as range_name', '?:product_features.feature_type', '?:product_filters.filter_id');
$ranges_fields = array('?:product_features_values.feature_id', 'COUNT(DISTINCT ?:products.product_id) as products', '?:product_filter_ranges.range_id', '?:product_filter_ranges_descriptions.range_name', '?:product_filter_ranges.filter_id', '?:product_features.feature_type');
$condition = $where = $join = $filter_vq = $filter_rq = '';
$advanced_variant_ids = $ranges_ids = $field_filters = $feature_ids = $field_ranges_ids = $field_ranges_counts = $field_range_values = $slider_vals = array();
if (!empty($params['features_hash']) && empty($params['skip_advanced_variants'])) {
list($av_ids, $ranges_ids, $_field_ranges_ids, $slider_vals, $field_ranges_ids) = fn_parse_features_hash($params['features_hash']);
$advanced_variant_ids = db_get_hash_multi_array("SELECT feature_id, variant_id FROM ?:product_feature_variants WHERE variant_id IN (?n)", array('feature_id', 'variant_id'), $av_ids);
}
if (!empty($params['category_id'])) {
if (Registry::get('settings.General.show_products_from_subcategories') == 'Y') {
$id_path = db_get_field("SELECT id_path FROM ?:categories WHERE category_id = ?i", $params['category_id']);
$category_ids = db_get_fields("SELECT category_id FROM ?:categories WHERE id_path LIKE ?l", $id_path . '/%');
} else {
$category_ids = array();
}
$category_ids[] = $params['category_id'];
$condition .= db_quote(" AND (categories_path = '' OR FIND_IN_SET(?i, categories_path))", $params['category_id']);
$where .= db_quote(" AND ?:products_categories.category_id IN (?n)", $category_ids);
} elseif (empty($params['get_for_home']) && empty($params['get_custom'])) {
$condition .= " AND categories_path = ''";
}
if (!empty($params['filter_id'])) {
$condition .= db_quote(" AND ?:product_filters.filter_id = ?i", $params['filter_id']);
}
if (!empty($params['item_ids'])) {
$condition .= db_quote(" AND ?:product_filters.filter_id IN (?a)", explode(',', $params['item_ids']));
}
if (!empty($params['get_for_home'])) {
$condition .= db_quote(" AND ?:product_filters.show_on_home_page = ?s", $params['get_for_home']);
}
if (!empty($params['exclude_feature_id'])) {
$condition .= db_quote(" AND ?:product_filters.feature_id NOT IN (?n)", $params['exclude_feature_id']);
}
if (fn_allowed_for('ULTIMATE')) {
$condition .= fn_get_company_condition('?:product_filters.company_id');
}
$sf_fields = db_quote("?:product_filters.feature_id, ?:product_filters.filter_id, ?:product_filters.field_type, ?:product_filters.round_to, ?:product_filters.display, ?:product_filters.display_count, ?:product_filters.display_more_count, ?:product_filter_descriptions.filter, ?:product_features_descriptions.prefix, ?:product_features_descriptions.suffix");
$sf_join = db_quote("LEFT JOIN ?:product_filter_descriptions ON ?:product_filter_descriptions.filter_id = ?:product_filters.filter_id AND ?:product_filter_descriptions.lang_code = ?s LEFT JOIN ?:product_features_descriptions ON ?:product_features_descriptions.feature_id = ?:product_filters.feature_id AND ?:product_features_descriptions.lang_code = ?s", CART_LANGUAGE, CART_LANGUAGE);
$sf_sorting = db_quote("position, filter");
/**
* Change SQL parameters before select product filters
*
* @param array $sf_fields String of comma-separated SQL fields to be selected in an SQL-query
* @param string $sf_join String with the complete JOIN information (JOIN type, tables and fields) for an SQL-query
* @param string $condition String containing SQL-query condition possibly prepended with a logical operator (AND or OR)
* @param string $sf_sorting String containing the SQL-query ORDER BY clause
* @param array $params Products filter search params
*/
fn_set_hook('get_filters_products_count_before_select_filters', $sf_fields, $sf_join, $condition, $sf_sorting, $params);
$limit = '';
if (fn_allowed_for('ULTIMATE:FREE')) {
$limit = db_quote(' LIMIT ?i', FILTERS_LIMIT);
}
$filters = db_get_hash_array("SELECT {$sf_fields} FROM ?:product_filters {$sf_join} WHERE ?:product_filters.status = 'A' ?p ORDER BY {$sf_sorting} {$limit}", 'filter_id', $condition);
$fields = fn_get_product_filter_fields();
if (empty($filters) && empty($params['advanced_filter'])) {
//.........这里部分代码省略.........
示例13: getStatic
/**
* Puts static SEO name to cache
* @param string $key cache key
* @param string $lang_code language code
* @param string $area current working area
* @return mixed cached data
*/
private static function getStatic($key, $lang_code, $area = AREA)
{
if ($area != 'C') {
return null;
}
if (!self::$init_cache) {
Registry::registerCache('seo_cache_static', array('seo_names'), Registry::cacheLevel('static') . $lang_code, true);
}
return Registry::get('seo_cache_static.' . $key);
}
示例14: getStatic
private static function getStatic($key)
{
if (!self::$init_cache) {
Registry::registerCache('yandex_delivery_cache_static', YD_CACHE_STATIC, Registry::cacheLevel('time'));
}
return Registry::get('yandex_delivery_cache_static.' . $key);
}
示例15: set
public function set($name, $data, $condition, $cache_level = null)
{
if (!empty($data)) {
apcu_store($this->_mapTags($name) . '/' . $cache_level, $data, $cache_level == Registry::cacheLevel('time') ? TIME + $condition : $this->global_ttl);
}
}