Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F847772
D161.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Apr 19, 5:39 PM
Size
8 KB
Mime Type
text/x-diff
Expires
Sun, Apr 20, 5:39 PM (14 m, 35 s)
Engine
blob
Format
Raw Data
Handle
602564
Attached To
D161: INP-1509 - Change concept used for category path matching to module root category
D161.diff
View Options
Index: branches/5.2.x/core/admin_templates/categories/xml/tree_categories.tpl
===================================================================
--- branches/5.2.x/core/admin_templates/categories/xml/tree_categories.tpl
+++ branches/5.2.x/core/admin_templates/categories/xml/tree_categories.tpl
@@ -3,18 +3,18 @@
<inp2:m_if check="Field" field="CachedDescendantCatsQty">
<folder
name="<inp2:Field name='Name'/>"
- href="<inp2:CategoryLink template='catalog/catalog' direct_link='1' pass='m' m_opener='r'/>"
+ href="<inp2:AdminTreeLink template='catalog/catalog'/>"
icon="<inp2:c_ModulePath module='core'/>img/icons/<inp2:ItemIcon grid='Default' icon_prefix='icon24_'/>"
onclick="checkCatalog(<inp2:Field name='CategoryId' db="db"/>, '<inp2:GetModulePrefix/>')"
load_url="<inp2:CategoryLink direct_link="1" pass='m'/>">
</folder>
<inp2:m_else/>
<item
- href="<inp2:CategoryLink template='catalog/catalog' direct_link='1' pass='m' m_opener='r'/>"
+ href="<inp2:AdminTreeLink template='catalog/catalog'/>"
icon="<inp2:c_ModulePath module='core'/>img/icons/<inp2:ItemIcon grid='Default' icon_prefix='icon24_'/>"
onclick="checkCatalog(<inp2:Field name='CategoryId' db="db"/>, '<inp2:GetModulePrefix/>')"><inp2:Field name="Name"/></item>
</inp2:m_if>
</inp2:m_DefineElement>
<tree>
<inp2:c.tree_PrintList render_as="category" per_page="-1"/>
-</tree>
\ No newline at end of file
+</tree>
Index: branches/5.2.x/core/admin_templates/tree.tpl
===================================================================
--- branches/5.2.x/core/admin_templates/tree.tpl
+++ branches/5.2.x/core/admin_templates/tree.tpl
@@ -92,12 +92,12 @@
</table>
<script type="text/javascript">
- function checkCatalog($cat_id) {
+ function checkCatalog($cat_id, $module_prefix) {
var $ret = checkEditMode(false);
var $right_frame = getFrame('main');
if ($ret && $right_frame.$is_catalog) {
- $right_frame.$Catalog.go_to_cat($cat_id);
+ $right_frame.$Catalog.go_to_cat($cat_id, $module_prefix);
return 1; // this opens folder, but disables click
}
Index: branches/5.2.x/core/units/categories/categories_event_handler.php
===================================================================
--- branches/5.2.x/core/units/categories/categories_event_handler.php
+++ branches/5.2.x/core/units/categories/categories_event_handler.php
@@ -2185,9 +2185,13 @@
$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 . ')',
+ 'onclick' => 'checkCatalog(' . $root_category . ', "c")',
);
+ if ( $this->Application->ConfigValue('Catalog_PreselectModuleTab') ) {
+ $section_adjustments['in-portal:browse']['url']['anchor'] = 'tab-c';
+ }
+
$section_adjustments['in-portal:browse_site'] = Array (
'url' => Array ('editing_mode' => $settings['default_editing_mode']),
);
Index: branches/5.2.x/core/units/categories/categories_tag_processor.php
===================================================================
--- branches/5.2.x/core/units/categories/categories_tag_processor.php
+++ branches/5.2.x/core/units/categories/categories_tag_processor.php
@@ -361,11 +361,9 @@
/* @var $category_helper CategoryHelper */
$category_path = explode('|', substr($object->GetDBField('ParentPath'), 1, -1));
- $module_info = $category_helper->getCategoryModule($params, $category_path);
-
- // In-Edit & Proj-CMS module prefixes doesn't have custom field with item template
- if ($module_info && $module_info['Var'] != 'adm' && $module_info['Var'] != 'st') {
+ $module_info = $category_helper->getCategoryModule($params, $category_path);
+ if ( $module_info ) {
// 2. get item template by current category & module prefix
$rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor');
/* @var $rewrite_processor kRewriteUrlProcessor */
@@ -917,6 +915,30 @@
}
/**
+ * Builds link to a category in the Admin Tree.
+ *
+ * @param array $params Tag params.
+ *
+ * @return string
+ */
+ protected function AdminTreeLink(array $params)
+ {
+ $params['direct_link'] = 1;
+ $params['pass'] = 'm';
+ $params['m_opener'] = 'r';
+
+ if ( $this->Application->ConfigValue('Catalog_PreselectModuleTab') ) {
+ $module_prefix = $this->GetModulePrefix($params);
+
+ if ( $module_prefix ) {
+ $params['anchor'] = 'tab-' . $module_prefix;
+ }
+ }
+
+ return $this->CategoryLink($params);
+ }
+
+ /**
* Returns module prefix based on root category for given
*
* @param Array $params
@@ -933,7 +955,8 @@
/* @var $category_helper CategoryHelper */
$module_info = $category_helper->getCategoryModule($params, $parent_path);
- return $module_info['Var'];
+
+ return $module_info ? $module_info['Var'] : 'c';
}
function ImageSrc($params)
Index: branches/5.2.x/core/units/configuration/configuration_event_handler.php
===================================================================
--- branches/5.2.x/core/units/configuration/configuration_event_handler.php
+++ branches/5.2.x/core/units/configuration/configuration_event_handler.php
@@ -382,7 +382,7 @@
// reset cache
$changed = $this->Application->GetVar($event->getPrefixSpecial() . '_changed', Array ());
- $require_refresh = Array ('AdvancedUserManagement', 'Site_Name', 'AdminConsoleInterface', 'UsePopups');
+ $require_refresh = Array ('AdvancedUserManagement', 'Site_Name', 'AdminConsoleInterface', 'UsePopups', 'Catalog_PreselectModuleTab');
$refresh_sections = array_intersect($require_refresh, $changed);
$require_full_refresh = Array ('Site_Name', 'AdminConsoleInterface');
Index: branches/5.2.x/core/units/helpers/category_helper.php
===================================================================
--- branches/5.2.x/core/units/helpers/category_helper.php
+++ branches/5.2.x/core/units/helpers/category_helper.php
@@ -31,53 +31,33 @@
var $_primaryLanguageId = false;
/**
- * Returns module information based on given module name or current category (relative to module root categories)
+ * Returns module information based on given module name or current category
+ * (relative to module root categories).
*
- * @param Array $params
- * @param Array $category_ids category parent path (already as array)
- * @return Array
- * @access public
+ * @param array $params Tag params.
+ * @param array $category_path Category parent path.
+ *
+ * @return array
*/
- public function getCategoryModule($params, $category_ids)
+ public function getCategoryModule(array $params, array $category_path)
{
- $module_info = Array ();
-
+ // Get module by name.
if ( isset($params['module']) ) {
- // get module by name specified
- $module_info = $this->Application->findModule('Name', $params['module']);
-
- }
- elseif ( $category_ids ) {
- // get module by category path
- $module_root_categories = $this->getModuleRootCategories();
- $common_categories = array_intersect($category_ids, $module_root_categories);
- $module_category_id = array_shift($common_categories); // get 1st common category
- $module_info = $this->Application->findModule('RootCat', $module_category_id);
+ return $this->Application->findModule('Name', $params['module']);
}
- return $module_info;
- }
-
- /**
- * Returns root categories from all modules
- *
- * @return Array
- * @access protected
- */
- protected function getModuleRootCategories()
- {
- static $root_categories = null;
+ // Get module by category path.
+ if ( $category_path ) {
+ foreach ( array_reverse($category_path) as $module_category_id ) {
+ $module_info = $this->Application->findModule('RootCat', $module_category_id);
- if ( !isset($root_categories) ) {
- $root_categories = Array ();
- foreach ($this->Application->ModuleInfo as $module_info) {
- array_push($root_categories, $module_info['RootCat']);
+ if ( $module_info && $module_info['Var'] != 'adm' ) {
+ return $module_info;
+ }
}
-
- $root_categories = array_unique($root_categories);
}
- return $root_categories;
+ return array();
}
/**
@@ -378,4 +358,4 @@
return $text;
}
- }
\ No newline at end of file
+ }
Index: branches/5.2.x/core/units/sections/sections_config.php
===================================================================
--- branches/5.2.x/core/units/sections/sections_config.php
+++ branches/5.2.x/core/units/sections/sections_config.php
@@ -61,7 +61,7 @@
'label' => 'la_title_Structure', // 'la_tab_Browse',
'url' => Array ('t' => 'catalog/catalog', 'pass' => 'm'),
'late_load' => Array ('t' => 'categories/xml/tree_categories', 'pass' => 'm', 'm_cat_id' => 0),
- 'onclick' => 'checkCatalog(0)',
+ 'onclick' => 'checkCatalog(0, "c")',
'permissions' => Array ('view'),
'priority' => 2,
'type' => stTREE,
@@ -235,4 +235,4 @@
'type' => stTREE,
),
),
- );
\ No newline at end of file
+ );
Event Timeline
Log In to Comment