Beispiel #1
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;
    }
}
Beispiel #2
0
 /**
  * if we are using a theming system, invoke theme, else just print the
  * content
  *
  * @param string  $content the content that will be themed
  * @param boolean $print   are we displaying to the screen or bypassing theming?
  * @param boolean $maintenance  for maintenance mode
  *
  * @return void           prints content on stdout
  * @access public
  */
 function theme(&$content, $print = FALSE, $maintenance = FALSE)
 {
     $ret = FALSE;
     // TODO: Split up; this was copied verbatim from CiviCRM 4.0's multi-UF theming function
     // but the parts should be copied into cleaner subclass implementations
     $config = CRM_Core_Config::singleton();
     if ($config->userSystem->is_drupal && function_exists('theme') && !$print) {
         if ($maintenance) {
             drupal_set_breadcrumb('');
             drupal_maintenance_theme();
             if ($region = CRM_Core_Region::instance('html-header', FALSE)) {
                 CRM_Utils_System::addHTMLHead($region->render(''));
             }
             print theme('maintenance_page', array('content' => $content));
             exit;
         }
         $ret = TRUE;
         // TODO: Figure out why D7 returns but everyone else prints
     }
     $out = $content;
     $config =& CRM_Core_Config::singleton();
     if (!$print && $config->userFramework == 'WordPress') {
         if (is_admin()) {
             require_once ABSPATH . 'wp-admin/admin-header.php';
         } else {
             // FIX ME: we need to figure out to replace civicrm content on the frontend pages
         }
     }
     if ($ret) {
         return $out;
     } else {
         print $out;
     }
 }
Beispiel #3
0
/**
 * @file guifi_gml.inc.php
 */
function guifi_gml($zid, $action = "help", $type = 'gml')
{
    if ($action == "help") {
        $zone = db_fetch_object(db_query('SELECT title, nick FROM {guifi_zone} WHERE id = %d', $zid));
        drupal_set_breadcrumb(guifi_zone_ariadna($zid));
        $output = '<div id="guifi">';
        $output .= '<h2>' . t('Zone %zname%', array('%zname%' => $zone->title)) . '</h2>';
        $output .= '<p>' . t('You must specify which data do you want to export, the following options are available:') . '</p>';
        $output .= '<ol><li>' . l(t('Nodes'), "guifi/gml/" . $zid . "/nodes", array('title' => t('export zone nodes in gml format'))) . '</li>';
        $output .= '<li>' . l(t('Links'), "guifi/gml/" . $zid . "/links", array('title' => t('export zone links in gml format'))) . '</li></ol>';
        $output .= '<p>' . t('The <a href="http://opengis.net/gml/">GML</a> is a Markup Language XML for Geography described at the <a href="http://www.opengeospatial.org/">Open Geospatial Consortium</a>') . '</p>';
        $output .= '<p>' . t('<b>IMPORTANT LEGAL NOTE:</b> This network information is under the <a href="http://guifi.net/ComunsSensefils/">Comuns Sensefils</a> license, and therefore, available for any other network under the same licensing. If is not your case, you should ask for permission before using it.</a>') . '</p>';
        $output .= "</div>";
        print theme('page', $output, t('export %zname% in GML format', array('%zname%' => $z->title)));
        return;
    }
    switch ($action) {
        case 'links':
            guifi_gml_links($zid, $type);
            break;
        case 'nodes':
            guifi_gml_nodes($zid, $type);
            break;
    }
}
 /**
  * if we are using a theming system, invoke theme, else just print the
  * content
  *
  * @param string  $type    name of theme object/file
  * @param string  $content the content that will be themed
  * @param array   $args    the args for the themeing function if any
  * @param boolean $print   are we displaying to the screen or bypassing theming?
  * @param boolean $ret     should we echo or return output
  * @param boolean $maintenance  for maintenance mode
  *
  * @return void           prints content on stdout
  * @access public
  */
 function theme($type, &$content, $args = NULL, $print = FALSE, $ret = FALSE, $maintenance = FALSE)
 {
     // TODO: Split up; this was copied verbatim from CiviCRM 4.0's multi-UF theming function
     // but the parts should be copied into cleaner subclass implementations
     if (function_exists('theme') && !$print) {
         if ($maintenance) {
             drupal_set_breadcrumb('');
             drupal_maintenance_theme();
             print theme('maintenance_page', array('content' => $content));
             exit;
         }
         $out = $content;
         $ret = TRUE;
     } else {
         $out = $content;
     }
     $config =& CRM_Core_Config::singleton();
     if (!$print && $config->userFramework == 'WordPress') {
         if (is_admin()) {
             require_once ABSPATH . 'wp-admin/admin-header.php';
         } else {
             // FIX ME: we need to figure out to replace civicrm content on the frontend pages
         }
     }
     if ($ret) {
         return $out;
     } else {
         print $out;
     }
 }
Beispiel #5
0
/**
 * Implements template_preprocess_html()
 */
function mica_bootstrap_preprocess_html(&$variables)
{
    // hide breadcrumb on home page
    if ($variables['is_front']) {
        drupal_set_breadcrumb(array());
    }
}
Beispiel #6
0
/**
 * Override or insert variables into the page template.
 */
function casasrealprod_process_page(&$variables)
{
    // Hook into color.module.
    if (module_exists('color')) {
        _color_page_alter($variables);
    }
    // Always print the site name and slogan, but if they are toggled off, we'll
    // just hide them visually.
    $variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
    $variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
    if ($variables['hide_site_name']) {
        // If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
        $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
    }
    if ($variables['hide_site_slogan']) {
        // If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
        $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
    }
    // Since the title and the shortcut link are both block level elements,
    // positioning them next to each other is much simpler with a wrapper div.
    if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
        // Add a wrapper div using the title_prefix and title_suffix render elements.
        $variables['title_prefix']['shortcut_wrapper'] = array('#markup' => '<div class="shortcut-wrapper clearfix">', '#weight' => 100);
        $variables['title_suffix']['shortcut_wrapper'] = array('#markup' => '</div>', '#weight' => -99);
        // Make sure the shortcut link is the first item in title_suffix.
        $variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
    }
    if (isset($variables['node']) && $variables['node']->type == "casas" && strpos(drupal_get_path_alias(), '/booking') > 0) {
        drupal_add_js(drupal_get_path('theme', 'casasrealprod') . '/js/casas_booking_manager.js');
        $breadcrumbs = array();
        $breadcrumbs[] = l(t('Home'), '<front>');
        $breadcrumbs[] = l(t('Las Casas'), 'node/10');
        $breadcrumbs[] = l($variables['node']->title, 'node/' . $variables['node']->nid);
        drupal_set_breadcrumb($breadcrumbs);
        $variables['title'] = t('Search for Availability');
        $variables['breadcrumb'] = theme('breadcrumb', array('breadcrumb' => drupal_get_breadcrumb()));
    }
    if (strpos(drupal_get_path_alias(), 'bookings') !== FALSE) {
        drupal_add_js(drupal_get_path('theme', 'casasrealprod') . '/js/casas_booking_manager.js');
    }
    if (strpos(drupal_get_path_alias(), 'checkout') !== FALSE) {
        $parts = explode('/', current_path());
        $last = array_pop($parts);
        $title = drupal_get_title();
        if (is_numeric($last)) {
            $title = t('Fill your personal data');
        } else {
            if ($last == 'review') {
                $title = t('Review order');
            }
        }
        $variables['title'] = $title;
    }
}
/**
 * Override theme_breadcrumb().
 */
function maxhealthcare_breadcrumb($breadcrumb)
{
    $links = array();
    $path = '';
    // Get URL arguments
    $arguments = explode('/', request_uri());
    // Remove empty values
    foreach ($arguments as $key => $value) {
        if (empty($value)) {
            unset($arguments[$key]);
        }
    }
    $arguments = array_values($arguments);
    // Add 'Home' link
    $links[] = l(t('Home'), '<front>');
    // Add other links
    if (!empty($arguments)) {
        foreach ($arguments as $key => $value) {
            // Don't make last breadcrumb a link
            if ($key == count($arguments) - 1) {
                $links[] = drupal_get_title();
            } else {
                if (!empty($path)) {
                    $path .= '/' . $value;
                } else {
                    $path .= $value;
                }
                $links[] = l(drupal_ucfirst($value), $path);
            }
        }
    }
    // Set custom breadcrumbs
    drupal_set_breadcrumb($links);
    // Get custom breadcrumbs
    $breadcrumb = drupal_get_breadcrumb();
    // Hide breadcrumbs if only 'Home' exists
    if (count($breadcrumb) > 1) {
        return '<div class="breadcrumb">' . implode(' &raquo; ', $breadcrumb) . '</div>';
    }
}
Beispiel #8
0
/**
 * Breadcrumb themeing
 */
function ciclo20v2_breadcrumb($breadcrumb)
{
    if (!empty($breadcrumb)) {
        $html = '';
        if (preg_match('/^og\\/users\\/\\d+\\/invite$/', $_GET[q]) == 1) {
            $node = node_load(arg(2));
            if (!empty($node)) {
                $links = array();
                $links[] = l(t('Home'), '<front>');
                $links[] = l(t('Groups'), 'og');
                $links[] = l($node->title, 'node/' . $node->nid);
                $links[] = l(t('List'), 'og/users/' . $node->nid);
                // Set custom breadcrumbs
                drupal_set_breadcrumb($links);
                // Get custom breadcrumbs
                $breadcrumb = drupal_get_breadcrumb();
            }
        }
        if (count($breadcrumb) > 1) {
            $html .= '<div class="breadcrumb">' . implode(' &gt; ', $breadcrumb) . '</div>';
        }
        return $html;
    }
}
 /**
  * Return the generated form output.
  * @param array $args List of parameter values passed through to the form depending on how the form has been configured.
  * This array always contains a value for language.
  * @param object $node The Drupal node object.
  * @param array $response When this form is reloading after saving a submission, contains the response from the service call.
  * Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data).
  * @return Form HTML.
  * @todo: Implement this method 
  */
 public static function get_form($args, $node, $response = null)
 {
     global $user;
     $checks = self::check_prerequisites();
     $args = self::getArgDefaults($args);
     if ($checks !== true) {
         return $checks;
     }
     iform_load_helpers(array('map_helper'));
     data_entry_helper::add_resource('jquery_form');
     self::$ajaxFormUrl = iform_ajaxproxy_url($node, 'location');
     self::$ajaxFormSampleUrl = iform_ajaxproxy_url($node, 'sample');
     $auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
     $typeTerms = array(empty($args['transect_type_term']) ? 'Transect' : $args['transect_type_term'], empty($args['section_type_term']) ? 'Section' : $args['section_type_term']);
     $settings = array('locationTypes' => helper_base::get_termlist_terms($auth, 'indicia:location_types', $typeTerms), 'locationId' => isset($_GET['id']) ? $_GET['id'] : null, 'canEditBody' => true, 'canEditSections' => true, 'canAllocBranch' => $args['managerPermission'] == "" || user_access($args['managerPermission']), 'canAllocUser' => $args['managerPermission'] == "" || user_access($args['managerPermission']));
     $settings['attributes'] = data_entry_helper::getAttributes(array('id' => $settings['locationId'], 'valuetable' => 'location_attribute_value', 'attrtable' => 'location_attribute', 'key' => 'location_id', 'fieldprefix' => 'locAttr', 'extraParams' => $auth['read'], 'survey_id' => $args['survey_id'], 'location_type_id' => $settings['locationTypes'][0]['id'], 'multiValue' => true));
     $settings['section_attributes'] = data_entry_helper::getAttributes(array('valuetable' => 'location_attribute_value', 'attrtable' => 'location_attribute', 'key' => 'location_id', 'fieldprefix' => 'locAttr', 'extraParams' => $auth['read'], 'survey_id' => $args['survey_id'], 'location_type_id' => $settings['locationTypes'][1]['id'], 'multiValue' => true));
     if ($args['allow_user_assignment']) {
         if (false == ($settings['cmsUserAttr'] = extract_cms_user_attr($settings['attributes']))) {
             return 'This form is designed to be used with the CMS User ID attribute setup for locations in the survey, or the "Allow users to be assigned to transects" option unticked.';
         }
         // keep a copy of the cms user ID attribute so we can use it later.
         self::$cmsUserAttrId = $settings['cmsUserAttr']['attributeId'];
     }
     // need to check if branch allocation is active.
     if ($args['branch_assignment_permission'] != '') {
         if (false == ($settings['branchCmsUserAttr'] = self::extract_attr($settings['attributes'], "Branch CMS User ID"))) {
             return '<br />This form is designed to be used with either<br />1) the Branch CMS User ID attribute setup for locations in the survey, or<br />2) the "Permission name for Branch Manager" option left blank.<br />';
         }
         // keep a copy of the branch cms user ID attribute so we can use it later.
         self::$branchCmsUserAttrId = $settings['branchCmsUserAttr']['attributeId'];
     }
     data_entry_helper::$javascript .= "indiciaData.sections = {};\n";
     $settings['sections'] = array();
     $settings['numSectionsAttr'] = "";
     $settings['maxSectionCount'] = $args['maxSectionCount'];
     $settings['autocalcSectionLengthAttrId'] = empty($args['autocalc_section_length_attr_id']) ? 0 : $args['autocalc_section_length_attr_id'];
     $settings['defaultSectionGridRef'] = empty($args['default_section_grid_ref']) ? 'parent' : $args['default_section_grid_ref'];
     if ($settings['locationId']) {
         data_entry_helper::load_existing_record($auth['read'], 'location', $settings['locationId']);
         $settings['walks'] = data_entry_helper::get_population_data(array('table' => 'sample', 'extraParams' => $auth['read'] + array('view' => 'detail', 'location_id' => $settings['locationId'], 'deleted' => 'f'), 'nocache' => true));
         // Work out permissions for this user: note that canAllocBranch setting effectively shows if a manager.
         if (!$settings['canAllocBranch']) {
             // Check whether I am a normal user and it is allocated to me, and also if I am a branch manager and it is allocated to me.
             $settings['canEditBody'] = false;
             $settings['canEditSections'] = false;
             if ($args['allow_user_assignment'] && count($settings['walks']) == 0 && isset($settings['cmsUserAttr']['default']) && !empty($settings['cmsUserAttr']['default'])) {
                 foreach ($settings['cmsUserAttr']['default'] as $value) {
                     // multi value
                     if ($value['default'] == $user->uid) {
                         // comparing string against int so no triple equals
                         $settings['canEditBody'] = true;
                         $settings['canEditSections'] = true;
                         break;
                     }
                 }
             }
             // If a Branch Manager and not a main manager, then can't edit the number of sections
             if ($args['branch_assignment_permission'] != '' && user_access($args['branch_assignment_permission']) && isset($settings['branchCmsUserAttr']['default']) && !empty($settings['branchCmsUserAttr']['default'])) {
                 foreach ($settings['branchCmsUserAttr']['default'] as $value) {
                     // now multi value
                     if ($value['default'] == $user->uid) {
                         // comparing string against int so no triple equals
                         $settings['canEditBody'] = true;
                         $settings['canAllocUser'] = true;
                         break;
                     }
                 }
             }
         }
         // for an admin user the defaults apply, which will be can do everything.
         // find the number of sections attribute.
         foreach ($settings['attributes'] as $attr) {
             if ($attr['caption'] === 'No. of sections') {
                 $settings['numSectionsAttr'] = $attr['fieldname'];
                 for ($i = 1; $i <= $attr['displayValue']; $i++) {
                     $settings['sections']["S{$i}"] = null;
                 }
                 $existingSectionCount = empty($attr['displayValue']) ? 1 : $attr['displayValue'];
                 data_entry_helper::$javascript .= "\$('#" . str_replace(':', '\\\\:', $attr['id']) . "').attr('min',{$existingSectionCount}).attr('max'," . $args['maxSectionCount'] . ");\n";
                 if (!$settings['canEditSections']) {
                     data_entry_helper::$javascript .= "\$('#" . str_replace(':', '\\\\:', $attr['id']) . "').attr('readonly','readonly').css('color','graytext');\n";
                 }
             }
         }
         $sections = data_entry_helper::get_population_data(array('table' => 'location', 'extraParams' => $auth['read'] + array('view' => 'detail', 'parent_id' => $settings['locationId'], 'deleted' => 'f', 'orderby' => 'id'), 'nocache' => true));
         foreach ($sections as $section) {
             $code = $section['code'];
             data_entry_helper::$javascript .= "indiciaData.sections.{$code} = {'geom':'" . $section['boundary_geom'] . "','id':'" . $section['id'] . "','sref':'" . $section['centroid_sref'] . "','system':'" . $section['centroid_sref_system'] . "'};\n";
             $settings['sections'][$code] = $section;
         }
     } else {
         // not an existing site therefore no walks. On initial save, no section data is created.
         foreach ($settings['attributes'] as $attr) {
             if ($attr['caption'] === 'No. of sections') {
                 $settings['numSectionsAttr'] = $attr['fieldname'];
                 data_entry_helper::$javascript .= "\$('#" . str_replace(':', '\\\\:', $attr['id']) . "').attr('min',1).attr('max'," . $args['maxSectionCount'] . ");\n";
             }
         }
         $settings['walks'] = array();
     }
     if ($settings['numSectionsAttr'] === '') {
         for ($i = 1; $i <= $settings['maxSectionCount']; $i++) {
             $settings['sections']["S{$i}"] = null;
         }
     }
     $r = '<div id="controls">';
     $headerOptions = array('tabs' => array('#site-details' => lang::get('Site Details')));
     if ($settings['locationId']) {
         $headerOptions['tabs']['#your-route'] = lang::get('Your Route');
         if ($args['always_show_section_details'] || count($settings['section_attributes']) > 0) {
             $headerOptions['tabs']['#section-details'] = lang::get('Section Details');
         }
     }
     if (count($headerOptions['tabs'])) {
         $r .= data_entry_helper::tab_header($headerOptions);
         data_entry_helper::enable_tabs(array('divId' => 'controls', 'style' => 'Tabs', 'progressBar' => isset($args['tabProgress']) && $args['tabProgress'] == true));
     }
     $r .= self::get_site_tab($auth, $args, $settings);
     if ($settings['locationId']) {
         $r .= self::get_your_route_tab($auth, $args, $settings);
         if ($args['always_show_section_details'] || count($settings['section_attributes']) > 0) {
             $r .= self::get_section_details_tab($auth, $args, $settings);
         }
     }
     $r .= '</div>';
     // controls
     data_entry_helper::enable_validation('input-form');
     if (function_exists('drupal_set_breadcrumb')) {
         $breadcrumb = array();
         $breadcrumb[] = l(lang::get('Home'), '<front>');
         $breadcrumb[] = l(lang::get('Sites'), $args['sites_list_path']);
         if ($settings['locationId']) {
             $breadcrumb[] = data_entry_helper::$entity_to_load['location:name'];
         } else {
             $breadcrumb[] = lang::get('New Site');
         }
         drupal_set_breadcrumb($breadcrumb);
     }
     // Inform JS where to post data to for AJAX form saving
     data_entry_helper::$javascript .= 'indiciaData.ajaxFormPostUrl="' . self::$ajaxFormUrl . "\";\n";
     data_entry_helper::$javascript .= 'indiciaData.ajaxFormPostSampleUrl="' . self::$ajaxFormSampleUrl . "\";\n";
     data_entry_helper::$javascript .= 'indiciaData.website_id="' . $args['website_id'] . "\";\n";
     data_entry_helper::$javascript .= "indiciaData.indiciaSvc = '" . data_entry_helper::$base_url . "';\n";
     data_entry_helper::$javascript .= "indiciaData.readAuth = {nonce: '" . $auth['read']['nonce'] . "', auth_token: '" . $auth['read']['auth_token'] . "'};\n";
     data_entry_helper::$javascript .= "indiciaData.currentSection = '';\n";
     data_entry_helper::$javascript .= "indiciaData.sectionTypeId = '" . $settings['locationTypes'][1]['id'] . "';\n";
     data_entry_helper::$javascript .= "indiciaData.sectionDeleteConfirm = \"" . lang::get('Are you sure you wish to delete section') . "\";\n";
     data_entry_helper::$javascript .= "indiciaData.sectionInsertConfirm = \"" . lang::get('Are you sure you wish to insert a new section after section') . "\";\n";
     data_entry_helper::$javascript .= "indiciaData.sectionChangeConfirm = \"" . lang::get('Do you wish to save the currently unsaved changes you have made to the Section Details?') . "\";\n";
     data_entry_helper::$javascript .= "indiciaData.numSectionsAttrName = \"" . $settings['numSectionsAttr'] . "\";\n";
     data_entry_helper::$javascript .= "indiciaData.maxSectionCount = \"" . $settings['maxSectionCount'] . "\";\n";
     data_entry_helper::$javascript .= "indiciaData.autocalcSectionLengthAttrId = " . $settings['autocalcSectionLengthAttrId'] . ";\n";
     data_entry_helper::$javascript .= "indiciaData.defaultSectionGridRef = '" . $settings['defaultSectionGridRef'] . "';\n";
     if ($settings['locationId']) {
         data_entry_helper::$javascript .= "selectSection('S1', true);\n";
     }
     return $r;
 }
Beispiel #10
0
/**
 * Process variables for search-results.tpl.php.
 *
 * The $variables array contains the following arguments:
 * - $results
 * - $type
 *
 * @see search-results.tpl.php
 * default preprocess search function  is altered for adding  drupal collapsible fieldset to advanced search 
 */
function alim_preprocess_search_results(&$variables) {
$keys = search_get_keys();
 $tot_res_cnt = 0;
	if($variables['type'] == 'alimsearch' ){ // only for advanced search groups the search results in to fieldsets 	
		$variables['search_results'] = '';
		$crumb = drupal_get_breadcrumb();   
		$c = count($crumb);
		unset($crumb[$c-1]);
		drupal_set_breadcrumb($crumb);
		drupal_set_title('Search Results');
		foreach($variables['results'] as $key => $val ){
		     
				$value = "";$ct ='';
				$value .= $val['pagerval'];
				if($val['empty'])
				$value .= $val['empty'];
				foreach ($val['results'] as $result) {
					$value .= theme('search_result', $result, $variables['type']);
				}
				  $tot_res_cnt += $val['tot_res_cnt'];
				$ct .= '<div><a href="#search-'.$key.'" >'.$val['search_ind'].' </a></div>';
				$variables['search_results'] .= theme('fieldset', // collpasible group of results in advanced search 
													array(
													'#title' => $val['fullname'],
													'#collapsible' => TRUE,
													'#collapsed' => FALSE,
													'#value' => $value,
													'#attributes' => array('id' => 'search-'.$key)
													)
													);
				$variables['counter_left'] .= 	 $ct ;
		
		}
		// Provide alternate search results template.
		$variables['template_files'][] = 'search-results-'. $variables['type'];	// adding template sugessions
	
	}else{ // for simple search 
		$variables['search_results'] = '';
		$crumb = drupal_get_breadcrumb();   
		$c = count($crumb);
		unset($crumb[$c-1]);
		drupal_set_breadcrumb($crumb);
		drupal_set_title('Search Results');
		// $variables['search_results'] = '';
		foreach ($variables['results'] as $result) {
			$variables['search_results'] .= theme('search_result', $result, $variables['type']);
		}
		if(arg(0) == 'alimsearch' ){
			$variables['pager'] = theme('pager', NULL, 10, 0);
		}
		else{
			$variables['pager'] = theme('pager', NULL, 100, 0);
		}
		// Provide alternate search results template.
		$variables['template_files'][] = 'search-results-'. $variables['type']; // adding template sugessions
		global $pager_total_items;
        $tot_res_cnt = $pager_total_items[0]; 
	} 
	
   $script = "var search_key_value = '".$keys." => result count - ".substr($tot_res_cnt,0,30)."'";
   drupal_add_js($script, 'inline', 'footer');
 
}
<?php //print theme('breadcrumb', drupal_get_breadcrumb( )); ?>
<?php if(arg(0) == 'events'){
		$crumbs = drupal_get_breadcrumb();
		if(empty($crumbs[4])){
			unset($crumbs[3]);
		}
		drupal_set_breadcrumb($crumbs);	
		print theme('breadcrumb', drupal_get_breadcrumb( ));
	}
?>
<div class="vertical_tab_container">
	<div class="vertical_tab_elements">
		<?php print theme('wistar_vertical_tabs');?>
		<div class="content">			
			<?php print theme('wistar_content_heading', $node);?>
			<div class="node technology node-technology">
				<div class="section">
					<?php if($rows): ?>
					<!-- store expandable list -->
					<div class="expandable_list_container">
						<div class="expandable_list_elements">
							<ul class="expandable_list">
								<?php foreach( $view->result as $idx => $result ): ?>
									<li>
										<a class="anchor" href="#">
											<?php print $result->node_title; ?>
											<?php if($date = $view->render_field('field_event_date_value', $idx)): ?>
												<?php print ' - ' . $date; ?>
											<?php endif; ?>
											<span class="icon">&nbsp;</span>
										</a>				
Beispiel #12
0
 /**
  * if we are using a theming system, invoke theme, else just print the
  * content
  *
  * @param string  $type    name of theme object/file
  * @param string  $content the content that will be themed
  * @param array   $args    the args for the themeing function if any
  * @param boolean $print   are we displaying to the screen or bypassing theming?
  * @param boolean $ret     should we echo or return output
  * @param boolean $maintenance  for maintenance mode
  * 
  * @return void           prints content on stdout
  * @access public
  */
 function theme($type, &$content, $args = null, $print = false, $ret = false, $maintenance = false)
 {
     if (function_exists('theme') && !$print) {
         if ($maintenance) {
             drupal_set_breadcrumb('');
             drupal_maintenance_theme();
         }
         $out = theme($type, $content, $args);
     } else {
         $out = $content;
     }
     if ($ret) {
         return $out;
     } else {
         print $out;
     }
 }
function wizardAutoDetect($searchTitle = '')
{
    // We expect the URL to contain the Swimlane-Page title - Strip the query string from the URL if it exists
    $ruri = request_uri();
    if (strpos($ruri, '?') !== false) {
        $ruri = substr($ruri, 0, strpos($ruri, '?'));
    }
    // We expect the URL to contain the Swimlane-Page (node) title for the target swimlane/wizard
    $ruri = explode('/', $ruri);
    $swimlaneTitle = $ruri[count($ruri) - 1];
    $swimlaneTitle = urldecode($swimlaneTitle);
    // We may have been given the title to search for
    if ($searchTitle !== '') {
        $swimlaneTitle = $searchTitle;
    }
    // SQL to find the Swimlane-Page node based on the title
    $q = "\n        SELECT nid AS nid\n        FROM node n\n        WHERE\n            n.type = 'swim_lane_page'\n            AND InStr(n.title, '{$swimlaneTitle}')<>0\n        LIMIT 1\n    ";
    // Debug
    if (strpos(request_uri(), '-DEBUG-WIZARDDETECT-QUERY-') !== false) {
        dsm($q);
    }
    // Search for this node
    $result = db_query($q);
    $swimlaneNid = false;
    foreach ($result as $record) {
        $swimlaneNid = $record->nid;
    }
    if ($swimlaneNid === false) {
        return "Error - Could not find the target swimlane title ({$swimlaneTitle})";
    }
    // Get the File-Id of the Wizard-Excel-Source field in the target Swimlane-Page node
    $n = node_load($swimlaneNid);
    $fid = false;
    if (!empty($n->field_swimlane_wizexcelfile) && is_array($n->field_swimlane_wizexcelfile) && !empty($n->field_swimlane_wizexcelfile['und'])) {
        $fid = $n->field_swimlane_wizexcelfile['und'][0]['fid'];
    }
    if ($fid === false) {
        return 'Error - This this swimlane does not have an associated wizard';
    }
    // Get the real path of this file
    $dFile = file_load($fid);
    if ($dFile === false) {
        print 'Error - Wizard (source-file) not found';
        return;
    }
    $wizSrcPath = drupal_realpath($dFile->uri);
    // Verify this path truly exists
    if (!file_exists($wizSrcPath)) {
        print 'Error - The Wizard-Excel-Source sheet is missing! - ' . $wizSrcPath . '<br/>';
        print '<span class="admin-only">Please <a href="/node/' . $swimlaneNid . '/edit">edit the swimlane</a>, and upload the appropriate excel spreadsheet</span>';
        if (function_exists('debugEmail')) {
            $serverDomain = 'https://' . $_SERVER['SERVER_NAME'];
            debugEmail('critical', 'An Excel-Source spreadsheet is missing for the "' . $n->title . '" Wizard! <br/>' . 'The expected path of this file was: ' . $wizSrcPath . '<br/>' . "This swimlane/wizard can be editted from <a href=\"{$serverDomain}/node/{$swimlaneNid}/edit\">{$serverDomain}/node/{$swimlaneNid}/edit</a><br/> " . '
                        <form action="/dev/ulswimlanefile" method="post">
                            <input type="hidden" name="nid" id="nid" value="' . $swimlaneNid . '" /><br/>
                            <b>Please upload the excel file for this swimlane now:</b><br/>
                            <input type="file" name="excelFile" id="excelFile" /><br/>
                            <input type="submit" />
                        </form>
                    ');
        }
        return;
    }
    // Load BUSA Wizard dependencies
    include 'sites/all/themes/bususa/templates/wizard/BusinessUSAWizard.classes.php';
    // Create and print the wizard
    $wiz = new BusinessUSAWizard();
    $wiz->swimlaneNid = $swimlaneNid;
    $wiz->loadFromExcel($wizSrcPath);
    $html = $wiz->render();
    // Debug
    if (strpos(request_uri(), '-DEBUG-VERBOSE-WIZARD-') !== false) {
        dsm(array('wiz' => $wiz, 'wiz->getAllTagsUsedInWizard' => $wiz->getAllTagsUsedInWizard()));
    }
    // Build Breadcrumbs
    $breadcrumb = array();
    $breadcrumb[] = l('Home', '<front>');
    $breadcrumb[] = $wiz->title;
    drupal_set_breadcrumb($breadcrumb);
    // Fix a styling bug where the width of the content area is not taking all space (can this be done through contexts while applying single-column layout?)
    $html .= '
        <style>
            /* The following style(s) are stored inside sites\\all\\themes\\bususa\\templates\\wizard\\wizard.php */
            #region-content {
                width: 100%;
            }
        </style>
    ';
    // If this wizard should be loaded in Widget mode, then we only want everything in $html to be the ONLY markup printed within the body tag...
    // for this we use the global $overrideBodyMarkup variable - refer to html.tpl.php to see the use of this override
    if (!empty($_GET['widget']) && (intval($_GET['widget']) === 1 || trim(strtolower($_GET['widget'])) === 'true')) {
        global $overrideBodyMarkup;
        $overrideBodyMarkup = $html;
    }
    return $html;
}
Beispiel #14
0
/**
 * Generate a custom breadcrumb trail
 */
function ardent_custom_breadcrumb($vars)
{
    $breadcrumb = array();
    // Set home as the first item
    $breadcrumb[] = l(t('Home'), '<front>');
    // Add node types into breadcrumb trail
    switch ($vars['node']->type) {
        case 'publications':
            $breadcrumb[] = l(t('Articles'), 'publications');
            break;
    }
    drupal_set_breadcrumb($breadcrumb);
    return $breadcrumb;
}
    $spaceString = '&nbsp';
    while ($length > 0) {
        $spaceString .= '&nbsp';
        $length -= 1;
    }
    $table_rows[$row['display_order']]['category'] = $row['category'];
    $table_rows[$row['display_order']]['highlight_yn'] = $row['highlight_yn'];
    $table_rows[$row['display_order']]['indentation_level'] = $row['indentation_level'];
    $table_rows[$row['display_order']]['amount_display_type'] = $row['amount_display_type'];
    $table_rows[$row['display_order']][$row['fiscal_year']]['amount'] = $row['amount'];
    $years[$row['fiscal_year']] = $row['fiscal_year'];
}
rsort($years);
if (preg_match('/featuredtrends/', $_GET['q'])) {
    $links = array(l(t('Home'), ''), l(t('Trends'), 'featured-trends'), '<a href="/featured-trends?slide=2">Capital Projects Fund Aid Revenues</a>', 'Capital Projects Fund Aid Revenues Details');
    drupal_set_breadcrumb($links);
}
?>

<?php 
if ($node->widgetConfig->table_title) {
    echo '<h3>' . $node->widgetConfig->table_title . '</h3>';
}
?>

<a class="trends-export" href="/export/download/trends_capital_proj_rev_by_agency_csv?dataUrl=/node/<?php 
echo $node->nid;
?>
">Export</a>
<table class="fy-ait">
  <tbody>
Beispiel #16
0
function wistar_preprocess_node(&$vars) {
	$node = $vars['node'];

	if( $vars['node'] ) {
		$vars['template_files'][] = 'node-' . $vars['node']->nid;
	}

	$vars['node']->comment = $vars['node']->comments = $vars['node']->comment_form = 0;
	if (module_exists('comment') && isset($vars['node'])) {
		$vars['node']->comments = comment_render($vars['node']);
		$vars['node']->comment_form = drupal_get_form('comment_form',array('nid' => $vars['node']->nid));
	}

	$node->comment = 0;

	if($vars['node']->type=='newsletter') {
		$crumbs = drupal_get_breadcrumb();
		array_pop($crumbs);
		$crumbs[] = l('Wistar Today', 'wistar-today');
		$crumbs[] = l('News and Media', 'news-and-media');
		$crumbs[] = l('Focus Newsletter', 'news-and-media/focus-newsletter');
		$crumbs[] = $vars['node']->title;
		drupal_set_breadcrumb($crumbs);
	}

	if($node->type=='article') {
		$crumbs = drupal_get_breadcrumb();
		array_pop($crumbs);
		$crumbs[] = l('Wistar Today', 'wistar-today');
		$crumbs[] = l('News and Media', 'news-and-media');
		$crumbs[] = l('Focus Newsletter', 'news-and-media/focus-newsletter');
		//pa($node->field_article_newsletter[0]['nid'],1);
		if(!empty($node->field_article_newsletter[0]['nid'])){
			$node_newsletter = node_load($node->field_article_newsletter[0]['nid']);
			if(!empty($node_newsletter->field_newsletter_date[0]['value'])){
				$crumbs[] = l($node_newsletter->field_newsletter_date[0]['value'], $node_newsletter->path);
			}
		}
		$crumbs[] = $node->title;
		drupal_set_breadcrumb($crumbs);
	}
}
Beispiel #17
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';
        }
    }
    if (array_key_exists('logged_in_via_saml', $variables) && $variables['logged_in_via_saml']) {
        $show_logout = theme_get_setting('show_logout_for_saml_users');
    } else {
        $show_logout = theme_get_setting('show_logout_for_regular_users');
    }
    // We add logout link here to be able to always print it last. (Hence not part
    // of any menu).
    if ($user->uid > 0 && $show_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);
        }
    }
    if (!theme_get_setting('show_breadcrumbs', 'loop')) {
        drupal_set_breadcrumb(array());
    }
}
 /**
  * Adds a Drupal breadcrumb to the page.
  * Pass a parameter called @options, containing an associative array of paths and captions.
  * The paths can contain replacements wrapped in # characters which will be replaced by the $_GET
  * parameter of the same name.
  */
 public static function breadcrumb($auth, $args, $tabalias, $options, $path)
 {
     if (!isset($options['path'])) {
         return 'Please set an array of entries in the @path option';
     }
     $breadcrumb[] = l('Home', '<front>');
     foreach ($options['path'] as $path => $caption) {
         $parts = explode('?', $path, 2);
         $options = array();
         if (count($parts) > 1) {
             foreach ($_REQUEST as $key => $value) {
                 // GET parameters can be used as replacements.
                 $parts[1] = str_replace("#{$key}#", $value, $parts[1]);
             }
             $query = array();
             parse_str($parts[1], $query);
             $options['query'] = $query;
         }
         $path = $parts[0];
         // don't use Drupal l function as a it messes with query params
         $caption = lang::get($caption);
         $breadcrumb[] = l($caption, $path, $options);
     }
     $breadcrumb[] = drupal_get_title();
     drupal_set_breadcrumb($breadcrumb);
     return '';
 }
Beispiel #19
0
/**
 * Display a node.
 *
 * This is a hook used by node modules. It allows a module to define a
 * custom method of displaying its nodes, usually by displaying extra
 * information particular to that node type.
 *
 * @param $node
 *   The node to be displayed.
 * @param $teaser
 *   Whether we are to generate a "teaser" or summary of the node, rather than
 *   display the whole thing.
 * @param $page
 *   Whether the node is being displayed as a standalone page. If this is
 *   TRUE, the node title should not be displayed, as it will be printed
 *   automatically by the theme system. Also, the module may choose to alter
 *   the default breadcrumb trail in this case.
 * @return
 *   $node. The passed $node parameter should be modified as necessary and
 *   returned so it can be properly presented. Nodes are prepared for display
 *   by assembling a structured array in $node->content, rather than directly
 *   manipulating $node->body and $node->teaser. The format of this array is
 *   the same used by the Forms API. As with FormAPI arrays, the #weight
 *   property can be used to control the relative positions of added elements.
 *   If for some reason you need to change the body or teaser returned by
 *   node_prepare(), you can modify $node->content['body']['#value']. Note
 *   that this will be the un-rendered content. To modify the rendered output,
 *   see hook_nodeapi($op = 'alter').
 *
 * For a detailed usage example, see node_example.module.
 */
function hook_view($node, $teaser = FALSE, $page = FALSE)
{
    if ($page) {
        $breadcrumb = array();
        $breadcrumb[] = l(t('Home'), NULL);
        $breadcrumb[] = l(t('Example'), 'example');
        $breadcrumb[] = l($node->field1, 'example/' . $node->field1);
        drupal_set_breadcrumb($breadcrumb);
    }
    $node = node_prepare($node, $teaser);
    $node->content['myfield'] = array('#value' => theme('mymodule_myfield', $node->myfield), '#weight' => 1);
    return $node;
}
Beispiel #20
0
/**
 *
 * @param $cnmlid
 *
 * @param $action
 *
 * @return
 */
function guifi_cnml($cnmlid, $action = 'help')
{
    guifi_log(GUIFILOG_TRACE, 'function guifi_cnml()', $cnmlid);
    if (!is_numeric($cnmlid)) {
        return;
    }
    if ($action == "help") {
        $zone = db_fetch_object(db_query('SELECT title, nick ' . 'FROM {guifi_zone} ' . 'WHERE id = %d', $cnmlid));
        drupal_set_breadcrumb(guifi_zone_ariadna($cnmlid));
        $output = '<div id="guifi">';
        $output .= '<h2>' . t('Zone %zname%', array('%zname%' => $zone->title)) . '</h2>';
        $output .= '<p>' . t('You must specify which data do you want to export, the following options are available:') . '</p>';
        $output .= '<ol><li>' . l(t('Zones'), "guifi/cnml/" . $cnmlid . "/zones", array('title' => t('export zone and zone childs in CNML format'))) . '</li>';
        $output .= '<li>' . l(t('Zones and nodes'), "guifi/cnml/" . $cnmlid . "/nodes", array('title' => t('export zones and nodes in CNML format (short)'))) . '</li>';
        $output .= '<li>' . l(t('Detailed'), "guifi/cnml/" . $cnmlid . "/detail", array('title' => t('export zones, nodes and devices in CNML format (long)'))) . '</li></ol>';
        $output .= '<p>' . t('The <b>C</b>ommunity <b>N</b>etwork <b>M</b>arkup <b>L</b>anguage (<a href="' . base_path() . 'node/3521">CNML</a>) is a XML format to interchange network information between services or servers.') . '</p>';
        $output .= '<p>' . t('<b>IMPORTANT LEGAL NOTE:</b> This network information is under the <a href="http://guifi.net/ComunsSensefils/">Comuns Sensefils</a> license, and therefore, available for any other network under the same licensing. If is not your case, you should ask for permission before using it.</a>') . '</p>';
        $output .= "</div>";
        print theme('page', $output, t('export %zname% in CNML format', array('%zname%' => $z->title)));
        exit;
    }
    function links($iid, $iipv4_id, $ident, $nl)
    {
        $links->count = 0;
        $links->xml = "";
        $qlinks = db_query("SELECT l2.* FROM {guifi_links} l1 LEFT JOIN {guifi_links} l2 ON l1.id=l2.id WHERE l1.device_id<>l2.device_id AND l1.interface_id=%d AND l1.ipv4_id=%d", $iid, $iipv4_id);
        while ($l = db_fetch_object($qlinks)) {
            $links->count++;
            $links->xml .= xmlopentag($ident, 'link', array('id' => $l->id, 'linked_device_id' => $l->device_id, 'linked_node_id' => $l->nid, 'linked_interface_id' => $l->interface_id, 'link_type' => $l->link_type, 'link_status' => $l->flag));
            $links->xml .= xmlclosetag($ident, 'link', $nl);
        }
        return $links->xml;
    }
    global $base_url;
    // load nodes and zones in memory for faster execution
    switch ($action) {
        case 'zones':
        case 'nodes':
        case 'detail':
            $tree = guifi_cnml_tree($cnmlid);
            $sql_devices = 'SELECT * FROM {guifi_devices} d';
            $sql_radios = 'SELECT * FROM {guifi_radios} r ORDER BY r.radiodev_counter ASC';
            $sql_interfaces = 'SELECT i.*,a.ipv4,a.id ipv4_id, a.netmask FROM {guifi_interfaces} i, {guifi_ipv4} a WHERE i.id=a.interface_id';
            $sql_links = 'SELECT l1.id, l1.device_id, l1.interface_id, l1.ipv4_id, l2.device_id linked_device_id, l2.nid linked_node_id, l2.interface_id linked_interface_id, l2.ipv4_id linked_radiodev_counter, l1.link_type, l1.flag status FROM {guifi_links} l1, {guifi_links} l2 WHERE l1.id=l2.id AND l1.device_id != l2.device_id';
            $sql_services = 'SELECT s.* FROM {guifi_services} s';
            break;
        case 'node':
            $qnode = db_query(sprintf('SELECT l.*,r.body body ' . 'FROM {guifi_location} l, {node} n, {node_revisions} r ' . 'WHERE l.id=n.nid AND n.vid=r.vid ' . '  AND l.id in (%s)', $cnmlid));
            while ($node = db_fetch_object($qnode)) {
                $tree[] = $node;
            }
            $sql_devices = sprintf('SELECT * FROM {guifi_devices} d WHERE nid in (%s)', $cnmlid);
            $sql_radios = sprintf('SELECT r.* FROM {guifi_radios} r, {guifi_devices} d WHERE d.nid in (%s) AND d.id=r.id ORDER BY r.radiodev_counter ASC', $cnmlid);
            $sql_interfaces = sprintf('SELECT i.*,a.ipv4,a.id ipv4_id, a.netmask FROM {guifi_devices} d, {guifi_interfaces} i, {guifi_ipv4} a WHERE d.nid in (%s) AND d.id=i.device_id AND i.id=a.interface_id', $cnmlid);
            $sql_links = sprintf('SELECT l1.id, l1.device_id, l1.interface_id, l1.ipv4_id, l2.device_id linked_device_id, l2.nid linked_node_id, l2.interface_id linked_interface_id, l2.ipv4_id linked_radiodev_counter, l1.link_type, l1.flag status FROM {guifi_links} l1, {guifi_links} l2 WHERE l1.nid in (%s) AND l1.id=l2.id AND l1.device_id != l2.device_id', $cnmlid);
            $sql_services = sprintf('SELECT s.*, r.body FROM {guifi_devices} d, {guifi_services} s, {node} n, {node_revisions} r WHERE d.nid in (%s) AND d.id=s.device_id AND n.nid=s.id AND n.vid=r.vid', $cnmlid);
            break;
        case 'nodecount':
            $CNML = fnodecount($cnmlid);
            print_pretty_CNML($CNML);
            return;
            break;
        case 'ips':
            $CNML = dump_guifi_ips();
            print_pretty_CNML($CNML);
            return;
            break;
        case 'ospfnet':
            //http://guifi.net/guifi/cnml/NNNN/ospfnet    NNNN = node id OSPF zone
            $CNML = ospf_net($cnmlid);
            print_pretty_CNML($CNML);
            return;
            break;
        case 'domains':
            $CNML = dump_guifi_domains($cnmlid, $action);
            print_pretty_CNML($CNML);
            return;
            break;
        case 'plot':
            plot_guifi();
            return;
            break;
        case 'growthmap':
            //http://guifi.net/guifi/cnml/0/growthmap?lat1=1.23&lon1=2.34&lat2=1.22&lon2=2.23
            $json = growth_map($_GET["lat1"], $_GET["lon1"], $_GET["lat2"], $_GET["lon2"]);
            //drupal_set_header('Content-Type: application/xml; charset=utf-8');
            echo $json;
            return;
            break;
        case 'home':
            $CNML = guifi_cnml_home($cnmlid);
            print_pretty_CNML($CNML);
            return;
            break;
    }
    // load devices in memory for faster execution
    global $devices;
    $qdevices = db_query($sql_devices);
    while ($device = db_fetch_object($qdevices)) {
        $devices[$device->nid][$device->id] = $device;
    }
    // load radios in memory for faster execution
    global $radios;
    $qradios = db_query($sql_radios);
    while ($radio = db_fetch_object($qradios)) {
        $radios[$radio->nid][$radio->id][$radio->radiodev_counter] = $radio;
    }
    // load interfaces in memory for faster execution
    global $interfaces;
    $qinterfaces = db_query($sql_interfaces);
    while ($interface = db_fetch_object($qinterfaces)) {
        $interfaces[$interface->device_id][$interface->radiodev_counter][$interface->interface_id][] = $interface;
    }
    // load links in memory for faster execution
    global $links;
    $qlinks = db_query($sql_links);
    while ($link = db_fetch_object($qlinks)) {
        $links[$link->device_id][$link->interface_id][$link->id] = $link;
    }
    // load services in memory for faster execution
    global $services;
    $qservices = db_query($sql_services);
    while ($service = db_fetch_object($qservices)) {
        $services[$service->device_id][$service->id] = $service;
    }
    // load radio models in memory for faster execution
    global $models;
    $qmodel = db_query("SELECT mid, fid, model FROM guifi_model_specs ORDER BY mid");
    while ($model = db_fetch_object($qmodel)) {
        $models[$model->mid] = $model->model;
    }
    // print_r($models);
    //  print_r($tree);
    function _add_cnml_node(&$CNML, $node, &$summary, $action)
    {
        global $devices;
        global $radios;
        global $interfaces;
        global $links;
        global $services;
        global $models;
        $nodesummary->ap = 0;
        $nodesummary->client = 0;
        $nodesummary->devices = 0;
        $nodesummary->services = 0;
        $nodesummary->links = 0;
        if ($action != 'zones') {
            //      $nodeXML = $CNML->addChild('node',htmlspecialchars($node->body,ENT_QUOTES));
            $nodeXML = $CNML->addChild('node');
            foreach ($node as $key => $value) {
                if ($value) {
                    switch ($key) {
                        case 'body':
                            break;
                        case 'id':
                            $nodeXML->addAttribute('id', $value);
                            break;
                        case 'nick':
                            $nodeXML->addAttribute('title', $value);
                            break;
                        case 'lat':
                            $nodeXML->addAttribute('lat', $value);
                            break;
                        case 'lon':
                            $nodeXML->addAttribute('lon', $value);
                            break;
                        case 'elevation':
                            if ($value) {
                                $nodeXML->addAttribute('antenna_elevation', $value);
                            }
                            break;
                        case 'status_flag':
                            $nodeXML->addAttribute('status', $value);
                            break;
                        case 'graph_server':
                            $nodeXML->addAttribute('graph_server', $value);
                            break;
                        case 'timestamp_created':
                            $nodeXML->addAttribute('created', date('Ymd hi', $value));
                            break;
                        case 'timestamp_changed':
                            $nodeXML->addAttribute('updated', date('Ymd hi', $value));
                            break;
                    }
                }
            }
        }
        $summary->nodes++;
        if ($node->lon < $summary->minx) {
            $summary->minx = $node->lon;
        }
        if ($node->lat < $summary->miny) {
            $summary->miny = $node->lat;
        }
        if ($node->lon > $summary->maxx) {
            $summary->maxx = $node->lon;
        }
        if ($node->lat > $summary->maxy) {
            $summary->maxy = $node->lat;
        }
        // if report type = 'detail', going to list all node content
        // devices
        if (is_array($devices[$node->id])) {
            if (count($devices[$node->id])) {
                foreach ($devices[$node->id] as $id => $device) {
                    if ($action == 'detail') {
                        $deviceXML = $nodeXML->addChild('device', htmlspecialchars($device->comment, ENT_QUOTES));
                        foreach ($device as $key => $value) {
                            if ($value) {
                                switch ($key) {
                                    case 'body':
                                        comment;
                                    case 'id':
                                        $main_ip = guifi_main_ip($value);
                                        $deviceXML->addAttribute('id', $value);
                                        $deviceXML->addAttribute('mainipv4', $main_ip[ipv4]);
                                        break;
                                    case 'nick':
                                        $deviceXML->addAttribute('title', $value);
                                        break;
                                    case 'type':
                                        $deviceXML->addAttribute('type', $value);
                                        break;
                                    case 'flag':
                                        $deviceXML->addAttribute('status', $value);
                                        break;
                                    case 'graph_server':
                                        $deviceXML->addAttribute('graph_server', $value);
                                        break;
                                    case 'timestamp_created':
                                        $deviceXML->addAttribute('created', date('Ymd hi', $value));
                                        break;
                                    case 'timestamp_changed':
                                        $deviceXML->addAttribute('updated', date('Ymd hi', $value));
                                        break;
                                        // case 'mainipv4': $deviceXML->addAttribute('mainipv4',guifi_main_ip(id)); break;
                                }
                            }
                        }
                        // TODO obtenir model_id i firmware del device o no de extra
                        if (!empty($device->extra)) {
                            $device->variable = unserialize($device->extra);
                            if ($device->type == 'radio') {
                                if (isset($device->variable['firmware'])) {
                                    $deviceXML->addAttribute('firmware', $device->variable['firmware']);
                                }
                            }
                            if (isset($device->variable['model_id'])) {
                                $model_name = $models[(int) $device->variable['model_id']];
                                $deviceXML->addAttribute('name', $model_name);
                            }
                            if (!empty($device->variable['mrtg_index'])) {
                                $deviceXML->addAttribute('snmp_index', $device->variable['mrtg_index']);
                            }
                        }
                    }
                    $nodesummary->devices++;
                    // device radios
                    if (is_array($radios[$node->id][$device->id])) {
                        if (count($radios[$node->id][$device->id])) {
                            foreach ($radios[$node->id][$device->id] as $id => $radio) {
                                if ($action == 'detail') {
                                    $radioXML = $deviceXML->addChild('radio', htmlspecialchars($radio->comment, ENT_QUOTES));
                                    $radioXML->addAttribute('id', $radio->radiodev_counter);
                                    $radioXML->addAttribute('device_id', $device->id);
                                    foreach ($radio as $key => $value) {
                                        if ($value) {
                                            switch ($key) {
                                                case 'radiodev_counter':
                                                case 'comment':
                                                    break;
                                                case 'ssid':
                                                    $radioXML->addAttribute('ssid', $value);
                                                    break;
                                                case 'mode':
                                                    $radioXML->addAttribute('mode', $value);
                                                    break;
                                                case 'protocol':
                                                    $radioXML->addAttribute('protocol', $value);
                                                    break;
                                                case 'channel':
                                                    $radioXML->addAttribute('channel', $value);
                                                    break;
                                                case 'antenna_angle':
                                                    $radioXML->addAttribute('antenna_angle', $value);
                                                    break;
                                                case 'antenna_gain':
                                                    $radioXML->addAttribute('antenna_gain', $value);
                                                    break;
                                                case 'antenna_azimuth':
                                                    $radioXML->addAttribute('antenna_azimuth', $value);
                                                    break;
                                                case 'clients_accepted':
                                                    $radioXML->addAttribute('clients_accepted', $value);
                                                    break;
                                            }
                                        }
                                    }
                                    if (isset($device->variable['model_id'])) {
                                        // TODO resolve issue  wlanX ( 1,2,3,4, etc.. ) incremental.
                                        if (in_array($model_name, array('Routerboard 112', 'Routerboard 133', 'Routerboard 133C', 'Routerboard 153', 'Routerboard 333', 'Routerboard 411', 'Routerboard 433', 'Routerboard 532', 'Routerboard 600', 'Routerboard 800', 'Supertrasto guifiBUS guifi.net', 'Routerboard SXT 5HnD', 'Routerboard 493/G', 'OmniTIK Uxx-5HnD', 'Routerboard SXT Lite2', 'Routerboard SXT Lite5', 'Routerboard 2011', 'Routerboard Sextant'))) {
                                            switch ($device->variable['firmware']) {
                                                case 'RouterOSv2.9':
                                                case 'RouterOSv3.x':
                                                case 'RouterOSv4.0+':
                                                case 'RouterOSv4.7+':
                                                case 'RouterOSv5.x':
                                                case 'RouterOSv6.x':
                                                    $radioXML->addAttribute('snmp_name', 'wlan' . (string) ($id + 1));
                                                    break;
                                            }
                                        } else {
                                            $snmp = db_fetch_object(db_query('SELECT snmp_id FROM guifi_configuracioUnSolclic WHERE id=%d', $device->usc_id));
                                            list($modeap, $modesta) = explode("|", $snmp->snmp_id);
                                            if (empty($modesta)) {
                                                $modesta = $modeap;
                                            }
                                            if (eregi("^[0-9]+\$", $modeap)) {
                                                $snmp_iname = 'snmp_index';
                                            } else {
                                                $snmp_iname = 'snmp_name';
                                            }
                                            if (eregi("^[0-9]+\$", $modesta)) {
                                                $snmp_ciname = 'snmp_index';
                                            } else {
                                                $snmp_ciname = 'snmp_name';
                                            }
                                            if ($radio->mode == 'client') {
                                                $radioXML->addAttribute($snmp_ciname, $modesta);
                                            } else {
                                                $radioXML->addAttribute($snmp_iname, $modeap);
                                            }
                                        }
                                    }
                                    switch ($radio->mode) {
                                        case 'ap':
                                            $nodesummary->ap++;
                                            break;
                                        case 'client':
                                            $nodesummary->client++;
                                            break;
                                    }
                                }
                                // device radio interfaces
                                if (is_array($interfaces[$device->id][$radio->radiodev_counter])) {
                                    if (count($interfaces[$device->id][$radio->radiodev_counter])) {
                                        foreach ($interfaces[$device->id][$radio->radiodev_counter] as $radio_interfaces) {
                                            foreach ($radio_interfaces as $interface) {
                                                if (!array_search($interface->interface_type, array('a' => 'wds/p2p', 'b' => 'wLan', 'c' => 'wLan/Lan', 'd' => 'Wan')) and !array_search($interface->interface_class, array('a' => 'wds/p2p'))) {
                                                    continue;
                                                }
                                                if ($interface->interface_type == 'Wan' and $radio->mode != 'client') {
                                                    continue;
                                                }
                                                if ($action == 'detail') {
                                                    $interfaceXML = $radioXML->addChild('interface');
                                                    foreach ($interface as $key => $value) {
                                                        if ($value) {
                                                            switch ($key) {
                                                                case 'id':
                                                                    $interfaceXML->addAttribute('id', $interface->id);
                                                                    break;
                                                                case 'mac':
                                                                    $interfaceXML->addAttribute('mac', $interface->mac);
                                                                    break;
                                                                case 'ipv4':
                                                                    $interfaceXML->addAttribute('ipv4', $interface->ipv4);
                                                                    break;
                                                                case 'netmask':
                                                                    $interfaceXML->addAttribute('mask', $interface->netmask);
                                                                    break;
                                                                case 'interface_type':
                                                                    $interfaceXML->addAttribute('type', $interface->interface_type);
                                                                    break;
                                                            }
                                                        }
                                                    }
                                                }
                                                // linked interfaces
                                                if (is_array($links[$device->id][$interface->id])) {
                                                    if (count($links[$device->id][$interface->id])) {
                                                        foreach ($links[$device->id][$interface->id] as $id => $link) {
                                                            if (!array_search($link->link_type, array('a' => 'ap/client', 'b' => 'wds'))) {
                                                                continue;
                                                            }
                                                            if ($link->ipv4_id != $interface->ipv4_id) {
                                                                continue;
                                                            }
                                                            $nodesummary->links++;
                                                            if ($action == 'detail') {
                                                                $linkXML = $interfaceXML->addChild('link');
                                                                foreach ($link as $key => $value) {
                                                                    if ($value) {
                                                                        switch ($key) {
                                                                            case 'id':
                                                                                $linkXML->addAttribute('id', $link->id);
                                                                                break;
                                                                            case 'linked_node_id':
                                                                                $linkXML->addAttribute('linked_node_id', $link->linked_node_id);
                                                                                break;
                                                                            case 'linked_device_id':
                                                                                $linkXML->addAttribute('linked_device_id', $link->linked_device_id);
                                                                                break;
                                                                            case 'linked_interface_id':
                                                                                $linkXML->addAttribute('linked_interface_id', $link->linked_interface_id);
                                                                                break;
                                                                            case 'link_type':
                                                                                $linkXML->addAttribute('link_type', $link->link_type);
                                                                                break;
                                                                            case 'status':
                                                                                $linkXML->addAttribute('link_status', $link->status);
                                                                                break;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        // foreach link
                                                    }
                                                }
                                                //interface links
                                            }
                                        }
                                        // foreach radio interface
                                    }
                                }
                                // radio interfaces
                            }
                            // foreach radios
                        }
                    }
                    // device radios
                    // device interfaces
                    if (is_array($interfaces[$device->id])) {
                        if (count($interfaces[$device->id])) {
                            foreach ($interfaces[$device->id] as $device_interfaces) {
                                foreach ($device_interfaces as $counter_interfaces) {
                                    foreach ($counter_interfaces as $interface) {
                                        if (array_search($interface->interface_type, array('a' => 'wds/p2p', 'b' => 'wLan', 'c' => 'wlan/Lan')) and array_search($interface->interface_class, array('a' => 'wds/p2p'))) {
                                            continue;
                                        }
                                        if ($action == 'detail') {
                                            $interfaceXML = $deviceXML->addChild('interface');
                                            foreach ($interface as $key => $value) {
                                                if ($value) {
                                                    switch ($key) {
                                                        case 'id':
                                                            $interfaceXML->addAttribute('id', $interface->id);
                                                            break;
                                                        case 'mac':
                                                            $interfaceXML->addAttribute('mac', $interface->mac);
                                                            break;
                                                        case 'ipv4':
                                                            $interfaceXML->addAttribute('ipv4', $interface->ipv4);
                                                            break;
                                                        case 'netmask':
                                                            $interfaceXML->addAttribute('mask', $interface->netmask);
                                                            break;
                                                        case 'interface_type':
                                                            $interfaceXML->addAttribute('type', $interface->interface_type);
                                                            break;
                                                    }
                                                }
                                            }
                                        }
                                        // linked interfaces
                                        if (is_array($links[$device->id][$interface->id])) {
                                            if (count($links[$device->id][$interface->id])) {
                                                foreach ($links[$device->id][$interface->id] as $id => $link) {
                                                    if (array_search($link->link_type, array('a' => 'ap/client', 'b' => 'wds'))) {
                                                        continue;
                                                    }
                                                    if ($link->ipv4_id != $interface->ipv4_id) {
                                                        continue;
                                                    }
                                                    if ($action == 'detail') {
                                                        $linkXML = $interfaceXML->addChild('link');
                                                        foreach ($link as $key => $value) {
                                                            if ($value) {
                                                                switch ($key) {
                                                                    case 'id':
                                                                        $linkXML->addAttribute('id', $link->id);
                                                                        break;
                                                                    case 'linked_node_id':
                                                                        $linkXML->addAttribute('linked_node_id', $link->linked_node_id);
                                                                        break;
                                                                    case 'linked_device_id':
                                                                        $linkXML->addAttribute('linked_device_id', $link->linked_device_id);
                                                                        break;
                                                                    case 'linked_interface_id':
                                                                        $linkXML->addAttribute('linked_interface_id', $link->linked_interface_id);
                                                                        break;
                                                                    case 'link_type':
                                                                        $linkXML->addAttribute('link_type', $link->link_type);
                                                                        break;
                                                                    case 'status':
                                                                        $linkXML->addAttribute('link_status', $link->status);
                                                                        break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                // foreach link
                                            }
                                        }
                                        //interface links
                                    }
                                }
                            }
                            // foreach interface
                        }
                    }
                    //interface
                    // services
                    if (is_array($services[$device->id])) {
                        if (count($services[$device->id])) {
                            foreach ($services[$device->id] as $id => $service) {
                                if ($action == 'detail') {
                                    $serviceXML = $deviceXML->addChild('service', htmlspecialchars($service->body, ENT_QUOTES));
                                    foreach ($service as $key => $value) {
                                        if ($value) {
                                            switch ($key) {
                                                case 'body':
                                                    break;
                                                case 'id':
                                                    $serviceXML->addAttribute('id', $value);
                                                    break;
                                                case 'nick':
                                                    $serviceXML->addAttribute('title', $value);
                                                    break;
                                                case 'service_type':
                                                    $serviceXML->addAttribute('type', $value);
                                                    break;
                                                case 'status_flag':
                                                    $serviceXML->addAttribute('status', $value);
                                                    break;
                                                case 'timestamp_created':
                                                    $serviceXML->addAttribute('created', date('Ymd hi', $value));
                                                    break;
                                                case 'timestamp_changed':
                                                    $serviceXML->addAttribute('updated', date('Ymd hi', $value));
                                                    break;
                                            }
                                        }
                                    }
                                }
                                $nodesummary->services++;
                            }
                            // foreach service
                        }
                    }
                    // service
                }
                // foreach device
            }
        }
        // devices
        $summary->ap += $nodesummary->ap;
        $summary->client += $nodesummary->client;
        $summary->devices += $nodesummary->devices;
        $summary->links += $nodesummary->links;
        $summary->services += $nodesummary->services;
        if ($action != 'zones') {
            if ($nodesummary->ap) {
                $nodeXML->addAttribute('access_points', $nodesummary->ap);
            }
            if ($nodesummary->client) {
                $nodeXML->addAttribute('clients', $nodesummary->client);
            }
            if ($nodesummary->devices) {
                $nodeXML->addAttribute('devices', $nodesummary->devices);
            }
            if ($nodesummary->links) {
                $nodeXML->addAttribute('links', $nodesummary->links);
            }
            if ($nodesummary->services) {
                $nodeXML->addAttribute('services', $nodesummary->services);
            }
        }
        return;
    }
    // _add_cnml_node
    function _add_cnml_zone(&$CNML, $zone, $action)
    {
        $summary->nodes = 0;
        $summary->minx = 179.9;
        $summary->miny = 89.90000000000001;
        $summary->maxx = -179.9;
        $summary->maxy = -89.90000000000001;
        $summary->devices = 0;
        $summary->ap = 0;
        $summary->client = 0;
        $summary->services = 0;
        $summary->links = 0;
        $zoneXML = $CNML->addChild('zone', htmlspecialchars($zone->body, ENT_QUOTES));
        reset($zone);
        foreach ($zone as $key => $value) {
            if ($value) {
                switch ($key) {
                    case 'body':
                        break;
                    case 'childs':
                        foreach ($value as $child) {
                            $summary2 = _add_cnml_zone($zoneXML, $child, $action);
                            $summary->nodes += $summary2->nodes;
                            $summary->devices += $summary2->devices;
                            $summary->ap += $summary2->ap;
                            $summary->client += $summary2->client;
                            $summary->servers += $summary2->servers;
                            $summary->links += $summary2->links;
                            $summary->services += $summary2->services;
                            if ($summary2->minx < $summary->minx) {
                                $summary->minx = $summary2->minx;
                            }
                            if ($summary2->miny < $summary->miny) {
                                $summary->miny = $summary2->miny;
                            }
                            if ($summary2->maxx > $summary->maxx) {
                                $summary->maxx = $summary2->maxy;
                            }
                            if ($summary2->maxy > $summary->maxy) {
                                $summary->maxy = $summary2->maxy;
                            }
                        }
                        break;
                    case 'nodes':
                        $summary = (object) array();
                        foreach ($value as $child) {
                            _add_cnml_node($zoneXML, $child, $summary, $action);
                        }
                        break;
                    case 'id':
                        $zoneXML->addAttribute('id', $value);
                        break;
                    case 'parent_id':
                        $zoneXML->addAttribute('parent_id', $value);
                        break;
                    case 'title':
                        $zoneXML->addAttribute('title', $value);
                        break;
                    case 'time_zone':
                        $zoneXML->addAttribute('time_zone', $value);
                        break;
                    case 'ntp_servers':
                        $zoneXML->addAttribute('ntp_servers', $value);
                        break;
                    case 'dns_servers':
                        $zoneXML->addAttribute('dns_servers', $value);
                        break;
                    case 'graph_server':
                        $zoneXML->addAttribute('graph_server', $value);
                        break;
                    case 'timestamp_created':
                        $zoneXML->addAttribute('created', date('Ymd hi', $value));
                        break;
                    case 'timestamp_changed':
                        $zoneXML->addAttribute('updated', date('Ymd hi', $value));
                        break;
                }
            }
        }
        $zoneXML->addAttribute('zone_nodes', $summary->nodes);
        if ($zone->minx != 0 and $zone->miny != 0 and $zone->maxx != 0 and $zone->maxy != 0) {
            $zoneXML->addAttribute('box', $zone->minx . ',' . $zone->miny . ',' . $zone->maxx . ',' . $zone->maxy);
        } else {
            $zoneXML->addAttribute('box', $summary->minx . ',' . $summary->miny . ',' . $summary->maxx . ',' . $summary->maxy);
        }
        if ($summary->ap) {
            $zoneXML->addAttribute('access_points', $summary->ap);
        }
        if ($summary->client) {
            $zoneXML->addAttribute('clients', $summary->client);
        }
        if ($summary->devices) {
            $zoneXML->addAttribute('devices', $summary->devices);
        }
        if ($summary->services) {
            $zoneXML->addAttribute('services', $summary->services);
        }
        if ($summary->links) {
            $zoneXML->addAttribute('links', $summary->links);
        }
        return $summary;
    }
    $summary->nodes = 0;
    $summary->minx = 179.9;
    $summary->miny = 89.90000000000001;
    $summary->maxx = -179.9;
    $summary->maxy = -89.90000000000001;
    $summary->devices = 0;
    $summary->ap = 0;
    $summary->client = 0;
    $summary->services = 0;
    $summary->links = 0;
    $CNML = new SimpleXMLElement('<cnml></cnml>');
    $CNML->addAttribute('version', '0.1');
    $CNML->addAttribute('server_id', '1');
    $CNML->addAttribute('server_url', 'http://guifi.net');
    $CNML->addAttribute('generated', date('Ymd hi', time()));
    $classXML = $CNML->addChild('class');
    if ($action != 'node') {
        $classXML->addAttribute('network_description', $action);
        $classXML->addAttribute('mapping', 'y');
        $networkXML = $CNML->addChild('network');
        if (count($tree)) {
            foreach ($tree as $zone_id => $zone) {
                $summary2 = _add_cnml_zone($networkXML, $zone, $action);
                $summary->nodes += $summary2->nodes;
                $summary->devices += $summary2->devices;
                $summary->ap += $summary2->ap;
                $summary->client += $summary2->client;
                $summary->servers += $summary2->servers;
                $summary->links += $summary2->links;
                $summary->services += $summary2->services;
            }
        }
        $networkXML->addAttribute('nodes', $summary->nodes);
        $networkXML->addAttribute('devices', $summary->devices);
        $networkXML->addAttribute('ap', $summary->ap);
        $networkXML->addAttribute('client', $summary->client);
        $networkXML->addAttribute('services', $summary->services);
        $networkXML->addAttribute('links', $summary->links);
    } else {
        $classXML->addAttribute('node_description', $cnmlid);
        $classXML->addAttribute('mapping', 'y');
        $summary->devices = 0;
        $summary->ap = 0;
        $summary->client = 0;
        $summary->services = 0;
        $summary->links = 0;
        // print_r($tree);
        foreach ($tree as $nodeid => $node) {
            $summary = _add_cnml_node($CNML, $node, $summary, 'detail');
        }
    }
    print_pretty_CNML($CNML);
    return;
}
Beispiel #21
0
function negd_breadcrumb($variables)
{
    $arg_0 = arg(0);
    $arg_1 = arg(1);
    // print_r($arg_0.$arg_1);
    $breadcrumb = $variables['breadcrumb'];
    switch ($arg_0) {
        case 'vms':
            if ($arg_1 == 'home') {
                $breadcrumb[] .= l('Get Connected', 'contact-us');
                drupal_set_breadcrumb($breadcrumb);
            } elseif ($arg_1 == 'register') {
                $breadcrumb[] .= l('Get Connected', 'contact-us');
                $breadcrumb[] .= l('User Login', 'volunteer/login');
                drupal_set_breadcrumb($breadcrumb);
            }
            break;
        case 'e-gcf-case-scenarios':
            $breadcrumb[] .= l('What We Do', 'key-activities');
            $breadcrumb[] .= l('Capacity Building', 'capacity-building-0');
            $breadcrumb[] .= l('eGovernance Competency Framework (e-GCF)', 'e-gcf');
            drupal_set_breadcrumb($breadcrumb);
            break;
        case 'node':
            switch ($arg_1) {
                case '327':
                    $breadcrumb[] .= l('Get Connected', 'node/327');
                    drupal_set_breadcrumb($breadcrumb);
                    break;
                case '97':
                    $breadcrumb[] .= l('What We Do', 'node/97');
                    $breadcrumb[] .= l('Programme Management', 'node/97');
                    drupal_set_breadcrumb($breadcrumb);
                    break;
                case '162':
                    $breadcrumb[] .= l('What We Do', 'node/97');
                    $breadcrumb[] .= l('Capacity Building', 'node/141');
                    $breadcrumb[] .= l('eGovernance Competency Framework (e-GCF)', 'node/34');
                    drupal_set_breadcrumb($breadcrumb);
                    break;
                case '164':
                    $breadcrumb[] .= l('What We Do', 'node/97');
                    $breadcrumb[] .= l('Capacity Building', 'node/141');
                    $breadcrumb[] .= l('eGovernance Competency Framework (e-GCF)', 'node/34');
                    drupal_set_breadcrumb($breadcrumb);
                    break;
                case '55':
                    $breadcrumb[] .= l('Careers', 'node/55');
                    drupal_set_breadcrumb($breadcrumb);
                    break;
            }
            break;
        case 'collaboration':
            if ($arg_1 == 'login') {
                $breadcrumb[] = l('Home', '<front>');
                drupal_set_breadcrumb($breadcrumb);
            } elseif ($arg_1 == 'register') {
                $breadcrumb[] .= l('My Negd Login', 'collaboration/login');
                drupal_set_breadcrumb($breadcrumb);
            }
            break;
        case 'feedback-negd':
            $breadcrumb[] .= l('Get Connected', 'node/327');
            drupal_set_breadcrumb($breadcrumb);
            break;
    }
    if (isset($breadcrumb) && !empty($breadcrumb)) {
        $crumbs = '<div class="breadcrumbs"><ul>';
        if (isset(node_load($arg_1)->type) && (node_load($arg_1)->type == "blog" || node_load($arg_1)->type == "forum" || node_load($arg_1)->type == "quiz")) {
            unset($breadcrumb[2]);
            $breadcrumb[0] = l('Home', '<front>');
            $breadcrumb[1] = l('My NeGD', 'node/415');
            $crumbs .= '<li>' . $breadcrumb[0] . '</li>';
            $crumbs .= '<li>' . $breadcrumb[1] . '</li>';
        }
        if (isset(node_load($arg_1)->type) && node_load($arg_1)->type == "egcf_case_scenarios") {
            unset($breadcrumb[2]);
            $breadcrumb[0] = l('Home', '<front>');
            $breadcrumb[1] = l('What We Do', 'key-activities');
            $breadcrumb[2] = l('Capacity Building', 'capacity-building-0');
            $breadcrumb[3] = l('eGovernance Competency Framework (e-GCF)', 'e-gcf');
            $breadcrumb[4] = l('e-GCF Case Scenarios', 'e-gcf-case-scenarios');
            $crumbs .= '<li>' . $breadcrumb[0] . '</li>';
            $crumbs .= '<li>' . $breadcrumb[1] . '</li>';
            $crumbs .= '<li>' . $breadcrumb[2] . '</li>';
            $crumbs .= '<li>' . $breadcrumb[3] . '</li>';
            $crumbs .= '<li>' . $breadcrumb[4] . '</li>';
        } else {
            foreach ($breadcrumb as $value) {
                $crumbs .= '<li>' . $value . '</li>';
            }
        }
        $crumbs .= '<li>' . drupal_get_title() . '</li>';
        $crumbs .= '</ul></div>';
        return $crumbs;
    }
}
Beispiel #22
0
 /**
  * Reset an additional breadcrumb tag to the existing breadcrumb
  *
  * @return void
  * @access public
  */
 function resetBreadCrumb()
 {
     $bc = array();
     drupal_set_breadcrumb($bc);
 }
$node1  = node_load(arg(1));
$grop_title = substr($node1->title,0,30);
if(strlen($node1->title)>30)
$grop_title .= ' ...';
$node3  = node_load(arg(2));
$post_title = substr($node3->title,0,30);
if(strlen($node2->title)>30)
$post_title .= ' ...';


unset($breadcrumb);
$breadcrumb = array();
$breadcrumb[] =  l(t('Home'), '<front>') ;
$breadcrumb[] =  l(t($grop_title), 'groupdetails/'.arg(1)) ;
$breadcrumb[] =  l(t($post_title), 'group-post/'.arg(1).'/'.arg(2)) ;
drupal_set_breadcrumb($breadcrumb);
?>

<?php 
$args=$_GET['reply'];
if($args =="reply")
{

if($user->uid)
{

?>

<script type="text/javascript">
 $(window).load( function() {
	//$(document).one('mousemove',function(e){
function guifi_domain_print($domain = NULL)
{
    if ($domain == NULL) {
        print theme('page', t('Not found'), FALSE);
        return;
    }
    $output = '<div id="guifi">';
    $title = '';
    drupal_set_breadcrumb(guifi_node_ariadna($node));
    switch (arg(4)) {
        case 'all':
        case 'data':
        default:
            $table = theme('table', NULL, guifi_domain_print_data($domain));
            $output .= theme('box', $title, $table);
            if (arg(4) == 'data') {
                break;
            }
        case 'delegations':
            $header = array(t('Delegation'), t('IPv4 Address'), t('Nameserver'));
            $table = theme('table', $header, guifi_delegations_print_data($domain['name'], $domain['scope']));
            $output .= theme('box', t('Delegations'), $table);
            if (arg(4) == 'delegations') {
                break;
            }
        case 'hosts':
            $header = array(t('HostName'), t('Alias'), t('IPv4 Address'), t('IPv6 Address'), t('Namserver'), t('MailServer'), t('MX Priority'));
            $table = theme('table', $header, guifi_hosts_print_data($domain['id']));
            $output .= theme('box', t('Hostnames'), $table);
            break;
    }
    $output .= '</div>';
    drupal_set_title(t('View domain %dname', array('%dname' => $domain['name'])));
    $output .= theme_links(module_invoke_all('link', 'node', $node, FALSE));
    print theme('page', $output, FALSE);
    return;
}
function cubert_preprocess_page(&$variables)
{
    $node = !empty($variables['node']) ? $variables['node'] : NULL;
    // Show correct breadcrumb path for Help Articles
    if (!empty($node) && $node->type == 'help_article') {
        $wrapper = entity_metadata_wrapper('node', $node);
        $categories = isset($wrapper->field_categories) ? $wrapper->field_categories->value() : array();
        $category = !empty($categories) ? current($categories) : NULL;
        $breadcrumb = array();
        $breadcrumb[] = l(t('Home'), '<front>');
        $breadcrumb[] = l(t('Support'), 'support');
        $breadcrumb[] = l(t('Help Articles'), 'support/help');
        if (!empty($category)) {
            $machine_name = preg_replace('@[^a-z0-9-]+@', '-', strtolower($category->name));
            $breadcrumb[] = l($category->name, 'support/help/' . $machine_name);
        }
        drupal_set_breadcrumb($breadcrumb);
    }
    // Show correct breadcrumb path for Tickets
    if (!empty($node) && $node->type == 'project_issue') {
        $breadcrumb = array();
        $breadcrumb[] = l(t('Home'), '<front>');
        $breadcrumb[] = l(t('Support'), 'support');
        $breadcrumb[] = l(t('Tickets'), 'support/tickets/my/all');
        drupal_set_breadcrumb($breadcrumb);
    }
    if (user_access('administer site configuration')) {
        $hide_tabs = array('user/%/project-issue', 'user/%/shortcuts', 'user/%/queue', 'user/%/time_sheet', 'user/%/useractivity', 'user/%/friends-activity');
        if (!empty($variables['tabs']['#primary'])) {
            foreach ($variables['tabs']['#primary'] as $key => $tab) {
                $path = !empty($tab['#link']['path']) ? $tab['#link']['path'] : NULL;
                if (in_array($path, $hide_tabs)) {
                    unset($variables['tabs']['#primary'][$key]);
                }
            }
        }
    }
}
function guifi_device_print($device = NULL)
{
    if ($device == NULL) {
        print theme('page', t('Not found'), FALSE);
        return;
    }
    $output = '<div id="guifi">';
    $node = node_load(array('nid' => $device[nid]));
    $title = t('Node:') . ' <a href="' . url('node/' . $node->nid) . '">' . $node->nick . '</a> &middot; ' . t('Device:') . '&nbsp;' . $device[nick];
    drupal_set_breadcrumb(guifi_node_ariadna($node));
    switch (arg(4)) {
        case 'all':
        case 'data':
        default:
            $table = theme_table(null, guifi_device_print_data($device), array('class' => 'device-data'));
            $output .= theme('box', $title, $table);
            if (arg(4) == 'data') {
                break;
            }
        case 'comment':
            if (!empty($device['comment'])) {
                $output .= theme('box', t('Comments'), $device['comment']);
            }
            if (arg(4) == 'comment') {
                break;
            }
        case 'graphs':
            if (empty($device['interfaces'])) {
                break;
            }
            // device graphs
            $table = theme('table', array(t('traffic overview')), guifi_device_graph_overview($device));
            $output .= theme('box', t('device graphs'), $table);
            if (arg(4) == 'graphs') {
                break;
            }
        case 'links':
            // links
            $output .= theme('box', NULL, guifi_device_links_print($device));
            if (arg(4) == 'links') {
                break;
            }
        case 'interfaces':
            if (empty($device['interfaces'])) {
                break;
            }
            $header = array(t('id'), t('connects with'), t('connector'), t('comments'), t('mac'), t('ip address'), t('netmask'));
            $tables = theme_table($header, guifi_device_print_interfaces($device), array('class' => 'device-data'));
            $output .= theme('box', t('physical ports & connections'), $tables);
            foreach (array('vlans', 'aggregations', 'tunnels') as $iClass) {
                $rows = guifi_device_print_iclass($iClass, $device);
                if (empty($rows)) {
                    continue;
                }
                if ($iClass == 'vlans') {
                    $header = array(t('type'), t('name'), t('parent'), t('vlan'), t('comments'), t('mac'), t('ip address'), t('netmask'));
                } else {
                    $header = array(t('type'), t('name'), t('parent'), t('comments'), t('mac'), t('ip address'), t('netmask'));
                }
                $tables = theme_table($header, $rows, array('class' => 'device-data'));
                $output .= theme('box', t($iClass), $tables);
            }
            break;
        case 'services':
            $output .= theme('box', t('services information'), theme_guifi_services_list($device['id']));
            $output .= '</div>';
            return;
    }
    $output .= '</div>';
    drupal_set_title(t('View device %dname', array('%dname' => $device['nick'])));
    $output .= theme_links(module_invoke_all('link', 'node', $node, FALSE));
    print theme('page', $output, FALSE);
    return;
}
Beispiel #27
0
 /**
  * Set LC breadcrumbs
  *
  * @return void
  */
 protected function setBreadcrumbs()
 {
     $widget = $this->getHandler()->getWidget('\\XLite\\View\\Location');
     $lcNodes = array_map(function (\XLite\View\Location\Node $node) {
         return $node->getContent();
     }, $widget->getNodes());
     array_shift($lcNodes);
     // Add store root node
     $trails = menu_get_active_trail();
     array_splice($trails, 1, 0, array(array('title' => t('Store'), 'href' => \XLite\Core\Converter::buildFullURL(), 'link_path' => '', 'localized_options' => array(), 'type' => MENU_VISIBLE_IN_BREADCRUMB)));
     menu_set_active_trail($trails);
     $drupalNodes = array_slice(drupal_get_breadcrumb(), 0, 2);
     drupal_set_breadcrumb(array_merge($drupalNodes, $lcNodes));
 }
function _scratchy_theme_forum($node, $teaser, $page)
{
    $parents = taxonomy_get_parents_all($node->tid);
    $breadcrumb = array();
    $breadcrumb[] = l('Home', '');
    $breadcrumb[] = l('Forums', 'forum');
    if ($parents) {
        $parents = array_reverse($parents);
        foreach ($parents as $p) {
            if ($p->tid == $tid) {
                $title = $p->name;
            } else {
                $breadcrumb[] = l($p->name, 'forum/' . $p->tid);
            }
        }
    }
    drupal_set_breadcrumb($breadcrumb);
    $output = '<div class="node' . (!$node->status ? ' unpublished' : '') . ($node->sticky && !$page ? ' sticky' : '') . '">
  <div class="boxtop">
    <div class="bc ctr"></div>
    <div class="bc ctl"></div>
  </div>
  <div class="boxcontent">
    <div class="boxtitle' . ($node->sticky && !$page ? '-sticky' : '') . '">
      <h1>' . ($teaser ? l($node->title, "node/{$node->nid}") : check_plain($node->title)) . '</h1>
    </div>
    <div class="subboxcontent">';
    // Removed for now.  I SHALL RETURN!
    /*if ($tabs = theme('menu_local_tasks')) {
        $output .= $tabs;
      }*/
    $output .= '<div class="content">';
    if ($teaser && $node->teaser) {
        $output .= $node->teaser;
    } else {
        $output .= $node->body;
    }
    $output .= '</div>';
    if (theme_get_setting("toggle_node_info_{$node->type}")) {
        $submitted['node_submitted'] = array('title' => t("By !author at @date", array('!author' => theme('username', $node), '@date' => format_date($node->created, 'small'))), 'html' => TRUE);
    } else {
        $submitted['node_submitted'] = array();
    }
    $terms = array();
    if (module_exists('taxonomy')) {
        $terms = taxonomy_link("taxonomy terms", $node);
    }
    $links = array_merge($submitted, $terms);
    if ($node->links) {
        $links = array_merge($links, $node->links);
    }
    if (count($links)) {
        $output .= '<div class="links">' . theme('links', $links, array('class' => 'links inline')) . "</div>\n";
    }
    $output .= '</div>
  </div>
  <div class="boxbtm">
    <div class="bc cbr"></div>
    <div class="bc cbl"></div>
  </div>
</div>';
    return $output;
}
Beispiel #29
0
/**
 * Display a node.
 *
 * This is a hook used by node modules. It allows a module to define a
 * custom method of displaying its nodes, usually by displaying extra
 * information particular to that node type.
 *
 * @param $node
 *   The node to be displayed, as returned by node_load().
 * @param $view_mode
 *   View mode, e.g. 'full', 'teaser', ...
 * @return
 *   $node. The passed $node parameter should be modified as necessary and
 *   returned so it can be properly presented. Nodes are prepared for display
 *   by assembling a structured array, formatted as in the Form API, in
 *   $node->content. As with Form API arrays, the #weight property can be
 *   used to control the relative positions of added elements. After this
 *   hook is invoked, node_view() calls field_attach_view() to add field
 *   views to $node->content, and then invokes hook_node_view() and
 *   hook_node_view_alter(), so if you want to affect the final
 *   view of the node, you might consider implementing one of these hooks
 *   instead.
 *
 * For a detailed usage example, see node_example.module.
 *
 * @ingroup node_api_hooks
 */
function hook_view($node, $view_mode)
{
    if (node_is_page($node)) {
        $breadcrumb = array();
        $breadcrumb[] = l(t('Home'), NULL);
        $breadcrumb[] = l(t('Example'), 'example');
        $breadcrumb[] = l($node->field1, 'example/' . $node->field1);
        drupal_set_breadcrumb($breadcrumb);
    }
    $node->content['myfield'] = array('#value' => theme('mymodule_myfield', $node->myfield), '#weight' => 1);
    return $node;
}
Beispiel #30
0
function budgets_supplier_view($node, $teaser = FALSE, $page = FALSE)
{
    global $user;
    if (!isset($node->nid)) {
        $node = node_load(array('nid' => $node->id));
    }
    if ($node->sticky) {
        $node->sticky = 0;
    }
    guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_view(teaser)', $teaser);
    node_prepare($node, $teaser);
    if ($teaser) {
        $body = node_teaser($node->body, TRUE, $node->rated == true ? 600 : 300);
        $body = strip_tags($body, '<br> ');
        if ($node->rated) {
            if (!empty($node->logo)) {
                $img = '<img class="supplier-logo" src="/' . $node->logo . '" width="150">';
            }
            if (!empty($node->web_url)) {
                $img = '<a href="' . $node->web_url . '">' . $img . '</a>';
            }
            $body = "<div class=\"supplier-rated\">" . $img . $body . "</div>";
        }
        $node->content['body']['#value'] = $body;
    }
    if ($node->rated) {
        $node->content['body']['#value'] = '<p class="rating" >' . $node->official_rating . '</p>' . $node->content['body']['#value'];
    }
    $node->content['header'] = array('#value' => theme_budgets_supplier_header($node, $teaser), '#weight' => -10);
    if ($page) {
        drupal_set_breadcrumb(guifi_zone_ariadna($node->zone_id, 'node/%d/view/suppliers'));
        $body = $node->content['body']['#value'];
        if (!empty($node->logo)) {
            $img = '<img class="supplier-logo" src="/' . $node->logo . '" width="200">';
        }
        if (!empty($node->web_url)) {
            $img = '<a href="' . $node->web_url . '">' . $img . '</a>';
        }
        // Quotes
        //to-do
        // Accounting
        guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_view(accounting)', $node->accounting_urls);
        if (count($node->accounting_urls) > 1 and !empty($node->accounting_urls[0]['url'])) {
            // There are accounting urls
            $rows = array();
            foreach ($node->accounting_urls as $value) {
                guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_view(value)', $value);
                if (!empty($value['url'])) {
                    $rows[] = array(array('data' => $value['node_id']), array('data' => '<a href="' . $value['url'] . '">' . $value['url'] . '</a>'), array('data' => $value['comment']));
                }
            }
            $headers = array(array('data' => t('Node')), array('data' => t('Url')), array('data' => t('Comment')));
            $body .= '<br><hr><h2>' . t('Accounting') . '</h2>' . theme('table', $headers, $rows);
        }
        $node->content['body']['#value'] = $img . ' ' . $body;
    }
    $node->content['footer'] = array('#value' => theme_budgets_supplier_footer($node, $teaser), '#weight' => 10);
    return $node;
    // format antic
    $node = node_prepare($node, $teaser);
    $output = '';
    $qquotes = pager_query(sprintf('SELECT id ' . 'FROM {supplier_quote} ' . 'WHERE supplier_id = %d ' . 'ORDER BY title, partno, id', $node->nid), variable_get('default_nodes_main', 10));
    $output .= '<h3>' . t('Contact information:') . '<h3 />' . t('Phone') . ':' . $node->phone . t(' Email: ') . $user->uid ? l($node->notification) : l('login to view email contact', 'user/login');
    if (!$teaser) {
        $output .= '<br<br><hr><h2>' . t('Quotes') . '</h2>';
        while ($quote = db_fetch_object($qquotes)) {
            $output .= node_view(node_load(array('nid' => $quote->id)), TRUE, FALSE);
        }
        empty($quote) ? $output .= t('No quotes available') : NULL;
        $node->content['quotes'] = array('#value' => $output . theme('pager', NULL, variable_get('default_nodes_main', 10)), '#weight' => 1);
    }
    return $node;
}