本文整理汇总了PHP中JApplicationCms::getMenu方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationCms::getMenu方法的具体用法?PHP JApplicationCms::getMenu怎么用?PHP JApplicationCms::getMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JApplicationCms
的用法示例。
在下文中一共展示了JApplicationCms::getMenu方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Class constructor
*
* @param JApplicationCms $app JApplicationCms Object
* @param JMenu $menu JMenu object
*
* @since 3.4
*/
public function __construct(JApplicationCms $app = null, JMenu $menu = null)
{
$this->app = $app ? $app : JApplicationCms::getInstance('site');
$this->menu = $menu ? $menu : $this->app->getMenu();
// Add core rules
if ($this->app->get('force_ssl') == 2) {
$this->attachParseRule(array($this, 'parseCheckSSL'), self::PROCESS_BEFORE);
}
$this->attachParseRule(array($this, 'parseInit'), self::PROCESS_BEFORE);
$this->attachBuildRule(array($this, 'buildInit'), self::PROCESS_BEFORE);
$this->attachBuildRule(array($this, 'buildComponentPreprocess'), self::PROCESS_BEFORE);
if ($this->app->get('sef')) {
if ($this->app->get('sef_suffix')) {
$this->attachParseRule(array($this, 'parseFormat'), self::PROCESS_BEFORE);
$this->attachBuildRule(array($this, 'buildFormat'), self::PROCESS_AFTER);
}
$this->attachParseRule(array($this, 'parseSefRoute'), self::PROCESS_DURING);
$this->attachBuildRule(array($this, 'buildSefRoute'), self::PROCESS_DURING);
$this->attachParseRule(array($this, 'parsePaginationData'), self::PROCESS_AFTER);
$this->attachBuildRule(array($this, 'buildPaginationData'), self::PROCESS_AFTER);
if ($this->app->get('sef_rewrite')) {
$this->attachBuildRule(array($this, 'buildRewrite'), self::PROCESS_AFTER);
}
}
$this->attachParseRule(array($this, 'parseRawRoute'), self::PROCESS_DURING);
$this->attachBuildRule(array($this, 'buildBase'), self::PROCESS_AFTER);
}
示例2: __construct
/**
* MonitorRouter constructor.
*
* @param JApplicationCms $app Application object that the router should use
* @param JMenu $menu Menu object that the router should use
* @param MonitorModelProject $modelProject Project model to use in the router.
* @param MonitorModelIssue $modelIssue Issue model to use in the router.
*
* @throws Exception
*/
public function __construct($app = null, $menu = null, $modelProject = null, $modelIssue = null)
{
JLoader::register('MonitorModelAbstract', JPATH_ROOT . '/administrator/components/com_monitor/model/abstract.php');
JLoader::register('MonitorModelProject', JPATH_ROOT . '/administrator/components/com_monitor/model/project.php');
JLoader::register('MonitorModelIssue', JPATH_ROOT . '/administrator/components/com_monitor/model/issue.php');
if ($app) {
$this->app = $app;
} else {
$this->app = JFactory::getApplication();
}
if ($menu) {
$this->menu = $menu;
} else {
$this->menu = $this->app->getMenu();
}
if ($modelProject) {
$this->modelProject = $modelProject;
} else {
$this->modelProject = new MonitorModelProject($app, false);
}
if ($modelIssue) {
$this->modelIssue = $modelIssue;
} else {
$this->modelIssue = new MonitorModelIssue($app, false);
}
}
示例3: __construct
/**
* Class constructor.
*
* @param JApplicationCms $app Application-object that the router should use
* @param JMenu $menu Menu-object that the router should use
*
* @since 3.4
*/
public function __construct($app = null, $menu = null)
{
if ($app) {
$this->app = $app;
} else {
$this->app = JFactory::getApplication('site');
}
if ($menu) {
$this->menu = $menu;
} else {
$this->menu = $this->app->getMenu();
}
}
示例4: calcBase
/**
* Get base menu item.
*
* If itemid is not specified or does not exist, return active menu item.
* If there is no active menu item, fall back to home page for the current language.
* If there is no home page, return null.
*
* @param int $itemid
*
* @return object|null
*/
protected function calcBase($itemid = null)
{
$menu = $this->app->getMenu();
// Get base menu item.
$base = $itemid ? $menu->getItem($itemid) : null;
if (!$base) {
// Use active menu item or fall back to default menu item.
$base = $this->active ?: $this->default;
}
// Return base menu item.
return $base;
}
示例5: getParams
/**
* Get the configuration for the component and (if given) the active menu item.
*
* TODO: may be removed when new MVC is implemented completely
*
* @return \Joomla\Registry\Registry Object containing the parameters.
*/
public function getParams()
{
if ($this->app instanceof JApplicationSite) {
$params = $this->app->getParams();
$active = $this->app->getMenu()->getActive();
if ($active) {
$params->merge($active->params);
}
} else {
$params = JComponentHelper::getParams('com_monitor');
}
return $params;
}
示例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') && $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;
if ($active) {
$active_link = JRoute::_($active->link . '&Itemid=' . $active->id, false);
$current_link = JUri::getInstance()->toString(array('path', 'query'));
// Load menu associations
if ($active_link == $current_link) {
$associations = MenusHelper::getAssociations($active->id);
}
// Check if we are on the homepage
$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 = JUri::getInstance()->toString(array('path', 'query'));
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" />');
}
}
}
}
}
示例7: getMenu
/**
* Return a reference to the JMenu object.
*
* @param string $name The name of the application/client.
* @param array $options An optional associative array of configuration settings.
*
* @return JMenu JMenu object.
*
* @since 3.2
*/
public function getMenu($name = 'site', $options = array())
{
$menu = parent::getMenu($name, $options);
return $menu;
}
示例8: __construct
/**
* Class constructor
*
* @param array $options Array of options
* @param JApplicationCms $app JApplicationCms Object
* @param JMenu $menu JMenu object
*
* @since 3.4
*/
public function __construct($options = array(), JApplicationCms $app = null, JMenu $menu = null)
{
parent::__construct($options);
$this->app = $app ? $app : JApplicationCms::getInstance('site');
$this->menu = $menu ? $menu : $this->app->getMenu();
}
示例9: onAfterDispatch
/**
* Method to add alternative meta tags for associated menu items.
*
* @return void
*
* @since 1.7
*/
public function onAfterDispatch()
{
$doc = JFactory::getDocument();
$menu = $this->app->getMenu();
$server = JUri::getInstance()->toString(array('scheme', 'host', 'port'));
$option = $this->app->input->get('option');
$eName = JString::ucfirst(JString::str_ireplace('com_', '', $option));
if ($this->app->isSite() && $this->params->get('alternate_meta') && $doc->getType() == 'html') {
// Get active menu item.
$active = $menu->getActive();
$assocs = array();
$home = false;
// Load menu associations.
if ($active) {
$active_link = JRoute::_($active->link . '&Itemid=' . $active->id, false);
// Get current link.
$current_link = JUri::getInstance()->toString(array('path', 'query'));
// Check the exact menu item's URL.
if ($active_link == $current_link) {
$associations = MenusHelper::getAssociations($active->id);
unset($associations[$active->language]);
$assocs = array_keys($associations);
// If the menu item is a home menu item and the URLs are identical, we are on the homepage
$home = true;
}
}
// Load component associations.
$cName = JString::ucfirst($eName . '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'));
$lang_code = $this->app->input->cookie->getString(JApplicationHelper::getHash('language'));
// No cookie - let's try to detect browser language or use site default.
if (!$lang_code) {
if ($this->params->get('detect_browser', 1)) {
$lang_code = JLanguageHelper::detectLanguage();
} else {
$lang_code = $this->default_lang;
}
}
unset($cassociations[$lang_code]);
$assocs = array_merge(array_keys($cassociations), $assocs);
}
// Handle the default associations.
if ($this->params->get('item_associations') || $active && $active->home && $home) {
$languages = JLanguageHelper::getLanguages('lang_code');
foreach ($assocs as $language) {
if (!JLanguage::exists($language)) {
continue;
}
$lang = $languages[$language];
if (isset($cassociations[$language])) {
$link = JRoute::_($cassociations[$language] . '&lang=' . $lang->sef);
// Check if language is the default site language and remove url language code is on
if ($lang->sef == $this->lang_codes[$this->default_lang]->sef && $this->params->get('remove_default_prefix') == '1') {
$link = preg_replace('|/' . $lang->sef . '/|', '/', $link, 1);
}
$doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language));
} elseif (isset($associations[$language])) {
$item = $menu->getItem($associations[$language]);
if ($item) {
$link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $lang->sef);
$doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language));
}
}
}
}
}
}
示例10: setLimits
/**
* Set the navigation limit and limitstart
*
* @param int $limitStart_override Specific limitstart to use, if both start and length are specified
* @param int $limitlength_override Specific limitlength to use, if both start and length are specified
*
* @return void
*/
public function setLimits($limitStart_override = null, $limitlength_override = null)
{
$input = $this->app->input;
// Plugins using setLimits - these limits would get overwritten by render() or getData() calls
if (isset($this->limitLength) && isset($this->limitStart) && is_null($limitStart_override) && is_null($limitlength_override)) {
return;
}
/*
* $$$ hugh - added the overrides, so things like visualizations can just turn
* limits off, by passing 0's, without having to go round the houses setting
* the request array before calling this method.
*/
if (!is_null($limitStart_override) && !is_null($limitlength_override)) {
// Might want to set the request vars here?
$limitStart = $limitStart_override;
$limitLength = $limitlength_override;
} else {
$package = $this->app->getUserState('com_fabrik.package', 'fabrik');
$item = $this->getTable();
$params = $this->getParams();
$id = $this->getId();
$this->randomRecords = $input->get('fabrik_random', $this->randomRecords);
// $$$ rob don't make the key list.X as the registry doesn't seem to like keys with just '1' a
$context = 'com_' . $package . '.list' . $this->getRenderContext() . '.';
$limitStart = $this->randomRecords ? $this->getRandomLimitStart() : 0;
// Deal with the fact that you can have more than one list on a page so limitstart has to be specific per table
// If list is rendered as a content plugin don't set the limits in the session
if ($this->app->scope == 'com_content') {
$limitLength = $input->getInt('limit' . $id, $item->rows_per_page);
if (!$this->randomRecords) {
$limitStart = $input->getInt('limitstart' . $id, $limitStart);
}
} else {
// If a list (assoc with a menu item) loads a form, with db join & front end select - don't use the orig menu's rows_per_page value.
$mambot = $this->isMambot || $input->get('tmpl') === 'component' && $input->getInt('ajax') === 1;
$rowsPerPage = FabrikWorker::getMenuOrRequestVar('rows_per_page', $item->rows_per_page, $mambot);
// If a menu item specifically sets the # of rows to show this should be stored (and used) in its own session context.
// See: http://fabrikar.com/forums/index.php?threads/list-results-split-by-wrong-rows-per-page-number.42182/#post-213703
if (!$this->app->isAdmin() && !$mambot) {
$menus = $this->app->getMenu();
$menu = $menus->getActive();
if (is_object($menu)) {
if (!is_null($menu->params->get('rows_per_page'))) {
$context .= $menu->id . '.';
}
}
}
$limitLength = $this->app->getUserStateFromRequest($context . 'limitlength', 'limit' . $id, $rowsPerPage);
if (!$this->randomRecords) {
$limitStart = $this->app->getUserStateFromRequest($context . 'limitstart', 'limitstart' . $id, $limitStart, 'int');
}
}
if ($this->outputFormat == 'feed') {
$limitLength = $input->getInt('limit', $params->get('rsslimit', 150));
$maxLimit = $params->get('rsslimitmax', 2500);
if ($limitLength > $maxLimit) {
$limitLength = $maxLimit;
}
}
if ($limitStart < 0) {
$limitStart = 0;
}
}
$this->limitLength = $limitLength;
$this->limitStart = $limitStart;
}