本文整理汇总了PHP中menu_get_item函数的典型用法代码示例。如果您正苦于以下问题:PHP menu_get_item函数的具体用法?PHP menu_get_item怎么用?PHP menu_get_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了menu_get_item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: spanjestrijders_breadcrumb
/**
* Return a themed breadcrumb trail. (Taken from Zen)
*
* http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_menu_breadcrumb_alter/7
* if ($breadcrumb[0]['href'] == '<front>') { $breadcrumb[0]['title'] = 'iish'; }
* en ook breadcrumb op home
*
* @param $variables
* - title: An optional string to be used as a navigational heading to give
* context for breadcrumb links to screen-reader users.
* - title_attributes_array: Array of HTML attributes for the title. It is
* flattened into a string within the theme function.
* - breadcrumb: An array containing the breadcrumb links.
* @return
* A string containing the breadcrumb output.
*/
function spanjestrijders_breadcrumb($variables)
{
$breadcrumb = $variables['breadcrumb'];
// Return the breadcrumb with separators.
if (!empty($breadcrumb)) {
$breadcrumb_separator = ' > ';
$trailing_separator = $title = '';
$item = menu_get_item();
if (!empty($item['tab_parent'])) {
// If we are on a non-default tab, use the tab's title.
$title = check_plain($item['title']);
} else {
$title = drupal_get_title();
}
if ($title) {
$trailing_separator = $breadcrumb_separator;
}
// Provide a navigational heading to give context for breadcrumb links to
// screen-reader users.
if (empty($variables['title'])) {
$variables['title'] = t('You are here');
}
// Unless overridden by a preprocess function, make the heading invisible.
if (!isset($variables['title_attributes_array']['class'])) {
$variables['title_attributes_array']['class'][] = 'element-invisible';
}
$heading = '<h2' . drupal_attributes($variables['title_attributes_array']) . '>' . $variables['title'] . '</h2>';
// return '<div class="breadcrumb">' . $heading . implode($breadcrumb_separator, $breadcrumb) . $trailing_separator . $title . '</div>';
return '<div class="breadcrumb">' . $heading . implode($breadcrumb_separator, $breadcrumb) . '</div>';
}
// Otherwise, return an empty string.
return '';
}
示例2: getRouterItem
/**
* Returns a router item.
*
* This is a wrapper around menu_get_item() that sets additional keys
* (route, link_path, alias, fragments).
*
* @param $path
* The path for which the corresponding router item is returned.
* For example, node/5.
*
* @return array|null
* The router item.
*/
function getRouterItem($path)
{
$normalpath = drupal_get_normal_path($path);
try {
$item = menu_get_item($normalpath);
} catch (Exception $e) {
// Some modules throw an exception, if a path has unloadable arguments.
// We don't care, because we don't actually load this page.
return NULL;
}
// Some additional keys.
if (empty($item) || !is_array($item)) {
return NULL;
}
// 'route' is a less ambiguous name for a router path than 'path'.
$item['route'] = $item['path'];
// 'href' sounds more like it had already run through url().
$item['link_path'] = $normalpath;
$item['alias'] = drupal_get_path_alias($normalpath);
$item['fragments'] = explode('/', $normalpath);
if (!isset($item['localized_options'])) {
$item['localized_options'] = array();
}
if ('crumbs_special_menu_link_page' === $item['page_callback']) {
$item['href'] = '<nolink>';
}
if ($normalpath !== $item['href']) {
$pos = strlen($item['href']);
$item['variadic_suffix'] = substr($normalpath, $pos);
} else {
$item['variadic_suffix'] = NULL;
}
return $item;
}
示例3: hook_og_vocab_is_admin_context
/**
* Allow modules to return TRUE if we are insiede an OG vocab admin
* context.
*
* @return
* If countext found array keyed by the group-type and the group ID.
*/
function hook_og_vocab_is_admin_context()
{
$item = menu_get_item();
if (strpos($item['path'], 'foo/admin') === 0) {
return array('group_type' => 'node', 'gid' => 1);
}
}
示例4: onKernelRequest
/**
* This method is based on menu_execute_active_handler() which is called
* in Drupal 7's front controller (index.php).
*
* @param GetResponseEvent $event
*
* @throws AccessDeniedException if the Drupal route is prohibited for
* logged in user.
*
* @see menu_execute_active_handler() for analogous function.
*/
public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
if ($this->matcher->matches($request)) {
$router_item = menu_get_item();
$request->attributes->set('_router_item', $router_item);
}
}
示例5: iit_humanscience_preprocess_page
/**
* Override or insert variables for the page templates.
*/
function iit_humanscience_preprocess_page(&$vars)
{
$page = menu_get_item();
if ($page['path'] == 'home') {
//dpm($vars);
drupal_add_js(drupal_get_path('theme', 'iit_humanscience') . '/scripts/home.js', array('type' => 'file', 'group' => JS_THEME, 'every_page' => FALSE));
drupal_add_css(drupal_get_path('theme', 'iit_humanscience') . '/css/home.css', array('type' => 'file', 'group' => CSS_THEME, 'every_page' => FALSE));
}
}
示例6: futurium_isa_theme_preprocess_page
function futurium_isa_theme_preprocess_page(&$variables) {
$item = menu_get_item();
if (isset($_GET['period'])) {
if ($_GET['q'] == 'analytics') {
$period = str_replace('1_', ' ', $_GET['period']);
$period = str_replace('_', ' ', $period);
$title = drupal_get_title();
$title .= ' - Last ' . $period;
drupal_set_title($title);
}
}
if (!user_is_logged_in()) {
unset($variables['tabs']);
}
unset($variables['navbar_classes_array'][1]);
$variables['navbar_classes_array'][] = 'container-fullwidth';
if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {
$variables['content_column_class'] = ' class="col-sm-6"';
}
elseif (!empty($variables['page']['sidebar_first']) || !empty($variables['page']['sidebar_second'])) {
$variables['content_column_class'] = ' class="col-sm-9"';
}
else {
$variables['content_column_class'] = ' class="container-fullwidth"';
}
$search_form = drupal_get_form('search_form');
$search_box = drupal_render($search_form);
$variables['search_box'] = $search_box;
$panels_callbacks = array(
'page_manager_page_execute',
'page_manager_node_view_page',
'page_manager_user_view_page',
'page_manager_user_edit_page',
'page_manager_node_add',
'page_manager_node_edit',
'page_manager_term_view_page',
'entity_translation_edit_page',
'user_pages_user_users',
'user_pages_user_user_login',
'user_pages_user_user_register',
'user_pages_user_user_password',
);
$variables['content_wrapper'] = !in_array($item['page_callback'], $panels_callbacks, TRUE);
$variables['show_title'] = $variables['content_wrapper'];
}
示例7: generate
/**
* {@inheritDocs}
*/
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
{
$options = array('absolute' => $referenceType === self::ABSOLUTE_URL ? true : false);
$path = drupal_get_normal_path($name);
if ($item = menu_get_item($path)) {
return url($name, $options);
}
throw new RouteNotFoundException();
}
示例8: checkAccess
/**
* Check if the current logged-in user has access to a path.
*/
public function checkAccess($path, $langCode)
{
// Extra handling for front-page.
if (empty($path)) {
if (\Drupal::moduleHandler()->moduleExists('i18n_variable')) {
$path = \i18n_variable_get('site_frontpage', $langCode, $path);
} else {
$path = \variable_get('site_frontpage', $path);
}
}
return ($router_item = \menu_get_item($path)) && $router_item['access'];
}
示例9: moon_preprocess_html
/**
* Push the data about current page into JavaScript.
*
* @group: ActiveItem
*/
function moon_preprocess_html(&$variables)
{
$page = menu_get_item();
if (!empty($page['path'])) {
switch ($page['path']) {
// Taxonomy term pages.
case 'taxonomy/term/%':
if (isset($page['page_arguments'][0]->vocabulary_machine_name)) {
$term = $page['page_arguments'][0];
// Photo taxonomy term detected.
if ($term->vocabulary_machine_name == 'photo_type') {
_moon_add_menu_data_js('photo');
return;
}
// Video taxonomy term detected.
if ($term->vocabulary_machine_name == 'video_type') {
_moon_add_menu_data_js('video');
return;
}
// Photo taxonomy term detected.
if ($term->vocabulary_machine_name == 'author') {
$author = 'main';
if ($term->tid != MAIN_AUTHOR_TID) {
$author = 'special';
drupal_add_js(array('pageAuthor' => array('which' => $author, 'authorName' => $term->name, 'authorURL' => url('taxonomy/term/' . $term->tid, ['absolute' => TRUE]))), array('type' => 'setting'));
}
}
}
break;
// About pages(multilingual simulation).
// About pages(multilingual simulation).
case 'about':
_moon_add_menu_data_js('about');
break;
// Panel Node page.
// Panel Node page.
case 'node/%':
if (!empty($page['page_arguments'][0])) {
$node = $page['page_arguments'][0];
if ($node->type == 'photo') {
$author = 'main';
if (!empty($node->field_author[LANGUAGE_NONE][0]['tid']) && $node->field_author[LANGUAGE_NONE][0]['tid'] != MAIN_AUTHOR_TID) {
$author = 'special';
$tid = $node->field_author[LANGUAGE_NONE][0]['tid'];
$term = taxonomy_term_load($tid);
drupal_add_js(array('pageAuthor' => array('which' => $author, 'authorName' => $term->name, 'authorURL' => url('taxonomy/term/' . $term->tid, ['absolute' => TRUE]))), array('type' => 'setting'));
}
}
}
break;
}
}
}
示例10: check_link_access
/**
* Determines the first accessible internal path
*
* @param array|string $path
* The internal path or paths, such as "node/34".
*
* N.B. All links are assumed to be internal
* @return string|bool
* The first path found to be accessible, or FALSE if none are found.
*/
function check_link_access($path)
{
// standardise type
$paths = (array) $path;
foreach ($paths as $p) {
$router_item = menu_get_item($p == '' || $p == '<front>' ? variable_get('site_frontpage', 'node') : $p);
if ($router_item['access']) {
return $p;
}
}
return FALSE;
}
示例11: ginkgo_preprocess_page
/**
* Preprocessor for theme_page().
*/
function ginkgo_preprocess_page(&$vars)
{
// Add icon markup to main menu
ginkgo_icon_links($vars['primary_links']);
// If tabs are active, the title is likely shown in them. Don't show twice.
$vars['title'] = !empty($vars['tabs']) ? '' : $vars['title'];
// Respect anything people are requesting through context.
if (module_exists('context')) {
$vars['custom_layout'] = context_get('theme', 'layout') == 'custom' ? TRUE : FALSE;
$vars['attr']['class'] .= context_isset('theme', 'body_classes') ? " " . context_get('theme', 'body_classes') : '';
}
// Add a smarter body class than "not logged in" for determining whether
// we are on a login/password/user registration related page.
global $user;
$vars['mission'] = '';
if (!$user->uid && arg(0) == 'user') {
$vars['attr']['class'] .= ' anonymous-login';
$vars['mission'] = filter_xss_admin(variable_get('site_mission', ''));
}
// Theme specific settings
$settings = theme_get_settings('ginkgo');
// Show site title/emblem ?
$vars['site_name'] = isset($settings['emblem']) && !$settings['emblem'] ? '' : $vars['site_name'];
// Footer links
$vars['footer_links'] = isset($vars['footer_links']) ? $vars['footer_links'] : array();
$item = menu_get_item('admin');
if ($item && $item['access']) {
$vars['footer_links']['admin'] = $item;
}
// IE7 CSS
// @TODO: Implement IE styles key in tao.
$ie = base_path() . path_to_theme() . '/ie.css';
$vars['ie'] = "<!--[if lte IE 8]><style type='text/css' media='screen'>@import '{$ie}';</style><![endif]-->";
// Add spaces design CSS back in
if (!isset($_GET['print'])) {
if (empty($vars['spaces_design_styles'])) {
global $theme_info;
$space = spaces_get_space();
// Retrieve default colors from info file
if (isset($theme_info->info["spaces_design_{$space->type}"])) {
$default = $theme_info->info["spaces_design_{$space->type}"];
} else {
$default = '#3399aa';
}
$color = !empty($settings["color_{$space->type}"]) ? $settings["color_{$space->type}"] : $default;
$vars['styles'] .= theme('spaces_design', $color);
$vars['attr']['class'] .= ' spaces-design';
} else {
$vars['styles'] .= $vars['spaces_design_styles'];
}
}
}
示例12: connect
/**
* Returns routes to connect to the given application.
*
* @param Application $app An Application instance
*
* @throws \LogicException
* @return ControllerCollection A ControllerCollection instance
*/
public function connect(Application $app)
{
/** @var ControllerCollection $controllers */
$controllers = $app['controllers_factory'];
// Drupal front controller.
$controllers->match('/{q}', 'drupal.controller:deliverAction')->assert('q', '[^_].+$')->value('_legacy', 'drupal')->convert('q', function ($q) {
return drupal_get_normal_path($q);
})->convert('router_item', function ($router_item = array(), Request $request) {
$q = $request->get('q');
return menu_get_item($q);
});
return $controllers;
}
示例13: bootstrap_preprocess_breadcrumb
/**
* Implements hook_preprocess_breadcrumb().
*/
function bootstrap_preprocess_breadcrumb(&$variables)
{
$breadcrumb =& $variables['breadcrumb'];
// Optionally get rid of the homepage link.
$show_breadcrumb_home = theme_get_setting('bootstrap_breadcrumb_home');
if (!$show_breadcrumb_home) {
array_shift($breadcrumb);
}
if (theme_get_setting('bootstrap_breadcrumb_title') && !empty($breadcrumb)) {
$item = menu_get_item();
$breadcrumb[] = array('data' => !empty($item['tab_parent']) ? check_plain($item['title']) : drupal_get_title(), 'class' => array('active'));
}
}
示例14: buildForm
/**
* {@inheritdoc}
*/
public function buildForm()
{
global $user;
$output = array();
// Show which users can access this node.
$menu_item = menu_get_item();
$map = $menu_item['original_map'];
if ($map[0] != 'node' || !isset($map[1]) || !is_numeric($map[1]) || isset($map[2])) {
// Ignore anything but node/%.
return NULL;
}
if (isset($menu_item['map'][1]) && is_object($node = $menu_item['map'][1])) {
// We have the node.
} elseif (is_numeric($menu_item['original_map'][1])) {
$node = node_load($menu_item['original_map'][1]);
}
if (isset($node)) {
$nid = $node->id();
$langcode = $node->langcode->value;
$language = language_load($langcode);
$node_type = node_type_load($node->bundle());
$headers = array(t('username'), '<span title="' . t("Create '@langname'-language nodes of the '@Node_type' type.", array('@langname' => $language->name, '@Node_type' => $node_type->name)) . '">' . t('create') . '</span>', t('view'), t('update'), t('delete'));
$rows = array();
// Determine whether to use Ajax or pre-populate the tables.
if ($ajax = \Drupal::config('devel_node_access.settings')->get('user_ajax')) {
$output['#attached']['library'][] = 'devel_node_access/node_access';
}
// Find all users. The following operations are very inefficient, so we
// limit the number of users returned. It would be better to make a
// pager query, or at least make the number of users configurable. If
// anyone is up for that please submit a patch.
$query = db_select('users', 'u')->fields('u', array('uid'))->orderBy('u.access', 'DESC')->range(0, 9);
$uids = $query->execute()->fetchCol();
array_unshift($uids, 0);
$accounts = user_load_multiple($uids);
foreach ($accounts as $account) {
$username = theme('username', array('account' => $account));
$uid = $account->id();
if ($uid == $user->id()) {
$username = '<strong>' . $username . '</strong>';
}
$rows[] = array($username, array('id' => 'create-' . $nid . '-' . $uid, 'class' => 'dna-permission', 'data' => $ajax ? NULL : theme('dna_permission', array('permission' => self::explain_access('create', $node, $account, $langcode)))), array('id' => 'view-' . $nid . '-' . $uid, 'class' => 'dna-permission', 'data' => $ajax ? NULL : theme('dna_permission', array('permission' => self::explain_access('view', $node, $account, $langcode)))), array('id' => 'update-' . $nid . '-' . $uid, 'class' => 'dna-permission', 'data' => $ajax ? NULL : theme('dna_permission', array('permission' => self::explain_access('update', $node, $account, $langcode)))), array('id' => 'delete-' . $nid . '-' . $uid, 'class' => 'dna-permission', 'data' => $ajax ? NULL : theme('dna_permission', array('permission' => self::explain_access('delete', $node, $account, $langcode)))));
}
if (count($rows)) {
$output['title'] = array('#prefix' => '<h2>', '#markup' => t('Access permissions by user for the %langname language', array('%langname' => $language->name)), '#postfix' => '</h2>');
$output[] = array('#theme' => 'table', '#header' => $headers, '#rows' => $rows, '#attributes' => array('style' => 'text-align: left'));
$output[] = array('#theme' => 'form_element', '#description' => t('(This table lists the most-recently active users. Hover your mouse over each result for more details.)'));
}
}
return $output;
}
示例15: gitp_preprocess_breadcrumb
function gitp_preprocess_breadcrumb(&$variables)
{
if ($current = menu_get_item()) {
if (!empty($current['title'])) {
$title = $current['title'];
} else {
if (!empty($current['page_arguments'][0])) {
$title = $current['page_arguments'][0]->name;
} else {
$title = '';
}
}
}
$variables['breadcrumb'][] = $title;
}