Index: branches/5.3.x/core/kernel/db/cat_tag_processor.php =================================================================== diff -u -N -r15483 -r15698 --- branches/5.3.x/core/kernel/db/cat_tag_processor.php (.../cat_tag_processor.php) (revision 15483) +++ branches/5.3.x/core/kernel/db/cat_tag_processor.php (.../cat_tag_processor.php) (revision 15698) @@ -1,6 +1,6 @@ Application->getUnitOption($this->Prefix, 'Grids'); - $grid = $grids[ $params['grid'] ]; + $config = $this->getUnitConfig(); + $grid = $config->getGridByName($params['grid']); - if (!array_key_exists('Icons', $grid)) { + if ( !array_key_exists('Icons', $grid) ) { return ''; } $icons = $grid['Icons']; - 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] : ''; } - $status_fields = $this->Application->getUnitOption($this->Prefix, 'StatusField'); + $status_field = $config->getStatusField(true); - if (!$status_fields) { + if ( !$status_field ) { return $icons['default']; } $object = $this->getObject($params); /* @var $object kDBList */ - $value = $object->GetDBField($status_fields[0]); // sets base status icon + $value = $object->GetDBField($status_field); // sets base status icon - if ($value == STATUS_ACTIVE) { -// if( $object->HasField('IsPop') && $object->GetDBField('IsPop') ) $value = 'POP'; -// if( $object->HasField('IsHot') && $object->GetDBField('IsHot') ) $value = 'HOT'; - if( $object->HasField('IsNew') && $object->GetDBField('IsNew') ) $value = 'NEW'; -// if( $object->HasField('EditorsPick') && $object->GetDBField('EditorsPick') ) $value = 'PICK'; + if ( $value == STATUS_ACTIVE ) { + /*if ( $object->HasField('IsPop') && $object->GetDBField('IsPop') ) { + $value = 'POP'; + } + + if ( $object->HasField('IsHot') && $object->GetDBField('IsHot') ) { + $value = 'HOT'; + }*/ + + if ( $object->HasField('IsNew') && $object->GetDBField('IsNew') ) { + $value = 'NEW'; + } + + /*if ( $object->HasField('EditorsPick') && $object->GetDBField('EditorsPick') ) { + $value = 'PICK'; + }*/ } return array_key_exists($value, $icons) ? $icons[$value] : $icons['default']; @@ -282,15 +294,13 @@ */ function DisplayOriginal($params) { - // original id found & greather then zero + show original + // original id found & greater then zero + show original $display_original = isset($params['display_original']) && $params['display_original']; - $owner_field = $this->Application->getUnitOption($this->Prefix, 'OwnerField'); - if (!$owner_field) { - $owner_field = 'CreatedById'; - } - $object = $this->getObject($params); + /* @var $object kCatDBItem */ + + $owner_field = $this->getUnitConfig()->getOwnerField('CreatedById'); $perm_value = $this->PermHelper->ModifyCheckPermission($object->GetDBField($owner_field), $object->GetDBField('CategoryId'), $this->Prefix); return $display_original && ($perm_value == 1) && $this->Application->GetVar($this->Prefix.'.original_id'); @@ -315,10 +325,8 @@ $params['cat_id'] = $object->isLoaded() ? $object->GetDBField('ParentPath') : $this->Application->GetVar('m_cat_id'); // 2. owner restriction - $owner_field = $this->Application->getUnitOption($this->Prefix, 'OwnerField'); - if (!$owner_field) { - $owner_field = 'CreatedById'; - } + $owner_field = $this->getUnitConfig()->getOwnerField('CreatedById'); + $is_owner = $object->GetDBField($owner_field) == $this->Application->RecallVar('user_id'); return $perm_helper->TagPermissionCheck($params, $is_owner); @@ -359,10 +367,10 @@ $cache_key = $object->Prefix . '_additional_images[%' . $this->Application->incrementCacheSerial($object->Prefix, $object->GetID(), false) . '%]'; $ret = $this->Application->getCache($cache_key); - if ($ret === false) { + if ( $ret === false ) { $this->Conn->nextQueryCachable = true; $sql = 'SELECT ImageId - FROM ' . $this->Application->getUnitOption('img', 'TableName') . ' + FROM ' . $this->Application->getUnitConfig('img')->getTableName() . ' WHERE ResourceId = ' . $object->GetDBField('ResourceId') . ' AND DefaultImg != 1 AND Enabled = 1'; $ret = $this->Conn->GetOne($sql) ? 1 : 0; @@ -393,13 +401,13 @@ $object = $this->getObject($params); /* @var $object kDBList */ - if (!isset($favorite_status[$this->Special])) { + if ( !isset($favorite_status[$this->Special]) ) { $resource_ids = $object->GetCol('ResourceId'); $user_id = $this->Application->RecallVar('user_id'); $sql = 'SELECT FavoriteId, ResourceId - FROM '.$this->Application->getUnitOption('fav', 'TableName').' - WHERE (PortalUserId = '.$user_id.') AND (ResourceId IN ('.implode(',', $resource_ids).'))'; + FROM ' . $this->Application->getUnitConfig('fav')->getTableName() . ' + WHERE (PortalUserId = ' . $user_id . ') AND (ResourceId IN (' . implode(',', $resource_ids) . '))'; $favorite_status[$this->Special] = $this->Conn->GetCol($sql, 'ResourceId'); } @@ -583,25 +591,27 @@ function AdvancedSearchForm($params) { - $search_table = $this->Application->getUnitOption('confs', 'TableName'); + $search_table = $this->Application->getUnitConfig('confs')->getTableName(); $module_name = $this->Application->findModule('Var', $this->Prefix, 'Name'); $sql = 'SELECT * - FROM '.$search_table.' - WHERE (ModuleName = '.$this->Conn->qstr($module_name).') AND (AdvancedSearch = 1) + FROM ' . $search_table . ' + WHERE (ModuleName = ' . $this->Conn->qstr($module_name) . ') AND (AdvancedSearch = 1) ORDER BY DisplayOrder'; $search_config = $this->Conn->Query($sql); $ret = ''; + foreach ($search_config as $record) { $params['name'] = $this->SelectParam($params, 'and_or_render_as,and_or_block'); $params['field'] = $record['FieldName']; $params['andor'] = $this->Application->ParseBlock($params); - $params['name'] = $this->SelectParam($params, $record['FieldType'].'_render_as,'.$record['FieldType'].'_block'); + $params['name'] = $this->SelectParam($params, $record['FieldType'] . '_render_as,' . $record['FieldType'] . '_block'); $params['caption'] = $this->Application->Phrase($record['DisplayName']); $ret .= $this->Application->ParseBlock($params); } + return $ret; } @@ -623,20 +633,22 @@ $row_data = $this->Application->getCache($cache_key); if ( $row_data === false ) { + $config = $this->getUnitConfig(); + if ( $local && ($category_id > 0) ) { // scan only current category & it's children list ($tree_left, $tree_right) = $this->Application->getTreeIndex($category_id); $sql = 'SELECT MAX(item_table.Modified) AS ModDate, MAX(item_table.CreatedOn) AS NewDate - FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . ' item_table + FROM ' . $config->getTableName() . ' item_table LEFT JOIN ' . TABLE_PREFIX . 'CategoryItems ci ON (item_table.ResourceId = ci.ItemResourceId) LEFT JOIN ' . TABLE_PREFIX . 'Categories c ON c.CategoryId = ci.CategoryId WHERE c.TreeLeft BETWEEN ' . $tree_left . ' AND ' . $tree_right; } else { // scan all categories in system $sql = 'SELECT MAX(Modified) AS ModDate, MAX(CreatedOn) AS NewDate - FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName'); + FROM ' . $config->getTableName(); } $this->Conn->nextQueryCachable = true; @@ -693,10 +705,12 @@ $category_id = $this->Application->findModule('Var', $this->Prefix, 'RootCat'); } - $id_field = $this->Application->getUnitOption('c', 'IDField'); - $title_field = $this->Application->getUnitOption('c', 'TitleField'); - $table_name = $this->Application->getUnitOption('c', 'TableName'); + $category_config = $this->Application->getUnitConfig('c'); + $id_field = $category_config->getIDField(); + $title_field = $category_config->getTitleField(); + $table_name = $category_config->getTableName(); + $count_helper = $this->Application->recallObject('CountHelper'); /* @var $count_helper kCountHelper */ @@ -745,10 +759,11 @@ } $category_ids = explode('|', substr($category_ids, 1, -1)); + $category_config = $this->Application->getUnitConfig('c'); - $id_field = $this->Application->getUnitOption('c', 'IDField'); - $title_field = $this->Application->getUnitOption('c', 'TitleField'); - $table_name = $this->Application->getUnitOption('c', 'TableName'); + $id_field = $category_config->getIDField(); + $title_field = $category_config->getTitleField(); + $table_name = $category_config->getTableName(); $sql = 'SELECT '.$title_field.' AS CategoryName, '.$id_field.', l' . $this->Application->GetVar('m_lang') . '_CachedNavbar AS CachedNavbar FROM '.$table_name.' @@ -841,7 +856,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', @@ -870,9 +886,11 @@ { static $languages = null; - if (!isset($languages)) { - $sql = 'SELECT ' . $this->Application->getUnitOption('lang', 'IDField') . ' - FROM ' . $this->Application->getUnitOption('lang', 'TableName') . ' + if ( !isset($languages) ) { + $language_config = $this->Application->getUnitConfig('lang'); + + $sql = 'SELECT ' . $language_config->getIDField() . ' + FROM ' . $language_config->getTableName() . ' WHERE Enabled = 1'; $languages = $this->Conn->GetCol($sql); } @@ -884,7 +902,8 @@ foreach ($languages as $language_id) { $check_field = 'l' . $language_id . '_' . $field; - if ($object->GetErrorMsg($check_field, false)) { + + if ( $object->GetErrorMsg($check_field, false) ) { return true; } } @@ -900,7 +919,7 @@ */ function AllowedCategoriesJSON($params) { - if ($this->Application->RecallVar('user_id') == USER_ROOT) { + if ( $this->Application->RecallVar('user_id') == USER_ROOT ) { $categories = true; } else { @@ -910,13 +929,10 @@ $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')); } - $json_helper = $this->Application->recallObject('JSONHelper'); - /* @var $json_helper JSONHelper */ - - return $json_helper->encode($categories); + return json_encode($categories); } } \ No newline at end of file