예제 #1
0
function hc_bootstrap_preprocess_page(&$variables)
{
    //Set default section to display
    if (drupal_is_front_page()) {
        menu_set_active_item('food-and-groceries');
    }
    /**
    * Add page template suggestions based on the aliased path. For instance, if the current
    * page has an alias of about/history/early, we'll have templates of:
    * page-about-history-early.tpl.php, page-about-history.tpl.php, page-about.tpl.php
    * Whichever is found first is the one that will be used.
    */
    if (module_exists('path')) {
        $alias = drupal_get_path_alias(str_replace('/edit', '', $_GET['q']));
        if ($alias != $_GET['q']) {
            $template_filename = 'page';
            foreach (explode('/', $alias) as $path_part) {
                $template_filename = $template_filename . '-' . $path_part;
                $vars['template_files'][] = $template_filename;
            }
        }
    }
    //Add shopping cart to available output
    $variables['side_cart'] = block_render('views', 'sidebar_cart-cart');
}
예제 #2
0
 /**
  * @param  null                                                                    $path
  * @param  bool                                                                    $deliver
  * @return object|Response
  * @Route("/{path}", name="controller", defaults={"deliver" = true}, requirements={"path" = ".+"})
  * @throws \Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
  */
 public function callbackAction($path = null, $deliver = true)
 {
     menu_set_active_item($path);
     $page_callback_result = menu_execute_active_handler($path, $deliver);
     if (is_int($page_callback_result)) {
         switch ($page_callback_result) {
             case MENU_NOT_FOUND:
                 // Print a 404 page.
                 throw new NotFoundHttpException();
                 break;
             case MENU_ACCESS_DENIED:
                 // Print a 403 page.
                 throw new AccessDeniedHttpException();
                 break;
             case MENU_SITE_OFFLINE:
                 // Print a 503 page.
                 throw new ServiceUnavailableHttpException();
                 break;
         }
     } elseif (!$deliver) {
         $content = drupal_render($page_callback_result);
         return new Response($content);
     } else {
         $response = $this->get('bangpound_drupal.response');
         $response->setContent($page_callback_result);
         return $response;
     }
 }
예제 #3
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>';
    }
}
 /**
  * Main entry point to clone an item.
  */
 function clone_page($js, $input, $original, $step = NULL)
 {
     drupal_set_title($this->get_page_title('clone', $original), PASS_THROUGH);
     // If a step not set, they are trying to create a new clone. If a step
     // is set, they're in the process of cloning an item.
     if (!empty($this->plugin['use wizard']) && !empty($step)) {
         $item = $this->edit_cache_get(NULL, 'clone');
     }
     if (empty($item)) {
         // To make a clone of an item, we first export it and then re-import it.
         // Export the handler, which is a fantastic way to clean database IDs out of it.
         $export = ctools_export_crud_export($this->plugin['schema'], $original);
         $item = ctools_export_crud_import($this->plugin['schema'], $export);
         $item->{$this->plugin['export']['key']} = 'clone_of_' . $item->{$this->plugin['export']['key']};
     }
     // Tabs and breadcrumb disappearing, this helps alleviate through cheating.
     // ...not sure this this is the best way.
     $trail = menu_set_active_item(ctools_export_ui_plugin_base_path($this->plugin));
     $name = $original->{$this->plugin['export']['key']};
     $form_state = array('plugin' => $this->plugin, 'object' => &$this, 'ajax' => $js, 'item' => $item, 'op' => 'add', 'form type' => 'clone', 'original name' => $name, 'rerender' => TRUE, 'no_redirect' => TRUE, 'step' => $step, 'function args' => func_get_args());
     $output = $this->edit_execute_form($form_state);
     if (!empty($form_state['executed']) && empty($form_state['rebuild'])) {
         $this->redirect($form_state['op'], $form_state['item']);
     }
     return $output;
 }
예제 #5
0
/**
 * Helper function that builds the nested lists of a nice menu.
 *
 * @param $menu
 *   Menu array from which to build the nested lists.
 */
function lullacog_nice_menu_build($menu)
{
    // Retrieve original path so we can repair it after our hack.
    $original_path = $_GET['q'];
    if (function_exists('context_active_values')) {
        // Retrieve the first active menu path found.
        $active_paths = context_active_values('menu');
        if (!empty($active_paths)) {
            $path = current($active_paths);
            if (menu_get_item($path)) {
                menu_set_active_item($path);
            }
        }
    }
    $output = theme_nice_menu_build($menu);
    menu_set_active_item($original_path);
    return $output;
}
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;
}
예제 #7
0
/**
 * Override or insert variables into the page template.
 */
function loop_preprocess_page(&$variables)
{
    global $user;
    $arg = arg();
    if ($user->uid > 0) {
        // Prepare system search block for page.tpl.
        if (module_exists('search_api_page')) {
            $variables['search'] = module_invoke('search_api_page', 'block_view', 'default');
        } else {
            $variables['search'] = module_invoke('search', 'block_view', 'form');
        }
    }
    // Drupal core got a minor bug with active trail on 'My account'.
    if ($arg[0] == 'user' && isset($arg[1]) && is_numeric($arg[1])) {
        if (!isset($arg[2])) {
            menu_set_active_item('user');
        } else {
            if ($arg[2] != 'messages') {
                menu_set_active_item('user');
            }
        }
    }
    if ($variables['is_front']) {
        $update_script_path = $GLOBALS['base_root'] . '/' . path_to_theme() . '/scripts/frontpage-column-width.js';
        drupal_add_js($update_script_path, 'file');
    }
    // Remove search form when no search results are found.
    if (isset($variables['page']['content']['system_main']['results']) && $variables['page']['content']['system_main']['results']['#results']['result count'] == 0) {
        unset($variables['page']['content']['system_main']['form']);
    }
    // Fetch a user block (my content) on user pages).
    if ($arg[0] == 'user') {
        $variables['loop_user_my_content'] = module_invoke('loop_user', 'block_view', 'loop_user_my_content');
        if (module_exists('pcp')) {
            $variables['user_completion_block'] = module_invoke('pcp', 'block_view', 'pcp_profile_percent_complete');
        }
        hide($variables['tabs']['#secondary']);
    }
    if ($arg[0] == 'front') {
        $variables['loop_frontpage_welcometext'] = module_invoke('loop_frontpage', 'block_view', 'loop_frontpage_welcometext');
    }
    // Load Loop primary menu.
    if (module_exists('loop_navigation') && $user->uid > 0) {
        $variables['main_menu_block'] = module_invoke('system', 'block_view', 'main-menu');
        $variables['management_menu_block'] = module_invoke('system', 'block_view', 'management');
        $variables['primary_menu_block'] = module_invoke('menu', 'block_view', 'menu-loop-primary-menu');
    }
    // Load Loop user menu.
    if (module_exists('loop_user') && $arg[0] == 'user') {
        $variables['user_menu_block'] = module_invoke('system', 'block_view', 'user-menu');
        $variables['user_public_block'] = module_invoke('loop_user', 'block_view', 'loop_user_my_content');
    }
    // Check if we are using a panel page to define layout.
    $panel = panels_get_current_page_display();
    if (empty($panel)) {
        $variables['no_panel'] = TRUE;
        if ($arg['0'] == 'search') {
            $variables['layout_class'] = 'layout-full-width';
        } else {
            $variables['layout_class'] = 'layout-default-inverted';
        }
    }
    // We add logout link here to be able to always print it last. (Hence not part
    // of any menu).
    if ($user->uid > 0 && !(array_key_exists('hide_logout', $variables) && $variables['hide_logout'])) {
        $variables['logout_link'] = l(t('Logout'), 'user/logout', array('attributes' => array('class' => array('nav--logout'))));
    }
    // Set title for page types. For some reason it does not work through page
    // title module.
    if (!empty($variables['node'])) {
        if ($variables['node']->type == 'page') {
            // Set page title.
            drupal_set_title($variables['node']->title);
        }
    }
}
예제 #8
0
 /**
  * Controller returns an entire Drupal page as a Symfony response.
  *
  * @param $q
  * @param $router_item
  *
  * @return Response
  *
  * @see drupal_deliver_page
  * @Route(requirements={"q" = "\.+"}, defaults={"_legacy" = "drupal"})
  * @ParamConverter("router_item", converter="drupal.router_item")
  */
 public function deliverAction($q, $router_item)
 {
     menu_set_active_item($q);
     $page_callback_result = $this->executeAction($router_item);
     $default_delivery_callback = NULL;
     if (!isset($default_delivery_callback)) {
         $default_delivery_callback = $router_item['delivery_callback'];
     }
     $delivery_callback = !empty($default_delivery_callback) ? $default_delivery_callback : 'drupal_deliver_html_page';
     // Give modules a chance to alter the delivery callback used, based on
     // request-time context (e.g., HTTP request headers).
     drupal_alter('page_delivery_callback', $delivery_callback);
     if (function_exists($delivery_callback)) {
         $delivery_callback = function ($page_callback_result) use($delivery_callback) {
             ob_start();
             $delivery_callback($page_callback_result);
             return new Response((string) ob_get_clean());
         };
         return $delivery_callback($page_callback_result);
     } else {
         // If a delivery callback is specified, but doesn't exist as a function,
         // something is wrong, but don't print anything, since it's not known
         // what format the response needs to be in.
         watchdog('delivery callback not found', 'callback %callback not found: %q.', array('%callback' => $delivery_callback, '%q' => $_GET['q']), WATCHDOG_ERROR);
     }
 }
<?php menu_set_active_item('news-and-media/focus-newsletter'); ?>
<?php print theme('breadcrumb', drupal_get_breadcrumb()); ?>
<div class="vertical_tab_container">
	<div class="vertical_tab_elements">
		<?php print theme('wistar_vertical_tabs', 3);?>
		<?php menu_set_active_item('node/'.$node->nid); ?>
		<div class="content">			
			<div id="content-header">
				<?php print theme('wistar_content_heading', null, t('Focus Newsletter'));?>
				<div id="newsletter-navigation">
					<?php $node->prevnext_type = 'newsletter'; ?>
					<?php $navigation = theme('wistar_page_navigation', $node); 
						$navigation = str_replace('newsletter','Issue',$navigation);
						echo $navigation;
					?>
				</div>
			</div>
			<div id="node-<?php print $node->nid; ?>" class="node-page-newsletter node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> clear-block">
				<div class="section">
					<div class="wysiwyg">	
						<div class="content">
							<?php if(!empty($node->field_newsletter_image[0]['view'])): ?>
								<?php $render_image = $node->field_newsletter_image[0]['view']; ?>
								<?php if(!empty($node->field_newsletter_image_link[0]['url'])): ?>
									<?php $url = $node->field_newsletter_image_link[0]['url']; ?>
									<div class="image"><?php print l($render_image, $url, array('html' => TRUE)); ?></div>
								<?php else: ?>
									<div class="image"><?php print $node->field_newsletter_image[0]['view']; ?></div>
								<?php endif; ?>
							<?php endif;?>
							<div class="content-holder">
예제 #10
0
/**
 * Implements template_preprocess_page().
 *
 * @see gbif_navigation_node_view().
 * @see http://www.dibe.gr/blog/set-path-determining-active-trail-drupal-7-menu
 * @see https://drupal.org/node/1292590 for setting active user menu.
 */
function bvng_preprocess_page(&$variables)
{
    $req_path = $variables['page']['content']['requested_path'];
    $altered_path = FALSE;
    if (!empty($variables['node']->type)) {
        switch ($variables['node']->type) {
            case 'newsarticle':
                $altered_path = drupal_get_normal_path('newsroom/news');
                // taxonomy/term/566
                $variables['node']->type_title = t('GBIF News');
                break;
            case 'usesofdata':
                $altered_path = drupal_get_normal_path('newsroom/uses');
                // taxonomy/term/567
                $variables['node']->type_title = t('Featured Data Use');
                break;
            case 'event_ims':
                $altered_path = drupal_get_normal_path('newsroom/events');
                // taxonomy/term/569
                $variables['node']->type_title = t('Event Details');
                break;
            case 'resource_ims':
                $altered_path = drupal_get_normal_path('resources/summary');
                // taxonomy/term/569
                $variables['node']->type_title = t('Resource Details');
                break;
            case 'generictemplate':
                if (drupal_match_path($req_path, 'node/241')) {
                    $altered_path = 'user';
                }
                break;
        }
    } elseif (strpos($req_path, 'allnewsarticles') !== FALSE) {
        $altered_path = drupal_get_normal_path('newsroom/news');
        // taxonomy/term/566
    } elseif (strpos($req_path, 'alldatausearticles') !== FALSE) {
        $altered_path = drupal_get_normal_path('newsroom/uses');
        // taxonomy/term/567
    } elseif (strpos($req_path, 'resources') !== FALSE) {
        $altered_path = drupal_get_normal_path('resources/summary');
        // taxonomy/term/764
    } elseif (strpos($req_path, 'events') !== FALSE) {
        $altered_path = drupal_get_normal_path('newsroom/events');
        // taxonomy/term/569
    } elseif (drupal_match_path($req_path, 'user') || drupal_match_path($req_path, 'user/*')) {
        $altered_path = 'user';
    } elseif (strpos($req_path, 'mendeley') !== FALSE) {
        $altered_path = drupal_get_normal_path('mendeley');
    }
    if ($altered_path) {
        if ($altered_path != 'user') {
            menu_tree_set_path('gbif-menu', $altered_path);
            // can't use menu_tree_set_path for user, it'll mess the tabs.
        }
        menu_set_active_item($altered_path);
    } else {
        $active_path = menu_tree_get_path('gbif-menu');
        menu_tree_set_path('gbif-menu', $active_path);
        menu_set_active_item($req_path);
    }
    if (isset($variables['page']['content']['system_main']['nodes'])) {
        $node_count = _bvng_node_count($variables['page']['content']['system_main']['nodes']);
    } else {
        $node_count = NULL;
    }
    $variables['page']['highlighted_title'] = _bvng_get_title_data($node_count, $variables['user'], $req_path);
    // Manually set page title.
    if ($req_path == 'taxonomy/term/565') {
        drupal_set_title(t('GBIF Newsroom'));
    }
    // Relocate the search form to region 'highlighted'.
    if (isset($variables['page']['content']['system_main']['search_form'])) {
        unset($variables['page']['content']['system_main']['search_form']['advanced']);
        $search_form = $variables['page']['content']['system_main']['search_form'];
        $search_form['#attributes']['class'][] = 'banner_search_input';
        $variables['page']['highlighted'][] = $search_form;
        unset($variables['page']['content']['system_main']['search_form']);
    }
    // Load javascript only when needed.
    switch ($req_path) {
        case 'node/223':
            // contact/directoryofcontacts
            drupal_add_js(drupal_get_path('theme', 'bvng') . '/js/contacts.js', array('type' => 'file', 'scope' => 'footer'));
            break;
    }
    if (drupal_is_front_page()) {
        drupal_add_js(libraries_get_path('leaflet') . '/leaflet.js', array('type' => 'file', 'scope' => 'footer', 'weight' => 10));
        drupal_add_js(libraries_get_path('moment') . '/moment.js', array('type' => 'file', 'scope' => 'footer', 'weight' => 20));
        drupal_add_js(drupal_get_path('theme', 'bvng') . '/js/cfg', array('type' => 'file', 'scope' => 'footer', 'weight' => 30));
        drupal_add_js(drupal_get_path('theme', 'bvng') . '/js/frontPageWidgets.js', array('type' => 'file', 'scope' => 'footer', 'weight' => 50));
        $variables['search_form'] = module_invoke('search', 'block_view', 'search_form');
        $variables['logo'] = drupal_get_path('theme', 'bvng') . '/images/logo_white.png';
        $variables['site_name'] = "Global Biodiversity Information Facility";
    }
    // Load javascript for every pages.
    // drupal_add_js(drupal_get_path('theme', 'bvng') . '/js/bootstrap.min.js', array('type' => 'file', 'scope' => 'footer'));
    drupal_add_js('http://dev.gbif.org/issues/s/en_UKkby86d-1988229788/6096/5/1.4.0-m2/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector.js?collectorId=a2e9eca4', array('type' => 'file', 'scope' => 'footer', 'async_js' => TRUE));
}
<?php
	$technology_tags_vid = 4;
	$technology_section_vid = 5;
	$technology_tags = array();
	if(count($node->taxonomy)) {
		foreach($node->taxonomy as $tid => $term) {
			if($term->vid == $technology_tags_vid) {
				$technology_tags[] = $term->name;
			}
			if($term->vid == $technology_section_vid) {
				$technology_section = $term->name;
				menu_set_active_item('technology-transfer/technologies/' . strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $technology_section)));
			}
		}
	}

	$sections = array();
	
	if(count($node->field_technology_inventor_ref)) {
		foreach($node->field_technology_inventor_ref as $idx => $ref) {
			$sections['Inventor(s)'] .= '<div>'	. $ref['view'] . '</div>';
		}
	}
		
	if(isset($node->field_technology_inventors[0]['safe']) && $inventors = $node->field_technology_inventors[0]['safe']) {
		$sections['Inventor(s)'] .= $inventors;
	}
	
	$sections['Tech ID'] = (isset($node->field_technology_id[0]['safe']) && $id = $node->field_technology_id[0]['safe']) ? $id : null;
	$sections['Background'] = (isset($node->field_technology_background[0]['safe']) && $background = $node->field_technology_background[0]['safe']) ? $background : null;
	$sections['Description'] = (isset($node->field_technology_description[0]['safe']) && $description = $node->field_technology_description[0]['safe']) ? $description : null;