Index: branches/5.2.x/core/units/categories/categories_event_handler.php =================================================================== diff -u -N -r14644 -r14664 --- branches/5.2.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 14644) +++ branches/5.2.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 14664) @@ -1,6 +1,6 @@ SetDBField($this->Application->RecallVar('dst_field'), $selected_ids['c']); $object->Update(); - $this->finalizePopup($event); + $event->SetRedirectParam('opener', 'u'); } /** @@ -330,10 +330,13 @@ $object->addFilter('perm_filter', TABLE_PREFIX . 'PermCache.PermId = 1'); // check for CATEGORY.VIEW permission if ($this->Application->RecallVar('user_id') != USER_ROOT) { // apply permission filters to all users except "root" + $view_filters = Array (); $groups = explode(',',$this->Application->RecallVar('UserGroups')); + foreach ($groups as $group) { $view_filters[] = 'FIND_IN_SET('.$group.', ' . TABLE_PREFIX . 'PermCache.ACL)'; } + $view_filter = implode(' OR ', $view_filters); $object->addFilter('perm_filter2', $view_filter); } @@ -512,9 +515,10 @@ 'advanced' => 'OnAdvancedSearch' ); + $keywords = $event->getEventParam('keyword_string'); $type = $this->Application->GetVar('search_type', 'simple'); - if ($keywords = $event->getEventParam('keyword_string')) { + if ( $keywords ) { // processing keyword_string param of ListProducts tag $this->Application->SetVar('keywords', $keywords); $type = 'simple'; @@ -654,9 +658,9 @@ return $page_id; } - function ParentGetPassedId(&$event) + function ParentGetPassedID(&$event) { - return parent::GetPassedId($event); + return parent::getPassedID($event); } /** @@ -759,6 +763,18 @@ break; } } + + // remember category filename change between temp and live records + if ( $temp_object->GetDBField('Filename') != $live_object->GetDBField('Filename') ) { + $filename_changes = $this->Application->GetVar($event->Prefix . '_filename_changes', Array ()); + + $filename_changes[ $live_object->GetID() ] = Array ( + 'from' => $live_object->GetDBField('Filename'), + 'to' => $temp_object->GetDBField('Filename') + ); + + $this->Application->SetVar($event->Prefix . '_filename_changes', $filename_changes); + } } /** @@ -845,6 +861,23 @@ } } } + + // change opener stack in case if edited category filename was changed + $filename_changes = $this->Application->GetVar($event->Prefix . '_filename_changes', Array ()); + + if ( $filename_changes ) { + $opener_stack =& $this->Application->makeClass('kOpenerStack'); + /* @var $opener_stack kOpenerStack */ + + list ($template, $params, $index_file) = $opener_stack->pop(); + + foreach ($filename_changes as $change_info) { + $template = str_ireplace($change_info['from'], $change_info['to'], $template); + } + + $opener_stack->push($template, $params, $index_file); + $opener_stack->save(); + } } /** @@ -976,7 +1009,7 @@ /** * Deletes all selected items. - * Automatically recurse into sub-items using temp handler, and deletes sub-items + * Automatically recourse into sub-items using temp handler, and deletes sub-items * by calling its Delete method if sub-item has AutoDelete set to true in its config file * * @param kEvent $event @@ -992,8 +1025,9 @@ $to_delete = Array (); $ids = $this->StoreSelectedIDs($event); + $recycle_bin = $this->Application->ConfigValue('RecycleBinFolder'); - if ( $recycle_bin = $this->Application->ConfigValue('RecycleBinFolder') ) { + if ( $recycle_bin ) { $rb =& $this->Application->recallObject('c.recycle', null, Array ('skip_autoload' => true)); /* @var $rb CategoriesItem */ @@ -1066,7 +1100,7 @@ } /** - * Controls all item paste operations. Can occur only with filled clipbord. + * Controls all item paste operations. Can occur only with filled clipboard. * * @param kEvent $event */ @@ -1232,7 +1266,7 @@ }*/ /** - * Cleares clipboard content + * Clears clipboard content * * @param kEvent $event */ @@ -1648,8 +1682,8 @@ /** * Sets page name to requested field in case when: - * 1. page was auto created (through theme file rebuld) - * 2. requested field is emtpy + * 1. page was auto created (through theme file rebuild) + * 2. requested field is empty * * @param kDBItem $object * @param string $field @@ -1711,7 +1745,7 @@ } if (($page_type == PAGE_TYPE_TEMPLATE) && ($template_info === false)) { - // do not autocreate system pages, when browsing through site + // do not auto-create system pages, when browsing through site return false; } @@ -1798,7 +1832,7 @@ $backup_category_id = $this->Application->GetVar('m_cat_id'); $object =& $this->Application->recallObject($this->Prefix . '.rebuild-path', null, Array ('skip_autoload' => true)); - /* @var $object kDBItem */ + /* @var $object CategoriesItem */ $parent_id = $base_category; @@ -1883,7 +1917,13 @@ $event->SetRedirectParam('action_completed', 1); } - function _resetMenuCache() + /** + * Performs reset of category-related caches (menu, structure dropdown, template mapping) + * + * @return void + * @access protected + */ + protected function _resetMenuCache() { // reset cms menu cache (all variables are automatically rebuild, when missing) if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { @@ -1920,19 +1960,19 @@ $root_category = $this->Application->getBaseCategory(); // set root category - $section_ajustments = $this->Application->getUnitOption($event->Prefix, 'SectionAdjustments'); + $section_adjustments = $this->Application->getUnitOption($event->Prefix, 'SectionAdjustments'); - $section_ajustments['in-portal:browse'] = Array ( + $section_adjustments['in-portal:browse'] = Array ( 'url' => Array ('m_cat_id' => $root_category), 'late_load' => Array ('m_cat_id' => $root_category), 'onclick' => 'checkCatalog(' . $root_category . ')', ); - $section_ajustments['in-portal:browse_site'] = Array ( + $section_adjustments['in-portal:browse_site'] = Array ( 'url' => Array ('editing_mode' => $settings['default_editing_mode']), ); - $this->Application->setUnitOption($event->Prefix, 'SectionAdjustments', $section_ajustments); + $this->Application->setUnitOption($event->Prefix, 'SectionAdjustments', $section_adjustments); // prepare structure dropdown $category_helper =& $this->Application->recallObject('CategoryHelper'); @@ -1944,15 +1984,9 @@ $fields['ParentId']['options'] = $category_helper->getStructureTreeAsOptions(); // limit design list by theme - $design_folders = Array ('tf.FilePath = "/designs"', 'tf.FilePath = "/platform/designs"'); - foreach ($this->Application->ModuleInfo as $module_name => $module_info) { - $design_folders[] = 'tf.FilePath = "/' . $module_info['TemplatePath'] . 'designs"'; - } - $design_folders = array_unique($design_folders); - $theme_id = $this->_getCurrentThemeId(); $design_sql = $fields['Template']['options_sql']; - $design_sql = str_replace('(tf.FilePath = "/designs")', '(' . implode(' OR ', $design_folders) . ')' . ' AND (t.ThemeId = ' . $theme_id . ')', $design_sql); + $design_sql = str_replace('(tf.FilePath = "/designs")', '(' . implode(' OR ', $this->getDesignFolders()) . ')' . ' AND (t.ThemeId = ' . $theme_id . ')', $design_sql); $fields['Template']['options_sql'] = $design_sql; // adds "Inherit From Parent" option to "Template" field @@ -1988,6 +2022,23 @@ } /** + * Returns folders, that can contain design templates + * + * @return array + * @access protected + */ + protected function getDesignFolders() + { + $ret = Array ('tf.FilePath = "/designs"', 'tf.FilePath = "/platform/designs"'); + + foreach ($this->Application->ModuleInfo as $module_info) { + $ret[] = 'tf.FilePath = "/' . $module_info['TemplatePath'] . 'designs"'; + } + + return array_unique($ret); + } + + /** * Removes this item and it's children (recursive) from structure dropdown * * @param kEvent $event @@ -2045,7 +2096,7 @@ ini_set('memory_limit', -1); $dummy =& $this->Application->recallObject($event->Prefix . '.rebuild', null, Array ('skip_autoload' => true)); - /* @var $dummy kDBItem */ + /* @var $dummy CategoriesItem */ $error_count = 0; foreach ($files as $a_file => $file_info) { @@ -2205,7 +2256,9 @@ } // processing fields from other tables - if ($foreign_field = $search_config[$field]['ForeignField']) { + $foreign_field = $search_config[$field]['ForeignField']; + + if ( $foreign_field ) { $exploded = explode(':', $foreign_field, 2); if ($exploded[0] == 'CALC') { // ignoring having type clauses in simple search @@ -2380,7 +2433,7 @@ WHERE '.$where_clause.' GROUP BY '.$items_table.'.'.$this->Application->getUnitOption($event->Prefix, 'IDField').' ORDER BY Relevance DESC'; - $res = $this->Conn->Query($sql); + $this->Conn->Query($sql); if ( !$search_table_exists ) { $sql = 'ALTER TABLE ' . $search_table . ' @@ -2459,7 +2512,7 @@ */ protected function OnGetConstrainInfo(&$event) { - $contarain = ''; // for OnSave + $constrain = ''; // for OnSave $event_name = $event->getEventParam('original_event'); $actual_event_name = $event->getEventParam('actual_event'); @@ -2468,18 +2521,18 @@ $object =& $event->getObject(); /* @var $object kDBItem */ - $contarain = 'ParentId = ' . $object->GetDBField('ParentId'); + $constrain = 'ParentId = ' . $object->GetDBField('ParentId'); } elseif ( $actual_event_name == 'OnPreparePriorities' ) { - $contarain = 'ParentId = ' . $this->Application->GetVar('m_cat_id'); + $constrain = 'ParentId = ' . $this->Application->GetVar('m_cat_id'); } elseif ( $event_name == 'OnSave' ) { - $contarain = ''; + $constrain = ''; } else { - $contarain = 'ParentId = ' . $this->Application->GetVar('m_cat_id'); + $constrain = 'ParentId = ' . $this->Application->GetVar('m_cat_id'); } - $event->setEventParam('constrain_info', Array ($contarain, '')); + $event->setEventParam('constrain_info', Array ($constrain, '')); } } \ No newline at end of file