Index: branches/5.3.x/core/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r15677 -r15698 --- branches/5.3.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 15677) +++ branches/5.3.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 15698) @@ -1,6 +1,6 @@ Application->getUnitOption($this->Prefix, 'Grids'); - $grid = $grids[ $params['grid'] ]; + $grid = $this->getUnitConfig()->getGridByName($params['grid']); - if (!array_key_exists('Icons', $grid)) { + if ( !array_key_exists('Icons', $grid) ) { return ''; } $icons = $grid['Icons']; - $icon_prefix = array_key_exists('icon_prefix', $params)? $params['icon_prefix'] : 'icon16_'; + $icon_prefix = array_key_exists('icon_prefix', $params) ? $params['icon_prefix'] : 'icon16_'; - if (array_key_exists('name', $params)) { + if ( array_key_exists('name', $params) ) { $icon_name = $params['name']; + return array_key_exists($icon_name, $icons) ? $icons[$icon_name] : ''; } $object = $this->getObject($params); /* @var $object kDBList */ - if ($object->GetDBField('ThemeId') > 0) { - if (!$object->GetDBField('IsMenu')) { + if ( $object->GetDBField('ThemeId') > 0 ) { + if ( !$object->GetDBField('IsMenu') ) { return $icon_prefix . 'section_menuhidden_system.png'; } + return $icon_prefix . 'section_system.png'; } $status = $object->GetDBField('Status'); - if ($status == STATUS_DISABLED) { + if ( $status == STATUS_DISABLED ) { return $icon_prefix . 'section_disabled.png'; } - if (!$object->GetDBField('IsMenu')) { + if ( !$object->GetDBField('IsMenu') ) { return $icon_prefix . 'section_menuhidden.png'; } - if ($status == STATUS_PENDING) { + if ( $status == STATUS_PENDING ) { return $icon_prefix . 'section_pending.png'; } - if ($object->GetDBField('IsNew') && ($icon_prefix == 'icon16_')) { + if ( $object->GetDBField('IsNew') && ($icon_prefix == 'icon16_') ) { return $icon_prefix . 'section_new.png'; // show gris icon only in grids } @@ -126,7 +127,7 @@ $object = $this->getObject($params); /* @var $object kDBItem */ - $ci_table = $this->Application->getUnitOption('ci', 'TableName'); + $ci_table = $this->Application->getUnitConfig('ci')->getTableName(); $module_prefixes = implode(',', $this->Conn->qstrArray($this->_getModulePrefixes())); @@ -265,8 +266,9 @@ $cache = $this->Application->getCache($cache_key); if ($cache === false) { - $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName'); + $config = $this->getUnitConfig(); + $id_field = $config->getIDField(); + $table_name = $config->getTableName(); // get symlinked categories, that are not yet deleted $this->Conn->nextQueryCachable = true; @@ -497,9 +499,11 @@ $category_id = $this->Application->GetVar('m_cat_id'); if ($category_id != $parent_id) { + $config = $this->getUnitConfig(); + $sql = 'SELECT ParentId - FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . ' - WHERE ' . $this->Application->getUnitOption($this->Prefix, 'IDField') . ' = ' . $category_id; + FROM ' . $config->getTableName() . ' + WHERE ' . $config->getIDField() . ' = ' . $category_id; $parent_id = $this->Conn->GetOne($sql); } @@ -901,19 +905,19 @@ $sym_category_id = $object->GetDBField('SymLinkCategoryId'); - if (is_null($sym_category_id)) - { + if ( is_null($sym_category_id) ) { return false; } - $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName'); + $config = $this->getUnitConfig(); + $id_field = $config->getIDField(); + $table_name = $config->getTableName(); - $sql = 'SELECT '.$id_field.' - FROM '.$table_name.' - WHERE '.$id_field.' = '.$sym_category_id; + $sql = 'SELECT ' . $id_field . ' + FROM ' . $table_name . ' + WHERE ' . $id_field . ' = ' . $sym_category_id; - return $this->Conn->GetOne($sql)? true : false; + return $this->Conn->GetOne($sql) ? true : false; } /** @@ -958,7 +962,8 @@ */ protected function SpellingSuggestions($params) { - $keywords = htmlspecialchars_decode( trim($this->Application->GetVar('keywords')) ); + $keywords = htmlspecialchars_decode(trim($this->Application->GetVar('keywords'))); + if ( !$keywords ) { return ''; } @@ -971,7 +976,7 @@ return $suggestion; } - $table_name = $this->Application->getUnitOption('spelling-dictionary', 'TableName'); + $table_name = $this->Application->getUnitConfig('spelling-dictionary')->getTableName(); // 2. search suggestion in database $this->Conn->nextQueryCachable = true; @@ -993,7 +998,7 @@ $curl_helper = $this->Application->recallObject('CurlHelper'); /* @var $curl_helper kCurlHelper */ - $xml_data = $curl_helper->Send( $url . urlencode($keywords) ); + $xml_data = $curl_helper->Send($url . urlencode($keywords)); $xml_helper = $this->Application->recallObject('kXMLHelper'); /* @var $xml_helper kXMLHelper */ @@ -1991,25 +1996,24 @@ $category_ids = explode('|', substr($object->GetDBField('ParentPath'), 1, -1)); - $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName'); - + $config = $this->getUnitConfig(); $language = (int)$this->Application->GetVar('m_lang'); - if (!$language) { + if ( !$language ) { $language = 1; } - $sql = 'SELECT l'.$language.'_Name AS Name, NamedParentPath - FROM '.$table_name.' - WHERE '.$id_field.' IN ('.implode(',', $category_ids).')'; + $sql = 'SELECT l' . $language . '_Name AS Name, NamedParentPath + FROM ' . $config->getTableName() . ' + WHERE ' . $config->getIDField() . ' IN (' . implode(',', $category_ids) . ')'; $categories_data = $this->Conn->Query($sql); $ret = ''; foreach ($categories_data as $index => $category_data) { - if ($category_data['Name'] == 'Content') { + if ( $category_data['Name'] == 'Content' ) { continue; } + $block_params['title'] = $category_data['Name']; $block_params['template'] = preg_replace('/^Content\//i', '', $category_data['NamedParentPath']); $block_params['is_first'] = $index == 1; // because Content is 1st element @@ -2058,15 +2062,17 @@ function ModifyUnitConfig($params) { $root_category = $this->Application->RecallVar('IsRootCategory_' . $this->Application->GetVar('m_wid')); - if (!$root_category) { - return ; + + if ( !$root_category ) { + return; } - $edit_tab_presets = $this->Application->getUnitOption($this->Prefix, 'EditTabPresets'); - $edit_tab_presets['Default'] = Array ( - 'permissions' => $edit_tab_presets['Default']['permissions'], - ); - $this->Application->setUnitOption($this->Prefix, 'EditTabPresets', $edit_tab_presets); + $config = $this->getUnitConfig(); + $edit_tab_preset = $config->getEditTabPresetByName('Default'); + + $config->addEditTabPresets(Array ( + 'Default' => Array ('permissions' => $edit_tab_preset['permissions']) + )); } /** @@ -2077,22 +2083,19 @@ */ function PrintCatalogExportTemplates($params) { + $ret = Array (); $prefixes = explode(',', $params['prefixes']); - $ret = Array (); foreach ($prefixes as $prefix) { - if ($this->Application->prefixRegistred($prefix)) { - $module_path = $this->Application->getUnitOption($prefix, 'ModuleFolder') . '/'; + if ( $this->Application->prefixRegistred($prefix) ) { + $module_path = $this->Application->getUnitConfig($prefix)->getModuleFolder() . '/'; $module_name = $this->Application->findModule('Path', $module_path, 'Name'); $ret[$prefix] = mb_strtolower($module_name) . '/export'; } } - $json_helper = $this->Application->recallObject('JSONHelper'); - /* @var $json_helper JSONHelper */ - - return $json_helper->encode($ret); + return json_encode($ret); } /** @@ -2120,7 +2123,8 @@ $object = $this->getObject($params); /* @var $object kDBList */ - $edit_template = $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePath') . '/' . $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePrefix') . 'edit'; + $config = $this->getUnitConfig(); + $edit_template = $config->getAdminTemplatePath() . '/' . $config->getAdminTemplatePrefix() . 'edit'; $url_params = Array ( 'm_opener' => 'd', @@ -2176,7 +2180,7 @@ $perm_helper = $this->Application->recallObject('PermissionsHelper'); /* @var $perm_helper kPermissionsHelper */ - $perm_prefix = $this->Application->getUnitOption($this->Prefix, 'PermItemPrefix'); + $perm_prefix = $this->getUnitConfig()->getPermItemPrefix(); $categories = $perm_helper->getPermissionCategories($perm_prefix . '.' . ($object->IsNewItem() ? 'ADD' : 'MODIFY')); } @@ -2227,7 +2231,7 @@ $object = $this->Application->recallObject($module_prefix); /* @var $object kCatDBItem */ - $title_field = $this->Application->getUnitOption($module_prefix, 'TitleField'); + $title_field = $this->Application->getUnitConfig($module_prefix)->getTitleField(); $block_params = $this->prepareTagParams($params); $block_params['name'] = $params['render_as'];