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; }