Example #1
0
/**
 * Add current page to breadcrumb
 */
function urbanmediaspace_mothership_breadcrumb($breadcrumb)
{
    if (!empty($breadcrumb)) {
        // Find the source node for translation nodes.
        $source = translation_path_get_translations($_GET['q']);
        if ($source) {
            $source = $source['da'];
        } else {
            $source = $_GET['q'];
        }
        $menu = db_fetch_object(db_query("SELECT menu_name\n                                        FROM {menu_links}\n                                       WHERE link_path = '%s'", $source))->menu_name;
        // Change the active item to source node, to make active trail work and back
        // again to not crash other parts of the page, after getting the menu tree.
        $old_path = $_GET['q'];
        menu_set_active_item($source);
        $tree = menu_tree_page_data($menu);
        menu_set_active_item($old_path);
        // Find active trail.
        global $language;
        $trail = array();
        urbanmediaspace_mothership_active_trail($tree, $trail, $language->language);
        // Found trail, lets create links.
        if (!empty($trail)) {
            // Reset breadcrumb (do to menu_set_active_trail).
            $breadcrumb = array(l(t('Home'), '<front>'));
            // Build new breadcrumb.
            $size = count($trail) - 1;
            for ($i = 0; $i < $size; $i++) {
                $breadcrumb[] = l($trail[$i]['title'], $trail[$i]['link_path']);
            }
            // Insert project, if the 3dmodel is shown.
            if (arg(0) == '3dmodel') {
                $breadcrumb[] = l(t('Project'), 'projektet');
            }
            // Last item should not be at link.
            $breadcrumb[] = t($trail[$i]['title']);
        } else {
            if (arg(1) == 'apachesolr_search') {
                // Fix link to search.
                $breadcrumb[1] = l(t('Search'), 'search/apachesolr_search');
            } else {
                // User current page title, as no trail was found.
                $title = drupal_get_title();
                if (!empty($title)) {
                    $breadcrumb[] = t($title);
                }
            }
        }
        return '<div class="breadcrumb">' . implode(' > ', $breadcrumb) . '</div>';
    }
}
Example #2
0
/**
 * Implements template_preprocess_block().
 */
function ec_resp_preprocess_block(&$variables)
{
    global $user, $language;
    $block_no_panel = array('search' => 'form', 'print' => 'print-links', 'print_ui' => 'print-links', 'workbench' => 'block', 'social_bookmark' => 'social-bookmark', 'views' => 'view_ec_content_slider-block', 'om_maximenu' => array('om-maximenu-1', 'om-maximenu-2'), 'menu' => 'menu-service-tools', 'cce_basic_config' => 'footer_ipg');
    // List of all blocks that don't need their title to be displayed.
    $block_no_title = array('fat_footer' => 'fat-footer', 'om_maximenu' => array('om-maximenu-1', 'om-maximenu-2'), 'menu' => 'menu-service-tools', 'cce_basic_config' => 'footer_ipg');
    $block_no_body_class = array();
    $panel = TRUE;
    foreach ($block_no_panel as $key => $value) {
        if ($variables['block']->module == $key) {
            if (is_array($value)) {
                foreach ($value as $delta) {
                    if ($variables['block']->delta == $delta) {
                        $panel = FALSE;
                        break;
                    }
                }
            } else {
                if ($variables['block']->delta == $value) {
                    $panel = FALSE;
                    break;
                }
            }
        }
    }
    $title = TRUE;
    foreach ($block_no_title as $key => $value) {
        if ($variables['block']->module == $key) {
            if (is_array($value)) {
                foreach ($value as $delta) {
                    if ($variables['block']->delta == $delta) {
                        $title = FALSE;
                        break;
                    }
                }
            } else {
                if ($variables['block']->delta == $value) {
                    $title = FALSE;
                    break;
                }
            }
        }
    }
    $body_class = TRUE;
    foreach ($block_no_body_class as $key => $value) {
        if ($variables['block']->module == $key && $variables['block']->delta == $value) {
            $body_class = FALSE;
        }
    }
    $variables['panel'] = $panel;
    $variables['title'] = $title;
    $variables['body_class'] = $body_class;
    if (isset($variables['block']->bid)) {
        switch ($variables['block']->bid) {
            case 'locale-language':
                $languages = language_list();
                $items = array();
                $items[] = array('data' => '<span class="off-screen">' . t("Current language") . ':</span> ' . $language->language, 'class' => array('selected'), 'title' => $language->native, 'lang' => $language->language);
                // Get path of translated content.
                $translations = translation_path_get_translations(current_path());
                $language_default = language_default();
                foreach ($languages as $language_object) {
                    $prefix = $language_object->language;
                    $language_name = $language_object->name;
                    if (isset($translations[$prefix])) {
                        $path = $translations[$prefix];
                    } else {
                        $path = current_path();
                    }
                    // Get the related url alias
                    // Check if the multisite language negotiation
                    // with suffix url is enabled.
                    $language_negociation = variable_get('language_negotiation_language');
                    if (isset($language_negociation['locale-url-suffix'])) {
                        $delimiter = variable_get('language_suffix_delimiter', '_');
                        $alias = drupal_get_path_alias($path, $prefix);
                        if ($alias == variable_get('site_frontpage', 'node')) {
                            $path = $prefix == 'en' ? '' : 'index';
                        } else {
                            if ($alias != $path) {
                                $path = $alias;
                            } else {
                                $path = drupal_get_path_alias(isset($translations[$language_name]) ? $translations[$language_name] : $path, $language_name);
                            }
                        }
                    } else {
                        $path = drupal_get_path_alias($path, $prefix);
                    }
                    // Add enabled languages.
                    if ($language_name != $language->name) {
                        $items[] = array('data' => l($language_name, filter_xss($path), array('attributes' => array('hreflang' => $prefix, 'lang' => $prefix, 'title' => $language_name), 'language' => $language_object)));
                    }
                }
                $variables['language_list'] = theme('item_list', array('items' => $items));
                break;
            case 'system-user-menu':
                if ($user->uid) {
                    $name = theme('username', array('account' => $user, 'nolink' => TRUE));
                    $variables['welcome_message'] = "<div class='username'>" . t('Welcome,') . ' <strong>' . $name . '</strong></div>';
                }
                $menu = menu_navigation_links("user-menu");
                $items = array();
                // Manage redirection after login.
                $status = drupal_get_http_header('status');
                if (strpos($status, '404') !== FALSE) {
                    $dest = 'home';
                } elseif (strpos(current_path(), 'user/register') !== FALSE) {
                    $dest = 'home';
                } elseif (strpos(current_path(), 'user/login') !== FALSE) {
                    $dest = 'home';
                } else {
                    $dest = drupal_get_path_alias();
                }
                foreach ($menu as $item_id) {
                    // Get icon links to menu item.
                    $icon = isset($item_id['attributes']['data-image']) ? $item_id['attributes']['data-image'] : '';
                    // Get display title option.
                    $display_title = isset($item_id['attributes']['data-display-title']) ? $item_id['attributes']['data-display-title'] : 1;
                    // Add the icon.
                    if ($icon) {
                        if ($display_title) {
                            $item_id['title'] = '<span class="glyphicon glyphicon-' . $icon . '" aria-hidden="true"></span> ' . $item_id['title'];
                        } else {
                            // If the title is not supposed to be displayed, add a visually
                            // hidden title that is accessible for screen readers.
                            $item_id['title'] = '<span class="glyphicon glyphicon-' . $icon . ' menu-no-title" aria-hidden="true"></span><span class="sr-only">' . $item_id['title'] . '</span>';
                        }
                    }
                    // Add redirection for login, logout and register.
                    if ($item_id['href'] == 'user/login' || $item_id['href'] == 'user/register') {
                        $item_id['query']['destination'] = $dest;
                    }
                    if ($item_id['href'] == 'user/logout') {
                        $item_id['query']['destination'] = '<front>';
                    }
                    // Add icon before menu item
                    // TODO: make it editable in administration.
                    switch ($item_id['href']) {
                        case 'user':
                            $item_id['attributes']['type'] = 'user';
                            break;
                        case 'user/login':
                            $item_id['attributes']['type'] = 'login';
                            break;
                        case 'user/logout':
                            $item_id['attributes']['type'] = 'logout';
                            break;
                        case 'admin/workbench':
                            $item_id['attributes']['type'] = 'workbench';
                            break;
                    }
                    $item_id['html'] = TRUE;
                    $items[] = l($item_id['title'], $item_id['href'], $item_id);
                }
                $variables['menu_items'] = implode('', $items);
                break;
            case 'easy_breadcrumb-easy_breadcrumb':
                $variables['menu_breadcrumb'] = menu_tree('menu-breadcrumb-menu');
                break;
        }
    }
}
function _opensourcery_rebuild_secondary_links()
{
    // menus are built in English, so set active trail there
    $new_paths = translation_path_get_translations($_GET['q']);
    // save current path
    $current = $_GET['q'];
    if ($new_paths['en']) {
        menu_set_active_item($new_paths['en']);
    }
    $secondary_links = menu_secondary_links();
    // reset active item
    menu_set_active_item($current);
    return $secondary_links;
}
Example #4
0
/**
 * Implements template_preprocess_block().
 *
 * Backport from the ec_resp theme (2.0).
 */
function ec_resp_17_preprocess_block(&$variables)
{
    global $language;
    if (isset($variables['block']->bid) && $variables['block']->bid == 'locale-language') {
        $languages = language_list();
        $items = array();
        $items[] = array('data' => '<span class="off-screen">' . t("Current language") . ':</span> ' . $language->language, 'class' => array('selected'), 'title' => $language->native, 'lang' => $language->language);
        // Get path of translated content.
        $translations = translation_path_get_translations(current_path());
        $language_default = language_default();
        foreach ($languages as $language_object) {
            $prefix = $language_object->language;
            $language_name = $language_object->name;
            if (isset($translations[$prefix])) {
                $path = $translations[$prefix];
            } else {
                $path = current_path();
            }
            // Get the related url alias
            // Check if the multisite language negotiation
            // with suffix url is enabled.
            $language_negociation = variable_get('language_negotiation_language');
            if (isset($language_negociation['locale-url-suffix'])) {
                $delimiter = variable_get('language_suffix_delimiter', '_');
                $alias = drupal_get_path_alias($path, $prefix);
                if ($alias == variable_get('site_frontpage', 'node')) {
                    $path = $prefix == 'en' ? '' : 'index';
                } else {
                    if ($alias != $path) {
                        $path = $alias;
                    } else {
                        $path = drupal_get_path_alias(isset($translations[$language_name]) ? $translations[$language_name] : $path, $language_name);
                    }
                }
            } else {
                $path = drupal_get_path_alias($path, $prefix);
            }
            // Add enabled languages.
            if ($language_name != $language->name) {
                $items[] = array('data' => l($language_name, filter_xss($path), array('attributes' => array('hreflang' => $prefix, 'lang' => $prefix, 'title' => $language_name), 'language' => $language_object)));
            }
        }
        $variables['language_list'] = theme('item_list', array('items' => $items));
    }
}