GFAko toponimia eta Bergarakoa alderatzeko orria

Lotutako hitzak berbaren dagokion sarreran erantsita azalduko dira.


'.l('CSV', $_GET['q'], array('query' => 'nola=CSV')).'

'; $output .= drupal_get_form('bilatu_form'); $csv = isset($_GET['nola']) && $_GET['nola'] == 'CSV' ? TRUE : FALSE; drupal_add_js(drupal_get_path('module', 'toponimo') .'/js/wz_tooltip.js', 'module', 'footer'); $auzo = get_terms_from_vocabulary(5); $mota = get_terms_from_vocabulary(6); $orriko = $csv ? 10000 : 50; $where = array(); if(!empty($_SESSION['bila']['toponimo'])){ $key = db_escape_string($_SESSION['bila']['toponimo']); $where[] = sprintf('(LOWER(n.title) LIKE "%%%s%%" OR LOWER(g.NOMBRE) like "%%%s%%")', $key, $key); } $where_sql = $where ? ' WHERE ' . join($where, ' AND ') : ''; $result = pager_query($sql = 'SELECT t.nid, n.title toponimo, t.s5 auzo, t.s6 mota, t.ohar, g.id gfa_id, g.NOMBRE nombre, g.TIPO_E tipo_e, g.calle, g.portal, g.bis FROM topo_gfa g LEFT JOIN content_field_gfa_id c ON g.id = c.field_gfa_id_value LEFT JOIN toponimo t ON c.nid = t.nid LEFT JOIN node n ON t.nid = n.nid' . $where_sql, $orriko); drupal_set_message($sql, 'status'); while($row = db_fetch_array($result)){ $row['auzo'] = $auzo[$row['auzo']]; $row['mota'] = $mota[$row['mota']]; $row['nid'] = $csv ? $row['nid'] : l($row['nid'], "node/{$row['nid']}"); $row['ohar'] = $csv ? strip_tags($row['ohar']) : extra_glob_it($row['ohar']); $rows[] = $row; } $headers = array('NID', 'Toponimo', 'Auzo', 'Elementu geografiko', 'Ohar', 'GFA_ID', 'GFA toponimo', 'GFA mota', 'GFA kale', 'GFA atari', 'GFA bis'); if($csv){ send_csv($rows); } else { $output .= theme('table', $headers, $rows); $output .= theme('pager'); print $output; } function get_terms_from_vocabulary($vid){ $terms = array(); $tree = taxonomy_get_tree($vid); foreach($tree as $term){ $terms[$term->tid] = $term->name; } return $terms; } function send_csv($rows) { header( 'Content-Type: text/csv' ); header( 'Content-Disposition: attachment;filename=toponimo.csv'); $fp = fopen('php://output', 'w'); foreach($rows as $row){ fputcsv($fp, $row, ';', '"'); } fclose($fp); exit; } function bilatu_form(){ $form['toponimo'] = array( '#type' => 'textfield', '#title' => t('Toponimoa'), '#size' => 24, '#default_value' => isset($_SESSION['bila']['toponimo']) ? $_SESSION['bila']['toponimo'] : '', ); /*Toponimoa $form['auzo'] = array( '#type' => 'select', '#value' => t('Auzoa'), '#options' => array(0 => 'Edozein'), '#default_value' => isset($_SESSION['bila']['toponimo']) ? $_SESSION['bila']['toponimo'] : '', );*/ $form['submit'] = array( '#type' => 'submit', '#value' => t('Bilatu') ); return $form; } function bilatu_form_submit($form, &$form_state){ $_SESSION['bila'] = $form_state['values']; drupal_goto($_GET['q']); } ?>

Batere ez.
Lotura berria erantsi