Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/helpers/mod_rewrite_helper.php
Show All 30 Lines | |||||
{ | { | ||||
if ($rewrite_mode == REWRITE_MODE_BUILD) { | if ($rewrite_mode == REWRITE_MODE_BUILD) { | ||||
return $this->_buildCategoryItemUrl($prefix, $params, $keep_events); | return $this->_buildCategoryItemUrl($prefix, $params, $keep_events); | ||||
} | } | ||||
$module_prefix = $this->_parseCategoryItemUrl($url_parts, $params, $prefix); | $module_prefix = $this->_parseCategoryItemUrl($url_parts, $params, $prefix); | ||||
if ($module_prefix !== false) { | if ($module_prefix !== false) { | ||||
/** @var kRewriteUrlProcessor $rewrite_processor */ | |||||
$rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor'); | $rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor'); | ||||
/* @var $rewrite_processor kRewriteUrlProcessor */ | |||||
$params['pass'][] = $module_prefix; | $params['pass'][] = $module_prefix; | ||||
$rewrite_processor->setModulePrefix($module_prefix); | $rewrite_processor->setModulePrefix($module_prefix); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
/** | /** | ||||
* Build category item part of url | * Build category item part of url | ||||
* | * | ||||
* @param string $prefix_special | * @param string $prefix_special | ||||
* @param Array $params | * @param Array $params | ||||
* @param bool $keep_events | * @param bool $keep_events | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function _buildCategoryItemUrl($prefix_special, &$params, $keep_events) | protected function _buildCategoryItemUrl($prefix_special, &$params, $keep_events) | ||||
{ | { | ||||
static $default_per_page = Array (); | static $default_per_page = Array (); | ||||
/** @var kRewriteUrlProcessor $rewrite_processor */ | |||||
$rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor'); | $rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor'); | ||||
/* @var $rewrite_processor kRewriteUrlProcessor */ | |||||
$ret = ''; | $ret = ''; | ||||
list ($prefix) = explode('.', $prefix_special); | list ($prefix) = explode('.', $prefix_special); | ||||
$processed_params = $rewrite_processor->getProcessedParams($prefix_special, $params, $keep_events); | $processed_params = $rewrite_processor->getProcessedParams($prefix_special, $params, $keep_events); | ||||
if ($processed_params === false) { | if ($processed_params === false) { | ||||
return ''; | return ''; | ||||
} | } | ||||
if ( isset($params[$prefix_special . '_event']) && $params[$prefix_special . '_event'] ) { | if ( isset($params[$prefix_special . '_event']) && $params[$prefix_special . '_event'] ) { | ||||
$params['events[' . $prefix_special . ']'] = $params[$prefix_special . '_event']; | $params['events[' . $prefix_special . ']'] = $params[$prefix_special . '_event']; | ||||
unset($params[$prefix_special . '_event']); | unset($params[$prefix_special . '_event']); | ||||
} | } | ||||
if (!array_key_exists($prefix, $default_per_page)) { | if (!array_key_exists($prefix, $default_per_page)) { | ||||
/** @var ListHelper $list_helper */ | |||||
$list_helper = $this->Application->recallObject('ListHelper'); | $list_helper = $this->Application->recallObject('ListHelper'); | ||||
/* @var $list_helper ListHelper */ | |||||
$default_per_page[$prefix] = $list_helper->getDefaultPerPage($prefix); | $default_per_page[$prefix] = $list_helper->getDefaultPerPage($prefix); | ||||
} | } | ||||
if ($processed_params[$prefix_special . '_id']) { | if ($processed_params[$prefix_special . '_id']) { | ||||
$category_id = array_key_exists('m_cat_id', $params) ? $params['m_cat_id'] : $this->Application->GetVar('m_cat_id'); | $category_id = array_key_exists('m_cat_id', $params) ? $params['m_cat_id'] : $this->Application->GetVar('m_cat_id'); | ||||
// if template is also item template of category, then remove template | // if template is also item template of category, then remove template | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
{ | { | ||||
static $default_per_page = Array (); | static $default_per_page = Array (); | ||||
if ( $rewrite_mode != REWRITE_MODE_BUILD ) { | if ( $rewrite_mode != REWRITE_MODE_BUILD ) { | ||||
// don't parse anything | // don't parse anything | ||||
return true; | return true; | ||||
} | } | ||||
/** @var kRewriteUrlProcessor $rewrite_processor */ | |||||
$rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor'); | $rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor'); | ||||
/* @var $rewrite_processor kRewriteUrlProcessor */ | |||||
$ret = ''; | $ret = ''; | ||||
list ($prefix) = explode('.', $prefix_special); | list ($prefix) = explode('.', $prefix_special); | ||||
$processed_params = $rewrite_processor->getProcessedParams($prefix_special, $params, $keep_events); | $processed_params = $rewrite_processor->getProcessedParams($prefix_special, $params, $keep_events); | ||||
if ($processed_params === false) { | if ($processed_params === false) { | ||||
return ''; | return ''; | ||||
} | } | ||||
if (!array_key_exists($prefix, $default_per_page)) { | if (!array_key_exists($prefix, $default_per_page)) { | ||||
/** @var ListHelper $list_helper */ | |||||
$list_helper = $this->Application->recallObject('ListHelper'); | $list_helper = $this->Application->recallObject('ListHelper'); | ||||
/* @var $list_helper ListHelper */ | |||||
$default_per_page[$prefix] = $list_helper->getDefaultPerPage($prefix); | $default_per_page[$prefix] = $list_helper->getDefaultPerPage($prefix); | ||||
} | } | ||||
if ($processed_params[$prefix_special . '_id']) { | if ($processed_params[$prefix_special . '_id']) { | ||||
return false; | return false; | ||||
} | } | ||||
else { | else { | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
$item_filename = end($url_parts); | $item_filename = end($url_parts); | ||||
if ( is_numeric($item_filename) ) { | if ( is_numeric($item_filename) ) { | ||||
// this page, don't process here | // this page, don't process here | ||||
return false; | return false; | ||||
} | } | ||||
/** @var kRewriteUrlProcessor $rewrite_processor */ | |||||
$rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor'); | $rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor'); | ||||
/* @var $rewrite_processor kRewriteUrlProcessor */ | |||||
if ( $prefix == 'bb' && preg_match('/^bb_([\d]+)/', $item_filename, $regs) ) { | if ( $prefix == 'bb' && preg_match('/^bb_([\d]+)/', $item_filename, $regs) ) { | ||||
// process topics separately, because they don't use item filenames | // process topics separately, because they don't use item filenames | ||||
array_pop($url_parts); | array_pop($url_parts); | ||||
$rewrite_processor->partParsed($item_filename, 'rtl'); | $rewrite_processor->partParsed($item_filename, 'rtl'); | ||||
return $this->_parseTopicUrl($regs[1], $vars); | return $this->_parseTopicUrl($regs[1], $vars); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | |||||
* | * | ||||
* @param int $topic_id | * @param int $topic_id | ||||
* @param Array $vars | * @param Array $vars | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function _parseTopicUrl($topic_id, &$vars) | protected function _parseTopicUrl($topic_id, &$vars) | ||||
{ | { | ||||
/** @var kRewriteUrlProcessor $rewrite_processor */ | |||||
$rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor'); | $rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor'); | ||||
/* @var $rewrite_processor kRewriteUrlProcessor */ | |||||
$sql = 'SELECT c.ParentPath, c.CategoryId | $sql = 'SELECT c.ParentPath, c.CategoryId | ||||
FROM ' . TABLE_PREFIX . 'Categories AS c | FROM ' . TABLE_PREFIX . 'Categories AS c | ||||
WHERE c.CategoryId = ' . (int)$vars['m_cat_id']; | WHERE c.CategoryId = ' . (int)$vars['m_cat_id']; | ||||
$cat_item = $this->Conn->GetRow($sql); | $cat_item = $this->Conn->GetRow($sql); | ||||
$item_template = $rewrite_processor->GetItemTemplate($cat_item, 'bb', $vars['m_theme']); | $item_template = $rewrite_processor->GetItemTemplate($cat_item, 'bb', $vars['m_theme']); | ||||
Show All 9 Lines |