本文整理汇总了PHP中JApplicationCms::getRouter方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationCms::getRouter方法的具体用法?PHP JApplicationCms::getRouter怎么用?PHP JApplicationCms::getRouter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JApplicationCms
的用法示例。
在下文中一共展示了JApplicationCms::getRouter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAfterDispatch
/**
* Add the canonical uri to the head.
*
* @return void
*
* @since 3.5
*/
public function onAfterDispatch()
{
$doc = $this->app->getDocument();
if (!$this->app->isSite() || $doc->getType() !== 'html') {
return;
}
$uri = JUri::getInstance();
$domain = $this->params->get('domain');
if ($domain === false || $domain === '') {
$domain = $uri->toString(array('scheme', 'host', 'port'));
}
$link = $domain . JRoute::_('index.php?' . http_build_query($this->app->getRouter()->getVars()), false);
if (rawurldecode($uri->toString()) !== $link) {
$doc->addHeadLink(htmlspecialchars($link), 'canonical');
}
}
示例2: onAfterInitialise
/**
* After initialise.
*
* @return void
*
* @since 1.6
*/
public function onAfterInitialise()
{
$this->app->item_associations = $this->params->get('item_associations', 0);
if ($this->app->isSite()) {
$router = $this->app->getRouter();
// Attach build rules for language SEF.
$router->attachBuildRule(array($this, 'preprocessBuildRule'), JRouter::PROCESS_BEFORE);
$router->attachBuildRule(array($this, 'buildRule'), JRouter::PROCESS_DURING);
if ($this->mode_sef) {
$router->attachBuildRule(array($this, 'postprocessSEFBuildRule'), JRouter::PROCESS_AFTER);
} else {
$router->attachBuildRule(array($this, 'postprocessNonSEFBuildRule'), JRouter::PROCESS_AFTER);
}
// Attach parse rules for language SEF.
$router->attachParseRule(array($this, 'parseRule'), JRouter::PROCESS_DURING);
}
}
示例3: getRouter
/**
* Return a reference to the JRouter object.
*
* @param string $name The name of the application.
* @param array $options An optional associative array of configuration settings.
*
* @return JRouter
*
* @since 3.2
*/
public static function getRouter($name = 'site', array $options = array())
{
$config = JFactory::getConfig();
$options['mode'] = $config->get('sef');
return parent::getRouter($name, $options);
}
示例4: getRouter
/**
* Return a reference to the JRouter object.
*
* @param string $name The name of the application.
* @param array $options An optional associative array of configuration settings.
*
* @return JRouter
*
* @since 3.2
*/
public static function getRouter($name = 'administrator', array $options = array())
{
return parent::getRouter($name, $options);
}
示例5: getTableAction
/**
* Return the url for the list form - this url is used when submitting searches, and ordering
*
* @return string action url
*/
public function getTableAction()
{
if (isset($this->tableAction)) {
return $this->tableAction;
}
$input = $this->app->input;
$option = $input->get('option');
// Get the router
$router = $this->app->getRouter();
$package = $this->app->getUserState('com_fabrik.package', 'fabrik');
/* $$$ rob force these to be 0 once the menu item has been loaded for the first time
* subsequent loads of the link should have this set to 0. When the menu item is re-clicked
* rest filters is set to 1 again
*/
$router->setVar('resetfilters', 0);
if ($option !== $package) {
// $$$ rob these can't be set by the menu item, but can be set in {fabrik....}
$router->setVar('clearordering', 0);
$router->setVar('clearfilters', 0);
}
$queryVars = $router->getVars();
$form = $this->getFormModel();
$page = 'index.php?';
foreach ($queryVars as $k => $v) {
$rawK = FabrikString::rtrimword($k, '_raw');
$el = $form->getElement($k);
if ($el === false) {
$el = $form->getElement($rawK);
}
if (is_array($v)) {
/* $$$ rob if you were using URL filters such as
*
* &jos_fabble_activity___create_date[value][]=now
* &jos_fabble_activity___create_date[value][]=%2B2%20week&jos_fabble_activity___create_date[condition]=BETWEEN
*
* then we don't want to re-add them to the table action.
* Instead they are aded to the filter sessions and reapplied that way
* otherwise we ended up with elementname=Array in the query string
*/
/*
* $$$ hugh ... yeah, but $v is still an array, so we need to deal with it
* if it isn't an element ... like (say) ids[]=1&ids[]=2 in a table plugin, like
* email list
*/
if ($el === false && $k !== 'fabrik___filter') {
foreach ($v as $v1) {
$qs[] = $k . '[]=' . $v1;
}
}
} else {
if ($el === false) {
$qs[] = $k . '=' . $v;
} else {
/* $$$ e-kinst
* let's keep &id for com_content - in other case in Content Plugin
* we have incorrect action in form and as a result bad pagination URLS.
* In any case this will not be excessive (I suppose)
*/
if ($k == 'id' && $option == 'com_content') {
// At least. May be even $option != 'com_fabrik'
$qs[] = $k . '=' . $v;
}
// Check if its a tag element if it is we want to clear that when we clear the form
// (if the filter was set via the url we generally want to keep it though
/* 28/12/2011 $$$ rob testing never keeping querystring filters in the qs but instead always
* adding them to the filters (if no filter set up in element settings then hidden fields added anyway
* this is to try to get round issue of related data (countries->regions) filter region from country list,
* then clear filters (ok) but then if you go to 2nd page of results country url filter re-applied
*/
/* if($el->getElement()->plugin !== 'textarea' && $el->getParams()->get('textarea-tagify') !== true) {
$qs[] = "$k=$v";
} */
}
}
}
$action = $page . implode('&', $qs);
$action = preg_replace("/limitstart{$this->getId()}=(\\d+)?(&|)/", '', $action);
$action = FabrikString::removeQSVar($action, 'fabrik_incsessionfilters');
$action = FabrikString::rtrimword($action, '&');
$this->tableAction = JRoute::_($action);
return $this->tableAction;
}
示例6: onAfterDispatch
/**
* Method to add alternative meta tags for associated menu items.
*
* @return void
*
* @since 1.7
*/
public function onAfterDispatch()
{
$doc = JFactory::getDocument();
if ($this->app->isSite() && $this->params->get('alternate_meta', 1) && $doc->getType() == 'html') {
$languages = $this->lang_codes;
$homes = JLanguageMultilang::getSiteHomePages();
$menu = $this->app->getMenu();
$active = $menu->getActive();
$levels = JFactory::getUser()->getAuthorisedViewLevels();
$remove_default_prefix = $this->params->get('remove_default_prefix', 0);
$server = JUri::getInstance()->toString(array('scheme', 'host', 'port'));
$is_home = false;
$currentInternalUrl = 'index.php?' . http_build_query($this->app->getRouter()->getVars());
if ($active) {
$active_link = JRoute::_($active->link . '&Itemid=' . $active->id);
$current_link = JRoute::_($currentInternalUrl);
// Load menu associations
if ($active_link == $current_link) {
$associations = MenusHelper::getAssociations($active->id);
}
// Check if we are on the home page
$is_home = $active->home && ($active_link == $current_link || $active_link == $current_link . 'index.php' || $active_link . '/' == $current_link);
}
// Load component associations.
$option = $this->app->input->get('option');
$cName = JString::ucfirst(JString::str_ireplace('com_', '', $option)) . 'HelperAssociation';
JLoader::register($cName, JPath::clean(JPATH_COMPONENT_SITE . '/helpers/association.php'));
if (class_exists($cName) && is_callable(array($cName, 'getAssociations'))) {
$cassociations = call_user_func(array($cName, 'getAssociations'));
}
// For each language...
foreach ($languages as $i => &$language) {
switch (true) {
// Language without frontend UI || Language without specific home menu || Language without authorized access level
case !array_key_exists($i, JLanguageMultilang::getSiteLangs()):
case !isset($homes[$i]):
case isset($language->access) && $language->access && !in_array($language->access, $levels):
unset($languages[$i]);
break;
// Home page
// Home page
case $is_home:
$language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $homes[$i]->id);
break;
// Current language link
// Current language link
case $i == $this->current_lang:
$language->link = JRoute::_($currentInternalUrl);
break;
// Component association
// Component association
case isset($cassociations[$i]):
$language->link = JRoute::_($cassociations[$i] . '&lang=' . $language->sef);
break;
// Menu items association
// Heads up! "$item = $menu" here below is an assignment, *NOT* comparison
// Menu items association
// Heads up! "$item = $menu" here below is an assignment, *NOT* comparison
case isset($associations[$i]) && ($item = $menu->getItem($associations[$i])):
$language->link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $language->sef);
break;
// Too bad...
// Too bad...
default:
unset($languages[$i]);
}
}
// If there are at least 2 of them, add the rel="alternate" links to the <head>
if (count($languages) > 1) {
// Remove the sef from the default language if "Remove URL Language Code" is on
if (isset($languages[$this->default_lang]) && $remove_default_prefix) {
$languages[$this->default_lang]->link = preg_replace('|/' . $languages[$this->default_lang]->sef . '/|', '/', $languages[$this->default_lang]->link, 1);
}
foreach ($languages as $i => &$language) {
$doc->addHeadLink($server . $language->link, 'alternate', 'rel', array('hreflang' => $i));
}
// Add x-default language tag
if ($this->params->get('xdefault', 1)) {
$xdefault_language = $this->params->get('xdefault_language', $this->default_lang);
$xdefault_language = $xdefault_language == 'default' ? $this->default_lang : $xdefault_language;
if (isset($languages[$xdefault_language])) {
// Use a custom tag because addHeadLink is limited to one URI per tag
$doc->addCustomTag('<link href="' . $server . $languages[$xdefault_language]->link . '" rel="alternate" hreflang="x-default" />');
}
}
}
}
}