Index: branches/RC/core/units/general/helpers/mod_rewrite_helper.php =================================================================== diff -u -N -r10459 -r11501 --- branches/RC/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 10459) +++ branches/RC/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 11501) @@ -342,62 +342,43 @@ { if (!isset($url_parts[0])) return false; - if ($this->Application->isModuleEnabled('Proj-CMS')) { - $friendly = $this->Conn->GetRow( - ' SELECT CategoryId, NamedParentPath FROM '.TABLE_PREFIX.'Category - WHERE FriendlyURL = '.$this->Conn->qstr(implode('/', $url_parts))); - if ($friendly) { - $vars['m_cat_id'] = $friendly['CategoryId']; - $vars['t'] = preg_replace('/^content\//i', '', $friendly['NamedParentPath']); - return true; - } + $sql = 'SELECT CategoryId, NamedParentPath + FROM ' . TABLE_PREFIX . 'Category + WHERE FriendlyURL = ' . $this->Conn->qstr(implode('/', $url_parts)); + $friendly = $this->Conn->GetRow($sql); + if ($friendly) { + $vars['m_cat_id'] = $friendly['CategoryId']; + $vars['t'] = preg_replace('/^content\//i', '', $friendly['NamedParentPath']); + return true; + } - $template_path = 'content/'.implode('/', $url_parts); + $template_path = 'content/' . implode('/', $url_parts); - $sql = 'SELECT CategoryId, IsIndex, NamedParentPath FROM '.TABLE_PREFIX.'Category - WHERE - LOWER(NamedParentPath) = '.$this->Conn->qstr($template_path).' - AND - Status IN (1,4) '; - $template_found = $this->Conn->GetRow($sql); + $sql = 'SELECT CategoryId, IsIndex, NamedParentPath FROM '.TABLE_PREFIX.'Category + WHERE + LOWER(NamedParentPath) = '.$this->Conn->qstr($template_path).' + AND + Status IN (1,4) '; + $template_found = $this->Conn->GetRow($sql); - if ($template_found) { - // IsIndex = 2 is a Container-only page, meaning it should go to index-page child - if ($template_found['IsIndex'] == 2) { - $template_found = $this->Conn->GetRow(' - SELECT CategoryId, NamedParentPath FROM '.TABLE_PREFIX.'Category - WHERE ParentId = '.$template_found['CategoryId'].' AND IsIndex = 1 - '); - $vars['t'] = preg_replace('/^content\//i', '', $template_found['NamedParentPath']); - } - else { - $vars['t'] = implode('/', $url_parts); - } - $vars['m_cat_id'] = $template_found['CategoryId']; - $vars['is_virtual'] = true; // for template from POST - return true; + if ($template_found) { + // IsIndex = 2 is a Container-only page, meaning it should go to index-page child + if ($template_found['IsIndex'] == 2) { + $sql = 'SELECT CategoryId, NamedParentPath + FROM ' . TABLE_PREFIX . 'Category + WHERE ParentId = '.$template_found['CategoryId'].' AND IsIndex = 1'; + $template_found = $this->Conn->GetRow($sql); + $vars['t'] = preg_replace('/^content\//i', '', $template_found['NamedParentPath']); } - } + else { + $vars['t'] = implode('/', $url_parts); + } - if ($this->Application->isModuleEnabled('In-Edit')) { - $template_path = implode('/', $url_parts); - $sql = 'SELECT p.PageId, ci.CategoryId FROM '.TABLE_PREFIX.'Pages AS p - LEFT JOIN '.TABLE_PREFIX.'CategoryItems AS ci - ON ci.ItemResourceId = p.ResourceId - WHERE - Path = '.$this->Conn->qstr($template_path).' - AND - ci.PrimaryCat = 1 - AND - p.Status = 1'; - $template_found = $this->Conn->GetRow($sql); + $vars['m_cat_id'] = $template_found['CategoryId']; + $vars['is_virtual'] = true; // for template from POST - if ($template_found) { - $vars['m_cat_id'] = $template_found['CategoryId']; - $vars['t'] = $template_path; - return true; - } + return true; } return false; @@ -484,6 +465,8 @@ $this->ProcessLanguage($url_parts, $vars); $this->ProcessTheme($url_parts, $vars); + // bug #1: cancells all other processing in case, when cms page is found + // bug #2: doesn't match template partially, e.g. "test/case/other" will not match to page "test/case" with "other" left for future processing if ( $this->ProcessVirtualTemplate($url_parts, $vars) ) { return $vars; }