t('Projects map block'), ); $blocks['projects_numbers_block'] = array( 'info' => t('Projects numbers block'), ); return $blocks; } /** * Implements hook_block_view(). */ function oieau_projects_map_block_view($delta='') { $block = array(); switch($delta) { case 'projects_map_block' : $block['content'] = _oieau_projects_map_block_view(); break; case 'projects_numbers_block' : $block['content'] = _oieau_projects_numbers_block_view(); break; } return $block; } /** * Custom function to assemble renderable array for block content. * Returns a renderable array with the block content. * @return * returns a renderable array of block content. */ function _oieau_projects_map_block_view() { // Build block and add scripts for chropleth map. $block = array( '#type' => 'markup', '#attached' => array( 'css' => array( drupal_get_path('module', 'oieau_projects_map') . '/css/map.css', ), 'js' => array( drupal_get_path('module', 'oieau_projects_map') . '/js/leaflet.googlemutant.js', drupal_get_path('module', 'oieau_projects_map') . '/js/map.js', // 'https://maps.googleapis.com/maps/api/js?key=AIzaSyBM1FgzemK-X1TS3r-Z5Fw-xyACcEjkF0E', //e.v 2019/09/25 supprimer car fait une erreur js et ON NE L'UTILISE PLUS! ), ) ); // Load project data and pass it on to client-side. $query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'node') ->propertyCondition('status', 1) ->propertyCondition('type', array('projet')) ->fieldOrderBy('field_projet_date_debut', 'value', 'DESC'); // If on a term page, filter out projects. if (drupal_is_front_page()) { // dsm('frontpage'); //on affiche tous les projets } elseif(arg(0) === 'taxonomy' && arg(1) === 'term' && is_numeric(arg(2))) { // dsm('taxonomy'); $term = taxonomy_term_load(arg(2)); $query->fieldCondition('field_projet_' . $term->vocabulary_machine_name, 'tid', arg(2)); drupal_add_js(array('project_map_projects_localisation' => $term), 'setting'); } else { $activites_de_loieau = oieau_projects_map_get_activiteoieau_from_trail(); if (!empty($activites_de_loieau)) { $query->fieldCondition('field_projet_activites_en_lien', 'value', $activites_de_loieau); } else { //accès par continent on affiche tout } // // // // function oieau_projects_map_get_activiteoieau_from_trail() { // $active_trail = menu_get_active_trail(); // // dsm($active_trail); // if(isset($active_trail[1]['title'])) { // dsm($active_trail[1]['title']); // dsm($active_trail[2]['title']); // dsm($active_trail[3]['title']); // // //on doit récupérer le tid métier correspondant à la page (si on est sur Foramtion profrssionnelle -> International // // on doit rechercher lt tid du vocabulaire métier Foramtion profrssionnelle -> International // //comme il y a plein de term "a l'international" on doit bien vérifier la hiérarchie // /* // Les pages concernés sont - Formation professionnel > a l'international // - Documentation s et publications > a l'international // - Animations et résaeaux d'acteurs > a l'international // - Appui / assistance conseil > a l'international // - Système d'information > a l'international // - a l'international > Accès par continent <<<< $exception : cas spècial où on doit tout afficher // // 20171213 : NOUVEAU : en fait on doit se baser sur la taxonomi activité de l'oieau // champs field_projet_activites_en_lien dans 3 langues mais toute en fr traduit, donc on se base toujours sur fr // Formation professionnelle|Formation professionnelle // Documentation et publication|Documentation et publications // Animation de réseaux d'acteurs|Animation de réseaux d'acteurs // Appui - assistance - conseil|Appui / Assistance Conseil // Systèmes d'information|Systèmes d'information // A l'international|A l'international // */ // //////////////////////////////////////////////////// // //version avec field_projet_activites_en_lien // //on prend le niveau 1 du menu et on recherche tous les projets qui ont ce nom dans activité en lien // $active_trail[1]['title'] = str_replace(array('
', '
', '
'), array(' ', ' ', ' '), $active_trail[1]['title']); // dsm($active_trail[1]['title']); // $activites_de_loieau = ''; // dsm(oieau_utils_translation_get_translation_term($active_trail[1]['title'], 'all')); // if (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Formation professionnelle','all'))) { // $activites_de_loieau = oieau_utils_translation_get_translation_term($active_trail[1]['title'], 'fr'); // } elseif (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Documentation et publication', 'all'))) { // $activites_de_loieau = oieau_utils_translation_get_translation_term($active_trail[1]['title'], 'fr'); // } elseif (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Animation de réseaux d\'acteurs','all'))) { // $activites_de_loieau = oieau_utils_translation_get_translation_term($active_trail[1]['title'], 'fr'); // } elseif (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Appui - assistance - conseil','all'))) { // $activites_de_loieau = oieau_utils_translation_get_translation_term($active_trail[1]['title'], 'fr'); // } elseif (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Systèmes d\'information', 'all'))) { // $activites_de_loieau = oieau_utils_translation_get_translation_term($active_trail[1]['title'], 'fr'); // } // dsm($activites_de_loieau); // if (!empty($activites_de_loieau)) { // $query->fieldCondition('field_projet_activites_en_lien', 'value', $activites_de_loieau); // } else { // //accès par continent on affiche tout // } // // //////////////////////////////////////////////////// // //ancienne version avec field_projet_position_menu // // $exception = true; // // if(in_array($active_trail[1]['title'],array('A nivel internacional', 'Internationally', "A l'international")) && // // (isset($active_trail[2]['title']) && // // in_array($active_trail[2]['title'],array('Acceso por continente', 'Access per continent', "Accès par continent"))) && // // !isset($active_trail[3])) { // // $exception = false; // // } // // $active_trail[1]['title'] = str_replace('
', ' ', $active_trail[1]['title']); // // // // //e.vincent get by translated name // // //$metier = taxonomy_get_term_by_name($active_trail[1]['title']); // // $metier = oieau_utils_translation_get_term_by_name_translation($active_trail[1]['title'], $GLOBALS['language']->language); // // // // if(!empty($metier) && $exception) { // // $metier = array_shift(array_values($metier)); // // $query->fieldCondition('field_projet_position_menu', 'tid', $metier->tid); // // } else { // // // dsm('empty or $exception'); // // } // } } $result = $query->execute(); $projects = node_load_multiple(array_keys($result['node'])); // dsm($projects); // Reset array keys to prevent JS messing with the order. $projects = array_values($projects); // Transfer only necessary info to client-side. foreach ($projects as $key => $project) { $projects[$key] = new stdClass(); $projects[$key]->nid = $project->nid; $projects[$key]->title = $project->title; $projects[$key]->field_projet_date_debut['und'][0]['value'] = $project->field_projet_date_debut['und'][0]['value']; $projects[$key]->field_projet_date_fin['und'][0]['value'] = $project->field_projet_date_fin['und'][0]['value']; $projects[$key]->field_projet_pays['und'] = $project->field_projet_pays['und']; } //e.vincent send translation via setting $map_language = array(); $map_language['lang'] = $GLOBALS['language']->language; $map_language['project'] = t('Project'); $map_language['show_more'] = t('See more'); $map_language['click_country'] = t('Click on the country to see more details'); drupal_add_js(array('project_map_projects_data' => $projects), 'setting'); drupal_add_js(array('project_map_language_data' => $map_language), 'setting'); drupal_add_js(array('project_map_module_path' => base_path() . drupal_get_path('module', 'oieau_projects_map')), 'setting'); // Render map. E $map = leaflet_map_get_info(); $features = array( array( 'type' => 'point', 'lat' => 0, 'lon' => 0 ), ); if(drupal_is_front_page()) { $block['#markup'] = leaflet_render_map($map['projects_map'], $features, '550px'); } else { $block['#markup'] = leaflet_render_map($map['projects_map'], $features, '600px'); } return $block; } /** * Custom function to assemble renderable array for block content. * Returns a renderable array with the block content. * @return * returns a renderable array of block content. */ function _oieau_projects_numbers_block_view() { if(arg(0) === 'taxonomy' && arg(1) === 'term' && is_numeric(arg(2))) { $term = taxonomy_term_load(arg(2)); } $query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'node') ->propertyCondition('status', 1) ->propertyCondition('type', array('projet')); $active_trail = menu_get_active_trail(); $exception = true; // if($active_trail[1]['title'] == "A l'international" && // (isset($active_trail[2]['title']) && // $active_trail[2]['title'] == "Accès par continent") && // !isset($active_trail[3])) { // $exception = false; // } if(in_array($active_trail[1]['title'],array('A nivel internacional', 'Internationally', "A l'international")) && (isset($active_trail[2]['title']) && in_array($active_trail[2]['title'],array('Acceso por continente ', 'Access per continent', "Accès par continent"))) && !isset($active_trail[3])) { $exception = false; } if(isset($term) && $exception) { $query->fieldCondition('field_projet_' . $term->vocabulary_machine_name, 'tid', arg(2)); } $result = $query->execute(); $projects = node_load_multiple(array_keys($result['node'])); $count_pays = array(); $count_years = 0; $starting_year = date('Y'); $ending_year = 0; foreach ($projects as $key => $project) { foreach ($project->field_projet_pays[LANGUAGE_NONE] as $pays) { if(isset($count_pays[$pays['iso2']])) { $count_pays[$pays['iso2']]++; } else { $count_pays[$pays['iso2']] = 0; } } if(isset($project->field_projet_date_debut[LANGUAGE_NONE][0]['value'])) { if(date('Y', strtotime($project->field_projet_date_debut[LANGUAGE_NONE][0]['value'])) < $starting_year) { $starting_year = date('Y', strtotime($project->field_projet_date_debut[LANGUAGE_NONE][0]['value'])); } } if(isset($project->field_projet_date_fin[LANGUAGE_NONE][0]['value'])) { if(date('Y', strtotime($project->field_projet_date_fin[LANGUAGE_NONE][0]['value'])) > $ending_year) { $ending_year = date('Y', strtotime($project->field_projet_date_fin[LANGUAGE_NONE][0]['value'])); } } } $count_years = $ending_year - $starting_year; // Build block and add scripts for chropleth map. $block = array( '#type' => 'markup', '#attached' => array( 'css' => array( drupal_get_path('module', 'oieau_projects_map') . '/css/numbers.css', ), 'js' => array( drupal_get_path('module', 'oieau_projects_map') . '/js/odometer.min.js', ), ) ); $block['#markup'] = '
'; if(isset($term)) { $block['#markup'] .= '

' . t("IOW's action in @term is", array('@term' => $term->name)) . '

'; } else { $block['#markup'] .= '

' . t("IOW's action is") . '

'; } $block['#markup'] .= '
' . count($projects) . '
'.t('projects').'
'; $block['#markup'] .= '
' . count($count_pays) . '
'.t('country').'
'; $block['#markup'] .= '
' . ($count_years > 25 ? 25 : $count_years) . '
'. t('years of experience').'
'; $block['#markup'] .= '
'; return $block; } /** * Define one or map definitions to be used when rendering a map. * * leaflet_map_get_info() will grab every defined map, and the returned * associative array is then passed to leaflet_render_map(), along with a * collection of features. * * The settings array maps to the settings available to leaflet map object, * http://leafletjs.com/reference-1.0.2.html#map * * Layers are the available base layers for the map and, if you enable the * layer control, can be toggled on the map. On top of layers, you can add * overlays. Overlays are defined just a layers, but have their 'layer_type' * set to 'overlay'. See drupal.org/project/leaflet_more_maps for examples. * * @return array * Associative array containing a complete leaflet map definition. */ function oieau_projects_map_leaflet_map_info() { return array( 'projects_map' => array( 'label' => 'projects_map', 'description' => t('Map used to display projects'), 'settings' => array( 'dragging' => TRUE, 'touchZoom' => TRUE, 'scrollWheelZoom' => FALSE, 'doubleClickZoom' => TRUE, 'zoomControl' => TRUE, 'attributionControl' => TRUE, 'trackResize' => TRUE, 'fadeAnimation' => TRUE, 'zoomAnimation' => TRUE, 'closePopupOnClick' => TRUE, 'layerControl' => FALSE, 'minZoom' => 2, 'zoom' => 2 ), 'layers' => array( 'earth' => array( 'urlTemplate' => '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', 'options' => array( 'attribution' => 'OSM Mapnik' ), ), ), ), ); } /** * view projets / block_3 * require_once(drupal_get_path('module', 'oieau_projects_map') . '/oieau_projects_map.module'); * return oieau_projects_map_contextual_filter_view_par_continent(); */ function oieau_projects_map_contextual_filter_view_par_continent() { // dsm(__FUNCTION__); if (arg(0) == 'taxonomy' && arg(1) == 'term') { return false; } $active_trail = menu_get_active_trail(); if (in_array($active_trail[1]['title'], oieau_utils_translation_get_translation_term('Tous nos projets', 'all'))) { // dsm("return all0 new"); return 'all'; } //Si Sur page A l'international > Par continent : on affiche tout if (in_array($active_trail[1]['title'], oieau_utils_translation_get_translation_term('A l\'international', 'all')) && in_array($active_trail[2]['title'], oieau_utils_translation_get_translation_term('Accès par continent', 'all')) && !isset($active_trail[3]) ) { // dsm("return all1 new"); return 'all'; } // dsm('-'.$active_trail[1]['title'] .'-'); // dsm('-'.$active_trail[2]['title'].'-'); // dsm(in_array($active_trail[1]['title'], oieau_utils_translation_get_translation_term('A l\'international', 'all'))); // dsm(in_array($active_trail[2]['title'], oieau_utils_translation_get_translation_term('Nos projets par continent', 'all'))); if (in_array($active_trail[1]['title'], oieau_utils_translation_get_translation_term('A l\'international', 'all')) && in_array($active_trail[2]['title'], oieau_utils_translation_get_translation_term('Nos projets par continent', 'all')) && !isset($active_trail[3]) ) { // dsm("return all1 new"); return 'all'; } /////////////////////////////////////////////////////// // new method using field_projet_activites_en_lien // $activites_de_loieau = oieau_projects_map_get_activiteoieau_from_trail(); // // $activites_de_loieau = implode('+', $activites_de_loieau); // // dsm($activites_de_loieau); // return $activites_de_loieau; /////////////////////////////////////////////////////// // new //http://mantis.oieau.fr/view.php?id=2862 //en fait on doit toujours se basé sur le champs position dans le menu pour le block_3 //seul les pages internationla se base sur le champs activités de l'oieau... $tid = oieau_projects_map_get_metier_from_trail('hierarchy', $GLOBALS['language']->language); // dsm($tid); // $metier = oieau_utils_translation_get_term_by_name_translation($metier[0], $GLOBALS['language']->language); if(!empty($tid)) { // $metier = array_shift($metier); return $tid; } else { // dsm('no tid found'); } // dsm("new return false"); return false; //old value on position menu // $active_trail = menu_get_active_trail(); // if(in_array($active_trail[1]['title'], array("Internationally", "A l'international", 'A nivel internacional')) && // (isset($active_trail[2]['title']) && // in_array($active_trail[2]['title'], array("Access per continent", "Accès par continent", 'Acceso por continente'))) && // !isset($active_trail[3]) || (in_array($active_trail[1]['title'], array("All our projects", "Tous nos projets",'Todos nuestros proyectos')))) { // return "all"; // } // $last_menu = array_values(array_slice($active_trail, -1))[0]; // // if(isset($last_menu['title'])) { // $last_menu['title'] = str_replace('
', ' ', $last_menu['title']); // // //$metier = taxonomy_get_term_by_name($last_menu['title']); // $metier = oieau_utils_translation_get_term_by_name_translation($last_menu['title'], $GLOBALS['language']->language); // // if(!empty($metier)) { // if(count($metier) > 1) { // // foreach($metier as $m) { // // $parent = taxonomy_get_parents($m->tid); // $parent = array_shift(array_values($parent)); // // $second_last_menu = array_values(array_slice($active_trail, -2, 1))[0]; // $second_last_menu['title'] = str_replace('
', ' ', $second_last_menu['title']); // // if( // $second_last_menu['title'] == $parent->name // || // ( isset($parent->name_field[$GLOBALS['language']->language][0]['value']) // && $second_last_menu['title'] == $parent->name_field[$GLOBALS['language']->language][0]['value'] // ) // ) { // // return $m->tid; // } // } // } else { // $metier = array_shift(array_values($metier)); // // return $metier->tid; // } // } // } // // return false; } /** * views projets / block_1 * require_once(drupal_get_path('module', 'oieau_projects_map') . '/oieau_projects_map.module'); * return oieau_projects_map_contextual_filter_view_a_linternational(); */ function oieau_projects_map_contextual_filter_view_a_linternational() { // dsm(__FUNCTION__); if (arg(0) == 'taxonomy' && arg(1) == 'term') { return false; } // dsm(__FUNCTION__ . 'apres taxonomy'); /////////////////////////////////////////////////////// // new method using field_projet_activites_en_lien $activites_de_loieau = oieau_projects_map_get_activiteoieau_from_trail(); // $activites_de_loieau = implode('+', $activites_de_loieau); // dsm($activites_de_loieau); return $activites_de_loieau; // /////////////////////////////////////////////////////// // //old method using taxonomy metier // $active_trail = menu_get_active_trail(); // $first_menu = array_values(array_slice($active_trail, -2, 1))[0]; // if(isset($first_menu['title'])) { // $first_menu['title'] = str_replace('
', ' ', $first_menu['title']); // // //$metier = taxonomy_get_term_by_name($first_menu['title']); // $metier = oieau_utils_translation_get_term_by_name_translation($first_menu['title'], $GLOBALS['language']->language); // // if(!empty($metier)) { // $metier = array_shift(array_values($metier)); // // Get all children of top menu // $children = taxonomy_get_children($metier->tid); // $list = []; // foreach($children as $child) { // $list[] = $child->tid; // $children2 = taxonomy_get_children($child->tid); // if(!empty($children2)) { // foreach($children2 as $child2) { // $list[] = $child->tid; // } // } // } // $list = implode('+', $list); // return $list; // } // } // return false; } function oieau_projects_map_get_activiteoieau_from_trail() { // dsm(__FUNCTION__); $activites_de_loieau = []; $active_trail = menu_get_active_trail(); if(isset($active_trail[1]['title'])) { $active_trail[1]['title'] = str_replace(array('
', '
', '
'), array(' ', ' ', ' '), $active_trail[1]['title']); // dsm($active_trail[1]['title']); // dsm(oieau_utils_translation_get_translation_term($active_trail[1]['title'], 'all')); if (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Formation professionnelle','all'))) { $activites_de_loieau = oieau_utils_translation_get_translation_term($active_trail[1]['title'], 'fr'); } elseif (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Documentation et publication', 'all'))) { $activites_de_loieau = oieau_utils_translation_get_translation_term($active_trail[1]['title'], 'fr_view'); } elseif (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Animation de réseaux d\'acteurs','all'))) { $activites_de_loieau = oieau_utils_translation_get_translation_term($active_trail[1]['title'], 'fr'); } elseif (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Appui - assistance - conseil','all'))) { $activites_de_loieau = oieau_utils_translation_get_translation_term($active_trail[1]['title'], 'fr_view'); } elseif (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Systèmes d\'information', 'all'))) { $activites_de_loieau = oieau_utils_translation_get_translation_term($active_trail[1]['title'], 'fr'); } } // dsm($activites_de_loieau); return $activites_de_loieau; } function oieau_projects_map_get_metier_from_trail($type, $lang) { // dsm(__FUNCTION__); // dsm($lang); $metier = []; $active_trail = menu_get_active_trail(); $metier_taxonomy = oieau_import_get_taxonomy_hierarchy_format(4, true); if ($type == 'hierarchy') { //on doit retrouver le tid en utilisant toutes la hiérarchie // dsm($metier_taxonomy); // dsm($active_trail); $trail_name = []; if (count($active_trail) > 1) { $trail_name[] = mb_strtolower(str_replace(array('
', '
', '
'), array(' ', ' ', ' '), $active_trail[1]['title'])); } if (count($active_trail) > 2) { $trail_name[] = mb_strtolower(str_replace(array('
', '
', '
'), array(' ', ' ', ' '), $active_trail[2]['title'])); } if (count($active_trail) > 3) { $trail_name[] = mb_strtolower(str_replace(array('
', '
', '
'), array(' ', ' ', ' '), $active_trail[3]['title'])); } // dsm($trail_name); if (count($trail_name) == 1) { if (isset($metier_taxonomy[ $trail_name[0] ])) { // dsm($trail_name[0] .' = ' . $metier_taxonomy[ $trail_name[0] ]['tid']); $metier = $metier_taxonomy[ $trail_name[0] ]['tid']; } else { // dsm('not found '); dsm($trail_name[0] .' = ' . $metier_taxonomy[ $trail_name[0] ]['tid']); } } if (count($trail_name) == 2) { if (isset($metier_taxonomy[ $trail_name[0] ][ $trail_name[1] ])) { // dsm($trail_name[0] . '>' . $trail_name[1] .' = ' . $metier_taxonomy[ $trail_name[0] ][ $trail_name[1] ]['tid']); $metier = $metier_taxonomy[ $trail_name[0] ][ $trail_name[1] ]['tid']; } else { // dsm('not found'); dsm($trail_name[0] . '>' . $trail_name[1] .' = ' . $metier_taxonomy[ $trail_name[0] ][ $trail_name[1] ]['tid']); } } if (count($trail_name) == 3) { if (isset($metier_taxonomy[ $trail_name[0] ][ $trail_name[1] ][ $trail_name[2] ])) { // dsm($trail_name[0] . '>' . $trail_name[1]. '>' . $trail_name[2] .' = ' . $metier_taxonomy[ $trail_name[0] ][ $trail_name[1] ][ $trail_name[2] ]['tid']); $metier = $metier_taxonomy[ $trail_name[0] ][ $trail_name[1] ][ $trail_name[2] ]['tid']; } else { // dsm('not found'); dsm($trail_name[0] . '>' . $trail_name[1]. '>' . $trail_name[2] .' = ' . $metier_taxonomy[ $trail_name[0] ][ $trail_name[1] ][ $trail_name[2] ]['tid']); } } // dsm('nouveau tid'); // dsm($metier); } else { //bloc avancement projet if(isset($active_trail[1]['title'])) { $active_trail[1]['title'] = mb_strtolower(str_replace(array('
', '
', '
'), array(' ', ' ', ' '), $active_trail[1]['title'])); if (isset($metier_taxonomy[ $active_trail[1]['title'] ])) { // dsm($active_trail[1]['title'] .' = ' . $metier_taxonomy[ $active_trail[1]['title'] ]['tid']); $metier = $metier_taxonomy[ $active_trail[1]['title'] ]['tid']; } else { // dsm('not found'); } // dsm('new tid pour avancement projet'); // dsm($metier); // dsm($active_trail[1]['title']); // dsm(oieau_utils_translation_get_translation_term($active_trail[1]['title'], 'all')); // if (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Formation professionnelle','all'))) { // $metier = oieau_utils_translation_get_translation_term($active_trail[1]['title'], $lang); // } elseif (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Documentation et publication', 'all'))) { // $metier = oieau_utils_translation_get_translation_term($active_trail[1]['title'], $lang); //todo fr_annn // } elseif (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Animation de réseaux d\'acteurs','all'))) { // $metier = oieau_utils_translation_get_translation_term($active_trail[1]['title'], $lang); // } elseif (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Appui - assistance - conseil','all'))) { // $metier = oieau_utils_translation_get_translation_term($active_trail[1]['title'], $lang); // } elseif (in_array($active_trail[1]['title'] ,oieau_utils_translation_get_translation_term('Systèmes d\'information', 'all'))) { // $metier = oieau_utils_translation_get_translation_term($active_trail[1]['title'], $lang); // } } // // dsm('ancien tid pour avancement projet'); // dsm($metier); } unset($metier_taxonomy); return $metier; } /** * view projets / block_2 * require_once(drupal_get_path('module', 'oieau_projects_map') . '/oieau_projects_map.module'); * return oieau_projects_map_contextual_filter_view_a_linternational_avancementprojet(); */ function oieau_projects_map_contextual_filter_view_a_linternational_avancementprojet() { // dsm(__FUNCTION__); if (arg(0) == 'taxonomy' && arg(1) == 'term') { return false; } // dsm(__FUNCTION__ . 'apres taxonomy'); /////////////////////////////////////////////////////// // new method using field_projet_activites_en_lien // on doit trouver le tid qui va dans le champs field_metier qui tape dans la taxonomy // Métier //en fonction de la page //Si Sur page "tous nos projet" : on affiche tout $active_trail = menu_get_active_trail(); // dsm($active_trail); // dsm(oieau_utils_translation_get_translation_term('Tous nos projets', 'all')); // dsm(oieau_utils_translation_get_translation_term('A l\'international', 'all')); // dsm(oieau_utils_translation_get_translation_term('Accès par continent', 'all')); if (in_array($active_trail[1]['title'], oieau_utils_translation_get_translation_term('Tous nos projets', 'all'))) { // dsm("return all0 new"); return 'all'; } //Si Sur page A l'international > Par continent : on affiche tout if (in_array($active_trail[1]['title'], oieau_utils_translation_get_translation_term('A l\'international', 'all')) && in_array($active_trail[2]['title'], oieau_utils_translation_get_translation_term('Accès par continent', 'all')) && !isset($active_trail[3]) ) { // dsm("return all1 new"); return 'all'; } // dsm('-'.$active_trail[1]['title'] .'-'); // dsm('-'.$active_trail[2]['title'].'-'); // dsm(in_array($active_trail[1]['title'], oieau_utils_translation_get_translation_term('A l\'international', 'all'))); // dsm(in_array($active_trail[2]['title'], oieau_utils_translation_get_translation_term('Nos projets par continent', 'all'))); if (in_array($active_trail[1]['title'], oieau_utils_translation_get_translation_term('A l\'international', 'all')) && in_array($active_trail[2]['title'], oieau_utils_translation_get_translation_term('Nos projets par continent', 'all')) && !isset($active_trail[3]) ) { // dsm("return all1 new"); return 'all'; } //Si sur page NIVEAU 1 > A l'international, on ne prenq que le tid correspondant au niveau 1 $metier = oieau_projects_map_get_metier_from_trail('avancementprojet', $GLOBALS['language']->language); // dsm('metier found'); // dsm($metier); // $metier = oieau_utils_translation_get_term_by_name_translation($metier[0], $GLOBALS['language']->language); if(!empty($metier)) { // $metier = array_shift($metier); // dsm($metier); // dsm($metier->tid); // dsm($metier->name); // dsm("new return " . $metier->tid); // return $metier->tid; return $metier; } else { // dsm('no tid found'); } // dsm("new return false"); return false; // /////////////////////////////////////////////////////// // //old method using taxonomy metier // if (arg(0) == 'taxonomy' && arg(1) == 'term') { // dsm('return false0'); // return false; // } // // $active_trail = menu_get_active_trail(); // // /* // if($active_trail[1]['title'] == "A l'international" && // (isset($active_trail[2]['title']) && // $active_trail[2]['title'] == "Accès par continent") && // !isset($active_trail[3]) || ($active_trail[1]['title'] == "Tous nos projets")) { // return "all"; // } // */ // if(in_array($active_trail[1]['title'], array("Internationally", "A l'international", 'A nivel internacional')) && // // (isset($active_trail[2]['title']) && // in_array($active_trail[2]['title'], array("Access per continent", "Accès par continent", 'Acceso por continente'))) && // !isset($active_trail[3]) || (in_array($active_trail[1]['title'], array("All our projects", "Tous nos projets",'Todos nuestros proyectos')))) { // dsm('return all'); // return "all"; // } // // $first_menu = array_values(array_slice($active_trail, -2, 1))[0]; // if(isset($first_menu['title'])) { // $first_menu['title'] = str_replace('
', ' ', $first_menu['title']); // // //$metier = taxonomy_get_term_by_name($first_menu['title']); // $metier = oieau_utils_translation_get_term_by_name_translation($first_menu['title'], $GLOBALS['language']->language); // // if(!empty($metier)) { // $metier = array_shift(array_values($metier)); // dsm('return tid ' . $metier->tid); // return $metier->tid; // } // } // dsm('return false'); // return false; }