BuildListSpecial($params); $prefix_special = $this->Prefix.'.'.$special; $this->Special = $special; $params['skip_counting'] = true; $list =& $this->Application->recallObject( $prefix_special, $this->Prefix.'_List',$params); // $list->clearFilters(); // $list->addFilter('parent_filter', 'ParentId = '.$parent_cat_id, WHERE_FILTER, FLT_SYSTEM); //unset($params['skip_counting']); // $this->Application->HandleEvent($event, $prefix_special.':SetPagination', $params ); $list->Query(); return $list; } function SubCatCount($params) { $cat_object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params); $sql = ' SELECT COUNT(*) - 1 FROM '.$cat_object->TableName.' WHERE ParentPath LIKE "'.$cat_object->GetDBField('ParentPath').'%"'; return $this->Conn->GetOne($sql); } function IsNew($params) { $object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params); $ret = $object->GetDBField('IsNew') ? 1 : 0; return $ret; } function IsPick($params) { $object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params); $ret = $object->GetDBField('EditorsPick') ? 1 : 0; return $ret; } function ItemIcon($params) { $object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params); $status = $object->GetDBField('Status'); if($status == 1) { $ret = $object->GetDBField('IsNew') ? 'icon16_cat_new.gif' : 'icon16_cat.gif'; } else { $ret = $status ? 'icon16_cat_pending.gif' : 'icon16_cat_disabled.gif'; } return $ret; } function ItemCount($params) { $cat_object =& $this->getObject($params); $ci_table = $this->Application->getUnitOption('l-ci', 'TableName'); $sql = ' SELECT COUNT(*) FROM '.$cat_object->TableName.' c LEFT JOIN '.$ci_table.' ci ON c.CategoryId=ci.CategoryId WHERE c.ParentPath LIKE "'.$cat_object->GetDBField('ParentPath').'%" AND NOT (ci.CategoryId IS NULL)'; return $this->Conn->GetOne($sql); } function ListCategories($params) { return $this->PrintList2($params); } function RootCategoryName($params) { $root_phrase = $this->Application->ConfigValue('Root_Name'); $ret = $this->Application->Phrase($root_phrase); return $ret; } function CheckModuleRoot($params) { $module_name = getArrayValue($params, 'module') ? $params['module'] : 'In-Commerce'; $module =& $this->Application->recallObject('mod.'.$module_name); $module_root_cat = $module->GetDBField('RootCat'); $additional_cats = $this->SelectParam($params, 'add_cats'); if ($additional_cats) { $additional_cats = explode(',', $additional_cats); } else { $additional_cats = array(); } if ($this->Application->GetVar('m_cat_id') == $module_root_cat || in_array($this->Application->GetVar('m_cat_id'), $additional_cats)) { $home_template = getArrayValue($params, 'home_template'); if (!$home_template) return; $this->Application->Redirect($home_template, Array('pass'=>'all')); }; } function CategoryPath($params) { $module_name = getArrayValue($params, 'module') ? $params['module'] : 'In-Commerce'; $module =& $this->Application->recallObject('mod.'.$module_name); $module_root_cat = $module->GetDBField('RootCat'); $block_params['current'] = 0; $block_params['separator'] = $params['separator']; if(!isset($params['cat_id'])) { $params['cat_id'] = getArrayValue($params, 'cat_id') ? $params['cat_id'] : $this->Application->GetVar('m_cat_id'); $block_params['current'] = 1; } $product_id = $this->Application->GetVar('p_id'); if ($product_id) { $block_params['current'] = 0; } $block_params['is_module_root'] = ($params['cat_id'] == $module_root_cat) ? 1 : 0; if($params['cat_id'] == 0) { $block_params['name'] = $this->SelectParam($params, 'root_cat_render_as,block_root_cat,rootcatblock'); return $this->Application->ParseBlock($block_params); } else { $block_params['name'] = $this->SelectParam($params,'render_as,block'); // $cat_object = &$this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List' ); $sql = 'SELECT CategoryId, ParentId, '.$this->getTitleField().' AS Name FROM '.$this->Application->getUnitOption($this->Prefix, 'TableName').' WHERE CategoryId = '.$params['cat_id']; $res = $this->Conn->GetRow($sql); if ($res === false) { // in case if category is deleted return ''; } $block_params['cat_name'] = $res['Name']; $block_params['cat_id'] = $res['CategoryId']; $parent_params = $params; $parent_params['cat_id'] = $res['ParentId']; // which block to parse as current ? if ($block_params['is_module_root'] == 1) { // module root $block_params['name'] = $this->SelectParam($params, 'module_root_render_as,block_module_root,rootmoduleblock'); } if ($block_params['current'] == 1) { // current cat (label) $block_params['name'] = $this->SelectParam($params, 'current_render_as,block_current,currentblock'); } $this->Application->SetVar($this->Prefix.'_id', $res['CategoryId']); $current_cat = $this->Application->ParseBlock($block_params, 1); $this->Application->SetVar($this->Prefix.'_id', $res['ParentId']); $parent_cat = $this->CategoryPath($parent_params); return $parent_cat.$current_cat; } } function CurrentCategoryName($params) { $cat_object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List'); $sql = 'SELECT '.$this->getTitleField().' FROM '.$cat_object->TableName.' WHERE CategoryId = '.$this->Application->GetVar('m_cat_id'); return $this->Conn->GetOne($sql); } function getTitleField() { $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); return $ml_formatter->LangFieldName('Name'); } function CategoryLink($params) { // 'p_id'=>'0', ?? $params = array_merge(array('pass'=>'m'), $params); $cat_id = getArrayValue($params,'cat_id'); if ($cat_id === false) { // $cat_id = $this->Application->Parser->GetParam('cat_id'); $cat_id = $this->Application->GetVar($this->Prefix.'_id'); } if($cat_id == 'Root') { $object =& $this->Application->recallObject('mod.'.$params['module']); $params['m_cat_id'] = $object->GetDBField('RootCat'); unset($params['module']); } else{ $params['m_cat_id'] = $cat_id; } unset($params['cat_id']); $main_processor =& $this->Application->recallObject('m_TagProcessor'); return $main_processor->T($params); } function CategoryList($params) { //$object =& $this->Application->recallObject( $this->getPrefixSpecial() , $this->Prefix.'_List', $params ); $object =& $this->GetList($params); if ($object->RecordsCount == 0) { if (isset($params['block_no_cats'])) { $params['name'] = $params['block_no_cats']; return $this->Application->ParseBlock($params); } else { return ''; } } if (isset($params['block'])) { return $this->PrintList($params); } else { $params['block'] = $params['block_main']; if (isset($params['block_row_start'])) { $params['row_start_block'] = $params['block_row_start']; } if (isset($params['block_row_end'])) { $params['row_end_block'] = $params['block_row_end']; } return $this->PrintList2($params); } } function Meta($params) { $name = getArrayValue($params, 'name'); $object =& $this->Application->recallObject($this->Prefix.'.-item'); $field = $object->GetField('Meta'.$name); if ($field) return $field; switch ($name) { case 'Description': $conf = 'Category_MetaDesc'; break; case 'Keywords': $conf = 'Category_MetaKey'; break; } return $this->Application->ConfigValue($conf); } function BuildListSpecial($params) { if ( isset($params['parent_cat_id']) ) { $parent_cat_id = $params['parent_cat_id']; } else { $parent_cat_id = $this->Application->GetVar($this->Prefix.'_id'); if (!$parent_cat_id) { $parent_cat_id = $this->Application->GetVar('m_cat_id'); } if (!$parent_cat_id) { $parent_cat_id = 0; } } $types = $this->SelectParam($params, 'types'); $except = $this->SelectParam($params, 'except'); $no_special = isset($params['no_special']) && $params['no_special']; if ($types.$except.$parent_cat_id == '' || $no_special) { return parent::BuildListSpecial($params); } $special = crc32($types.$except.$parent_cat_id); return $special; } function IsCurrent($params) { return false; } /** * Substitutes category in last template base on current category * * @param Array $params */ function UpdateLastTemplate($params) { $category_id = $this->Application->GetVar('m_cat_id'); list($index_file, $env) = explode('|', $this->Application->RecallVar('last_template'), 2); $this->Application->SetVar(ENV_VAR_NAME, $env); $this->Application->HttpQuery->processQueryString(); // update required fields $this->Application->SetVar('m_cat_id', $category_id); $this->Application->Session->SaveLastTemplate($params['template']); } function GetParentCategory($params) { $parent_id = 0; $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); $table = $this->Application->getUnitOption($this->Prefix,'TableName'); $cat_id = $this->Application->GetVar('m_cat_id'); if ($cat_id > 0) { $sql = 'SELECT ParentId FROM '.$table.' WHERE '.$id_field.' = '.$cat_id; $parent_id = $this->Conn->GetOne($sql); } return $parent_id; } function InitCacheUpdater($params) { safeDefine('CACHE_PERM_CHUNK_SIZE', 30); $continue = $this->Application->GetVar('continue'); $total_cats = (int) $this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'Category'); if ($continue === false && $total_cats > CACHE_PERM_CHUNK_SIZE) { // first step, if category count > CACHE_PERM_CHUNK_SIZE, then ask for cache update return true; } if ($continue === false) { // if we don't have to ask, then assume user selected "Yes" in permcache update dialog $continue = 1; } $updater =& $this->Application->recallObject('kPermCacheUpdater', null, Array('continue' => $continue)); if ($continue === '0') { // No in dialog $updater->clearData(); $this->Application->Redirect($params['destination_template']); } $ret = false; // don't ask for update if ($continue == 1) { // Initial run $updater->setData(); } if ($continue == 2) { // Continuing // called from AJAX request => returns percent $needs_more = true; while ($needs_more && $updater->iteration < CACHE_PERM_CHUNK_SIZE) { // until proceeeded in this step category count exceeds category per step limit $needs_more = $updater->DoTheJob(); } if ($needs_more) { // still some categories are left for next step $updater->setData(); } else { // all done -> redirect $updater->clearData(); $this->Application->StoreVar('PermCache_UpdateRequired', 0); $this->Application->Redirect($params['destination_template']); } $ret = $updater->getDonePercent(); } return $ret; } function SaveWarning($params) { $main_prefix = getArrayValue($params, 'main_prefix'); if ($main_prefix && $main_prefix != '$main_prefix') { $top_prefix = $main_prefix; } else { $top_prefix = $this->Application->GetTopmostPrefix($this->Prefix); } $temp_tables = $this->Application->GetVar($top_prefix.'_mode') == 't'; $modified = $this->Application->RecallVar($top_prefix.'_modified'); if (!$temp_tables) { $this->Application->RemoveVar($top_prefix.'_modified'); return 'flag remoeved'; } $block_name = $this->SelectParam($params, 'render_as,name'); if ($block_name) { $block_params = $this->prepareTagParams($params); $block_params['name'] = $block_name; $block_params['edit_mode'] = $temp_tables ? 1 : 0; $block_params['display'] = $temp_tables && $modified ? 1 : 0; return $this->Application->ParseBlock($block_params); } else { return $temp_tables && $modified ? 1 : 0; } return ; } } ?>