/** * Override or insert variables into the page template. */ function rice_preprocess_page(&$vars) { // CSS drupal_add_css(drupal_get_path('theme', 'rice') . '/css/colors.css'); drupal_add_css(drupal_get_path('theme', 'rice') . '/css/columnal.css'); drupal_add_css(drupal_get_path('theme', 'rice') . '/css/custom.css'); drupal_add_css(drupal_get_path('theme', 'rice') . '/css/feed.css'); drupal_add_css(drupal_get_path('theme', 'rice') . '/js/owl-carousel/owl.carousel.css'); drupal_add_css(drupal_get_path('theme', 'rice') . '/js/owl-carousel/owl.transitions.css'); drupal_add_css(drupal_get_path('theme', 'rice') . '/js/owl-carousel/owl.theme.css'); drupal_add_css('https://fonts.googleapis.com/css?family=Cinzel'); // JS drupal_add_js(drupal_get_path('theme', 'rice') . '/js/jquery-1.8.0.min.js'); drupal_add_js(drupal_get_path('theme', 'rice') . '/js/modernizr.js'); drupal_add_js(drupal_get_path('theme', 'rice') . '/js/moment-with-locales.js'); drupal_add_js(drupal_get_path('theme', 'rice') . '/js/tools.js'); drupal_add_js(drupal_get_path('theme', 'rice') . '/js/owl-carousel/owl.carousel.js'); // Condition: Path $match = "<front>"; $path = drupal_get_path_alias($_GET['q']); $path_matches = drupal_match_path($path, $match); if ($path != $_GET['q']) { $path_matches = $path_matches || drupal_match_path($_GET['q'], $matches); } if ($path_matches) { //drupal_add_css(drupal_get_path('theme', 'rice').'/css/style.css'); } //Condition: Role $role = 'anonymous user'; if (in_array($role, $vars['user']->roles)) { //drupal_add_css(drupal_get_path('theme', 'rice').'/anonymous.css'); } }
/** * Allows to override activation of Colobox for the current URL. * * @param $active * A boolean indicating whether colorbox should be active for the current * URL or not. */ function hook_colorbox_active_alter(&$active) { $path = drupal_get_path_alias($_GET['q']); if (drupal_match_path($path, 'admin/config/colorbox_test')) { // Enable colorbox for this URL. $active = TRUE; } }
/** * Implementation of hook_page_alter() */ function andromeda_page_alter(&$page) { //match pages and unset sidebar on matched pages $pages = drupal_strtolower(theme_get_setting('andromeda_sidebar_visibility')); $path = drupal_strtolower(drupal_get_path_alias($_GET['q'])); if (drupal_match_path($path, $pages)) { unset($page['sidebar']); } }
/** * Control protected paths for node edit forms. * * The hook is typically implemented to check if a path should be protected for * CSRF attacks on the node edit forms. * * @param string $path * The path to check protection for. * * @return bool * TRUE is the path should be protected. * Note: this grant is permissive rather than restrictive. * * @see hook_field_access() */ function hook_content_lock_path_protected($path) { if (strpos($path, 'node/') === 0) { $paths_patterns = array('node/*/edit', 'node/*/revisions/*/revert'); foreach ($paths_patterns as $protected_pattern) { if (drupal_match_path($path, $protected_pattern)) { return TRUE; } } } }
public function match($path) { $record_path = $this->record['path']; $record_type = $this->record['type']; switch ($record_type) { case 'wildcard': return drupal_match_path($path, $record_path); case 'regex': $regex_result = preg_match_all('^' . $record_path . '^', $path); return !($regex_result === 0 || $regex_result === false); } return false; }
/** * Implement hook_js_alter() * Attempt to replace the system jQuery on non admin and non node admin pages with a newer version provided by the theme */ function govdexsupport_js_alter(&$javascript) { $node_admin_paths = array('node/*/edit', 'node/add', 'node/add/*', 'node/*/extend_review_date'); $replace_jquery = TRUE; if (path_is_admin(current_path())) { $replace_jquery = FALSE; } else { foreach ($node_admin_paths as $node_admin_path) { if (drupal_match_path(current_path(), $node_admin_path)) { $replace_jquery = FALSE; } } } // Swap out jQuery to use an updated version of the library. if ($replace_jquery) { $javascript['misc/jquery.js']['data'] = '//code.jquery.com/jquery-2.1.4.min.js'; } }
/** * Strips CSS files from a Drupal CSS array whose filenames start with * prefixes provided in the $match argument. */ function tao_css_stripped($match = array('modules/*'), $exceptions = NULL) { // Set default exceptions if (!is_array($exceptions)) { $exceptions = array('modules/system/system.css', 'modules/update/update.css', 'modules/openid/openid.css', 'modules/acquia/*'); } $css = drupal_add_css(); $match = implode("\n", $match); $exceptions = implode("\n", $exceptions); foreach (array_keys($css['all']['module']) as $filename) { if (drupal_match_path($filename, $match) && !drupal_match_path($filename, $exceptions)) { unset($css['all']['module'][$filename]); } } // This servers to move the "all" CSS key to the front of the stack. // Mainly useful because modules register their CSS as 'all', while // Tao has a more media handling. ksort($css); return $css; }
/** * Returns the name of the layout class associated with the current path. The * layout name is used as a body class, which causes the page to be styled * with the corresponding layout. This function makes it possible to use * different layouts on various pages of a site. * * @return <string> * The name of the layout associated with the current page. */ function _carbon_get_layout() { $layout_patterns = _carbon_variable_get('layout', array('<global>' => 'body-layout-fixed-abc')); $global_layout = $layout_patterns['<global>']; unset($layout_patterns['<global>']); $alias_path = drupal_get_path_alias($_GET['q']); $path = $_GET['q']; foreach ($layout_patterns as $pattern => $layout) { if (drupal_match_path($alias_path, $pattern) || drupal_match_path($path, $pattern)) { return $layout; } } return $global_layout; }
public function get_available_sorts() { $sorts = array(); /* foreach( $this->available_sorts as $key => $sort ) { if( $sort['status'] ) { $sorts[$key]['title'] = $sort['title']; $sorts[$key]['default'] = $sort['default']; } } */ $default_sorts = $this->default_sorts(); foreach ($default_sorts as $sort_name => $sort) { // get the settings for this page $visibility_type = $sort->visibility['type']; $visibility_pages = $sort->visibility['pages']; if ($visibility_type < 2) { $path = drupal_get_path_alias($_GET['q']); // Compare with the internal and path alias (if any). $page_match = drupal_match_path($path, $visibility_pages); if ($path != $_GET['q']) { $page_match = $page_match || drupal_match_path($_GET['q'], $visibility_pages); } // When $block->visibility has a value of 0, the block is displayed on // all pages except those listed in $block->pages. When set to 1, it // is displayed only on those pages listed in $block->pages. $page_match = !($visibility_type xor $page_match); if ($page_match) { foreach ($sort->fields as $key => $value) { $sorts[$key]['title'] = $value['display_value']; $sorts[$key]['default'] = $value['sort']; } } } } return $sorts; }
/** * Implements hook_preprocess_page(). * * @see page.tpl.php */ function bootstrap_psdpt_preprocess_page(&$variables) { global $base_url; // Internationalization Settings. global $language; $is_multilingual = 0; if (module_exists('i18n_menu') && drupal_multilingual()) { $is_multilingual = 1; } // WxT Settings. $theme_prefix = 'wb'; $theme_menu_prefix = 'wet-fullhd'; $wxt_active = variable_get('wetkit_wetboew_theme', 'wet-boew'); $library_path = libraries_get_path($wxt_active, TRUE); $wxt_active = str_replace('-', '_', $wxt_active); $wxt_active = str_replace('wet_boew_', '', $wxt_active); // Extra variables to pass to templates. $variables['library_path'] = $library_path; $variables['language'] = $language->language; $variables['language_prefix'] = $language->prefix; $variables['language_prefix_alt'] = $language->prefix == 'en' ? 'fr' : 'fra'; // Site Name. if (!empty($variables['site_name'])) { $variables['site_name_title'] = filter_xss(variable_get('site_name', 'Drupal')); $variables['site_name_unlinked'] = $variables['site_name_title']; $variables['site_name_url'] = url(variable_get('site_frontpage', 'node')); $variables['site_name'] = trim($variables['site_name_title']); } // Logo settings. $default_logo = theme_get_setting('default_logo'); $default_svg_logo = theme_get_setting('wetkit_theme_svg_default_logo'); $default_logo_path = $variables['logo']; $default_svg_logo_path = theme_get_setting('wetkit_theme_svg_logo_path'); $toggle_logo = theme_get_setting('toggle_logo'); $variables['logo_class'] = ''; $variables['logo_svg'] = ''; // Toggle Logo off/on. if ($toggle_logo == 0) { $variables['logo'] = ''; $variables['logo_svg'] = ''; $variables['logo_class'] = drupal_attributes(array('class' => 'no-logo')); } // Default Logo. if ($default_logo == 1) { $variables['logo'] = $library_path . '/assets/logo.png'; $variables['logo_svg'] = $library_path . '/assets/logo.svg'; // GCWeb or GC Intranet. if ($wxt_active == 'gcweb' || $wxt_active == 'gc_intranet') { $variables['logo'] = $library_path . '/assets/sig-blk-' . $language->language . '.png'; $variables['logo_svg'] = $library_path . '/assets/sig-blk-' . $language->language . '.svg'; } elseif ($wxt_active == 'gcwu_fegc') { $variables['logo'] = $library_path . '/assets/sig-' . $language->language . '.png'; $variables['logo_svg'] = $library_path . '/assets/sig-' . $language->language . '.svg'; } } // Custom Logo. if ($default_logo == 0) { if ($default_svg_logo == 1) { $variables['logo_svg'] = $base_url . '/' . $default_svg_logo_path; } } // Default GCWeb misc. if ($wxt_active == 'gcweb') { $variables['logo_bottom'] = $library_path . '/assets/wmms-blk' . '.png'; $variables['logo_bottom_svg'] = $library_path . '/assets/wmms-blk' . '.svg'; } // Add information about the number of sidebars. 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'] = ''; } // Primary menu. $variables['primary_nav'] = FALSE; if ($variables['main_menu']) { // Build links. $variables['primary_nav'] = menu_tree(variable_get('menu_main_links_source', 'main-menu')); // Provide default theme wrapper function. $variables['primary_nav']['#theme_wrappers'] = array('menu_tree__primary'); } // Secondary nav. $variables['secondary_nav'] = FALSE; if ($variables['secondary_menu']) { // Build links. $variables['secondary_nav'] = menu_tree(variable_get('menu_secondary_links_source', 'user-menu')); // Provide default theme wrapper function. $variables['secondary_nav']['#theme_wrappers'] = array('menu_tree__secondary'); } // Navbar. $variables['navbar_classes_array'] = array(''); if (theme_get_setting('bootstrap_navbar_position') !== '') { $variables['navbar_classes_array'][] = 'navbar-' . theme_get_setting('bootstrap_navbar_position'); } else { $variables['navbar_classes_array'][] = ''; } // Mega Menu Region. /* if (module_exists('menu_block') && empty($variables['mega_menu'])) { $menu_name = 'main_menu'; $data = array( '#pre_render' => array('_wetkit_menu_tree_build_prerender'), '#cache' => array( 'keys' => array('bootstrap_psdpt', 'menu', 'mega_menu', $menu_name), 'expire' => CACHE_TEMPORARY, 'granularity' => DRUPAL_CACHE_PER_ROLE ), '#menu_name' => $menu_name, ); $variables['page']['mega_menu'] = $data; }*/ // Splash Page. if (current_path() == 'splashify-splash') { // GCWeb Theme. if ($wxt_active == 'gcweb') { $variables['background'] = $library_path . '/img/splash/sp-bg-2.jpg'; } } // Panels Integration. if (module_exists('page_manager')) { // Page template suggestions for Panels pages. $panel_page = page_manager_get_current_page(); if (!empty($panel_page)) { // Add the active WxT theme machine name to the template suggestions. $suggestions[] = 'page__panels__' . $wxt_active; if (drupal_is_front_page()) { $suggestions[] = 'page__panels__' . $wxt_active . '__front'; } // Add the panel page machine name to the template suggestions. $suggestions[] = 'page__' . $panel_page['name']; // Merge the suggestions in to the existing suggestions // (as more specific than the existing suggestions). $variables['theme_hook_suggestions'] = array_merge($variables['theme_hook_suggestions'], $suggestions); $variables['panels_layout'] = TRUE; } else { $suggestions[] = 'page__' . $wxt_active; // Splash Page. if (current_path() == 'splashify-splash') { $suggestions[] = 'page__splash__' . $wxt_active; } // Merge the suggestions in to the existing suggestions (as more specific // than the existing suggestions). $variables['theme_hook_suggestions'] = array_merge($variables['theme_hook_suggestions'], $suggestions); } } // Header Navigation + Language Switcher. $menu = $is_multilingual ? i18n_menu_navigation_links('menu-wet-header') : menu_navigation_links('menu-wet-header'); $nav_bar_markup = theme('links__menu_menu_wet_header', array('links' => $menu, 'attributes' => array('id' => 'menu', 'class' => array('links', 'clearfix')), 'heading' => array('text' => 'Language Selection', 'level' => 'h2'))); $nav_bar_markup = strip_tags($nav_bar_markup, '<h2><li><a>'); if (module_exists('wetkit_language')) { $language_link_markup = '<li id="' . $theme_menu_prefix . '-lang">' . strip_tags($variables['menu_lang_bar'], '<a><span>') . '</li>'; if ($wxt_active == 'gcweb') { $variables['menu_bar'] = '<ul class="list-inline margin-bottom-none">' . $language_link_markup . '</ul>'; } else { if ($wxt_active == 'gcwu_fegc') { $variables['menu_bar'] = '<ul id="gc-bar" class="list-inline">' . preg_replace("/<h([1-6]{1})>.*?<\\/h\\1>/si", '', $nav_bar_markup) . $language_link_markup . '</ul>'; } else { if ($wxt_active == 'gc_intranet') { $variables['menu_bar'] = '<ul id="gc-bar" class="list-inline">' . $language_link_markup . '</ul>'; } else { $variables['menu_bar'] = '<ul class="text-right">' . preg_replace("/<h([1-6]{1})>.*?<\\/h\\1>/si", '', $nav_bar_markup) . $language_link_markup . '</ul>'; } } } } else { $variables['menu_bar'] = '<ul class="text-right">' . preg_replace("/<h([1-6]{1})>.*?<\\/h\\1>/si", '', $nav_bar_markup) . '</ul>'; } // Custom Search Box. if (module_exists('custom_search')) { $custom_search_form_name = 'custom_search_blocks_form_1'; $custom_search = array('#pre_render' => array('__wetkit_custom_search_prerender'), '#cache' => array('keys' => array('bootstrap_psdpt', 'custom_search', $custom_search_form_name), 'expire' => CACHE_TEMPORARY, 'granularity' => DRUPAL_CACHE_PER_USER), '#custom_search_form_name' => $custom_search_form_name, '#wxt_active' => $wxt_active); $variables['custom_search'] = $custom_search; // CDN Support. if ($wxt_active == 'gcweb') { $gcweb_cdn = theme_get_setting('gcweb_cdn'); if (!empty($gcweb_cdn)) { $variables['gcweb_cdn'] = TRUE; } else { $variables['gcweb_cdn'] = FALSE; } } // Visibility settings. $pages = drupal_strtolower(theme_get_setting('wetkit_search_box')); // Convert the Drupal path to lowercase. $path = drupal_strtolower(drupal_get_path_alias($_GET['q'])); // Compare the lowercase internal and lowercase path alias (if any). $page_match = drupal_match_path($path, $pages); if ($path != $_GET['q']) { $page_match = $page_match || drupal_match_path($_GET['q'], $pages); } // When $visibility has a value of 0 (VISIBILITY_NOTLISTED), // the block is displayed on all pages except those listed in $pages. // When set to 1 (VISIBILITY_LISTED), it is displayed only on those // pages listed in $pages. $visibility = 0; $page_match = !(0 xor $page_match); if ($page_match) { $variables['search_box'] = render($variables['custom_search']); $variables['search_box'] = str_replace('type="text"', 'type="search"', $variables['search_box']); } else { $variables['search_box'] = ''; } } // Terms Navigation. $menu = $is_multilingual ? i18n_menu_navigation_links('menu-wet-terms') : menu_navigation_links('menu-wet-terms'); $class = $wxt_active == 'gcwu_fegc' || $wxt_active == 'gc_intranet' ? array('list-inline') : array('links', 'clearfix'); $terms_bar_markup = theme('links__menu_menu_wet_terms', array('links' => $menu, 'attributes' => array('id' => 'gc-tctr', 'class' => $class), 'heading' => array())); $variables['page']['menu_terms_bar'] = $terms_bar_markup; // Mid Footer Region. if (module_exists('menu_block')) { $menu_name = 'mid_footer_menu'; $data = array('#pre_render' => array('_wetkit_menu_tree_build_prerender'), '#cache' => array('keys' => array('bootstrap_psdpt', 'menu', 'footer', $menu_name), 'expire' => CACHE_TEMPORARY, 'granularity' => DRUPAL_CACHE_PER_ROLE), '#menu_name' => $menu_name); $variables['page']['footer']['minipanel'] = $data; } // Unset powered by block. unset($variables['page']['footer']['system_powered-by']); // Footer Navigation. $menu = $is_multilingual ? i18n_menu_navigation_links('menu-wet-footer') : menu_navigation_links('menu-wet-footer'); $class = $wxt_active == 'gcwu_fegc' || $wxt_active == 'gc_intranet' ? array('list-inline') : array('links', 'clearfix'); $footer_bar_markup = theme('links__menu_menu_wet_footer', array('links' => $menu, 'attributes' => array('id' => 'menu', 'class' => $class), 'heading' => array())); $variables['page']['menu_footer_bar'] = $footer_bar_markup; // Footer Navigation (gcweb). if ($wxt_active == 'gcweb') { $variables['gcweb'] = array('feedback' => array('en' => 'http://www.canada.ca/en/contact/feedback.html', 'fr' => 'http://www.canada.ca/fr/contact/retroaction.html'), 'social' => array('en' => 'http://www.canada.ca/en/social/index.html', 'fr' => 'http://www.canada.ca/fr/sociaux/index.html'), 'mobile' => array('en' => 'http://www.canada.ca/en/mobile/index.html', 'fr' => 'http://www.canada.ca/fr/mobile/index.html')); } }
function get_layout() { $alias = drupal_get_path_alias($_GET['q']); foreach ($this->layouts as $k => $layout) { if ($k == 0) { continue; } $page_list = isset($layout->pages) ? $layout->pages : ''; if (empty($page_list)) { continue; } if (drupal_match_path($_GET['q'], $page_list) || drupal_match_path($alias, $page_list)) { return $k; } } return 0; }
/** * Get banner to show into current page in accord with settings * * @return <array> * Banners to show */ function engageny_show_banners() { $banners = engageny_get_banners(FALSE); $display_banners = array(); // Current path alias $path = drupal_strtolower(drupal_get_path_alias($_GET['q'])); // Check visibility for each banner foreach ($banners as $banner) { // Pages $pages = drupal_strtolower($banner['image_visibility']); // Check path for alias, and (if required) for path $page_match = drupal_match_path($path, $pages); if ($path != $_GET['q']) { $page_match = $page_match || drupal_match_path($_GET['q'], $pages); } // Add banner to visible banner if ($page_match) { $display_banners[] = $banner; } } return $display_banners; }
/** * Helper function for showing the title and subtitle of a site section in the * highlighted region. * * The description is retrieved from the description of the menu item. */ function _bvng_get_title_data($node_count = NULL, $user = NULL, $req_path = NULL) { $status = drupal_get_http_header("status"); // This way disassociates the taxanavigation voc, is more reasonable, but a bit heavy. // Only 'GBIF Newsroom' has a shorter name in the nav. $source_menu = strpos($req_path, 'user') !== FALSE ? 'user-menu' : 'gbif-menu'; $active_menu_item = menu_link_get_preferred(current_path(), $source_menu); if (strpos(current_path(), 'user') !== FALSE) { switch ($req_path) { case 'user/login': $title = array('name' => t('Login to GBIF'), 'description' => ''); break; case 'user/register': $title = array('name' => t('Register New GBIF Account'), 'description' => t('Please, register to the GBIF data portal for downloading data, or login if you already have an account')); break; case 'user/password': $title = array('name' => t('Request a new password'), 'description' => t('Please enter your username or the registered email address in order to reset your password')); break; case 'node/241': $title = array('name' => t('Thanks for registering!'), 'description' => t('Please verify your email address')); break; default: if (isset($user->uid) && $user->uid !== 0) { $user = user_load($user->uid); $name = ''; $name .= _bvng_get_field_value('user', $user, 'field_firstname'); $name .= ' '; $name .= _bvng_get_field_value('user', $user, 'field_lastname'); $title = array('name' => $name, 'description' => t('User account and personal settings')); } elseif ($status == '403 Forbidden') { $title = array('name' => t('You need to log in to visit this page'), 'description' => t('403 Forbidden: proper permission required')); } elseif (isset($user->uid) && $user->uid == 0) { $title = array('name' => t('Log in to GBIF'), 'description' => ''); } break; } } elseif ($status == '404 Not Found') { $title = array('name' => t("Hmm, the page can't be found"), 'description' => t('404 Not Found')); } elseif ($status == '403 Forbidden') { $title = array('name' => t('You need to log in to visit this page'), 'description' => t('403 Forbidden: proper permission required')); } elseif ($active_menu_item) { // The resource/summary and resources/keyinformation are shared by two menu parents // so we force the title here. if (drupal_match_path($req_path, 'taxonomy/term/764') || drupal_match_path($req_path, 'node/234') || drupal_match_path($req_path, 'resources/archive')) { $title = array('name' => t('Resources'), 'description' => t('Tools and information to support the GBIF community')); } else { $parent = menu_link_load($active_menu_item['plid']); $title = array('mild' => $parent['mlid'], 'name' => $parent['link_title'] == 'GBIF News' ? 'GBIF Newsroom' : $parent['link_title'], 'description' => $parent['options']['attributes']['title']); } } elseif (strpos(current_path(), 'taxonomy/term') !== FALSE) { $term = taxonomy_term_load(arg(2)); $title = array('name' => format_plural($node_count, 'Item tagged with "@term"', 'Items tagged with "@term"', array('@term' => $term->name))); } elseif (strpos(current_path(), 'search') !== FALSE) { $title = array('name' => t('Search GBIF')); } return $title; }
//$item = menu_get_item(); //if ($item['path'] == 'blog' ||$item['path'] == 'taxonomy/term/%' || $item['path'] == 'post-date/%') { //$wrapper_classes[] = 'blog'; //} //if (isset($vars['node']) && $vars['node']->type == 'article') { //$wrapper_classes[] = 'blog-single'; //} $path_alias = drupal_get_path_alias(); $path = drupal_get_normal_path($_GET['q']); $path_tearm = "taxonomy/term/*"; $path_view = "blog" . PHP_EOL . "post-date/*"; $path_node = "blog/*"; if (drupal_match_path($path_alias, $path_view) || drupal_match_path($path, $path_tearm)) { $wrapper_classes[] = 'blog'; } if (drupal_match_path($path_alias, $path_node)) { $wrapper_classes[] = 'blog-single'; } ?> <?php if (trim(implode(' ', $wrapper_classes)) == 'blog-single') { ?> <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script> <script type="text/javascript">stLight.options({publisher: "ur-6a7e320d-37d8-511-633d-4264e3ae8c", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script> <?php } ?>