Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1031 → Rev 1032

/trunk/papyrus/applettes/moteur_recherche/bibliotheque/more_recherche_spip_article.class.php
84,39 → 84,50
'hreflang' => '', 'accesskey' => '', 'title' => '',
'date_creation' => '', 'description' => '');
// Création de l'url
$var_recherche = str_replace(' ', '+', trim($motif));
$aso_resultat['url'] = $url_base.'article'.$article_id.'.html?var_recherche='.$var_recherche;
// Récupération du titre de la page
if (trim($Article->titre) != '') {
$aso_resultat['titre'] = htmlentities($Article->titre);
} else if (trim($Article->surtitre) != '') {
$aso_resultat['titre'] = htmlentities($Article->surtitre);
} else if (trim($Article->soustitre) != '') {
$aso_resultat['titre'] = htmlentities($Article->soustitre);
}
$aso_resultat['hreflang'] = htmlentities($Article->lang);
$aso_resultat['description'] = $this->couper($Article->texte, 450);
if (($jour = date('d', strtotime($Article->date)) ) != 0 ) {
$aso_resultat['date_creation'] .= '<span class="page_modification_jour"> '.$jour.'</span>'."\n";
}
if (($mois = $this->traduireMois(date('m', strtotime($Article->date))) ) != '' ) {
$aso_resultat['date_creation'] .= '<span class="page_modification_mois"> '.$mois.'</span>'."\n";
}
if (($annee = date('Y', strtotime($Article->date)) ) != 0 ) {
$aso_resultat['date_creation'] .= '<span class="page_modification_annee"> '.$annee.'</span>'."\n";
}
// Analyse du poids de cette page vis à vis des données
$tab_champs_a_visiter = array( 'surtitre', 'titre', 'soustitre', 'descriptif', 'chapo', 'texte', 'ps');
$tab_motif = explode(' ', $motif);
$bool_operateur_et = false;
foreach ($tab_champs_a_visiter as $val) {
$aso_resultat['poids'] += $this->retournerOccurenceMotif($motif, $Article->$val);
$compteur_mot = 0;
foreach ($tab_motif as $mot_motif) {
$nbre_mot = $this->retournerOccurenceMotif($mot_motif, $Article->$val);
if ($nbre_mot > 0) {
$compteur_mot++;
}
$aso_resultat['poids'] += $nbre_mot;
}
if ($compteur_mot == count($tab_motif)) {
$bool_operateur_et = true;
}
}
if ($aso_resultat['poids'] > 0) {
if ($aso_resultat['poids'] > 0 && $bool_operateur_et == true) {
// Création de l'url
$var_recherche = str_replace(' ', '+', trim($motif));
$aso_resultat['url'] = $url_base.'article'.$article_id.'.html?var_recherche='.$var_recherche;
// Récupération du titre de la page
if (trim($Article->titre) != '') {
$aso_resultat['titre'] = htmlentities($Article->titre);
} else if (trim($Article->surtitre) != '') {
$aso_resultat['titre'] = htmlentities($Article->surtitre);
} else if (trim($Article->soustitre) != '') {
$aso_resultat['titre'] = htmlentities($Article->soustitre);
}
$aso_resultat['hreflang'] = htmlentities($Article->lang);
$aso_resultat['description'] = $this->couper($Article->texte, 450);
if (($jour = date('d', strtotime($Article->date)) ) != 0 ) {
$aso_resultat['date_creation'] .= '<span class="page_modification_jour"> '.$jour.'</span>'."\n";
}
if (($mois = $this->traduireMois(date('m', strtotime($Article->date))) ) != '' ) {
$aso_resultat['date_creation'] .= '<span class="page_modification_mois"> '.$mois.'</span>'."\n";
}
if (($annee = date('Y', strtotime($Article->date)) ) != 0 ) {
$aso_resultat['date_creation'] .= '<span class="page_modification_annee"> '.$annee.'</span>'."\n";
}
$this->setResultat($aso_resultat);
}
}
245,6 → 256,9
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log$
* Revision 1.1 2006/05/19 10:04:55 jp_milcent
* Ajout d'un moteur de recherche analysant les articles des sites sous Spip.
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/