Index: branches/unlabeled/unlabeled-1.4.2/core/units/general/helpers/mod_rewrite_helper.php =================================================================== diff -u -r5970 -r6031 --- branches/unlabeled/unlabeled-1.4.2/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 5970) +++ branches/unlabeled/unlabeled-1.4.2/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 6031) @@ -147,6 +147,22 @@ function ProcessModuleItem(&$url_parts, &$vars, $set_t=true) { + if (preg_match('/^bb_.*/', $url_parts[0])) { + $cat_item = $this->Conn->GetRow(' + SELECT c.ParentPath, c.CategoryId FROM '.TABLE_PREFIX.'Category AS c + WHERE + c.CategoryId = '.$vars['m_cat_id']); + + if ($set_t) { + $item_template = $this->GetItemTemplate($cat_item, 'bb'); + $vars['t'] = $item_template; + } + + $this->Application->HandleEvent($bb_event, 'bb:ParseEnv', Array('url_parts' => $url_parts, 'vars' => $vars)); + $vars = $bb_event->getEventParam('vars'); + return 'bb'; + } + if (!isset($url_parts[0])) return false; if ( count($url_parts) != 1 ) return false; $url_part = array_shift($url_parts); @@ -171,25 +187,8 @@ if ($cat_item !== false) { // item found $module_prefix = $cat_item['ItemPrefix']; - $parent_path = implode(',',explode('|', substr($cat_item['ParentPath'], 1, -1))); + $item_template = $this->GetItemTemplate($cat_item, $module_prefix); - // item template is stored in module' system custom field - need to get that field Id - $item_template_field_id = $this->Conn->GetOne( - 'SELECT CustomFieldId - FROM '.TABLE_PREFIX.'CustomField - WHERE FieldName = '.$this->Conn->qstr($module_prefix.'_ItemTemplate')); - - // looking for item template through cats hierarchy sorted by parent path - $query = 'SELECT ccd.l1_cust_'.$item_template_field_id.', - FIND_IN_SET(c.CategoryId, '.$this->Conn->qstr($parent_path).') AS Ord1, - c.CategoryId, c.Name, ccd.l1_cust_'.$item_template_field_id.' - FROM '.TABLE_PREFIX.'Category AS c - LEFT JOIN '.TABLE_PREFIX.'CategoryCustomData AS ccd - ON ccd.ResourceId = c.ResourceId - WHERE c.CategoryId IN ('.$parent_path.') AND ccd.l1_cust_'.$item_template_field_id.' != \'\' - ORDER BY FIND_IN_SET(c.CategoryId, '.$this->Conn->qstr($parent_path).') DESC'; - $item_template = $this->Conn->GetOne($query); - // converting ResourceId to correpsonding Item id $module_config = $this->Application->getUnitOptions($module_prefix); $item_id = $this->Conn->GetOne( @@ -210,6 +209,29 @@ return false; } + function GetItemTemplate($category, $module_prefix) + { + $parent_path = implode(',',explode('|', substr($category['ParentPath'], 1, -1))); + + // item template is stored in module' system custom field - need to get that field Id + $item_template_field_id = $this->Conn->GetOne( + 'SELECT CustomFieldId + FROM '.TABLE_PREFIX.'CustomField + WHERE FieldName = '.$this->Conn->qstr($module_prefix.'_ItemTemplate')); + + // looking for item template through cats hierarchy sorted by parent path + $query = 'SELECT ccd.l1_cust_'.$item_template_field_id.', + FIND_IN_SET(c.CategoryId, '.$this->Conn->qstr($parent_path).') AS Ord1, + c.CategoryId, c.Name, ccd.l1_cust_'.$item_template_field_id.' + FROM '.TABLE_PREFIX.'Category AS c + LEFT JOIN '.TABLE_PREFIX.'CategoryCustomData AS ccd + ON ccd.ResourceId = c.ResourceId + WHERE c.CategoryId IN ('.$parent_path.') AND ccd.l1_cust_'.$item_template_field_id.' != \'\' + ORDER BY FIND_IN_SET(c.CategoryId, '.$this->Conn->qstr($parent_path).') DESC'; + $item_template = $this->Conn->GetOne($query); + return $item_template; + } + function ProcessPhisycalTemplate(&$url_parts, &$vars) { if (!isset($url_parts[0])) return false; @@ -351,6 +373,9 @@ } $this->ProcessCategory($url_parts, $vars); + + + if ( $this->ProcessModuleIndex($url_parts, $vars) ) { foreach ($this->Application->ModuleInfo as $module_name => $info) { $passed[] = $info['Var'];