Index: trunk/core/units/general/cat_tag_processor.php =================================================================== diff -u -r5536 -r6093 --- trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 5536) +++ trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 6093) @@ -2,6 +2,19 @@ class kCatDBTagProcessor extends kDBTagProcessor { + /** + * Permission Helper + * + * @var kPermissionsHelper + */ + var $PermHelper = null; + + function kCatDBTagProcessor() + { + parent::kDBTagProcessor(); + $this->PermHelper = $this->Application->recallObject('PermissionsHelper'); + } + function ItemIcon($params) { $object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params); @@ -23,6 +36,23 @@ return isset($icons[$value]) ? $icons[$value] : $icons['default']; } + function ItemLink($params) + { + // 'p_id'=>'0', ?? + $params = array_merge($params, array('pass'=>'m,'.$this->Prefix)); + $item_id = getArrayValue($params,$this->Prefix.'_id'); + if (!$item_id) { + $item_id = $this->Application->GetVar($this->Prefix.'_id'); + } + $params[$this->Prefix.'_id'] = $item_id; + + $item =& $this->Application->recallObject($this->getPrefixSpecial()); + $params['m_cat_id'] = $item->GetDBField('CategoryId'); + + $main_processor =& $this->Application->recallObject('m_TagProcessor'); + return $main_processor->T($params); + } + /** * Returns path where exported category items should be saved * @@ -49,33 +79,7 @@ $params['cat_id'] = $this->Application->RecallVar($params['session_var'], 0); } - $block_params['separator'] = $params['separator']; - - if ($params['cat_id'] == 0) { - $block_params['name'] = $params['rootcatblock']; - return $this->Application->ParseBlock($block_params); - } - else { - $cat_object =& $this->Application->recallObject('c', 'c_List'); - $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); - $sql = 'SELECT CategoryId, ParentId, '.$ml_formatter->LangFieldName('Name').' AS Name - FROM '.$cat_object->TableName.' - WHERE CategoryId = '.$params['cat_id']; - $res = $this->Conn->GetRow($sql); - if ($res === false) { - // in case if category is deleted - return ''; - } - $block_params['name'] = $params['block']; - $block_params['cat_name'] = $res['Name']; - $block_params['cat_id'] = $res['CategoryId']; - - $next_params['separator'] = $params['separator']; - $next_params['rootcatblock'] = $params['rootcatblock']; - $next_params['block'] = $params['block']; - $next_params['cat_id'] = $res['ParentId']; - return $this->CategoryPath($next_params).$this->Application->ParseBlock($block_params); - } + return $this->Application->ProcessParsedTag('c', 'CategoryPath', $params); } function BuildListSpecial($params) @@ -118,7 +122,7 @@ { if ($this->Special == 'import') { $this->Application->StoreVar('PermCache_UpdateRequired', 1); - $this->Application->Redirect('categories/cache_updater', Array('pass' => 'm', 'continue' => 1, 'no_amp' => 1)); + $this->Application->Redirect('categories/cache_updater', Array('m_opener' => 'r', 'pass' => 'm', 'continue' => 1, 'no_amp' => 1)); } elseif ($this->Special == 'export') { $template = $this->Application->getUnitOption($this->Prefix, 'ModuleFolder').'/'.$this->Special.'_finish'; @@ -132,7 +136,10 @@ function CatalogItemCount($params) { - $object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List', $params); + $object =& $this->GetList($params); + if (!$object->Counted) { + $object->CountRecs(); + } return $object->NoFilterCount != $object->RecordsCount ? $object->RecordsCount.' / '.$object->NoFilterCount : $object->RecordsCount; } @@ -149,6 +156,71 @@ return $review_tag_processor->TotalRecords($params); } + function InitCatalogTab($params) + { + $tab_params['mode'] = $this->Application->GetVar('tm'); // single/multi selection possible + $tab_params['special'] = $this->Application->GetVar('ts'); // use special for this tab + $tab_params['dependant'] = $this->Application->GetVar('td'); // is grid dependant on categories grid + + // set default params (same as in catalog) + if ($tab_params['mode'] === false) $tab_params['mode'] = 'multi'; + if ($tab_params['special'] === false) $tab_params['special'] = ''; + if ($tab_params['dependant'] === false) $tab_params['dependant'] = 'yes'; + + // pass params to block with tab content + $params['name'] = $params['render_as']; + $params['prefix'] = trim($this->Prefix.'.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.'); + $params['cat_prefix'] = trim('c.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.'); + $params['tab_mode'] = $tab_params['mode']; + $params['tab_dependant'] = $tab_params['dependant']; + $params['show_category'] = $tab_params['special'] == 'showall' ? 1 : 0; // this is advanced view -> show category name + + return $this->Application->ParseBlock($params, 1); + } + + /** + * Show CachedNavbar of current item primary category + * + * @param Array $params + * @return string + */ + function CategoryName($params) + { + // show category cachednavbar of + $object =& $this->getObject($params); + $category_id = isset($params['cat_id']) ? $params['cat_id'] : $object->GetDBField('CategoryId'); + + $category_path = $this->Application->getCache('category_paths', $category_id); + if ($category_path === false) { + // not chached + if ($category_id > 0) { + $category_path = trim($this->CategoryName( Array('cat_id' => 0) ).' > '.str_replace('&|&', ' > ', $object->GetDBField('CachedNavbar')), ' > '); + } + else { + $category_path = $this->Application->Phrase( $this->Application->ConfigValue('Root_Name') ); + } + $this->Application->setCache('category_paths', $category_id, $category_path); + } + return $category_path; + } + + /** + * Allows to determine if original value should be shown + * + * @param Array $params + * @return bool + */ + function DisplayOriginal($params) + { + // original id found & greather then zero + show original + $display_original = isset($params['display_original']) && $params['display_original']; + + $object =& $this->getObject($params); + $perm_value = $this->PermHelper->ModifyCheckPermission($object->GetDBField('CreatedById'), $object->GetDBField('CategoryId'), $this->Prefix); + + return $display_original && ($perm_value == 1) && $this->Application->GetVar($this->Prefix.'.original_id'); + } + } ?> \ No newline at end of file