本文整理汇总了PHP中JRouter::processBuildRules方法的典型用法代码示例。如果您正苦于以下问题:PHP JRouter::processBuildRules方法的具体用法?PHP JRouter::processBuildRules怎么用?PHP JRouter::processBuildRules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JRouter
的用法示例。
在下文中一共展示了JRouter::processBuildRules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processBuildRules
/**
* Process the build uri query data based on custom defined rules
*
* @param JUri &$uri The URI
*
* @return void
*
* @since 3.2
*/
protected function processBuildRules(&$uri)
{
// Make sure any menu vars are used if no others are specified
if ($this->_mode != JROUTER_MODE_SEF && $uri->getVar('Itemid') && count($uri->getQuery(true)) == 2) {
$app = JApplication::getInstance('site');
$menu = $app->getMenu();
// Get the active menu item
$itemid = $uri->getVar('Itemid');
$item = $menu->getItem($itemid);
if ($item) {
$uri->setQuery($item->query);
}
$uri->setVar('Itemid', $itemid);
}
// Process the attached build rules
parent::processBuildRules($uri);
// Get the path data
$route = $uri->getPath();
if ($this->_mode == JROUTER_MODE_SEF && $route) {
if ($limitstart = $uri->getVar('limitstart')) {
$uri->setVar('start', (int) $limitstart);
$uri->delVar('limitstart');
}
}
$uri->setPath($route);
}
示例2: processBuildRules
/**
* Process the build uri query data based on custom defined rules
*
* @param JUri &$uri The URI
* @param string $stage The stage that should be processed.
* Possible values: 'preprocess', 'postprocess'
* and '' for the main build stage
*
* @return void
*
* @since 3.2
* @deprecated 4.0 The special logic should be implemented as rule
*/
protected function processBuildRules(&$uri, $stage = self::PROCESS_DURING)
{
if ($stage == self::PROCESS_DURING) {
// Make sure any menu vars are used if no others are specified
$query = $uri->getQuery(true);
if ($this->_mode != 1 && isset($query['Itemid']) && (count($query) == 2 || count($query) == 3 && isset($query['lang']))) {
// Get the active menu item
$itemid = $uri->getVar('Itemid');
$lang = $uri->getVar('lang');
$item = $this->menu->getItem($itemid);
if ($item) {
$uri->setQuery($item->query);
}
$uri->setVar('Itemid', $itemid);
if ($lang) {
$uri->setVar('lang', $lang);
}
}
}
// Process the attached build rules
parent::processBuildRules($uri, $stage);
if ($stage == self::PROCESS_BEFORE) {
// Get the query data
$query = $uri->getQuery(true);
if (!isset($query['option'])) {
return;
}
// Build the component route
$component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $query['option']);
$router = $this->getComponentRouter($component);
$query = $router->preprocess($query);
$uri->setQuery($query);
}
if ($stage == self::PROCESS_DURING) {
// Get the path data
$route = $uri->getPath();
if ($this->_mode == JROUTER_MODE_SEF && $route) {
if ($limitstart = $uri->getVar('limitstart')) {
$uri->setVar('start', (int) $limitstart);
$uri->delVar('limitstart');
}
}
$uri->setPath($route);
}
}