/** * Checks if internationalization is enabled in a selected category * * @param string $cat Category code * @return bool TRUE if enabled, FALSE if not */ function cot_i18n_enabled($cat) { global $cfg, $structure; static $i18n_cats = false; if (!$i18n_cats) { // Get configured cats $i18n_cats = explode(',', $cfg['plugin']['i18n']['cats']); $i18n_cats = array_map('trim', $i18n_cats); } return in_array(cot_structure_parents('page', $cat, 'first'), $i18n_cats); }
/** * Update market categories counters * * @param string $cat Cat code * @return int * @global CotDB $db */ function cot_market_sync($cat) { global $db, $db_structure, $db_market, $cache; $parent = cot_structure_parents('market', $cat, 'first'); $cats = cot_structure_children('market', $parent, true, true); foreach ($cats as $c) { $subcats = cot_structure_children('market', $c, true, true); $count = $db->query("SELECT COUNT(*) FROM {$db_market} WHERE item_cat IN ('" . implode("','", $subcats) . "') AND item_state = 0")->fetchColumn(); $db->query("UPDATE {$db_structure} SET structure_count=" . (int) $count . " WHERE structure_area='market' AND structure_code = ?", $c); $summcount += $count; if ($cat == $c) { $catcount = $count; } } $cache && $cache->db->remove('structure', 'system'); return $catcount; }
/** * Функция загружает текущую конфигурацию * * @param string $extension Расширение * @param string $category $categoryКатегория */ protected function get_config($extension = '__default', $category = '__default') { $this->load_config_table(); if (!isset($this->config[$extension])) { $extension = '__default'; } if ($extension == '__default') { $category = '__default'; } else { if ($category != '__default') { $cat_parents = cot_structure_parents($extension, $category); $cat_parents = array_reverse($cat_parents); $category = '__default'; foreach ($cat_parents as $cat) { if (isset($this->config[$extension][$cat])) { $category = $cat; break; } } } if (!isset($this->config[$extension][$category])) { $extension = '__default'; $category = '__default'; } } $this->filepath = $this->config[$extension][$category]['filepath']; $this->thumbpath = $this->config[$extension][$category]['thumbspath']; $this->required = $this->config[$extension][$category]['required']; $this->allowed_ext = $this->config[$extension][$category]['allowed_ext']; $this->maxsize = $this->config[$extension][$category]['maxsize']; }