Index: branches/5.2.x/core/units/categories/categories_event_handler.php =================================================================== diff -u -N -r15720 -r15734 --- branches/5.2.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 15720) +++ branches/5.2.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 15734) @@ -1,6 +1,6 @@ Special == 'page') || ($event->Special == '-virtual') || ($event->Prefix == 'st') ) { + if ( ($event->Special == 'page') || $this->_isVirtual($event) || ($event->Prefix == 'st') ) { return $this->_getPassedStructureID($event); } @@ -660,7 +660,7 @@ */ protected function prepareObject(&$object, kEvent $event) { - if ( $event->Special == '-virtual' ) { + if ( $this->_isVirtual($event) ) { return; } @@ -678,6 +678,30 @@ } /** + * Checks, that this is virtual page + * + * @param kEvent $event + * @return int + * @access protected + */ + protected function _isVirtual(kEvent $event) + { + return strpos($event->Special, '-virtual') !== false; + } + + /** + * Gets right special for configuring virtual page + * + * @param kEvent $event + * @return string + * @access protected + */ + protected function _getCategorySpecial(kEvent $event) + { + return $this->_isVirtual($event) ? '-virtual' : $event->Special; + } + + /** * Set correct parent path for newly created categories * * @param kEvent $event @@ -1392,6 +1416,50 @@ } /** + * Creates needed sql query to load item, + * if no query is defined in config for + * special requested, then use list query + * + * @param kEvent $event + * @return string + * @access protected + */ + protected function ItemPrepareQuery(kEvent $event) + { + $object = $event->getObject(); + /* @var $object kDBItem */ + + $sqls = $object->getFormOption('ItemSQLs', Array ()); + $category_special = $this->_getCategorySpecial($event); + $special = isset($sqls[$category_special]) ? $category_special : ''; + + // preferred special not found in ItemSQLs -> use analog from ListSQLs + + return isset($sqls[$special]) ? $sqls[$special] : $this->ListPrepareQuery($event); + } + + /** + * Creates needed sql query to load list, + * if no query is defined in config for + * special requested, then use default + * query + * + * @param kEvent $event + * @return string + * @access protected + */ + protected function ListPrepareQuery(kEvent $event) + { + $object = $event->getObject(); + /* @var $object kDBItem */ + + $special = $this->_getCategorySpecial($event); + $sqls = $object->getFormOption('ListSQLs', Array ()); + + return $sqls[array_key_exists($special, $sqls) ? $special : '']; + } + + /** * Performs redirect to correct suggest confirmation template * * @param kEvent $event @@ -1738,8 +1806,8 @@ $t = $this->Application->GetVar('t'); $page = $this->Application->recallObject($this->Prefix . '.-virtual'); - if ($page->isLoaded()) { - $this->Application->SetVar('m_cat_id', $page->GetDBField('CategoryId') ); + if ( $page->isLoaded() ) { + $this->Application->SetVar('m_cat_id', $page->GetDBField('CategoryId')); } }*/ @@ -2679,7 +2747,7 @@ */ protected function LoadItem(kEvent $event) { - if ( $event->Special != '-virtual' ) { + if ( !$this->_isVirtual($event) ) { parent::LoadItem($event); return; } Index: branches/5.2.x/core/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r15720 -r15734 --- branches/5.2.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 15720) +++ branches/5.2.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 15734) @@ -1,6 +1,6 @@ Application->recallObject($this->Prefix . '.-virtual', null, $params); + $page = $this->Application->recallObject($this->Prefix . '.' . $this->_getPageSpecial($params), null, $params); /* @var $page kDBItem */ // 1. load by given id - $page_id = array_key_exists('page_id', $params) ? $params['page_id'] : false; - if ($page_id) { - if ($page_id != $page->GetID()) { + $page_id = array_key_exists('page_id', $params) ? $params['page_id'] : 0; + + if ( $page_id ) { + if ( $page_id != $page->GetID() ) { // load if different $page->Load($page_id); } @@ -1157,15 +1158,16 @@ // 2. load by template $template = array_key_exists('page', $params) ? $params['page'] : ''; - if (!$template) { + + if ( !$template ) { $template = $this->Application->GetVar('t'); } - // different path in structure AND design template differes from requested template - $structure_path_match = mb_strtolower( $page->GetDBField('NamedParentPath') ) == mb_strtolower('Content/' . $template); + // different path in structure AND design template differs from requested template + $structure_path_match = mb_strtolower($page->GetDBField('NamedParentPath')) == mb_strtolower('Content/' . $template); $design_match = $page->GetDBField('CachedTemplate') == $template; - if (!$structure_path_match && !$design_match) { + if ( !$structure_path_match && !$design_match ) { // Same sql like in "c:getPassedID". Load, when current page object doesn't match requested page object $themes_helper = $this->Application->recallObject('ThemesHelper'); /* @var $themes_helper kThemesHelper */ @@ -1179,6 +1181,30 @@ } /** + * Returns unique special for each used page + * + * @param Array $params + * @return string + * @access protected + */ + protected function _getPageSpecial($params) + { + $ret = Array (); + $page_id = array_key_exists('page_id', $params) ? $params['page_id'] : 0; + $template = array_key_exists('page', $params) ? $params['page'] : ''; + + if ( $page_id ) { + $ret[] = 'page_id=' . $page_id; + } + + if ( $template ) { + $ret[] = 'page=' . $template; + } + + return $ret ? '-virtual-' . kUtil::crc32(serialize($ret)) : '-virtual'; + } + + /** * Returns requested content block content of current or specified page * * @param Array $params