Index: branches/5.1.x/core/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r12127 -r12657 --- branches/5.1.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 12127) +++ branches/5.1.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 12657) @@ -1,6 +1,6 @@ Prefix != 'c') { - return parent::ItemIcon($params); + $grids = $this->Application->getUnitOption($this->Prefix, 'Grids'); + $grid = $grids[ $params['grid'] ]; + + if (!array_key_exists('Icons', $grid)) { + return ''; } + $icons = $grid['Icons']; + + if (array_key_exists('name', $params)) { + $icon_name = $params['name']; + return array_key_exists($icon_name, $icons) ? $icons[$icon_name] : ''; + } + $object =& $this->getObject($params); - if ($object->GetDBField('IsMenu')) { - $status = $object->GetDBField('Status'); - if ($status == 1) { - $ret = $object->GetDBField('IsNew') ? 'icon16_cat_new.gif' : 'icon16_folder.gif'; - } - else { - $ret = $status ? 'icon16_cat_pending.gif' : 'icon16_cat_disabled.gif'; - } + /* @var $object kDBList */ + + if ($object->GetDBField('CreatedBySystem')) { + return 'icon16_section_system.png'; } - else { - $ret = 'icon16_folder-red.gif'; + + $status = $object->GetDBField('Status'); + + if ($status == STATUS_DISABLED) { + return 'icon16_section_disabled.png'; } - return $ret; + if (!$object->GetDBField('IsMenu')) { + return 'icon16_section_menuhidden.png'; + } + + if ($status == STATUS_PENDING) { + return 'icon16_section_pending.png'; + } + + if ($object->GetDBField('IsNew')) { + return 'icon16_section_new.png'; + } + + return 'icon16_section.png'; } function ItemCount($params) @@ -182,7 +202,7 @@ $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'); + WHERE CategoryId = '.(int)$this->Application->GetVar('m_cat_id'); return $this->Conn->GetOne($sql); } @@ -601,10 +621,13 @@ function CatalogItemCount($params) { + $params['skip_quering'] = true; $object =& $this->GetList($params); + if (!$object->Counted) { $object->CountRecs(); } + return $object->NoFilterCount != $object->RecordsCount ? $object->RecordsCount.' / '.$object->NoFilterCount : $object->RecordsCount; } @@ -673,7 +696,7 @@ if (!isset($current_path)) { $sql = 'SELECT ParentPath FROM ' . TABLE_PREFIX . 'Category - WHERE CategoryId = ' . $this->Application->GetVar('m_cat_id'); + WHERE CategoryId = ' . (int)$this->Application->GetVar('m_cat_id'); $current_path = $this->Conn->GetOne($sql); } @@ -1033,7 +1056,12 @@ } else { // no relation with current category object -> query from db - $sql = 'SELECT l' . $this->Application->GetVar('m_lang') . '_CachedNavbar + $language_id = (int)$this->Application->GetVar('m_lang'); + if (!$language_id) { + $language_id = 1; + } + + $sql = 'SELECT l' . $language_id . '_CachedNavbar FROM ' . $object->TableName . ' WHERE ' . $object->IDField . ' = ' . $category_id; $cached_navbar = $this->Conn->GetOne($sql); @@ -1135,7 +1163,7 @@ $edit_code_before = $edit_code_after = ''; - if (EDITING_MODE == EDITING_MODE_CMS) { + if (EDITING_MODE == EDITING_MODE_CONTENT) { $bg_color = isset($params['bgcolor']) ? $params['bgcolor'] : '#ffffff'; $url_params = Array ( 'pass' => 'm,c,content', @@ -1162,11 +1190,11 @@ $edit_url = $this->Application->HREF('categories/edit_content', ADMIN_DIRECTORY, $url_params, 'index.php'); $edit_code_before = '
-
+
- +
-
Edit '.(defined('DEBUG_MODE') && DEBUG_MODE ? " - #{$num}" : '').'
+
' . $this->Application->Phrase('la_btn_EditContent', false) . ' '.(defined('DEBUG_MODE') && DEBUG_MODE ? " - #{$num}" : '').'
'; @@ -1331,7 +1359,7 @@ $ret = '' . "\n"; $ret .= '' . "\n"; - if (EDITING_MODE == EDITING_MODE_LAYOUT) { + if (EDITING_MODE == EDITING_MODE_DESIGN) { $ret .= ' '; @@ -1345,49 +1373,56 @@ $ret .= '' . "\n"; $ret .= '' . "\n"; $ret .= '' . "\n"; - // add form, so admin scripts could work - $ret .= '
- - -
'; + if (EDITING_MODE != EDITING_MODE_BROWSE) { + // add form, so admin scripts could work + $ret .= '
+ + +
'; + } return $ret; } @@ -1409,48 +1444,79 @@ $page =& $this->_getPage($params); - if (!$page->isLoaded()) { + if (!$page->isLoaded() || (($display_mode != 'end') && (EDITING_MODE == EDITING_MODE_BROWSE))) { // when "EditingScripts" tag is not used, make sure, that scripts are also included return $this->EditingScripts($params); } // show "EditPage" button only for pages, that exists in structure if ($display_mode != 'end') { - $url_params = Array( - 'pass' => 'm,c', - 'm_opener' => 'd', - 'c_id' => $page->GetID(), - 'c_mode' => 't', - 'c_event' => 'OnEdit', - 'front' => 1, - '__URLENCODE__' => 1, - '__NO_REWRITE__'=> 1, - 'escape' => 1, - 'index_file' => 'index.php', - ); + $edit_btn = ''; - $edit_url = $this->Application->HREF('categories/categories_edit', '/admin', $url_params); + if (EDITING_MODE == EDITING_MODE_CONTENT) { + $url_params = Array( + 'pass' => 'm,c', + 'm_opener' => 'd', + 'c_id' => $page->GetID(), + 'c_mode' => 't', + 'c_event' => 'OnEdit', + 'front' => 1, + '__URLENCODE__' => 1, + '__NO_REWRITE__'=> 1, + 'escape' => 1, + 'index_file' => 'index.php', + ); - $edit_btn = ''; + $edit_url = $this->Application->HREF('categories/categories_edit', ADMIN_DIRECTORY, $url_params); - if (EDITING_MODE == EDITING_MODE_LAYOUT) { $edit_btn .= ' -
+
- +
-
Save Layout
+
' . $this->Application->Phrase('la_btn_SectionProperties', false) . '
' . "\n"; - } + } elseif (EDITING_MODE == EDITING_MODE_DESIGN) { + $url_params = Array( + 'pass' => 'm,theme', + 'm_opener' => 'd', + 'theme_id' => $this->Application->GetVar('m_theme'), + 'theme_mode' => 't', + 'theme_event' => 'OnEdit', + 'theme-file_id' => $this->_getThemeFileId(), + 'front' => 1, + '__URLENCODE__' => 1, + '__NO_REWRITE__'=> 1, + 'escape' => 1, + 'index_file' => 'index.php', + ); - $edit_btn .= ' -
-
- + $edit_url = $this->Application->HREF('themes/file_edit', ADMIN_DIRECTORY, $url_params); + + $edit_btn .= ' +
+
+
+ +
+
' . $this->Application->Phrase('la_btn_SaveChanges', false) . '
+
+
+
+ +
+
' . $this->Application->Phrase('la_btn_Cancel', false) . '
+
-
Section Properties
-
' . "\n"; +
+
+ +
+
' . $this->Application->Phrase('la_btn_SectionTemplate', false) . '
+
' . "\n"; + } + if ($display_mode == 'start') { // button with border around the page $edit_code .= '
' . $edit_btn . '
'; @@ -1477,6 +1543,26 @@ return $edit_code; } + function _getThemeFileId() + { + $template = $this->Application->GetVar('t'); + + if (!$this->Application->TemplatesCache->TemplateExists($template) && !$this->Application->IsAdmin()) { + $cms_handler =& $this->Application->recallObject($this->Prefix . '_EventHandler'); + /* @var $cms_handler CategoriesEventHandler */ + + $template = ltrim($cms_handler->GetDesignTemplate(), '/'); + } + + $file_path = dirname($template) == '.' ? '' : '/' . dirname($template); + $file_name = basename($template); + + $sql = 'SELECT FileId + FROM ' . TABLE_PREFIX . 'ThemeFiles + WHERE (FilePath = ' . $this->Conn->qstr($file_path) . ') AND (FileName = ' . $this->Conn->qstr($file_name . '.tpl') . ')'; + return $this->Conn->GetOne($sql); + } + /** * Builds cached menu version * @@ -1736,10 +1822,18 @@ { $object =& $this->getObject($params); - $template = $object->GetDBField('NamedParentPath'); - $url_params = Array ('admin' => 1, 'pass' => 'm', 'm_cat_id' => $object->GetID(), 'index_file' => 'index.php'); + $themes_helper =& $this->Application->recallObject('ThemesHelper'); + /* @var $themes_helper kThemesHelper */ - return $this->Application->HREF($template, '_FRONT_END_', $url_params); + $url_params = Array ( + 'm_cat_id' => $object->GetID(), + 'm_theme' => $themes_helper->getCurrentThemeId(), + 'pass' => 'm', + 'admin' => 1, + 'index_file' => 'index.php' + ); + + return $this->Application->HREF($object->GetDBField('NamedParentPath'), '_FRONT_END_', $url_params); } /** @@ -1941,8 +2035,12 @@ $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName'); - $language = $this->Application->GetVar('m_lang'); + $language = (int)$this->Application->GetVar('m_lang'); + if (!$language) { + $language = 1; + } + $sql = 'SELECT l'.$language.'_Name AS Name, NamedParentPath FROM '.$table_name.' WHERE '.$id_field.' IN ('.implode(',', $category_ids).')';