* @version $id SVN * @access public * @license http://opensource.org/licenses/gpl-3.0.html */ include_once('../search/' . SQL . '.inc.php'); /** * LogKeywordsSearch() * * @param string $keywords * @param string $type * @param string $rub =-1 (option) * @return void */ function LogKeywordsSearch($keywords, $type, $searchtype, $rub = -1) { $sep = '##'; $fp = @fopen(LOG_KEYWORDS, 'a'); @fwrite($fp, $keywords . $sep); // mots clefs @fwrite($fp, $type . $sep); // type ADMIN ou PUBLIC @fwrite($fp, $searchtype . $sep); // type de recherche if ($rub != -1) @fwrite($fp, $rub . $sep); // rubrique matchées @fwrite($fp, i2c_realip() . $sep); // adresse @fwrite($fp, date('[d-m-y H:i:s]' . $sep)); // date @fwrite($fp, date("\n")); @fclose($fp); } /** * MatchDataFormat() * * @param string $keywords * @param string $searchtype * @return string $formatted_keywords */ function MatchDataFormat($keywords, $searchtype) { $keywords = trim(addslashes($keywords)); switch ($searchtype) { case 'one': if(strtolower(SQL)=='pgsql') { $words = explode(' ', $keywords); $formatted_keywords = ''; $op=''; foreach($words as $value) { $formatted_keywords .= $op . $value; $op=' | '; } trim($formatted_keywords); } if(strtolower(SQL)=='mysql') { $formatted_keywords = $keywords; } break; case 'all': $words = explode(' ', $keywords); $formatted_keywords = ''; $op=''; foreach($words as $value) { $formatted_keywords .= $op . $value; if(strtolower(SQL)=='pgsql') $op=' & '; if(strtolower(SQL)=='mysql') $op=' + '; } trim($formatted_keywords); break; case 'exp': if(strtolower(SQL)=='pgsql') { $words = explode(' ', $keywords); $formatted_keywords = ''; $op=''; foreach($words as $value) { $formatted_keywords .= $op . $value; $op=' & '; } trim($formatted_keywords); } if(strtolower(SQL)=='mysql') { $formatted_keywords = '"' . $keywords . '"'; } break; default: if(strtolower(SQL)=='pgsql') { $words = explode(' ', $keywords); $formatted_keywords = ''; $op=''; foreach($words as $value) { $formatted_keywords .= $op . $value; $op=' | '; } trim($formatted_keywords); } if(strtolower(SQL)=='mysql') { $formatted_keywords = $keywords; } break; } return $formatted_keywords; } function GetStatus($short_status) { $write = ' - '; switch ($short_status) { case 'PA': $write .= $GLOBALS['lang']['statut']['PA']; break; case 'AA': $write .= $GLOBALS['lang']['statut']['AA']; break; case 'P': $write = ''; break; case 'Y': $write = ''; break; case 'D': $write .= $GLOBALS['lang']['statut']['draft']; break; default: $write = ''; } return $write; } /** * DisplayPublicResults() * * @param string $keywords * @param string $searchtype * @return void (echo) **/ function DisplayPublicResults($keywords, $searchtype) { $type = 'PUBLIC'; if(defined('MOD_PROJECT') && MOD_PROJECT == true) DisplaySearchProject($keywords, $type, $searchtype); if(defined('MOD_NEWS') && MOD_NEWS == true) DisplaySearchNews($keywords, $type, $searchtype); //echo '
'; if(defined('MOD_PUBLICATION') && MOD_PUBLICATION == true) DisplaySearchPublication($keywords, $type, $searchtype); // echo '
'; if(defined('MOD_PUBLICATION') && MOD_PUBLICATION == true) DisplaySearchPubliContents($keywords, $type, $searchtype); //echo '
'; if(defined('MOD_WORKSHOP') && MOD_WORKSHOP == true) DisplaySearchWorkshop($keywords, $type, $searchtype); // echo '
'; if(defined('MOD_WORKSHOP') && MOD_WORKSHOP == true) DisplaySearchWorkshopRep($keywords, $type, $searchtype); // echo '
'; if(defined('MOD_WORKSHOP') && MOD_WORKSHOP == true) DisplaySearchWorkshopRepContents($keywords, $type, $searchtype); // echo '
'; if(defined('MOD_WORKSHOP') && MOD_WORKSHOP == true) DisplaySearchWorkshopCalendar($keywords, $type, $searchtype); // echo '
'; if(defined('MOD_WORKSHOP') && MOD_WORKSHOP == true) DisplaySearchWorkshopCom($keywords, $type, $searchtype); //echo '
'; if(defined('MOD_SDI') && MOD_SDI == true) DisplaySearchSdi($keywords, $type, $searchtype); //echo '
'; } /** * DisplaySearchProject() * Affiche les projets répondant à la requête sur $keywords * * @param string $keywords * @return string $content */ function DisplaySearchProject($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_project_search(MatchDataFormat($keywords, $searchtype), $type)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['project_module'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchNews() * Affiche les news répondant à la requête sur $keywords * * @param string $keywords * @return string $content */ function DisplaySearchNews($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_news_search(MatchDataFormat($keywords, $searchtype), $type)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['news_module'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchNews() * Affiche les news répondant à la requête sur $keywords * * @param string $keywords * @return string $content */ function DisplaySearchNewsletter($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_newsletter_search(MatchDataFormat($keywords, $searchtype), $type)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['newsletter_module'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; else { $content .= '
    ' . END_LINE; for($i = 0; $i < count($data); $i++) { /** * * NON IMPLEMENTE * if ($type == 'PUBLIC') { * $link_news = HrefMaker(array('rub' => $GLOBALS['links'][LANGUAGE]['news']['linkvalue'], 'id' => $data[$i]['news_id'])); * $published_display = $GLOBALS['lang']['statut']['published_on'] . ' ' . $data[$i]['date_display']; * } */ if ($type == 'ADMIN') { $link_newsletter = 'index.php?rub=newsletter&todo=det&id=' . $data[$i]['newsletter_id']; $published_display = $GLOBALS['lang']['divers']['date_crea'] . ' ' . $data[$i]['date_display']; } $newsletter_title = formatText($data[$i]['newsletter_title'], '2HTML'); $pertinence = FormatPertinenceIndice($data[$i]['pertinence']); $content .= '
  1. ' . END_LINE; $content .= '' . $newsletter_title . ''; $content .= '
    '; $content .= '' . $published_display . GetStatus($data[$i]['statut']) . ''; $content .= $pertinence; $content .= '
  2. ' . END_LINE; } $content .= '
' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchPublication() * Affiche les publications répondant à la requête sur $keywords * Requête éffectuée sur le titre et le résumé des publications * * @param string $keywords * @return string $content */ function DisplaySearchPublication($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_publication_search(MatchDataFormat($keywords, $searchtype), $type)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['publication_module'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchPubliContents() * Affiche les publications répondant à la requête sur $keywords * Requête éffectuée sur le contenu des publications ( titre & body ) * * @param string $keywords * @return string $content */ function DisplaySearchPubliContents($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_publication_content_search(MatchDataFormat($keywords, $searchtype), $type)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['det_publication_module'] . '

' . END_LINE; //if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) return true; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchWorkshop() * Affiche les groupes de travail répondant à la requête sur $keywords * Requête éffectuée sur le libellé et le résumé des groupes de travail * * @param string $keywords * @return string $content */ function DisplaySearchWorkshop($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_workshop_search(MatchDataFormat($keywords, $searchtype), $type)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['workshop_module'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchWorkshopRep() * Affiche les groupes de travail répondant à la requête sur $keywords * Requête éffectuée sur le contenu des rapports de groupes de travail ( titre & body ) * * @param string $keywords * @return string $content */ function DisplaySearchWorkshopRep($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_workrep_search(MatchDataFormat($keywords, $searchtype), $type)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['workshoprep_module'] . '

' . END_LINE; //if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) return true; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchWorkshopRepContents() * Affiche les groupes de travail répondant à la requête sur $keywords * Requête éffectuée sur le contenu des rapports de groupes de travail ( titre & body ) * * @param string $keywords * @return string $content */ function DisplaySearchWorkshopRepContents($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_workrep_content_search(MatchDataFormat($keywords, $searchtype), $type)); $content = '
'; $content .= '
' . $GLOBALS['lang']['search']['workshoprepcon_module'] . '
' . END_LINE; //if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) return true; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchWorkshopCalendar() * Affiche les groupes de travail répondant à la requête sur $keywords * Requête éffectuée sur les tâches du calendrier de groupes de travail ( libellé & contenu des tâches ) * * @param string $keywords * @return string $content */ function DisplaySearchWorkshopCalendar($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_workshop_calendar_search(MatchDataFormat($keywords, $searchtype), $type)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['workshopcal_module'] . '

' . END_LINE; //if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) return true; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchWorkshopCom() * Affiche les groupes de travail répondant à la requête sur $keywords * Requête éffectuée sur les discussions du calendrier de groupes de travail ( titre & contenu ) * * @param string $keywords * @return string $content */ function DisplaySearchWorkshopCom($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_workshop_com_search(MatchDataFormat($keywords, $searchtype), $type)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['workshopcom_module'] . '

' . END_LINE; //if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) return true; else { $content .= '' . END_LINE; if ($content == '') return ''; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchSdi() * Affiche les indicateurs répondant à la requête sur $keywords * Requête éffectuée sur les informations générales des indicateurs * * @param string $keywords * @return string $content */ function DisplaySearchSdi($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_sdi_search(MatchDataFormat($keywords, $searchtype), $type)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['sdi_module'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchYellowpages() * Affiche les organisations de l'annuaire répondant à la requête sur $keywords * * @param string $keywords * @return string $content */ function DisplaySearchYellowpages($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_yellowpages_search($keywords, $type, $searchtype)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['yellowpages_module'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchUser() * Affiche les utilisateurs répondant à la requête sur $keywords * * @param string $keywords * @return string $content */ function DisplaySearchUser($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_user_search($keywords, $type, $searchtype)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['user_module'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchTheme() * Affiche les theme répondant à la requête sur $keywords * * @param string $keywords * @return string $content */ function DisplaySearchTheme($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_theme_search($keywords, $type, $searchtype)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['theme_module'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchScale() * Affiche les échelles répondant à la requête sur $keywords * * @param string $keywords * @return string $content */ function DisplaySearchScale($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_scale_search($keywords, $type, $searchtype)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['scale_module'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplaySearchLevel() * Affiche les niveaux répondant à la requête sur $keywords * * @param string $keywords * @return string $content */ function DisplaySearchLevel($keywords, $type, $searchtype) { $data = $GLOBALS['sql_object']->DBSelect(SQL_level_search($keywords, $type, $searchtype)); $content = '
'; $content .= '

' . $GLOBALS['lang']['search']['level_module'] . '

' . END_LINE; if (count($data) == 1 && $data == 0) $content .= '

' . $GLOBALS['lang']['search']['no_result'] . '

' . END_LINE; else { $content .= '' . END_LINE; } $content .= '
' . END_LINE; echo $content; } /** * DisplayQueryTime() * Affiche le temps d'execution des requêtes * * @param float $start_time * @param float $end_time * @return string $content (echo) */ function DisplayQueryTime($start_time, $end_time) { $content = '
' . END_LINE; $content .= $GLOBALS['lang']['search']['query_time'] . ' ' . (substr($end_time - $start_time, 0, 5)) . ' ' . $GLOBALS['lang']['search']['query_seconds']; $content .= '
' . END_LINE; echo $content; } function DisplayAdvancedSearchForm() { $action = $GLOBALS['links'][LANGUAGE]['search-result']['linkvalue']; $content = '
'; $content .= '
'; $content .= ''; $content .= ''; $content .= '
'; $content .= '
'; $content .= '' . $GLOBALS['lang']['search']['one_of_them'] . ''; $content .= '' . $GLOBALS['lang']['search']['all_of_them'] . ''; $content .= '' . $GLOBALS['lang']['search']['expression'] . ''; $content .= '
'; $content .= '
'; $content.=''.END_LINE; $content .= '
'; $content .= '
'; echo $content; } function FormatPertinenceIndice($float) { $pertinence_i = ($float != 0) ? number_format(round($float, 3), 3, ',', ' ') : $GLOBALS['lang']['search']['score_not_good']; $pertinence= '- ' . $GLOBALS['lang']['search']['score_abbr'] . ' : ' . $pertinence_i . ''; return $pertinence; } ?>