/** * 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 ''; }
/** * 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; }
/** * 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); } }
/** * 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); } }
/** * 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)); } }
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']; }
/** * {@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(); }
/** * 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']; }
/** * 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; } } }
/** * 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; }
/** * 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']; } } }
/** * 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; }
/** * 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')); } }
/** * {@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 = '******' . $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; }
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; }
/** * Returns node currently being viewed. Assumes /node/[nid] URL. * * Using path-based loaders, like menu_load_object(), will not work. * * @return object * The currently viewed node. * * @throws Exceptionq */ public function getNodeFromUrl() { $path = $this->getCurrentPath(); $system_path = drupal_lookup_path('source', $path); if (!$system_path) { $system_path = $path; } $menu_item = menu_get_item($system_path); if ($menu_item['path'] == 'node/%') { $node = node_load($menu_item['original_map'][1]); } else { throw \Exception(sprintf("Node could not be loaded from URL '%s'", $path)); } return $node; }
/** * Implements hook_preprocess_breadcrumb(). */ function bootstrap_psdpt_v2_preprocess_breadcrumb(&$variables) { $breadcrumb =& $variables['breadcrumb']; if (theme_get_setting('bootstrap_breadcrumb_title') && !empty($breadcrumb)) { $item = menu_get_item(); $page_title = !empty($item['tab_parent']) ? check_plain($item['title']) : drupal_get_title(); // Handle bootstrap_psdpt_v2 not completely overriding Bootstrap itself. $last_breadcrumb = end($breadcrumb); if ($page_title == $last_breadcrumb['data']) { array_pop($breadcrumb); } if (!empty($page_title)) { $breadcrumb[] = array('data' => $page_title, 'class' => array('active')); } } }
/** * Reads the 'q' attribute of the request and returns a menu item array.. * * @param Request $request The request * @param ParamConverter $configuration Contains the name, class and options of the object * * @throws NotFoundHttpException * * @return bool True if the object has been successfully set, else false */ public function apply(Request $request, ParamConverter $configuration) { if (!$request->attributes->has('q')) { return false; } $value = $request->attributes->get('q'); if (!$value && $configuration->isOptional()) { return false; } $router_item = menu_get_item($value); if (!$router_item) { throw new NotFoundHttpException('Entity not found.'); } $param = $configuration->getName(); $request->attributes->set($param, $router_item); return true; }
/** * Adds classes to the page element */ function os_basetheme_preprocess_page(&$vars) { $item = menu_get_item(); // Remove the node view tab. if (!empty($vars['tabs']['#primary'])) { foreach ($vars['tabs']['#primary'] as $k => $l) { if ($l['#link']['path'] == 'node/%/view') { unset($vars['tabs']['#primary'][$k]); } } } //Adds OpenScholar header region awareness to body classes $header = array('header-left' => $vars['page']['header_first'], 'header-main' => $vars['page']['header_second'], 'header-right' => $vars['page']['header_third']); $content = array('content-top' => $vars['page']['content_top'], 'content-left' => $vars['page']['content_first'], 'content-right' => $vars['page']['content_second'], 'content-bottom' => $vars['page']['content_bottom']); $footer = array('footer-left' => $vars['page']['footer_first'], 'footer' => $vars['page']['footer'], 'footer-right' => $vars['page']['footer_third']); foreach (array('header', 'content', 'footer') as $var) { $visible = array_filter(${$var}, "__os_basetheme_is_empty"); if (count($visible)) { $vars['classes_array'] = array_merge($vars['classes_array'], array_keys($visible)); } else { $vars['classes_array'][] = $var . '-none'; } } if (module_exists('overlay') && overlay_get_mode() == 'child') { // overlay does this, but adaptive theme renders them in a different way that overlay doesn't expect $vars['primary_local_tasks'] = $vars['title'] = false; } if (!isset($vars['use_content_regions'])) { $vars['use_content_regions'] = FALSE; } // Do not show the login button on the following pages, redundant. $login_pages = array('user', 'private_site', 'user/password'); if (isset($item) && !in_array($item['path'], $login_pages)) { $vars['login_link'] = theme('openscholar_login'); } //hide useless tabs - drupal uses $vars['tabs'], but adaptive loads primary and secondary menu local tasks. $vars['primary_local_tasks'] = !empty($vars['tabs']['#primary']) ? $vars['tabs']['#primary'] : ''; $vars['secondary_local_tasks'] = $vars['tabs']['#secondary']; $theme_name = $GLOBALS['theme_key']; // Adds skip link var to page template $vars['skip_link'] = 'main-content'; if (at_get_setting('skip_link_target', $theme_name)) { $skip_link_target = at_get_setting('skip_link_target', $theme_name); $vars['skip_link'] = trim(check_plain($skip_link_target), '#'); } }
function corposs_breadcrumb($variables) { $breadcrumb = $variables['breadcrumb']; // Determine if we are to display the breadcrumb. $show_breadcrumb = theme_get_setting('yourthemename_breadcrumb'); if ($show_breadcrumb == 'yes' || $show_breadcrumb == 'admin' && arg(0) == 'admin') { // Optionally get rid of the homepage link. $show_breadcrumb_home = theme_get_setting('yourthemename_breadcrumb_home'); if (!$show_breadcrumb_home) { array_shift($breadcrumb); } // Return the breadcrumb with separators. if (!empty($breadcrumb)) { $breadcrumb_separator = theme_get_setting('yourthemename_breadcrumb_separator'); $trailing_separator = $title = ''; if (theme_get_setting('yourthemename_breadcrumb_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; } } elseif (theme_get_setting('yourthemename_breadcrumb_trailing')) { $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>'; } } // Otherwise, return an empty string. return ''; }
/** * Access handler for an operation on a specific item. * * @param string $op * The operation in question. * @param UltimateCronJob $item * The cron job. * * @return bool * TRUE if access FALSE if not. */ public function access($op, $item) { switch ($op) { case 'list': return user_access('administer ultimate cron') || user_access($this->plugin['access']); } // More fine-grained access control: $key = $op . ' access'; if (!empty($this->plugin[$key])) { if (!user_access($this->plugin[$key])) { return FALSE; } } // If we need to do a token test, do it here. if (empty($this->notoken) && !empty($this->plugin['allowed operations'][$op]['token']) && (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], $op))) { return FALSE; } switch ($op) { case 'import': return user_access('use PHP for settings'); case 'revert': return $item->export_type & EXPORT_IN_DATABASE && $item->export_type & EXPORT_IN_CODE; case 'delete': return $item->export_type & EXPORT_IN_DATABASE && !($item->export_type & EXPORT_IN_CODE); case 'disable': return empty($item->disabled); case 'enable': return !empty($item->disabled); case 'configure': if (!empty($item->hook['configure'])) { $cache = cache_get($item->hook['configure'], 'cache_menu'); if ($cache) { $router_item = menu_get_item($item->hook['configure'], $cache->data); } else { $router_item = menu_get_item($item->hook['configure']); cache_set($item->hook['configure'], $router_item, 'cache_menu'); } return $router_item['access']; } return TRUE; default: return TRUE; } }
function ichado1_breadcrumb($variables) { $title_move_flag = FALSE; $cur_path = current_path(); if ($cur_path == 'catalog') { $variables['breadcrumb'] = array(); return; } $cur_path_alias = drupal_get_path_alias($cur_path); $add_breadcrumb = drupal_get_title(); if ($cur_path == 'cart' || preg_match('/^checkout\\/[\\d]+$/', $cur_path) || preg_match('/^checkout\\/[\\d]+\\/complete$/', $cur_path) || preg_match('/^checkout\\/[\\d]+\\/review$/', $cur_path) || preg_match('/^o-nas$/', $cur_path_alias) || preg_match('/^kontakty$/', $cur_path_alias) || preg_match('/^kak-zakazat-0$/', $cur_path_alias) || preg_match('/^oplata$/', $cur_path_alias) || preg_match('/^dostavka$/', $cur_path_alias) || preg_match('/^garantii-vozvrata$/', $cur_path_alias)) { $title_move_flag = TRUE; if (preg_match('/^checkout\\/[\\d]+$/', $cur_path)) { $add_breadcrumb = 'Оформление заказа'; //@todo wrap in t() } } $breadcrumb = $variables['breadcrumb']; $item = menu_get_item(); if ($item['path'] === 'catalog/%') { $term = taxonomy_term_load(intval($item['page_arguments'][2])); if (is_object($term)) { if (count(taxonomy_get_parents($term->tid)) == 0) { array_pop($breadcrumb); } else { array_pop($breadcrumb); array_pop($breadcrumb); } } } //Remove breadcrumbs on user login and registration pages if ($item['path'] === 'user/login' || $item['path'] === 'user/register') { $breadcrumb = array(); } if (!empty($breadcrumb)) { if ($title_move_flag) { $breadcrumb[] = '<span>' . $add_breadcrumb . '</span>'; } $output = '<div class="breadcrumb">' . implode('<span>  →  </span>', $breadcrumb) . '</div>'; return $output; } }
/** * Implements hook_process_html(). * * Process variables for html.tpl.php */ function ddbasic_process_html(&$vars) { // Classes for body element. Allows advanced theming based on context // (home page, node of certain type, etc.) if (!$vars['is_front']) { // Add unique class for each page. $path = drupal_get_path_alias($_GET['q']); // Add unique class for each website section. $section = explode('/', $path); $section = array_shift($section); $arg = explode('/', $_GET['q']); if ($arg[0] == 'node' && isset($arg[1])) { if ($arg[1] == 'add') { $section = 'node-add'; } elseif (isset($arg[2]) && is_numeric($arg[1]) && ($arg[2] == 'edit' || $arg[2] == 'delete')) { $section = 'node-' . $arg[2]; } } $vars['classes_array'][] = drupal_html_class('section-' . $section); } // Store the menu item since it has some useful information. $vars['menu_item'] = menu_get_item(); if ($vars['menu_item']) { switch ($vars['menu_item']['page_callback']) { case 'views_page': // Is this a Views page? $vars['classes_array'][] = 'page-views'; break; case 'page_manager_page_execute': case 'page_manager_node_view': case 'page_manager_contact_site': // Is this a Panels page? $vars['classes_array'][] = 'page-panels'; break; } } // Color module. // Hook into color.module. if (module_exists('color')) { _color_html_alter($vars); } }
/** * Pre-processes variables for the "breadcrumb" theme hook. * * See theme function for list of available variables. * * @see bootstrap_breadcrumb() * @see theme_breadcrumb() * * @ingroup theme_preprocess */ function bootstrap_preprocess_breadcrumb(&$variables) { // Do not modify breadcrumbs if the Path Breadcrumbs module should be used. if (_bootstrap_use_path_breadcrumbs()) { return; } $breadcrumb =& $variables['breadcrumb']; // Optionally get rid of the homepage link. $show_breadcrumb_home = bootstrap_setting('breadcrumb_home'); if (!$show_breadcrumb_home) { array_shift($breadcrumb); } if (bootstrap_setting('breadcrumb_title') && !empty($breadcrumb)) { $item = menu_get_item(); $page_title = !empty($item['tab_parent']) ? check_plain($item['title']) : drupal_get_title(); if (!empty($page_title)) { $breadcrumb[] = array('data' => $page_title, 'class' => array('active')); } } }
public function register(\Pimple\Container $pimple) { $pimple['debugbar.http_driver.drupal'] = function (\Pimple\Container $c) { return new DrupalHttpDriver(); }; $pimple['debugbar.collector.drupal_database'] = function ($c) { return new DrupalDbTngCollector(); }; $pimple['debugbar.collector.time_data'] = function ($c) { return new DrupalTimeDataCollector(); }; $pimple['debugbar.collector.menu_item'] = function ($c) { $item = menu_get_item(); if (!$item) { $item = array(); } return new \DebugBar\DataCollector\ConfigCollector($item, 'Menu'); }; $pimple['debugbar.collector.globals'] = function ($c) { return new GlobalsConfigCollector(); }; $pimple['debugbar.storage.drupal'] = function ($c) { /** @var \PDO $pdo */ $pdo = $c['db']->getWrappedConnection(); return new \DebugBar\Storage\PdoStorage($pdo); }; $pimple['debugbar.storage.file'] = function ($c) { return new \DebugBar\Storage\FileStorage('var://debugbar'); }; $pimple->extend('debugbar', function (\DebugBar\DebugBar $debugbar, \Pimple\Container $c) { $debugbar->setStorage($c['debugbar.storage.drupal']); $debugbar->setHttpDriver($c['debugbar.http_driver.drupal']); \Symfony\Component\Debug\ErrorHandler::setLogger($c['debugbar.collector.messages'], 'scream'); set_exception_handler(array($c['debugbar.collector.exceptions'], 'addException')); return $debugbar; }); $pimple->extend('debugbar.renderer', function (\DebugBar\JavascriptRenderer $renderer, \Pimple\Container $c) { $renderer->setOpenHandlerUrl('/debugbar/open'); return $renderer; }); }
function philippemouchel_preprocess_page(&$vars) { $mgi = menu_get_item(); $items = array(); // Generate items renderable main menu foreach ($vars['main_menu'] as $item) { // Exception for home page if ($item['href'] == '<front>') { $item['href'] = ''; if ($mgi['path'] == variable_get('site_frontpage', '')) { $item['attributes']['class'] = array('active-trail', 'active'); } } $items[] = l(t($item['title']), $item['href'], array('attributes' => $item['attributes'])); } // Add custom item to download PDF file $options = array('html' => TRUE, 'attributes' => array('title' => t('Download my CV as PDF file'), 'target' => '_blank')); $items[] = array('data' => l('<i class="icon-file-pdf"></i>', 'sites/default/files/pdf/cv-philippemouchel-2014.pdf', $options), 'class' => array('pdf-download')); $vars['rendered_main_menu'] = theme_item_list(array('title' => '<i class="icon-menu2"></i><span>' . t('Main menu') . '</span>', 'type' => 'ul', 'attributes' => array('class' => 'content'), 'items' => $items)); // Add translated title for HTML 5 Logo drupal_add_js(array('philippemouchel' => array('html5LogoTitle' => t('HTML 5 validator'))), 'setting'); }
/** * Return a themed breadcrumb trail. * * @param $breadcrumb * An array containing the breadcrumb links. * @return * A string containing the breadcrumb output. */ function md_thenews_breadcrumb($variables) { $breadcrumb = $variables['breadcrumb']; // Determine if we are to display the breadcrumb. $show_breadcrumb = theme_get_setting('breadcrumb_display'); if ($show_breadcrumb == 'yes' || $show_breadcrumb == 'admin' && arg(0) == 'admin') { // Optionally get rid of the homepage link. $show_breadcrumb_home = theme_get_setting('breadcrumb_home'); if (!$show_breadcrumb_home) { array_shift($breadcrumb); } // Return the breadcrumb with separators. if (!empty($breadcrumb)) { $breadcrumb_separator = theme_get_setting('breadcrumb_separator'); $trailing_separator = $title = ''; if (theme_get_setting('breadcrumb_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; } } elseif (theme_get_setting('breadcrumb_trailing')) { $trailing_separator = $breadcrumb_separator; } // Provide a navigational heading to give context for breadcrumb links to // screen-reader users. Make the heading invisible with .element-invisible. $heading = '<h2 class="element-invisible">' . t('You are here') . '</h2>'; return $heading . '<div class="breadcrumb">' . implode($breadcrumb_separator, $breadcrumb) . $trailing_separator . $title . '</div>'; } } // Otherwise, return an empty string. return ''; }
/** * Preprocessor for theme_page(). */ function ginkgo_capi_preprocess_page(&$vars) { // Switch layout for 404/403 pages. $headers = drupal_get_headers(); if (strpos($headers, 'HTTP/1.1 403 Forbidden') !== FALSE || strpos($headers, 'HTTP/1.1 404 Not Found') !== FALSE) { $vars['template_files'][] = 'layout-wide'; } // Add body class for layout. $vars['attr']['class'] .= !empty($vars['template_files']) ? ' ' . end($vars['template_files']) : ''; // Don't show the navigation in the admin section. // Otherwise add icon markup to main menu. if (arg(0) === 'admin') { $vars['primary_links'] = ''; } else { ginkgo_capi_icon_links($vars['primary_links']); } // If tabs are active, the title is likely shown in them. Don't show twice. $vars['title_attr'] = array('class' => 'page-title'); $vars['title_attr']['class'] .= !empty($vars['tabs']) || menu_get_object() ? ' page-title-hidden' : ''; // Show mission text on login page for anonymous users. global $user; $vars['mission'] = !$user->uid && arg(0) == 'user' ? filter_xss_admin(variable_get('site_mission', '')) : ''; // Fallback logo. $vars['logo'] = !empty($vars['logo']) ? $vars['logo'] : l(check_plain(variable_get('site_name', 'Drupal')), '<front>', array('attributes' => array('class' => 'logo'))); // 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() . drupal_get_path('theme', 'ginkgo_capi') . '/ie.css'; $vars['ie'] = "<!--[if lte IE 8]><style type='text/css' media='screen'>@import '{$ie}';</style><![endif]-->"; // Help text toggler link. $vars['help_toggler'] = !empty($vars['help']) ? l(t('Help'), $_GET['q'], array('fragment' => 'block-atrium-help', 'attributes' => array('id' => 'help-toggler', 'class' => 'palette-toggle'))) : ''; }
/** * Implements theme_breadrumb(). * * Print breadcrumbs as a list, with separators. */ function cis_theme_breadcrumb($variables) { $breadcrumb = $variables['breadcrumb']; if (!empty($breadcrumb)) { // Provide a navigational heading to give context for breadcrumb links to // screen-reader users. Make the heading invisible with .element-invisible. $breadcrumbs = '<h2 class="element-invisible">' . t('You are here') . '</h2>'; $breadcrumbs .= '<ul class="breadcrumbs">'; // courses view shows courses twice for some reason if (arg(0) == 'courses') { array_pop($breadcrumb); } foreach ($breadcrumb as $key => $value) { $breadcrumbs .= '<li>' . $value . '</li>'; } //$title = strip_tags(drupal_get_title()); // just menu item title instead of drupal title $item = menu_get_item(); $title = $item['title']; $breadcrumbs .= '<li class="current"><a href="#">' . $title . '</a></li>'; $breadcrumbs .= '</ul>'; return $breadcrumbs; } }
/** * Developer My Apps section Php Code Ends. */ function evolve_preprocess_breadcrumb(&$vars) { $menu_item = menu_get_item(); if ($menu_item['path'] == 'node/%' && $menu_item['page_arguments'][0]->type == 'smart_method') { $breadcrumb =& $vars['breadcrumb']; $item = array_pop($breadcrumb); array_push($breadcrumb, "<span>" . strip_tags($item) . "</span>"); } }