Esempio n. 1
1
/**
 * Preprocessor for page.tpl.php template file.
 */
function goodboymytheme_preprocess_page(&$vars, $hook)
{
    //----------------------------------------------------Goodboy my custom Stage 4 p.5
    if (arg(0) == 'node') {
        if ($vars['node']->type == 'film') {
            $vars['title'] = 'Films Films Films';
        }
    }
    // For easy printing of variables.
    $vars['logo_img'] = '';
    if (!empty($vars['logo'])) {
        $vars['logo_img'] = theme('image', array('path' => $vars['logo'], 'alt' => t('Home'), 'title' => t('Home')));
    }
    $vars['linked_logo_img'] = '';
    if (!empty($vars['logo_img'])) {
        $vars['linked_logo_img'] = l($vars['logo_img'], '<front>', array('attributes' => array('rel' => 'home', 'title' => t('Home')), 'html' => TRUE));
    }
    $vars['linked_site_name'] = '';
    if (!empty($vars['site_name'])) {
        $vars['linked_site_name'] = l($vars['site_name'], '<front>', array('attributes' => array('rel' => 'home', 'title' => t('Home'))));
    }
    // Site navigation links.
    $vars['main_menu_links'] = '';
    if (isset($vars['main_menu'])) {
        $vars['main_menu_links'] = theme('links__system_main_menu', array('links' => $vars['main_menu'], 'attributes' => array('id' => 'main-menu', 'class' => array('inline', 'main-menu')), 'heading' => array('text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible'))));
    }
    $vars['secondary_menu_links'] = '';
    if (isset($vars['secondary_menu'])) {
        $vars['secondary_menu_links'] = theme('links__system_secondary_menu', array('links' => $vars['secondary_menu'], 'attributes' => array('id' => 'secondary-menu', 'class' => array('inline', 'secondary-menu')), 'heading' => array('text' => t('Secondary menu'), 'level' => 'h2', 'class' => array('element-invisible'))));
    }
}
Esempio n. 2
1
/**
 * @file
 * This file is empty by default because the base theme chain (Alpha & Omega) provides
 * all the basic functionality. However, in case you wish to customize the output that Drupal
 * generates through Alpha & Omega this file is a good place to do so.
 * 
 * Alpha comes with a neat solution for keeping this file as clean as possible while the code
 * for your subtheme grows. Please read the README.txt in the /preprocess and /process subfolders
 * for more information on this topic.
 */
function songlap_preprocess_page(&$vars)
{
    if (drupal_is_front_page()) {
        $breadcrumb = array();
        $breadcrumb[] = t('Home');
        drupal_set_breadcrumb($breadcrumb);
    }
    if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_null(arg(3))) {
        $term = taxonomy_term_load(arg(2));
        $breadcrumb = '';
        $breadcrumb .= '<div class="breadcrumb">';
        $breadcrumb .= '<a href="' . $vars['front_page'] . '">' . t('Home') . '</a> ';
        $breadcrumb .= '» ' . $term->name;
        $breadcrumb .= '</div>';
        $vars['breadcrumb'] = $breadcrumb;
    }
    if ($_GET['q'] == 'projects') {
        $breadcrumb = '';
        $breadcrumb .= '<div class="breadcrumb">';
        $breadcrumb .= '<a href="' . $vars['front_page'] . '">' . t('Home') . '</a> ';
        $breadcrumb .= '» ' . t('Projects');
        $breadcrumb .= '</div>';
        $vars['breadcrumb'] = $breadcrumb;
    }
}
Esempio n. 3
1
function lt_preprocess_views_view(&$vars)
{
    if ($vars['view']->name == 'articles' && arg(0) == 'taxonomy') {
        $term = taxonomy_term_load(arg(2));
        $vars['header'] = '<h2 class="block-title">' . $term->name . '</h2>';
    }
}
Esempio n. 4
1
/**
 * Implemements hook_process_page
 * @param array $variables
 */
function fs_core_preprocess_page(&$variables)
{
    //Search form
    $search_form = drupal_get_form('search_form');
    $search_form_box = drupal_render($search_form);
    $variables['search_box'] = $search_form_box;
    if ($views_page = views_get_page_view()) {
        $variables['theme_hook_suggestions'][] = 'page__views__' . $views_page->name;
        $variables['theme_hook_suggestions'][] = 'page__views__' . $views_page->name . '_' . $views_page->current_display;
    }
    if (isset($variables['node']->type)) {
        $variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type;
    }
    // changes the links tree for the main menu, since by
    // default Drupal just provides first level ones
    $menu_tree = menu_tree_all_data('main-menu');
    $menu_tree = menu_tree_output($menu_tree);
    foreach ($menu_tree as $k => $v) {
        if (is_numeric($k) && count($v['#below'])) {
            $menu_tree[$k]['#below']['#theme_wrappers'][0] = 'menu_tree__submenu';
        }
    }
    $variables['main_menu'] = $menu_tree;
    if (arg(0) == 'taxonomy' && arg(1) == 'term') {
        $tid = (int) arg(2);
        $term = taxonomy_term_load($tid);
        if (is_object($term)) {
            $variables['theme_hook_suggestions'][] = 'page__taxonomy__' . $term->vocabulary_machine_name;
        }
    }
}
/**
 * Extract the specified array fields from the current or specified page.
 * Build a l() 'query' array suitable for use by Prepopulate.
 *
 * @param $fields
 *   Array of fields to process.
 * @param path
 *   If NULL, the current page. Otherwise, lookup the path and use that page.
 *   (Path lookup not yet implemented)
 *
 * @see freelinking_prepopulate_list_fields(), l()
 */
function freelinking_prepopulate_fields_from_page($fields, $plugin = 'nodecreate', $path = NULL)
{
    static $prepopulate;
    $query = array();
    $index = $plugin . serialize($fields);
    if (!$prepopulate[$index]) {
        $prepopulate[$index] = array_intersect_key(freelinking_prepopulate_list_fields($plugin), $fields);
    }
    if ($plugin == 'nodecreate' && arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) {
        $object = node_load(arg(1));
    }
    foreach ($prepopulate[$index] as $field => $definition) {
        switch ($field) {
            case 'og':
                $group = og_get_group_context();
                $query[$definition['prepopulate']] = $group->nid;
                break;
            case 'book':
                if ($node->book) {
                    $query['parent'] = $object->book['mlid'];
                }
                break;
            default:
                if ($object->{$field}) {
                    $query[$definition['prepopulate']] = $object->field;
                }
                break;
        }
    }
    return $query;
}
Esempio n. 6
0
/**
 * @file template.php
 * This file provides theme functions to override or extend Drupal behavior.
 *
 * @author Raymond Jelierse
 */

function equinox_preprocess_page(&$variables) {
  // Default JavaScript settings
  $theme_settings = array(
      'carouselTimeout' => 10000,
      'carouselTransitionSpeed' => 500,
  );

  // Refresh theme settings
  theme_get_setting('', TRUE);

  if (theme_get_setting('carousel_timeout') !== NULL) {
    $theme_settings['carouselTimeout'] = intval(theme_get_setting('carousel_timeout'));
  }

  if (theme_get_setting('carousel_transition_speed') !== NULL) {
    $theme_settings['carouselTransitionSpeed'] = intval(theme_get_setting('carousel_transition_speed'));
  }

  drupal_add_js(array('equinox' => $theme_settings), 'setting');
  $variables['scripts'] = drupal_get_js();

  // Create user menu
  $variables['user_menu'] = theme('links', menu_navigation_links('navigation'), array('id' => 'user-links-menu', 'class' => 'links user-links'));

  // Add check variable for administration section.
  $variables['is_admin'] = (arg(0) == 'admin');

  // Remove breadcrumb if not in the administration section.
  if (!$variables['is_admin']) {
    $variables['breadcrumb'] = '';
  }

  // Multilanguage site logo
  $variables['logo'] = sprintf('%s/images/logo-%s.png', url(drupal_get_path('theme', 'equinox')), $variables['language']->language);
}
Esempio n. 7
0
/**
 * Implementation of hook_preprocess_page().
 */
function stability_process_page(&$variables)
{
    global $user;
    $variables['login_account_links'] = '';
    if (theme_get_setting('login_account_links') || module_exists('uc_cart')) {
        $output = '';
        if (theme_get_setting('login_account_links')) {
            $output .= '<span class="login">
        <i class="fa fa-lock"></i> ' . l($user->uid ? t('My Account') : t('Login'), 'user') . '
      </span>';
            $output .= $user->uid ? '<span class="logout"><i class="fa fa-sign-out"></i> ' . l(t('Logout'), 'user/logout') . '</span>' : '';
            $output .= !$user->uid ? '<span class="register"><i class="fa fa-pencil-square-o"></i>' . t('Not a Member?') . ' ' . l(t('Register'), 'user/register') . '</span>' : '';
        }
        if (module_exists('uc_cart')) {
            $output .= '<span class="cart">
        <i class="fa fa-shopping-cart"></i> ' . l(t('Shopping Cart'), 'cart') . '
      </span>';
        }
        $variables['login_account_links'] = '
      <div class="header-top-right">
        ' . $output . '
      </div>';
    }
    $header_top_menu_tree = module_exists('i18n_menu') ? i18n_menu_translated_tree('menu-header-top-menu') : menu_tree('menu-header-top-menu');
    $variables['header_top_menu_tree'] = drupal_render($header_top_menu_tree);
    // Process Slideshow Sub Header
    if (theme_get_setting('sub_header') == 5 || arg(2) == 'sub-header' && arg(3) == '5') {
        drupal_add_js(drupal_get_path('theme', 'stability') . '/vendor/jquery.glide.min.js');
    }
    if (theme_get_setting('retina')) {
        drupal_add_js(drupal_get_path('theme', 'stability') . '/vendor/jquery.retina.js');
    }
    drupal_add_js(array('stability' => array('flickr_id' => theme_get_setting('flickr_id'), 'logo_sticky' => theme_get_setting('logo_sticky'))), 'setting');
}
Esempio n. 8
0
function iha_preprocess_page(&$variables)
{
    $search_box = drupal_render(drupal_get_form('search_form'));
    $variables['search_box'] = $search_box;
    if (drupal_is_front_page()) {
        unset($variables['page']['content']['system_main']['default_message']);
        //will remove message "no front page content is created"
        drupal_set_title('');
        //removes welcome message (page title)
    }
    if (arg(0) == 'node') {
        $variables['node_content'] =& $variables['page']['content']['system_main']['nodes'][arg(1)];
    }
    if (isset($variables['node']->type)) {
        $variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type;
    }
    // Prepare the mobile menu.
    $user_menu = menu_tree('user-menu');
    $main_menu = menu_tree('main-menu');
    $menu_tree = array_merge($main_menu, $user_menu);
    // FYI for future dev's - If need to add more menu items, then load the other menu through menu tree as well and do a
    // array merge or for loop to attach the items to the $menu_tree.
    $mobile_menu = '<ul class="list-unstyled main-menu">';
    foreach ($menu_tree as $mlid => $mm) {
        if (is_int($mlid)) {
            $mobile_menu .= iha_render_mobile_menu($mm);
        }
    }
    $mobile_menu .= '</ul>';
    $variables['mobile_menu'] = $mobile_menu;
}
Esempio n. 9
0
/**
 * Preprocessor for page.tpl.php template file.
 */
function bodia_my_theme_preprocess_page(&$vars, $hook)
{
    // For change title in node 3
    if (arg(1) == 3 && arg(0) == 'node') {
        $vars['title'] = 'Example template_preprocess_page';
    }
    // For easy printing of variables.
    $vars['logo_img'] = '';
    if (!empty($vars['logo'])) {
        $vars['logo_img'] = theme('image', array('path' => $vars['logo'], 'alt' => t('Home'), 'title' => t('Home')));
    }
    $vars['linked_logo_img'] = '';
    if (!empty($vars['logo_img'])) {
        $vars['linked_logo_img'] = l($vars['logo_img'], '<front>', array('attributes' => array('rel' => 'home', 'title' => t('Home')), 'html' => TRUE));
    }
    $vars['linked_site_name'] = '';
    if (!empty($vars['site_name'])) {
        $vars['linked_site_name'] = l($vars['site_name'], '<front>', array('attributes' => array('rel' => 'home', 'title' => t('Home'))));
    }
    // Site navigation links.
    $vars['main_menu_links'] = '';
    if (isset($vars['main_menu'])) {
        $vars['main_menu_links'] = theme('links__system_main_menu', array('links' => $vars['main_menu'], 'attributes' => array('id' => 'main-menu', 'class' => array('inline', 'main-menu')), 'heading' => array('text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible'))));
    }
    $vars['secondary_menu_links'] = '';
    if (isset($vars['secondary_menu'])) {
        $vars['secondary_menu_links'] = theme('links__system_secondary_menu', array('links' => $vars['secondary_menu'], 'attributes' => array('id' => 'secondary-menu', 'class' => array('inline', 'secondary-menu')), 'heading' => array('text' => t('Secondary menu'), 'level' => 'h2', 'class' => array('element-invisible'))));
    }
}
Esempio n. 10
0
/**
 * Preprocessor for theme('page').
 */
function cube_preprocess_page(&$vars)
{
    // Automatically adjust layout for page with right sidebar content if no
    // explicit layout has been set.
    $layout = module_exists('context_layouts') ? context_layouts_get_active_layout() : NULL;
    if (arg(0) != 'admin' && !empty($vars['page']['right']) && (!$layout || $layout['layout'] == 'default')) {
        $vars['theme_hook_suggestion'] = 'page__context_layouts_cube_columns';
        drupal_add_css(drupal_get_path('theme', 'cube') . '/layout-sidebar.css');
    }
    // Clear out help text if empty.
    if (empty($vars['help']) || !strip_tags($vars['help'])) {
        $vars['help'] = '';
    }
    // Help text toggler link.
    $vars['help_toggler'] = l(t('Help'), $_GET['q'], array('attributes' => array('id' => 'help-toggler', 'class' => array('toggler')), 'fragment' => 'help-text'));
    // Overlay is enabled.
    $vars['overlay'] = module_exists('overlay') && overlay_get_mode() === 'child';
    if ($vars['overlay']) {
    }
    // Display user links
    $vars['user_links'] = _cube_user_links();
    // Display tabs
    $vars['primary_tabs'] = menu_primary_local_tasks();
    $vars['secondary_tabs'] = menu_secondary_local_tasks();
}
Esempio n. 11
0
function mothership_preprocess_page(&$vars, $hook)
{
    // Define the content width
    // Add HTML tag name for title tag.
    $vars['site_name_element'] = $vars['is_front'] ? 'h1' : 'div';
    // Classes for body element. Allows advanced theming based on context
    // (home page, node of certain type, etc.)
    $body_classes = array($vars['body_classes']);
    if (!$vars['is_front']) {
        // Add unique classes for each page and website section
        $path = drupal_get_path_alias($_GET['q']);
        list($section, ) = explode('/', $path, 2);
        $body_classes[] = mothership_id_safe('page-' . $path);
        $body_classes[] = mothership_id_safe('section-' . $section);
        if (arg(0) == 'node') {
            if (arg(1) == 'add') {
                if ($section == 'node') {
                    array_pop($body_classes);
                    // Remove 'section-node'
                }
                $body_classes[] = 'section-node-add';
                // Add 'section-node-add'
            } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
                if ($section == 'node') {
                    array_pop($body_classes);
                    // Remove 'section-node'
                }
                $body_classes[] = 'section-node-' . arg(2);
                // Add 'section-node-edit' or 'section-node-delete'
            }
        }
    }
    $vars['body_classes'] = implode(' ', $body_classes);
    // Concatenate with spaces
}
/**
 * Prepare variables for the drawer layout template file.
 */
function template_preprocess_layout__double_fixed_inner_rev(&$variables)
{
    if ($variables['content']['sidebar'] && $variables['content']['drawer']) {
        $variables['classes'][] = 'layout-both-sidebars';
    } elseif ($variables['content']['sidebar'] || $variables['content']['drawer']) {
        $variables['classes'][] = 'layout-one-sidebar';
        if ($variables['content']['sidebar']) {
            $variables['classes'][] = 'layout-has-sidebar';
        } else {
            $variables['classes'][] = 'layout-has-drawer';
        }
    } else {
        $variables['classes'][] = 'layout-no-sidebars';
    }
    // Special handling for header image.
    $variables['main_attributes'] = array('class' => array('l-content'));
    if (arg(0) == 'user' && is_numeric(arg(1)) && !arg(2)) {
        // We are on the user profile page.
        $variables['main_attributes']['class'][] = 'account-page';
        // Check to see if there is a profile image.
        $account = user_load(arg(1));
        // Entity cache should save us here?
        if (isset($account->field_header_photo[LANGUAGE_NONE][0]['uri'])) {
            // Generate an image at the correct size.
            $image = image_style_url('header', $account->field_header_photo[LANGUAGE_NONE][0]['uri']);
            $variables['main_attributes']['style'] = 'background-image: url(' . $image . ')';
            // Add an addidional class.
            $variables['main_attributes']['class'][] = 'has-background';
        }
    }
}
Esempio n. 13
0
/**
 * Override or insert variables for the breadcrumb theme function.
 *
 * @param $variables
 *   An array of variables to pass to the theme function.
 * @param $hook
 *   The name of the theme hook being called ("breadcrumb" in this case).
 *
 * @see zen_breadcrumb()
 */
function zen_preprocess_breadcrumb(&$variables, $hook)
{
    // Define variables for the breadcrumb-related theme settings. This is done
    // here so that sub-themes can dynamically change the settings under
    // particular conditions in a preprocess function of their own.
    $variables['display_breadcrumb'] = check_plain(theme_get_setting('zen_breadcrumb'));
    $variables['display_breadcrumb'] = $variables['display_breadcrumb'] == 'yes' || $variables['display_breadcrumb'] == 'admin' && arg(0) == 'admin' ? TRUE : FALSE;
    $variables['breadcrumb_separator'] = filter_xss_admin(theme_get_setting('zen_breadcrumb_separator'));
    $variables['display_trailing_separator'] = theme_get_setting('zen_breadcrumb_trailing') ? TRUE : FALSE;
    // Optionally get rid of the homepage link.
    if (!theme_get_setting('zen_breadcrumb_home')) {
        array_shift($variables['breadcrumb']);
    }
    // Add the title of the page to the end of the breadcrumb list.
    if (!empty($variables['breadcrumb']) && theme_get_setting('zen_breadcrumb_title')) {
        $item = menu_get_item();
        if (!empty($item['tab_parent'])) {
            // If we are on a non-default tab, use the tab's title.
            $variables['breadcrumb'][] = check_plain($item['title']);
        } else {
            $variables['breadcrumb'][] = drupal_get_title();
        }
        // Turn off the trailing separator.
        $variables['display_trailing_separator'] = FALSE;
    }
    // Provide a navigational heading to give context for breadcrumb links to
    // screen-reader users.
    if (empty($variables['title'])) {
        $variables['title'] = t('You are here');
    }
}
Esempio n. 14
0
/**
 * Implementation of hook_preprocess_page().
 */
function progressive_preprocess_page(&$vars, $hook)
{
    global $user;
    if (arg(0) == 'user' && (arg(1) == 'register' || arg(1) == 'password' || arg(1) == '' && !$user->uid)) {
        $vars['theme_hook_suggestions'][] = 'page__user__login';
    }
}
Esempio n. 15
0
/**
 * Override or insert PHPTemplate variables into the templates.
 */
function boldy_preprocess_page(&$vars)
{
    $vars['tabs2'] = menu_secondary_local_tasks();
    // Hook into color.module
    if (module_exists('color')) {
        _color_page_alter($vars);
    }
    // Classes for body element. Allows advanced theming based on context
    // (home page, node of certain type, etc.)
    $classes = explode(' ', $vars['body_classes']);
    // Remove the mostly useless page-ARG0 class.
    if ($index = array_search(preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-' . drupal_strtolower(arg(0))), $classes)) {
        unset($classes[$index]);
    }
    if (!$vars['is_front']) {
        // Add unique class for each page.
        $path = drupal_get_path_alias($_GET['q']);
        $classes[] = boldy_id_safe('page-' . $path);
        // Add unique class for each website section.
        list($section, ) = explode('/', $path, 2);
        if (arg(0) == 'node') {
            if (arg(1) == 'add') {
                $section = 'node-add';
            } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
                $section = 'node-' . arg(2);
            }
        }
        $classes[] = boldy_id_safe('section-' . $section);
    }
    $vars['body_classes_array'] = $classes;
    $vars['body_classes'] = implode(' ', $classes);
    // Concatenate with spaces.
}
Esempio n. 16
0
/**
 * Override or insert variables into the page templates.
 *
 * @param $variables
 *   An array of variables to pass to the theme template.
 * @param $hook
 *   The name of the template being rendered ("page" in this case.)
 */
function handbuilt_preprocess_page(&$variables, $hook)
{
    // Reset
    unset($variables['title_prefix']);
    unset($variables['title_suffix']);
    // Flag for main content only without secondary content
    if (empty($variables['page']['content-secondary'])) {
        $variables['classes_array'][] = 'no-secondary-content';
    }
    if (drupal_is_front_page()) {
        $variables['title'] = 'Recent essays';
    } else {
        if (arg(0) == 'search') {
            $variables['title_suffix'] = arg(2);
        } else {
            if (arg(0) == 'taxonomy' && arg(1) == 'term') {
                $variables['title_prefix'] = 'Tag';
            }
        }
    }
    // Move tabs into main content region
    // Not needed because we are using Blockify module
    // if (!empty($variables['tabs'])) {
    //     array_unshift($variables['page']['content-primary'], $variables['tabs']);
    //     unset($variables['tabs']);
    //   }
}
/**
 * Endpoint authentication configuration form.
 */
function services_edit_form_endpoint_authentication($form_state)
{
    $endpoint = services_endpoint_load(arg(4));
    // Loading runtime include as needed by services_authentication_info().
    module_load_include('runtime.inc', 'services');
    $form = array();
    $auth_modules = module_implements('services_authentication_info');
    $form['endpoint_object'] = array('#type' => 'value', '#value' => $endpoint);
    if (empty($auth_modules)) {
        $form['message'] = array('#type' => 'item', '#title' => t('Authentication'), '#description' => t('No authentication modules are installed, all requests will be anonymous.'));
        return $form;
    }
    if (empty($endpoint->authentication)) {
        $form['message'] = array('#type' => 'item', '#title' => t('Authentication'), '#description' => t('No authentication modules are enabled, all requests will be anonymous.'));
        return $form;
    }
    // Add configuration fieldsets for the authentication modules
    foreach ($endpoint->authentication as $module => $settings) {
        $info = services_authentication_info($module);
        if (empty($info)) {
            continue;
        }
        $form[$module] = array('#type' => 'fieldset', '#title' => isset($info['title']) ? $info['title'] : $module, '#tree' => TRUE);
        $module_settings_form = services_auth_invoke($module, 'security_settings', $settings);
        if (!empty($module_settings_form) && $module_settings_form !== TRUE && $settings == $module || is_array($settings)) {
            $form[$module] += $module_settings_form;
        } else {
            $form[$module]['message'] = array('#type' => 'item', '#value' => t('@module has no settings available.', array('@module' => drupal_ucfirst($module))));
        }
    }
    $form['submit'] = array('#type' => 'submit', '#value' => 'Save');
    return $form;
}
Esempio n. 18
0
function phptemplate_preprocess_page(&$vars)
{
    $vars['tabs2'] = menu_secondary_local_tasks();
    if (module_exists('path')) {
        $alias = drupal_get_path_alias(str_replace('/edit', '', $_GET['q']));
        if ($alias != $_GET['q']) {
            $suggestions = array();
            $template_filename = 'page';
            foreach (explode('/', $alias) as $path_part) {
                $template_filename = $template_filename . '-' . $path_part;
                $suggestions[] = $template_filename;
            }
            $vars['template_files'] = array_merge((array) $suggestions, $vars['template_files']);
        }
    }
    //todo i think this can be deleted
    if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
        $termid = arg(2);
        $parent_term = taxonomy_get_parents($termid);
        if (key($parent_term) == EMAILS_TERM_ID) {
            $term = taxonomy_get_term($termid);
            $vars['template_file'] = 'page-taxonomy-term-emails';
        }
    }
}
Esempio n. 19
0
 /**
  * {@inheritDocs}
  */
 public function match($pathinfo)
 {
     // The 'q' variable is pervasive in Drupal, so it's best to just keep
     // it even though it's very un-Symfony.
     $path = drupal_get_normal_path(substr($pathinfo, 1));
     if (variable_get('menu_rebuild_needed', FALSE) || !variable_get('menu_masks', array())) {
         menu_rebuild();
     }
     $original_map = arg(NULL, $path);
     $parts = array_slice($original_map, 0, MENU_MAX_PARTS);
     $ancestors = menu_get_ancestors($parts);
     $router_item = db_query_range('SELECT * FROM {menu_router} WHERE path IN (:ancestors) ORDER BY fit DESC', 0, 1, array(':ancestors' => $ancestors))->fetchAssoc();
     if ($router_item) {
         // Allow modules to alter the router item before it is translated and
         // checked for access.
         drupal_alter('menu_get_item', $router_item, $path, $original_map);
         // The requested path is an unalaised Drupal route.
         return array('_drupal' => true, '_controller' => function ($_router_item) {
             $router_item = $_router_item;
             if (!$router_item['access']) {
                 throw new AccessDeniedException();
             }
             if ($router_item['include_file']) {
                 require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
             }
             return call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
         }, '_route' => $router_item['path']);
     }
     throw new ResourceNotFoundException();
 }
Esempio n. 20
0
function boron_preprocess_page(&$vars, $hook)
{
    $body_classes = array($vars['body_classes']);
    if (!$vars['is_front']) {
        // Add unique classes for each page and website section
        $path = drupal_get_path_alias($_GET['q']);
        list($section, ) = explode('/', $path, 2);
        list(, $subsection) = explode('/', $path, 3);
        $body_classes[] = boron_id_safe('page-' . $path);
        $body_classes[] = boron_id_safe('section-' . $section);
        $body_classes[] = boron_id_safe('subsection-' . $subsection);
        if (arg(0) == 'node') {
            if (arg(1) == 'add') {
                if ($section == 'node') {
                    array_pop($body_classes);
                    // Remove 'section-node'
                }
                $body_classes[] = 'section-node-add';
                // Add 'section-node-add'
            } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
                if ($section == 'node') {
                    array_pop($body_classes);
                    // Remove 'section-node'
                }
                $body_classes[] = 'section-node-' . arg(2);
                // Add 'section-node-edit' or 'section-node-delete'
            }
        }
    }
    $vars['body_classes'] = implode(' ', $body_classes);
    // Concatenate with spaces
}
Esempio n. 21
0
/**
 * Returns HTML for a set of filter tips.
 *
 * @param array $variables
 *   An associative array containing:
 *   - tips: An array containing descriptions and a CSS ID in the form of
 *     'module-name/filter-id' (only used when $long is TRUE) for each
 *     filter in one or more text formats. Example:
 *     @code
 *       array(
 *         'Full HTML' => array(
 *           0 => array(
 *             'tip' => 'Web page addresses and e-mail addresses turn into links automatically.',
 *             'id' => 'filter/2',
 *           ),
 *         ),
 *       );
 *     @endcode
 *   - long: (optional) Whether the passed-in filter tips contain extended
 *     explanations, i.e. intended to be output on the path 'filter/tips'
 *     (TRUE), or are in a short format, i.e. suitable to be displayed below a
 *     form element. Defaults to FALSE.
 *
 * @return string
 *   The constructed HTML.
 *
 * @see theme_filter_tips()
 * @see _filter_tips()
 *
 * @ingroup theme_functions
 */
function bootstrap_filter_tips($variables)
{
    $format_id = arg(2);
    $current_path = current_path();
    $tips = _filter_tips(-1, TRUE);
    // Create a place holder for the tabs.
    $build['tabs'] = array('#theme' => 'item_list', '#items' => array(), '#attributes' => array('class' => array('nav', 'nav-tabs'), 'role' => 'tablist'));
    // Create a placeholder for the panes.
    $build['panes'] = array('#theme_wrappers' => array('container'), '#attributes' => array('class' => array('tab-content')));
    foreach ($tips as $name => $list) {
        $machine_name = str_replace('-', '_', drupal_html_class($name));
        $tab = array('data' => array('#type' => 'link', '#title' => check_plain($name), '#href' => $current_path, '#attributes' => array('role' => 'tab', 'data-toggle' => 'tab'), '#options' => array('fragment' => $machine_name)));
        if (!$format_id || $format_id === $machine_name) {
            $tab['class'][] = 'active';
            $format_id = $machine_name;
        }
        $build['tabs']['#items'][] = $tab;
        // Extract the actual tip.
        $tiplist = array();
        foreach ($list as $tip) {
            $tiplist[] = $tip['tip'];
        }
        // Construct the pane.
        $pane = array('#theme_wrappers' => array('container'), '#attributes' => array('class' => array('tab-pane', 'fade'), 'id' => $machine_name), 'list' => array('#theme' => 'item_list', '#items' => $tiplist));
        if ($format_id === $machine_name) {
            $pane['#attributes']['class'][] = 'active';
            $pane['#attributes']['class'][] = 'in';
            $format_id = $machine_name;
        }
        $build['panes'][] = $pane;
    }
    return drupal_render($build);
}
Esempio n. 22
0
/**
 * Implements template_preprocess_page.
 */
function mooc_foundation_access_preprocess_page(&$variables)
{
    // speedreader is enabled
    if (module_exists('speedreader')) {
        $variables['speedreader'] = TRUE;
    }
    // mespeak is enabled
    if (module_exists('mespeak')) {
        $variables['mespeak'] = TRUE;
    }
    // support for add child page shortcut
    $node = menu_get_object();
    if ($node && user_access('access printer-friendly version')) {
        $variables['tabs_extras'][200][] = '<hr>';
        $variables['tabs_extras'][200][] = l(t('Print'), 'book/export/html/' . arg(1));
    }
    $child_type = variable_get('book_child_type', 'book');
    if ($node && !empty($node->book) && (user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && isset($node->book['depth']) && $node->book['depth'] < MENU_MAX_DEPTH) {
        $variables['tabs_extras'][200][] = '<hr>';
        $variables['tabs_extras'][200][] = l(t('Add child page'), 'node/add/' . str_replace('_', '-', $child_type), array('query' => array('parent' => $node->book['mlid'])));
    }
    if (user_access('access contextual links')) {
        $variables['tabs_extras'][0][] = '<li class="cis_accessibility_check"></li>';
    }
}
Esempio n. 23
0
function phptemplate_username($object)
{
    if ($object->uid && $object->name) {
        // Shorten the name when it is too long or it will break many tables.
        if (arg(0) == 'user' or 'groups') {
            $name = $object->name;
        } else {
            if (drupal_strlen($object->name) > 20) {
                $name = drupal_substr($object->name, 0, 15) . '...';
            } else {
                $name = $object->name;
            }
        }
        if (user_access('access user profiles')) {
            $output = l($name, 'user/' . $object->uid, array('title' => t('View user profile.')));
        } else {
            $output = check_plain($name);
        }
    } else {
        if ($object->name) {
            // Sometimes modules display content composed by people who are
            // not registered members of the site (e.g. mailing list or news
            // aggregator modules). This clause enables modules to display
            // the true author of the content.
            if ($object->homepage) {
                $output = l($object->name, $object->homepage, array('class' => 'anonymous', 'title' => t('not verified')));
            } else {
                $output = '<span class="anonymous" title="' . t('not verified') . '">' . check_plain($object->name) . '</span>';
            }
        } else {
            $output = variable_get('anonymous', t('Anonymous'));
        }
    }
    return $output;
}
Esempio n. 24
0
function gitp_page_alter(&$page)
{
    if (arg(0) == 'node' && is_numeric(arg(1))) {
        $nid = arg(1);
        $node = node_load($nid);
        switch ($node->type) {
            case 'resources':
                $page['content_bottom'][] = field_view_field('node', $node, 'field_resources', 'full');
                unset($page['content']['system_main']['nodes'][$nid]['field_resources']);
                break;
            case 'news':
                break;
            default:
        }
    }
    if (isset($page['content']['system_main']['term_heading'])) {
        // This is a taxonomy term page
        if ($page['content']['system_main']['term_heading']['term']['#entity_type'] == 'taxonomy_term') {
            $page['content_bottom']['system_main']['nodes'] = $page['content']['system_main']['nodes'];
            $page['content_bottom']['system_main']['pager'] = $page['content']['system_main']['pager'];
            unset($page['content']['system_main']['nodes']);
            unset($page['content']['system_main']['pager']);
        }
    }
}
Esempio n. 25
0
function suitcase_preprocess_region(&$vars)
{
    if ($vars['region'] == 'content' && arg(0) == 'node' && is_numeric(arg(1)) && arg(2) !== 'edit') {
        $node = node_load(arg(1));
        if ($node->type == 'people' && !empty($node->field_people_category)) {
            $vars['categories'] = array();
            foreach ($node->field_people_category[LANGUAGE_NONE] as $category) {
                $tax = taxonomy_term_load($category['tid']);
                array_push($vars['categories'], $tax->name);
            }
        }
    } else {
        if ($vars['region'] == 'branding') {
            // Prepare Logo
            $vars['suitcase_config_logo'] = FALSE;
            $logo = variable_get('suitcase_config_logo');
            $vars['site_name'] = variable_get('site_name');
            if ($logo) {
                $logo_url = file_create_url($logo['uri']);
                $vars['suitcase_config_logo'] = '<div class="logo-img"><a href="' . $GLOBALS['base_url'] . '" rel="home" title="' . $vars['site_name'] . '" class="active"><img src="' . $logo_url . '" alt="Go to ' . $vars['site_name'] . ' home" id="logo" /></a></div>';
            }
            $vars['dept_url'] = variable_get('dept_url', $default = NULL);
            $vars['show_isu_nameplate'] = variable_get('suitcase_config_isu_nameplate_display', 1);
        }
    }
}
Esempio n. 26
0
/**
 * Preprocess breadcrumb
 * This will display only the inmediate parent of the current page and discard the rest
 */
function nbcu_breadcrumb($variables)
{
    $hideBreadcrumb = false;
    /* Check if breadcrump should be visible */
    if (is_numeric(arg(1))) {
        $node = node_load(arg(1));
        if (isset($node->field_hide_breadcrumb['und'][0]['value'])) {
            if ($node->field_hide_breadcrumb['und'][0]['value'] == 1) {
                $hideBreadcrumb = true;
            }
        }
    }
    $breadcrumb = $variables['breadcrumb'];
    //dpm($variables['breadcrumb']);
    if (!empty($breadcrumb)) {
        // Use CSS to hide titile .element-invisible.
        //$output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
        $breadcrumb[] = drupal_get_title();
        $total = count($breadcrumb);
        $breadcrumbHTML = $breadcrumb[$total - 2];
        //$output .= '<nav class="breadcrumb-nbc">' . implode(' » ', $breadcrumb) . '</nav>';
        $output = '<nav class="breadcrumb-nbc">' . $breadcrumbHTML . '</nav>';
        if ($hideBreadcrumb) {
            return '';
        } else {
            return $output;
        }
    }
}
Esempio n. 27
0
/**
 * Override or insert PHPTemplate variables into the templates.
 */
function deco_preprocess_html(&$vars)
{
    $vars['classes_array'] = isset($vars['classes_array']) ? $vars['classes_array'] : '';
    // variable to see if we have a triple sidebars and are not on block admin page
    $vars['sidebar_triple'] = FALSE;
    // add variable for block admin page
    $vars['block_admin'] = FALSE;
    if (arg(2) == 'block' && arg(3) == FALSE) {
        $vars['block_admin'] = TRUE;
        _deco_alert_layout($vars);
        $vars['classes_array'][] .= ' block-admin';
    } else {
        // convert secondary right sidebar to right sidebar if there's no right sidebar
        if (!empty($vars['page']['sidebar_right_sec']) && empty($vars['page']['sidebar_second'])) {
            $vars['page']['sidebar_second'] = $vars['page']['sidebar_right_sec'];
            $vars['page']['sidebar_right_sec'] = '';
        }
        // set a class on the body to allow easier css themeing based on the layout type
        if (!empty($vars['page']['sidebar_second']) && !empty($vars['page']['sidebar_right_sec']) && !empty($vars['page']['sidebar_first'])) {
            $vars['classes_array'][] .= ' sidebar-triple';
            $vars['sidebar_triple'] = TRUE;
        } elseif (!empty($vars['page']['sidebar_first']) && !empty($vars['page']['sidebar_second'])) {
            $vars['classes_array'][] .= ' sidebar-double';
        } elseif (!empty($vars['page']['sidebar_second']) && !empty($vars['page']['sidebar_right_sec'])) {
            $vars['classes_array'][] .= ' sidebar-right-double';
        } elseif (!empty($vars['page']['sidebar_first'])) {
            $vars['classes_array'][] .= ' sidebar-left';
        } elseif (!empty($vars['page']['sidebar_second']) || !empty($vars['page']['sidebar_right_sec'])) {
            $vars['classes_array'][] .= ' sidebar-right';
        }
        if (!empty($vars['page']['sidebar_second'])) {
            $vars['classes_array'][] .= ' rightbar';
        }
    }
}
Esempio n. 28
0
/**
 * implements hook_preprocess_page()
 *
 **/
function odsherredweb_preprocess_page(&$variables)
{
    $current_theme = variable_get('theme_default', 'none');
    // Search form
    $variables['simple_navigation_search'] = module_invoke('search', 'block_view', 'search');
    // Navigation
    $variables['sidebar_borger'] = _bellcom_generate_menu('menu-indhold', 'sidebar');
    $variables['sidebar_erhverv'] = _bellcom_generate_menu('menu-erhverv', 'sidebar');
    $variables['sidebar_politik'] = _bellcom_generate_menu('menu-politik', 'sidebar');
    // Add the site structure term id to the page div
    $node = node_load(arg(1));
    if (is_object($node) && isset($node->field_os2web_spotbox_sitestruct)) {
        $termParents = taxonomy_get_parents($node->field_os2web_spotbox_sitestruct[LANGUAGE_NONE][0]['tid']);
        $termId = 'tid-' . $node->field_os2web_spotbox_sitestruct[LANGUAGE_NONE][0]['tid'];
        $termIdParent = "";
        if (!empty($termParents)) {
            $termIdParent = 'tid-' . key($termParents);
        }
        $variables['attributes_array']['class'] = $termIdParent . ' ' . $termId;
    }
    // Paths
    $variables['path_js'] = base_path() . drupal_get_path('theme', $current_theme) . '/js';
    $variables['path_img'] = base_path() . drupal_get_path('theme', $current_theme) . '/images';
    $variables['path_css'] = base_path() . drupal_get_path('theme', $current_theme) . '/css';
    $variables['path_font'] = base_path() . drupal_get_path('theme', $current_theme) . '/font';
}
Esempio n. 29
-1
/**
 * Implements hook_form_system_theme_settings_alter()
 */
function drupalexp_form_system_theme_settings_alter(&$form, &$form_state, $form_id = NULL)
{
    $theme_key = arg(3);
    if (file_exists(drupal_get_path('theme', $theme_key) . '/template.php')) {
        require_once drupal_get_path('theme', $theme_key) . '/template.php';
    }
    $theme = drupalexp_get_theme();
    $form['drupalexp_settings'] = array('#type' => 'vertical_tabs');
    $form['drupal_core_settings'] = array('#type' => 'fieldset', '#title' => 'Drupal core', '#group' => 'drupalexp_settings', '#weight' => 99);
    $form['drupal_core_settings']['theme_settings'] = $form['theme_settings'];
    $form['drupal_core_settings']['logo'] = $form['logo'];
    $form['drupal_core_settings']['favicon'] = $form['favicon'];
    unset($form['theme_settings']);
    unset($form['logo']);
    unset($form['favicon']);
    drupalexp_layout_settings_form_alter($form);
    drupalexp_preset_settings_form_alter($form);
    drupalexp_basic_settings_form_alter($form);
    $form['breadcrumb'] = array('#type' => 'fieldset', '#title' => t('Breadcrumb settings'));
    $form['breadcrumb']['yourthemename_breadcrumb'] = array('#type' => 'select', '#title' => t('Display breadcrumb'), '#default_value' => theme_get_setting('yourthemename_breadcrumb'), '#options' => array('yes' => t('Yes'), 'admin' => t('Only in admin section'), 'no' => t('No')));
    $form['breadcrumb']['breadcrumb_options'] = array('#type' => 'container', '#states' => array('invisible' => array(':input[name="yourthemename_breadcrumb"]' => array('value' => 'no'))));
    $form['breadcrumb']['breadcrumb_options']['yourthemename_breadcrumb_separator'] = array('#type' => 'textfield', '#title' => t('Breadcrumb separator'), '#description' => t('Text only. DonÕt forget to include spaces.'), '#default_value' => theme_get_setting('yourthemename_breadcrumb_separator'), '#size' => 5, '#maxlength' => 10);
    $form['breadcrumb']['breadcrumb_options']['yourthemename_breadcrumb_home'] = array('#type' => 'checkbox', '#title' => t('Show home page link in breadcrumb'), '#default_value' => theme_get_setting('yourthemename_breadcrumb_home'));
    $form['breadcrumb']['breadcrumb_options']['yourthemename_breadcrumb_trailing'] = array('#type' => 'checkbox', '#title' => t('Append a separator to the end of the breadcrumb'), '#default_value' => theme_get_setting('yourthemename_breadcrumb_trailing'), '#description' => t('Useful when the breadcrumb is placed just before the title.'), '#states' => array('disabled' => array(':input[name="yourthemename_breadcrumb_title"]' => array('checked' => TRUE)), 'unchecked' => array(':input[name="yourthemename_breadcrumb_title"]' => array('checked' => TRUE))));
    $form['breadcrumb']['breadcrumb_options']['yourthemename_breadcrumb_title'] = array('#type' => 'checkbox', '#title' => t('Append the content title to the end of the breadcrumb'), '#default_value' => theme_get_setting('yourthemename_breadcrumb_title'), '#description' => t('Useful when the breadcrumb is not placed just before the title.'));
    $form['#submit'][] = 'drupalexp_form_system_theme_settings_submit';
    $form['#validate'][] = 'drupalexp_form_system_theme_settings_validate';
}
Esempio n. 30
-1
/**
 * Define some variables for use in theme templates.
 */
function redcrackle_process_page(&$variables)
{
    $tid = arg(2);
    // Assign site name and slogan toggle theme settings to variables.
    $variables['disable_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
    $variables['disable_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
    // Assign site name/slogan defaults if there is no value.
    if ($variables['disable_site_name']) {
        $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
    }
    if ($variables['disable_site_slogan']) {
        $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
    }
    if (!empty($tid) && arg(1) == 'term') {
        $term = taxonomy_term_load($tid);
        // Unset the default content
        //unset($variables['page']['content']);
        taxonomy_term_load($tid);
        $field_image = field_get_items('taxonomy_term', $term, 'field_image');
        $uri = !empty($field_image[0]['uri']) ? $field_image[0]['uri'] : '';
        $alt = !empty($field_image[0]['alt']) ? $field_image[0]['alt'] : '';
        if (!empty($uri)) {
            $variables['image_url'] = theme('image_style', array('path' => $uri, 'style_name' => 'large', 'alt' => $alt));
        }
        $variables['description'] = $term->description;
        $variables['theme_hook_suggestions'][] = 'page__taxonomy__services';
    }
}