$vocabulary) { if (drupal_strtolower($vocabulary->name) == drupal_strtolower($name)) { $ret = $vid; break; } } return $ret; } /** * Shared filter form for course lists. * * Filter values are taken from the form logic or, when absent, from the * session, in order for them to be persistent across non-form pages. * * @return array */ function fgcf_filter_form($form_state) { $form['filtre'] = array( '#title' => t('Filtrer les formations'), '#attributes' => array('class' => 'fgcf-filtre'), '#type' => 'fieldset', '#collapsible' => TRUE, ); $dif = isset($form_state['storage']['dif']) ? $form_state['storage']['dif'] : isset($_SESSION['fgcf']['dif']) ? $_SESSION['fgcf']['dif'] : FALSE; $form['filtre']['dif'] = array( '#type' => 'checkbox', '#default_value' => $dif, '#title' => t('Eligibles DIF'), ); $modalite = isset($form_state['storage']['modalite']) ? $form_state['storage']['modalite'] : isset($_SESSION['fgcf']['modalite']) ? $_SESSION['fgcf']['modalite'] : array(); $form['filtre']['modalite'] = array( '#title' => t('Modalité'), '#type' => 'checkboxes', '#options' => array( 'inter' => t('Inter-entreprises'), 'intra' => t('Intra-entreprise'), 'autres' => t('Autres'), ), '#default_value' => $modalite, ); $form['filtre']['submit'] = array( '#type' => 'submit', '#value' => t('Appliquer le filtre'), ); return $form; } function fgcf_init() { if (arg(0) == 'fgcf') { drupal_add_css(drupal_get_path('module', 'fgcf') .'/theme/css/fgcf.css'); } } /** * Submit handler for fgcf_filter_form(). * * @param array $form * @param array $form_state * * @return void */ function fgcf_filter_form_submit($form, &$form_state) { $form_state['storage']['modalite'] = $form_state['values']['modalite']; $form_state['storage']['dif'] = $form_state['values']['dif']; $_SESSION['fgcf'] = array( 'dif' => $form_state['storage']['dif'], 'modalite' => $form_state['storage']['modalite'], ); } /** * Implements hook_nodeapi(). * * @param object $node * @param string $op * @param mixed $a3 * @param mixed $a4 */ function fgcf_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { switch ($op) { case 'view': if ($a3 /* !teaser */ || !$a4 /* page */) { break; } drupal_add_css(drupal_get_path('module', 'fgcf') .'/theme/css/fgcf.css'); switch ($node->type) { case 'fgcf_prestataire': $bc = drupal_get_breadcrumb(); $bc[] = l(t('Catalogue formations'), 'fgcf'); $bc[] = l(t('Organismes'), 'fgcf/organisme'); drupal_set_breadcrumb($bc); break; case 'fgcf_fiche': $nat_config = variable_get('nat_config', NULL); $vid = isset($nat_config['types']['fgcf_thematique']) ? reset($nat_config['types']['fgcf_thematique']) : 0; unset($nat_config); $taxo2 = array(); foreach ($node->taxonomy as $tid => $term) { if ($term->vid != $vid) { $taxo2[$tid] = $term; } else { $node->fgcf_scat = $term; // Single by configuration } } $node->taxonomy = $taxo2; unset($taxo2, $tid, $term); // Build cat/scat[/scat]* path $cats = array(); $parents = taxonomy_get_parents($node->fgcf_scat->tid); foreach ($parents as $tid => $term) { $cats[] = $term; } $cats[] = $node->fgcf_scat; $node->content['fgcf_catpath'] = array( '#value' => theme('fgcf_thematiques', $cats), ); $bc = drupal_get_breadcrumb(); $bc[] = l(t('Catalogue formations'), 'fgcf'); $bc[] = l(t('Thématiques'), 'fgcf/thematique'); $bc[] = l($cats[0]->description, 'fgcf/thematique/'. $cats[0]->tid); $bc[] = l($cats[1]->description, 'fgcf/thematique/'. $cats[1]->tid); drupal_set_breadcrumb($bc); unset($cats, $parents, $tid, $term); break; } } } /** * Implements hook_perm(). * * @return array */ function fgcf_perm() { $ret = array( 'access course catalog', ); return $ret; } /** * Implements hook_menu(). * * @return array */ function fgcf_menu() { $read_access = array('access course catalog'); $items = array(); $items['fgcf'] = array( 'title' => 'Catalogue Formations', 'page callback' => 'fgcf_page_home', 'access arguments' => $read_access, 'menu_name' => 'primary-links', ); $items['fgcf/format'] = array( 'type' => MENU_CALLBACK, 'title' => 'Formations par format', 'page callback' => 'fgcf_page_format', 'access arguments' => $read_access, ); $items['fgcf/organisme'] = array( 'type' => MENU_CALLBACK, 'title' => 'Formations par organisme', 'page callback' => 'fgcf_page_organisme', 'access arguments' => $read_access, ); return $items; } function fgcf_page_format($format = 0) { $bc = drupal_get_breadcrumb(); $bc[] = l(t('Catalogue formations'), 'fgcf'); $filter_form = drupal_get_form('fgcf_filter_form'); $ret = $filter_form; $vid = _fgcf_get_vocabulary_by_name('FGCF Format de cours'); if (empty($format)) { $ret .= views_embed_view('fgcf_formats_de_formations', 'default', $vid); } else { $bc[] = l(t('Formats de formation'), 'fgcf/format'); $term = taxonomy_get_term($format); if (!is_object($term) || !isset($term->vid) || $term->vid != $vid) { $format = 0; } $ret .= views_embed_view('fgcf_formations_par_format', 'default', $format); } drupal_set_breadcrumb($bc); return $ret; } function fgcf_page_organisme() { $bc = drupal_get_breadcrumb(); $bc[] = l(t('Catalogue formations'), 'fgcf'); drupal_set_breadcrumb($bc); $filter_form = drupal_get_form('fgcf_filter_form'); $ret = $filter_form; $ret .= views_embed_view('fgcf_organismes_de_formation'); return $ret; } /** * Page callback for fgcf. * * @return string */ function fgcf_page_home() { drupal_add_css(drupal_get_path('module', 'fgcf') .'/theme/css/fgcf.css'); drupal_set_title('Catalogue des formations France Galop'); $filter_form = drupal_get_form('fgcf_filter_form'); $ret = theme('fgcf_home', $filter_form); return $ret; } /** * Preprocess callback for theme('fgcf_home'). * * @param unknown_type $variables * * @return void */ function fgcf_preprocess_fgcf_home(&$variables) { $variables['app_path'] = url('fgcf'); } /** * Implements hook_theme(). * * @param array $existing * @param string $type * @param string $theme * @param string $path * * @return array */ function fgcf_theme($existing, $type, $theme, $path) { $ret = array( 'fgcf_home' => array( 'arguments' => array('filter_form' => array()), 'template' => 'fgcf-home', 'path' => $path .'/theme', ), 'fgcf_thematiques' => array( 'arguments' => array('terms' => array()), ), /* 'fgcf_fiche_node_form' => array( 'arguments' => array('element' => NULL), 'template' => 'fgcf-fiche-node-form', 'path' => $path .'/theme', ), */ ); return $ret; } function fgcf_views_api() { $ret = array( 'api' => '3.0-alpha1', 'path' => drupal_get_path('module', 'fgcf') . '/views', ); return $ret; } /** * Theme function for course themes. * * @param array $terms * * @return string */ function theme_fgcf_thematiques($terms) { $items = array(); foreach ($terms as $tid => $term) { $items[] = l($term->description, taxonomy_term_path($term)); } // Build cat logo $cat_term = reset($terms); $nodes = nat_get_nids(array($cat_term->tid), TRUE); $cat_node = reset($nodes); $node_view = node_build_content($cat_node, FALSE, FALSE); $logo = drupal_render($node_view->content['field_fgcf_thematique_logo']); array_unshift($items, $logo); $ret = '