diff --git a/.gitattributes b/.gitattributes index b5327dfd8c9f86f373462ec9b4f07b2438c35d42..a503f2978b196bc431a7cb161730df005d01817a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -537,7 +537,6 @@ ecrire/exec/tourner.php -text ecrire/exec/upgrade.php -text ecrire/exec/valider_xml.php -text ecrire/exec/virtualiser.php -text -ecrire/extract/index.php -text ecrire/inc/actions.php -text ecrire/inc/afficher_objets.php -text ecrire/inc/agenda.php -text diff --git a/ecrire/action/editer_auteur.php b/ecrire/action/editer_auteur.php index 7042c11575d08dc6c595f540a0b97bb63257f7e5..e6956585da4cccaa02e6e71affed8f4ce115ead5 100644 --- a/ecrire/action/editer_auteur.php +++ b/ecrire/action/editer_auteur.php @@ -212,11 +212,17 @@ function action_legender_auteur_post($r) { spip_query("INSERT spip_auteurs_articles (id_article,id_auteur) VALUES ($id_article,$id_auteur)"); } - // Si on modifie la fiche auteur, reindexer - if ($GLOBALS['meta']['activer_moteur'] == 'oui') { - include_spip("inc/indexation"); - marquer_indexer('spip_auteurs', $id_auteur); - } + // Notifications, gestion des revisions, reindexation... + pipeline('post_edition', + array( + 'args' => array( + 'table' => 'spip_auteurs', + 'id_objet' => $id_auteur + ), + 'data' => $auteur + ) + ); + // ..et mettre a jour les fichiers .htpasswd et .htpasswd-admin ecrire_acces(); diff --git a/ecrire/action/editer_auteurs.php b/ecrire/action/editer_auteurs.php index 7b42e77148ce1d32401bee934234b894a4e945a1..41ba1bb6ffaa8c3e76b5dafea40b489f65850eb0 100644 --- a/ecrire/action/editer_auteurs.php +++ b/ecrire/action/editer_auteurs.php @@ -66,10 +66,18 @@ function supprimer_auteur_et_rediriger($type, $id, $id_auteur, $redirect) $jointure = table_jointure('auteur', $type); if (preg_match(',^[a-z]*$,',$type)){ spip_query("DELETE FROM spip_{$jointure} WHERE id_auteur="._q($id_auteur)." AND id_{$type}="._q($id)); - if ($GLOBALS['meta']['activer_moteur'] == 'oui') { - include_spip("inc/indexation"); - marquer_indexer("spip_".table_objet($type), $id); - } + + // Notifications, gestion des revisions, reindexation... + pipeline('post_edition', + array( + 'args' => array( + 'operation' => 'supprimer_auteur', + 'table' => 'spip_'.table_objet($type), + 'id_objet' => $id + ), + 'data' => null + ) + ); } if ($redirect) redirige_par_entete($redirect); @@ -83,11 +91,18 @@ function ajouter_auteur_et_rediriger($type, $id, $id_auteur, $redirect) $res = spip_query("SELECT id_$type FROM spip_{$jointure} WHERE id_auteur=" . _q($id_auteur) . " AND id_{$type}=" . $id); if (!spip_num_rows($res)) spip_abstract_insert("spip_{$jointure}", "(id_auteur,id_{$type})", "($id_auteur,$id)"); - - if ($GLOBALS['meta']['activer_moteur'] == 'oui') { - include_spip("inc/indexation"); - marquer_indexer("spip_".table_objet($type), $id); - } + + // Notifications, gestion des revisions, reindexation... + pipeline('post_edition', + array( + 'args' => array( + 'operation' => 'ajouter_auteur', + 'table' => 'spip_'.table_objet($type), + 'id_objet' => $id + ), + 'data' => null + ) + ); } if ($redirect) redirige_par_entete($redirect); diff --git a/ecrire/action/editer_breve.php b/ecrire/action/editer_breve.php index 86da89b9a79d3db5b0e1b536ff15e6568dcdb15c..5735f95d47ae561d4f1d516cdb1375c68bc3ce0d 100644 --- a/ecrire/action/editer_breve.php +++ b/ecrire/action/editer_breve.php @@ -188,17 +188,11 @@ function revisions_breves ($id_breve, $c=false) { suivre_invalideur("id='id_breve/$id_breve'"); } - // Demander une reindexation de la breve - if ($statut == 'publie') { - include_spip('inc/indexation'); - marquer_indexer('spip_breves', $id_breve); - } // Au besoin, changer le statut des rubriques concernees - calculer_rubriques_if($id_rubrique, $champs, $statut_ancien); - // Notification ? + // Notifications, revisions, reindexation... pipeline('post_edition', array( 'args' => array( diff --git a/ecrire/action/editer_mot.php b/ecrire/action/editer_mot.php index 787ce42a2d3be40756e5cde384ff02a1bc423280..e9242ec704bd5821011a36c74f93fc84c53cbc9c 100644 --- a/ecrire/action/editer_mot.php +++ b/ecrire/action/editer_mot.php @@ -45,17 +45,25 @@ function action_editer_mot_post($r) } } if ($nouv_mot ? $nouv_mot : ($nouv_mot = _request('nouv_mot'))) { - // recopie de: - // inserer_mot("spip_mots_$table", $table_id, $id_objet, $nouv_mot); - $result = spip_num_rows(spip_query("SELECT id_mot FROM spip_mots_$table WHERE id_mot="._q($nouv_mot)." AND $table_id=$id_objet")); - if (!$result) - spip_query("INSERT INTO spip_mots_$table (id_mot,$table_id) VALUES ("._q($nouv_mot).", $id_objet)"); - } + // recopie de: + // inserer_mot("spip_mots_$table", $table_id, $id_objet, $nouv_mot); + $result = spip_num_rows(spip_query("SELECT id_mot FROM spip_mots_$table WHERE id_mot="._q($nouv_mot)." AND $table_id=$id_objet")); + if (!$result) + spip_query("INSERT INTO spip_mots_$table (id_mot,$table_id) VALUES ("._q($nouv_mot).", $id_objet)"); + } - if ($table AND $GLOBALS['meta']['activer_moteur'] == 'oui') { - include_spip("inc/indexation"); - marquer_indexer("spip_$table", $id_objet); - } + // Notifications, gestion des revisions, reindexation... + if ($table) + pipeline('post_edition', + array( + 'args' => array( + 'operation' => 'editer_mot', + 'table' => 'spip_'.$table, + 'id_objet' => $id_objet + ), + 'data' => null + ) + ); $redirect = rawurldecode($redirect); diff --git a/ecrire/action/editer_rubrique.php b/ecrire/action/editer_rubrique.php index 9ee40aebdc189a53a86cfd27d7cbecc3b1057afd..640f9c96bb89a432909e32b495b2f4b528357e51 100644 --- a/ecrire/action/editer_rubrique.php +++ b/ecrire/action/editer_rubrique.php @@ -125,11 +125,6 @@ function revisions_rubriques($id_rubrique, $c=false) { spip_query("UPDATE spip_rubriques SET ".join(', ', $update)." WHERE id_rubrique=$id_rubrique"); - if ($GLOBALS['meta']['activer_moteur'] == 'oui') { - include_spip("inc/indexation"); - marquer_indexer('spip_rubriques', $id_rubrique); - } - propager_les_secteurs(); // Deplacement d'une rubrique publiee ==> chgt general de leur statut diff --git a/ecrire/action/editer_site.php b/ecrire/action/editer_site.php index 70fe418d764a64c1765b7032cd1b8c93a4108ed0..053abc3ecf6c6ecc39a21c6469b105d40bfd9372 100644 --- a/ecrire/action/editer_site.php +++ b/ecrire/action/editer_site.php @@ -259,12 +259,6 @@ function revisions_sites ($id_syndic, $c=false) { suivre_invalideur("id='id_syndic/$id_syndic'"); } - // Demander une reindexation du site - if ($statut == 'publie') { - include_spip('inc/indexation'); - marquer_indexer('spip_syndic', $id_syndic); - } - calculer_rubriques_if($id_rubrique, $champs, $statut_ancien); // Notification ? diff --git a/ecrire/action/instituer_forum.php b/ecrire/action/instituer_forum.php index f7b6c9dfff1c874ecbd7c8cfb9d0c5326d2de636..b5aadb7eea7405a2735b8aa92d813cf9bcacd3a4 100644 --- a/ecrire/action/instituer_forum.php +++ b/ecrire/action/instituer_forum.php @@ -45,18 +45,23 @@ function action_instituer_forum_dist() { $id_messages[] = $row['id_forum']; } - // Signaler au moteur de recherche qu'il faut reindexer le thread - if ($id_parent) { - include_spip('inc/indexation'); - marquer_indexer ('spip_forum', $id_parent); - } - // Notifier de la publication du message, s'il etait 'prop' if ($old=='prop' AND $statut=='publie') { if ($notifications = charger_fonction('notifications', 'inc')) { $notifications('forumvalide', $id_forum); } } + + // Reindexation du thread (par exemple) + pipeline('post_edition', + array( + 'args' => array( + 'table' => 'spip_forum', + 'id_objet' => $id_forum + ), + 'data' => null + ) + ); } ?> diff --git a/ecrire/action/legender.php b/ecrire/action/legender.php index cf539d74c9980d29fc920b9dec40a5e6ae7f395b..59b52cd4466e8caed8dcc58cba239aae46eb928e 100644 --- a/ecrire/action/legender.php +++ b/ecrire/action/legender.php @@ -36,35 +36,28 @@ function action_legender_post($r) $id_document = $r[1]; - $titre_document = (corriger_caracteres(_request('titre_document'))); - $descriptif_document = (corriger_caracteres(_request('descriptif_document'))); - // taille du document (cas des embed) if ($largeur_document = intval(_request('largeur_document')) - AND $hauteur_document = intval(_request('hauteur_document'))) - $wh = ", largeur='$largeur_document', - hauteur='$hauteur_document'"; - else $wh = ""; - - // Date du document (uniquement dans les rubriques) - if (!_request('jour_doc')) - $d = ''; - else { - $mois_doc = _request('mois_doc'); - $jour_doc = _request('jour_doc'); - if (_request('annee_doc') == "0000") - $mois_doc = "00"; - if ($mois_doc == "00") - $jour_doc = "00"; - $date = _request('annee_doc').'-'.$mois_doc.'-'.$jour_doc; + AND $hauteur_document = intval(_request('hauteur_document'))) { + set_request('largeur', $largeur_document); + set_request('hauteur', $hauteur_document); + } - if (preg_match('/^[0-9-]+$/', $date)) $d=" date='$date',"; + // Date du document (uniquement dans les rubriques) + if (_request('jour_doc') !== null) { + $mois_doc = _request('mois_doc'); + $jour_doc = _request('jour_doc'); + if (_request('annee_doc') == "0000") + $mois_doc = "00"; + if ($mois_doc == "00") + $jour_doc = "00"; + $date = _request('annee_doc').'-'.$mois_doc.'-'.$jour_doc; + if (preg_match('/^[0-9-]+$/', $date)) + set_request('date', $date); } - - spip_query("UPDATE spip_documents SET$d titre=" . _q($titre_document) . ", descriptif=" . _q($descriptif_document) . " $wh WHERE id_document=".$id_document); - // Demander l'indexation du document - include_spip('inc/indexation'); - marquer_indexer('spip_documents', $id_document); + include_spip('inc/modifier'); + revision_document($id_document); } + ?> diff --git a/ecrire/balise/formulaire_recherche.php b/ecrire/balise/formulaire_recherche.php index 7467de0097336b800910214c89a9fd38a8a2501f..eeeb8660e4618e506efd5012410cdf2f50505618 100644 --- a/ecrire/balise/formulaire_recherche.php +++ b/ecrire/balise/formulaire_recherche.php @@ -23,13 +23,8 @@ function balise_FORMULAIRE_RECHERCHE ($p) // http://doc.spip.org/@balise_FORMULAIRE_RECHERCHE_stat function balise_FORMULAIRE_RECHERCHE_stat($args, $filtres) { - // Si le moteur n'est pas active, pas de balise - if ($GLOBALS['meta']["activer_moteur"] != "oui") - return ''; - // filtres[0] doit etre un script (a revoir) - else - return array($filtres[0], $args[0]); + return array($filtres[0], $args[0]); } // http://doc.spip.org/@balise_FORMULAIRE_RECHERCHE_dyn diff --git a/ecrire/base/auxiliaires.php b/ecrire/base/auxiliaires.php index 2e8d37b2da78d00f34d3ca554f30e66e15b0ae1d..0fe842ccbb384a377b960b8278c64cfa12c352da 100644 --- a/ecrire/base/auxiliaires.php +++ b/ecrire/base/auxiliaires.php @@ -176,24 +176,6 @@ $spip_meta = array( $spip_meta_key = array( "PRIMARY KEY" => "nom"); -$spip_index = array( - "`hash`" => "bigint UNSIGNED NOT NULL", - "points" => "int UNSIGNED DEFAULT '0' NOT NULL", - "id_objet" => "int UNSIGNED NOT NULL", - "id_table" => "tinyint UNSIGNED NOT NULL" ); - -$spip_index_key = array( - "KEY `hash`" => "`hash`", - "KEY id_objet" => "id_objet", - "KEY id_table" => "id_table"); - -$spip_index_dico = array( - "`hash`" => "bigint UNSIGNED NOT NULL", - "dico" => "VARCHAR (30)"); - -$spip_index_dico_key = array( - "PRIMARY KEY" => "dico"); - $spip_versions = array ( "id_article" => "bigint(21) NOT NULL", "id_version" => "int unsigned DEFAULT '0' NOT NULL", @@ -280,12 +262,6 @@ $tables_auxiliaires['spip_mots_documents'] = array( $tables_auxiliaires['spip_meta'] = array( 'field' => &$spip_meta, 'key' => &$spip_meta_key); -$tables_auxiliaires['spip_index'] = array( - 'field' => &$spip_index, - 'key' => &$spip_index_key); -$tables_auxiliaires['spip_index_dico'] = array( - 'field' => &$spip_index_dico, - 'key' => &$spip_index_dico_key); $tables_auxiliaires['spip_versions'] = array( 'field' => &$spip_versions, 'key' => &$spip_versions_key); diff --git a/ecrire/base/optimiser.php b/ecrire/base/optimiser.php index 7ec3cdeabe338dfc57bc8d67b15ef405c9da6bb4..a474c8d1ddc8f60ff06b07d31f66b7e55dd04154 100644 --- a/ecrire/base/optimiser.php +++ b/ecrire/base/optimiser.php @@ -19,7 +19,12 @@ function optimiser_base($attente = 86400) { optimiser_base_une_table(); optimiser_base_disparus($attente); - optimiser_base_indexation(); + + // optimisation a passer dans le plugin indexation + include_spip('inc/indexation'); + if (function_exists('optimiser_base_indexation')) { + optimiser_base_indexation(); + } } @@ -397,29 +402,4 @@ function optimiser_base_disparus($attente = 86400) { } -// http://doc.spip.org/@optimiser_base_indexation -function optimiser_base_indexation($attente) { - // les objets inutiles - include_spip('inc/indexation'); - $liste_tables = liste_index_tables(); - foreach ($liste_tables as $id_table => $table_objet) { - $col_id = primary_index_table($table_objet); - $critere = critere_optimisation($table_objet); - if (strlen($critere)>0) - $critere = "AND $critere"; - - spip_query("UPDATE $table_objet SET idx='' WHERE idx<>'non' $critere"); - - $suppr = ''; - $s = spip_query("SELECT $col_id AS n FROM $table_objet WHERE idx='' $critere"); - while ($t = spip_abstract_fetch($s)) - $suppr .= ','.$t['n']; - $s = spip_query("SELECT $col_id AS n FROM $table_objet WHERE idx='non'"); - while ($t = spip_abstract_fetch($s)) - $suppr .= ','.$t['n']; - if ($suppr) - spip_query("DELETE FROM spip_index WHERE id_objet IN (0$suppr) AND id_table=$id_table"); - } -} - ?> diff --git a/ecrire/base/serial.php b/ecrire/base/serial.php index 58560881556aea0e033a9217d08385d82b2e47b1..f15a4b1fc0abb38438a96f4344814adcf36fa680 100644 --- a/ecrire/base/serial.php +++ b/ecrire/base/serial.php @@ -39,7 +39,6 @@ $spip_articles = array( "langue_choisie" => "VARCHAR(3) DEFAULT 'non'", "id_trad" => "bigint(21) DEFAULT '0' NOT NULL", "extra" => "longtext NULL", - "idx" => "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL", "id_version" => "int unsigned DEFAULT '0' NOT NULL", "nom_site" => "tinytext", "url_site" => "VARCHAR(255)", @@ -54,7 +53,6 @@ $spip_articles_key = array( "KEY statut" => "statut, date", "KEY url_site" => "url_site", "KEY date_modif" => "date_modif", - "KEY idx" => "idx", "KEY url_propre" => "url_propre"); $spip_articles_join = array( "id_article"=>"id_article", @@ -83,7 +81,6 @@ $spip_auteurs = array( "cookie_oubli" => "tinytext", "source" => "VARCHAR(10) DEFAULT 'spip' NOT NULL", "lang" => "VARCHAR(10) DEFAULT '' NOT NULL", - "idx" => "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL", "url_propre" => "VARCHAR(255)", "extra" => "longtext NULL"); @@ -92,7 +89,6 @@ $spip_auteurs_key = array( "KEY login" => "login", "KEY statut" => "statut", "KEY lang" => "lang", - "KEY idx" => "idx", "KEY en_ligne" => "en_ligne", "KEY url_propre" => "url_propre"); $spip_auteurs_join = array( @@ -112,13 +108,11 @@ $spip_breves = array( "lang" => "VARCHAR(10) DEFAULT '' NOT NULL", "langue_choisie" => "VARCHAR(3) DEFAULT 'non'", "maj" => "TIMESTAMP", - "idx" => "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL", "extra" => "longtext NULL", "url_propre" => "VARCHAR(255)"); $spip_breves_key = array( "PRIMARY KEY" => "id_breve", - "KEY idx" => "idx", "KEY id_rubrique" => "id_rubrique", "KEY url_propre" => "url_propre"); $spip_breves_join = array( @@ -149,13 +143,11 @@ $spip_mots = array( "id_groupe" => "bigint(21) NOT NULL", "type" => "text", "extra" => "longtext NULL", - "idx" => "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL", "url_propre" => "VARCHAR(255)", "maj" => "TIMESTAMP"); $spip_mots_key = array( "PRIMARY KEY" => "id_mot", - "KEY idx" => "idx", "KEY url_propre" => "url_propre"); $spip_groupes_mots = array( @@ -191,7 +183,6 @@ $spip_rubriques = array( "date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "lang" => "VARCHAR(10) DEFAULT '' NOT NULL", "langue_choisie" => "VARCHAR(3) DEFAULT 'non'", - "idx" => "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL", "extra" => "longtext NULL", "url_propre" => "VARCHAR(255)", "statut_tmp" => "varchar(10) DEFAULT '0' NOT NULL", @@ -201,7 +192,6 @@ $spip_rubriques = array( $spip_rubriques_key = array( "PRIMARY KEY" => "id_rubrique", "KEY lang" => "lang", - "KEY idx" => "idx", "KEY id_parent" => "id_parent", "KEY url_propre" => "url_propre"); @@ -219,7 +209,6 @@ $spip_documents = array( "hauteur" => "integer NOT NULL", "mode" => "ENUM('vignette', 'document') NOT NULL", "distant" => "VARCHAR(3) DEFAULT 'non'", - "idx" => "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL", "maj" => "TIMESTAMP"); $spip_documents_key = array( @@ -257,7 +246,6 @@ $spip_syndic = array( "url_syndic" => "text", "descriptif" => "text", "url_propre" => "VARCHAR(255)", - "idx" => "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL", "maj" => "TIMESTAMP", "syndication" => "VARCHAR(3)", "statut" => "varchar(10) DEFAULT '0' NOT NULL", @@ -275,7 +263,6 @@ $spip_syndic_key = array( "PRIMARY KEY" => "id_syndic", "KEY id_rubrique" => "id_rubrique", "KEY id_secteur" => "id_secteur", - "KEY idx" => "idx", "KEY statut" => "statut, date_syndic", "KEY url_propre" => "url_propre"); $spip_syndic_join = array( @@ -322,7 +309,6 @@ $spip_forum = array( "nom_site" => "text", "url_site" => "text", "statut" => "varchar(8) DEFAULT '0' NOT NULL", - "idx" => "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL", "ip" => "varchar(16)", "maj" => "TIMESTAMP", "id_auteur" => "bigint DEFAULT '0' NOT NULL", @@ -337,7 +323,6 @@ $spip_forum_key = array( "KEY id_message" => "id_message", "KEY id_syndic" => "id_syndic", "KEY id_rubrique" => "id_rubrique", - "KEY idx" => "idx", "KEY statut" => "statut, date_heure", "KEY date_thread" => "date_thread"); $spip_forum_join = array( @@ -359,13 +344,11 @@ $spip_signatures = array( "url_site" => "text", "message" => "mediumtext", "statut" => "varchar(10) DEFAULT '0' NOT NULL", - "idx" => "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL", "maj" => "TIMESTAMP"); $spip_signatures_key = array( "PRIMARY KEY" => "id_signature", "KEY id_article" => "id_article", - "KEY idx" => "idx", "KEY statut" => "statut"); $spip_signatures_join = array( "id_signature"=>"id_signature", diff --git a/ecrire/base/upgrade.php b/ecrire/base/upgrade.php index 1a5b3bc116cc456c9ae287d58e634b11802bb32a..1788b7ecf1e653ccbe825ae0b8b4f1852ac7008e 100644 --- a/ecrire/base/upgrade.php +++ b/ecrire/base/upgrade.php @@ -1464,6 +1464,18 @@ function maj_base($version_cible = 0) { maj_version('1.942'); } + // suppression de l'indexation dans la version standard + if (upgrade_vers(1.943, $version_installee, $version_cible)) { + foreach(array( + 'articles', 'auteurs', 'breves', 'mots', 'rubriques', 'documents', 'syndic', 'forum', 'signatures' + ) as $type) { + spip_query("ALTER TABLE spip_$type DROP KEY `idx`"); + spip_query("ALTER TABLE spip_$type DROP `idx`"); + } + spip_query("DROP TABLE spip_index"); + spip_query("DROP TABLE spip_index_dico"); + maj_version('1.943'); + } } ?> diff --git a/ecrire/configuration/syndications.php b/ecrire/configuration/syndications.php index 51b11453f683f8015ae82b5ffa8ee3e2bad00335..3002f664e3fb8ff2a6fe399785e2865a23b866b0 100644 --- a/ecrire/configuration/syndications.php +++ b/ecrire/configuration/syndications.php @@ -26,7 +26,6 @@ function configuration_syndications_dist() $activer_sites = $GLOBALS['meta']['activer_sites']; $activer_syndic = $GLOBALS['meta']["activer_syndic"]; $proposer_sites = $GLOBALS['meta']["proposer_sites"]; - $visiter_sites = $GLOBALS['meta']["visiter_sites"]; $moderation_sites = $GLOBALS['meta']["moderation_sites"]; $res = "\n<table border='0' cellspacing='1' cellpadding='3' width=\"100%\">"; @@ -89,19 +88,7 @@ function configuration_syndications_dist() $res .= afficher_choix('moderation_sites', $moderation_sites, array('oui' => _T('item_bloquer_liens_syndiques'), 'non' => _T('item_non_bloquer_liens_syndiques'))); - - // Si indexation, activer/desactiver pages recuperees - - $activer_moteur = $GLOBALS['meta']["activer_moteur"]; - if ($activer_moteur == "oui") { - $res .= "<hr /><p style='text-align: $spip_lang_left'>"; - $res .= _T('texte_utilisation_moteur_syndiques')." "; - $res .= "</p><blockquote><p><i>"._T('texte_utilisation_moteur_syndiques_2')."</i></p></blockquote>"; - - $res .= afficher_choix('visiter_sites', $visiter_sites, - array('non' => _T('item_limiter_recherche'), - 'oui' => _T('item_non_limiter_recherche'))); - } + $res .= "</div>"; $res .= "</td></tr>\n"; diff --git a/ecrire/exec/admin_vider.php b/ecrire/exec/admin_vider.php index ed5a3713da7d6833fce3b0ec63a44c8d7570488c..55afcbfdc5859a6cc8c72318a32619359c87d7b9 100644 --- a/ecrire/exec/admin_vider.php +++ b/ecrire/exec/admin_vider.php @@ -130,31 +130,6 @@ fin_cadre_relief(); fin_cadre_trait_couleur(); -// -// Purger la base d'indexation -// -debut_cadre_trait_couleur("racine-site-24.gif", false, "", _T('texte_effacer_donnees_indexation')); - - echo "\n<p style='text-align: justify;'>"; - if ($GLOBALS['meta']['activer_moteur'] == 'oui') - echo _T('texte_moteur_recherche_active'); - else { - echo "<b>"._T('texte_moteur_recherche_non_active')."</b> "; - $cpt = spip_abstract_fetch(spip_query("SELECT COUNT(*) AS n FROM spip_index")); - if ($cpt['n']) - echo _T('texte_commande_vider_tables_indexation'); - else - echo _T('texte_tables_indexation_vides'); - - } - echo '</p>'; - echo redirige_action_auteur('purger', 'index', "admin_vider",'', - "\n<div style='text-align: right'><input class='fondo' type='submit' value=\"" . - str_replace('"', '"', _T('bouton_effacer_index')) . - "\" /></div>", - " method='post'"); - -fin_cadre_trait_couleur(); echo "<br />"; diff --git a/ecrire/exec/auteurs.php b/ecrire/exec/auteurs.php index 40d89790713e7b3867fe4cfa7a54a2167f897c3a..3c76a2b3ee9eeffd48d4e57863b8e72d5362df25 100644 --- a/ecrire/exec/auteurs.php +++ b/ecrire/exec/auteurs.php @@ -268,7 +268,7 @@ function requete_auteurs($tri, $statut, $recherche=NULL) $tables = liste_des_champs(); $tables = array('auteur'=>$tables['auteur']); $results = recherche_en_base($recherche, $tables); - $in_auteurs = calcul_mysql_in('aut.id_auteur',implode(',',array_keys($results['auteur']))); + $in_auteurs = calcul_mysql_in('aut.id_auteur',array_keys($results['auteur'])); } // diff --git a/ecrire/exec/config_fonctions.php b/ecrire/exec/config_fonctions.php index bf6fb7528ce544171243afdbd1e50384fdc7a53c..7b920a9dff462198f8709d2ef296f370020a7f2d 100644 --- a/ecrire/exec/config_fonctions.php +++ b/ecrire/exec/config_fonctions.php @@ -43,7 +43,7 @@ function exec_config_fonctions_dist() lire_metas(); $reducteur = charger_fonction('reducteur', 'configuration'); - $indexeur = charger_fonction('indexeur', 'configuration'); +# $indexeur = charger_fonction('indexeur', 'configuration'); $compteur = charger_fonction('compteur', 'configuration'); $avertisseur = charger_fonction('avertisseur', 'configuration'); $versionneur = charger_fonction('versionneur', 'configuration'); @@ -54,7 +54,7 @@ function exec_config_fonctions_dist() $reducteur(), // Creation automatique de vignettes - $indexeur(), // Indexation pour moteur de recherche +# $indexeur(), // Indexation pour moteur de recherche $compteur(), // Gerant de statistique diff --git a/ecrire/extract/doc.php b/ecrire/extract/doc.php deleted file mode 100644 index 225408f27420c7dd88ecf270cbfbc810d9c62143..0000000000000000000000000000000000000000 --- a/ecrire/extract/doc.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -// -// Lit un document 'doc' et extrait son contenu en texte brut -// - -// NOTE : l'extracteur n'est pas oblige de convertir le contenu dans -// le charset du site, mais il *doit* signaler le charset dans lequel -// il envoie le contenu, de facon a ce qu'il soit converti au moment -// voulu ; dans le cas contraire le document sera lu comme s'il etait -// dans le charset iso-8859-1 - -// http://doc.spip.org/@extracteur_doc -function extracteur_doc($fichier, &$charset) { - - $charset = 'iso-8859-1'; - - @exec('metamail -d -q -b -c application/msword '.escapeshellarg($fichier), $r, $e); - if (!$e) return @join(' ', $r); - - # wvText - # http://wvware.sourceforge.net/ - $temp = tempnam(_DIR_CACHE, 'doc'); - @exec('wvText '.escapeshellarg($fichier).'> '.$temp, $r, $e); - lire_fichier($temp, $contenu); - @unlink($temp); - if (!$e) return $contenu; - - # antiword - # http://www.winfield.demon.nl/ - @exec('antiword '.escapeshellarg($fichier), $r, $e); - if (!$e) return @join(' ', $r); - - # catdoc - # http://www.45.free.net/~vitus/ice/catdoc/ - @exec('catdoc '.escapeshellarg($fichier), $r, $e); - if (!$e) return @join(' ', $r); - -} - -// Sait-on extraire ce format ? -// TODO: ici tester si les binaires fonctionnent -$GLOBALS['extracteur']['doc'] = 'extracteur_doc'; - -?> diff --git a/ecrire/extract/index.php b/ecrire/extract/index.php deleted file mode 100644 index 62d8fe9f6db631bd3a19140699101c9e281c9f9d..0000000000000000000000000000000000000000 --- a/ecrire/extract/index.php +++ /dev/null @@ -1 +0,0 @@ -X diff --git a/ecrire/extract/pdf.php b/ecrire/extract/pdf.php deleted file mode 100644 index aa8a83c3d69a0bb99f4752034d30d186f4288ed5..0000000000000000000000000000000000000000 --- a/ecrire/extract/pdf.php +++ /dev/null @@ -1,319 +0,0 @@ -<?php - -// -// Lit un document 'pdf' et extrait son contenu en texte brut -// - -// NOTE : l'extracteur n'est pas oblige de convertir le contenu dans -// le charset du site, mais il *doit* signaler le charset dans lequel -// il envoie le contenu, de facon a ce qu'il soit converti au moment -// voulu ; dans le cas contraire le document sera lu comme s'il etait -// dans le charset iso-8859-1 - -// http://doc.spip.org/@extracteur_pdf -function extracteur_pdf($fichier, &$charset) { - - /* methode tout PHP - $pdf = new Format_PDF; - $texte = $pdf->extraire_texte($fichier); - echo $texte; - exit; - */ - - $charset = 'iso-8859-1'; - - # metamail - @exec('metamail -d -q -b -c application/pdf '.escapeshellarg($fichier), $r, $e); - if (!$e) return @join(' ', $r); - - # pdftotext - # http://www.glyphandcog.com/Xpdf.html - # l'option "-enc utf-8" peut echouer ... dommage ! - @exec('pdftotext '.escapeshellarg($fichier).' -', $r, $e); - if (!$e) return @join(' ', $r); -} - -// Sait-on extraire ce format ? -// TODO: ici tester si les binaires fonctionnent -$GLOBALS['extracteur']['pdf'] = 'extracteur_pdf'; - - - - - - -// -// Methode tout PHP (a tester) -// - -// http://doc.spip.org/@Format_PDF -class Format_PDF { - var $trans_chars; - var $flag_mono, $flag_brut; - -// http://doc.spip.org/@convertir_caracteres - function convertir_caracteres($texte) { - if (!$this->trans_chars) { - // Caracteres speciaux - $this->trans_chars = array( - // ligatures typographiques (!) - chr(2) => 'fi', - chr(3) => 'fl', - chr(174) => 'fi', - chr(175) => 'fl', - // "e" accent aigu - chr(0) => chr(233) - ); - } - $texte = strtr($texte, $this->trans_chars); - // Caracteres non-ascii codes en octal - while (preg_match(',\\\\([0-7][0-7][0-7]),', $texte, $regs)) { - $c = chr(octdec($regs[1])); - $texte = str_replace($regs[0], $c, $texte); - $this->trans_chars[$regs[0]] = $c; - } - return $texte; - } - -// http://doc.spip.org/@recoller_texte - function recoller_texte($stream) { - static $chars_voyelles, $chars_fusion, $chars_caps, $chars_nums, $bichars_fusion; - if (!$chars_voyelles) { - $chars_voyelles = array('a'=>1, 'e'=>1, 'i'=>1, 'o'=>1, 'u'=>1, 'y'=>1); - $chars_fusion = array('v'=>1, 'w'=>1, 'x'=>1, 'V'=>1, 'W'=>1, 'T'=>1); - $chars_caps = array('A'=>1, 'B'=>1, 'C'=>1, 'D'=>1, 'E'=>1, 'F'=>1, 'G'=>1, - 'H'=>1, 'I'=>1, 'J'=>1, 'K'=>1, 'L'=>1, 'M'=>1, 'N'=>1, - 'O'=>1, 'P'=>1, 'Q'=>1, 'R'=>1, 'S'=>1, 'T'=>1, 'U'=>1, - 'V'=>1, 'W'=>1, 'X'=>1, 'Y'=>1, 'Z'=>1); - $chars_nums = array('0'=>1, '1'=>1, '2'=>1, '3'=>1, '4'=>1, '5'=>1, '6'=>1, '7'=>1, '8'=>1, '9'=>1); - $bichars_fusion = array('ve'=>1, 'vo'=>1, 'ev'=>1, 'ov'=>1, - 'xe'=>1, 'xo'=>1, 'ox'=>1, 'ex'=>1, - 'we'=>1, 'wo'=>1, 'ow'=>1, 'ew'=>1, 'ff'=>1); - } - // Longueur max pour limiter les erreurs d'extraction - $chaine_len = 140; - - $stream = preg_split(",\)[^(]*\(,", $stream); - $extrait = ''; - $fini = false; - $this->flag_brut = false; - // Cette boucle est capable de basculer entre deux trois d'execution : - // - normal (plusieurs caracteres par chaine avec fusion) - // - brut (plusieurs caracteres par chaine sans fusion) - // - mono (un caractere par chaine) - while (1) { - if ($this->flag_mono) { - // Un caractere par chaine : fusion rapide - while (list(, $s) = each($stream)) { - if (strlen($s) != 1) { - if (strlen($s) < $chaine_len) $extrait .= $s; - $this->flag_mono = false; - break; - } - $extrait .= $s; - } - if ($this->flag_mono) break; - } - else if ($this->flag_brut) { - // Concatenation sans fusion - while (list(, $s) = each($stream)) $extrait .= $s; - break; - } - $prev_s = ''; - $prev_c = ''; - $prev_l = 0; - $nb_mono = 0; - $nb_brut = 0; - // Cas general : appliquer les regles de fusion - while (list(, $s) = each($stream)) { - $l = strlen($s); - if ($l >= $chaine_len) continue; - $c = $s{0}; - // Annulation de la cesure - if ($prev_c == '-') { - $extrait .= substr($prev_s, 0, -1); - } - else { - $extrait .= $prev_s; - $len_w = strpos($s.' ', ' '); - $prev_len_w = $prev_l - strrpos($prev_s, ' '); - $court = ($prev_len_w < 3 OR $len_w < 3); - // Heuristique pour separation des mots - if (/*$len_w == 1 OR $prev_len_w == 1 - OR */($court AND ($chars_fusion[$prev_c] OR $chars_fusion[$c] - OR ($chars_caps[$prev_c] AND ($chars_caps[$c] OR $chars_nums[$c])))) - OR ($prev_c == 'f' AND $chars_voyelles[$c]) - OR $bichars_fusion[$prev_c.$c]) { - } - else $extrait .= ' '; - } - $prev_c = $s{$l - 1}; - $prev_s = $s; - $prev_l = $l; - // Detection du format mono-caractere - if ($l == 1) { - if (++$nb_mono >= 3) { - $this->flag_mono = true; - break; - } - } - else { - $nb_mono = 0; - if ($c == ' ' OR $prev_c == ' ') { - $this->flag_brut = true; - break; - } - } - } - $extrait .= $prev_s; - if (!$this->flag_mono && !$this->flag_brut) break; - } - return $extrait; - } - -// http://doc.spip.org/@extraire_texte - function extraire_texte($fichier) { - - $source_len = 1024*1024; - $stream_len = 20*1024; - $texte_len = 40*1024; - - $f = fopen($fichier, "rb"); - if (!$f) die ("Fichier $fichier impossible a ouvrir"); - - $in_stream = false; - - // Decouper le fichier en objets - unset($objs); - $objs = fread($f, $source_len); - $objs = preg_split('/[\s>]endobj\s+/', $objs); -# echo "<h3>".count($objs)." objets présents dans le buffer</h3>"; - - // Parcourir le fichier pour trouver les streams - reset($objs); - $n = count($objs); - for ($i = 0; $i < $n; $i++) { - $obj = $objs[$i]; - - if (!$in_stream) { - // Stream (eviter les commentaires) - $ok = preg_match("/stream(\r\n?|\n)/", $obj); // version rapide d'abord - if ($ok) $ok = preg_match("/[\r\n](([^\r\n%]*[ \t>])*stream(\r\n?|\n))/", $obj, $regs); - if (!$ok) continue; - $p = strpos($obj, $regs[1]); - $t = substr($obj, $p + strlen($regs[1])); - $stream = ""; - $in_stream = true; - - $obj_text = substr($obj, 0, $p + strlen($regs[1])); - - // Parasites avant et apres - //$obj_text = preg_replace("/^\s+obj\s+/", "", $obj_text); - //$obj_text = preg_replace("/(\s+endobj)\s+.*$/", "\\1", $obj_text); - - // Commentaires - $obj_text = preg_replace("/\\\\%/", ' ', $obj_text); - $obj_text = preg_replace("/%[^\r\n]*[\r\n]+/", '', $obj_text); - - // Dictionnaire - $obj_dict = ""; - //if (ereg("<<(.*)>>", $obj_text, $regs)) - if (preg_match("/<<(.*)>>/s", $obj_text, $regs)) // bug ?! - $obj_dict = $regs[1]; - -# echo "<hr>"; -# echo "Objet numéro $i<p>"; -# echo "<pre>".htmlspecialchars($obj_text)."</pre>"; - } - else { - $t = " endobj ".$obj; // approximation - } - unset($obj); - - // Recoller les morceaux du stream (au cas ou un "obj" se trouvait en clair dans un stream) - if ($in_stream) { - if (!($p = strpos($t, "endstream")) && !($q = strpos($t, "endobj"))) { - $stream .= $t; -# echo "<span style='color: red'>Stream continué</span><p>"; - continue; - } - $in_stream = false; - if ($p) $stream .= substr($t, 0, $p); - else $stream .= substr($t, 0, $q); - unset($t); - - // Decoder le contenu du stream - $encoding = ''; - if (preg_match(",/Filter\s*/([A-Za-z]+),", $obj_dict, $regs)) - $encoding = $regs[1]; - switch($encoding) { - case 'FlateDecode': - $stream = gzuncompress($stream); // pb avec certains PDFs !? - break; - case '': - break; - default: - $stream = ''; - } - /*if (preg_match("/\(d.marrage:\)/", $stream, $regs)) { - $fs = fopen("demarrage.txt", "w"); - fwrite($fs, $regs[0]); - fclose($fs); - exit; - }*/ - } - - if (!$stream) continue; - -# echo "Stream : ".strlen($stream)." octets<p>"; - - // Eviter les fontes embarquees, etc. - if (preg_match(',^%!,', $stream)) { - unset($stream); - continue; - } - // Detection texte / binaire - $stream = substr($stream, 0, $stream_len); - $stream = str_replace('\\(', ",", $stream); - $stream = str_replace('\\)', ",", $stream); - $n1 = substr_count($stream, '('); - $n2 = substr_count($stream, ')'); - $freq = (substr_count($stream, ' ') + $n1 + $n2) / strlen($stream); - if ($freq < 0.04 || (!$n1 && !$n2)) { -# echo "no text (1)<p>"; - //echo htmlspecialchars($stream); - unset($stream); - continue; - } - $dev = abs($n1 - $n2) / ($n1 + $n2); - if ($dev > 0.05) { -# echo "no text (2)<p>"; - unset($stream); - continue; - } - // Extraction des chaines - if (strpos($stream, '<<') && strpos($stream, '>>')) - $stream = preg_replace(',<<.*?'.'>>,s', '', $stream); // bug avec preg - $stream = substr($stream, strpos($stream, '(') + 1); - $stream = substr($stream, 0, strrpos($stream, ')')); // ici un bug occasionnel... - $stream = $this->convertir_caracteres($stream); - $extrait = $this->recoller_texte($stream); - unset($stream); - $texte .= $extrait; - - // Se limiter a une certaine taille de texte en sortie - if (strlen($texte) > $texte_len) { - $texte = substr($texte, 0, strrpos(substr($texte, 0, $texte_len), ' ')); - break; - } - } - - fclose($f); - - return $texte; - } - -} // class - - -?> diff --git a/ecrire/extract/rtf.php b/ecrire/extract/rtf.php deleted file mode 100644 index e7b5b7bb80c7b44bf6cc7e0cfce0150d5313b4c1..0000000000000000000000000000000000000000 --- a/ecrire/extract/rtf.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -// -// Lit un document 'rtf' et extrait son contenu en texte brut -// - -// NOTE : l'extracteur n'est pas oblige de convertir le contenu dans -// le charset du site, mais il *doit* signaler le charset dans lequel -// il envoie le contenu, de facon a ce qu'il soit converti au moment -// voulu ; dans le cas contraire le document sera lu comme s'il etait -// dans le charset iso-8859-1 - -// http://doc.spip.org/@extracteur_rtf -function extracteur_rtf($fichier, &$charset) { - - $charset = 'iso-8859-1'; - - @exec('metamail -d -q -b -c application/rtf '.escapeshellarg($fichier), $r, $e); - if (!$e) return @join(' ', $r); - - # wvText - # http://wvware.sourceforge.net/ - $temp = tempnam(_DIR_CACHE, 'rtf'); - @exec('wvText '.escapeshellarg($fichier).'> '.$temp, $r, $e); - lire_fichier($temp, $contenu); - @unlink($temp); - if (!$e) return $contenu; - - - # unrtf - # http://www.gnu.org/software/unrtf/unrtf.html - # --html car avec --text les accents sont perdus :( - @exec('unrtf --html '.escapeshellarg($fichier), $r, $e); - if (!$e) return join(' ', $r); - - # catdoc - # http://www.45.free.net/~vitus/ice/catdoc/ - @exec('catdoc '.escapeshellarg($fichier), $r, $e); - if (!$e) return join(' ', $r); - -} - -// Sait-on extraire ce format ? -// TODO: ici tester si les binaires fonctionnent -$GLOBALS['extracteur']['rtf'] = 'extracteur_rtf'; - -?> diff --git a/ecrire/inc/ajouter_documents.php b/ecrire/inc/ajouter_documents.php index 8bd2cafccfa3c36a3bb8f2e8b5e199165b3a2ce7..91e839d3405249b0b49f1cad85724e9c182fd0d4 100644 --- a/ecrire/inc/ajouter_documents.php +++ b/ecrire/inc/ajouter_documents.php @@ -254,9 +254,17 @@ function ajouter_un_document($source, $nom_envoye, $type_lien, $id_lien, $mode, else $documents_actifs[$fichier] = $id_document; - // Demander l'indexation du document - include_spip('inc/indexation'); - marquer_indexer('spip_documents', $id_document); + // Notifications, gestion des revisions, reindexation... + pipeline('post_edition', + array( + 'args' => array( + 'operation' => 'ajouter_document', + 'table' => 'spip_documents', + 'id_objet' => $id_document + ), + 'data' => null + ) + ); return $type_image; } @@ -425,6 +433,6 @@ function liste_archive_taille($files) . affdate_heure(date("Y-m-d H:i:s", $file['mtime'])) .")</tt></li>"; } - return$res; + return $res; } ?> diff --git a/ecrire/inc/config.php b/ecrire/inc/config.php index d0bcc9516a1383df81badbd4b739a71c7e461185..cb482ecd4c75cfbf8746cf8c147d9f11b8e48f8e 100644 --- a/ecrire/inc/config.php +++ b/ecrire/inc/config.php @@ -61,7 +61,6 @@ function liste_metas() 'activer_sites' => 'non', 'proposer_sites' => 0, 'activer_syndic' => 'oui', - 'visiter_sites' => 'non', 'moderation_sites' => 'non', 'forums_publics' => 'posteriori', @@ -76,7 +75,6 @@ function liste_metas() 'quoi_de_neuf' => 'non', 'forum_prive_admin' => 'non', - 'activer_moteur' => 'non', 'articles_versions' => 'non', 'activer_statistiques' => 'non', @@ -190,12 +188,6 @@ function appliquer_modifs_config() { if ($accepter_forum == 'abo') ecrire_meta('accepter_visiteurs', 'oui'); - // Activer le moteur : dresser la liste des choses a indexer - if (($i = _request('activer_moteur')) == 'oui' AND ($i != $GLOBALS['meta']["activer_moteur"])) { - include_spip('inc/indexation'); - creer_liste_indexation(); - } - if ($i = _request('langues_auth') AND is_array($i)) { set_request('langues_multilingue', join($i, ",")); } diff --git a/ecrire/inc/cron.php b/ecrire/inc/cron.php index 605d6e1aed3408a20fd878fac7b15c843a2be74e..e96fb09dd6a2940223291789cad57dc840ec3d01 100644 --- a/ecrire/inc/cron.php +++ b/ecrire/inc/cron.php @@ -159,10 +159,6 @@ function taches_generales() { if ($GLOBALS['meta']["activer_syndic"] == "oui") $taches_generales['syndic'] = 90; - // indexation - if ($GLOBALS['meta']["activer_moteur"] == "oui") - $taches_generales['indexation'] = 90; - // maintenance (ajax, verifications diverses) $taches_generales['maintenance'] = 3600 * 2; diff --git a/ecrire/inc/distant.php b/ecrire/inc/distant.php index a7d944b576b09e5fa0e85904bfa5ca0bfab3ee61..68b582a1db6171a4bffd62c4cdbba23a91533b0d 100644 --- a/ecrire/inc/distant.php +++ b/ecrire/inc/distant.php @@ -43,13 +43,17 @@ function copie_locale($source, $mode='auto') { if (!$contenu) return false; ecrire_fichier(_DIR_RACINE.$local, $contenu); - // signaler au moteur de recherche qu'il peut reindexer ce doc - $id_document = spip_abstract_fetch(spip_query("SELECT id_document FROM spip_documents WHERE fichier=" . _q($source))); - $id_document = $id_document['id_document']; - if ($id_document) { - include_spip('inc/indexation'); - marquer_indexer('spip_documents', $id_document); - } + // pour une eventuelle indexation + pipeline('post_edition', + array( + 'args' => array( + 'operation' => 'copie_locale', + 'source' => $source, + 'fichier' => $local + ), + 'data' => null + ) + ); } } diff --git a/ecrire/inc/editer_mot.php b/ecrire/inc/editer_mot.php index 22365c661c01b4d47d995f2f1593f511288c434c..ceb0825fbf29543dcdfb402d384878a56674d5ac 100644 --- a/ecrire/inc/editer_mot.php +++ b/ecrire/inc/editer_mot.php @@ -62,17 +62,24 @@ function inc_editer_mot_dist($objet, $id_objet, $cherche_mot, $select_groupe, $f // La reponse $reponse = ''; + $modifier = false; if ($flag AND $cherche_mot) { - $reindexer = false; list($reponse, $nouveaux_mots) = recherche_mot_cle($cherche_mot, $select_groupe, $objet, $id_objet, $table, $table_id, $url_base); foreach($nouveaux_mots as $nouv_mot) { if ($nouv_mot!='x') { - $reindexer |= inserer_mot("spip_mots_$table", $table_id, $id_objet, $nouv_mot); + $modifier |= inserer_mot("spip_mots_$table", $table_id, $id_objet, $nouv_mot); } } - if ($reindexer AND ($GLOBALS['meta']['activer_moteur'] == 'oui')) { - include_spip("inc/indexation"); - marquer_indexer("spip_$table", $id_objet); + if ($modifier) { + pipeline('post_edition', + array( + 'args' => array( + 'table' => 'spip_'.$table, + 'id_objet' => $id_objet + ), + 'data' => null + ) + ); } } diff --git a/ecrire/inc/import.php b/ecrire/inc/import.php index f3b38ccfe94e1f08572df4a8deb8a2ca1c1bc3a2..aebf8781b84fac1ba3a67170c9bf00b32dd3bbc5 100644 --- a/ecrire/inc/import.php +++ b/ecrire/inc/import.php @@ -15,7 +15,6 @@ if (!defined("_ECRIRE_INC_VERSION")) return; include_spip('inc/presentation'); include_spip('inc/acces'); include_spip('inc/meta'); -include_spip('inc/indexation'); // pour la fonction primary_index_table include_spip('base/abstract_sql'); // NB: Ce fichier peut ajouter des tables (old-style) diff --git a/ecrire/inc/indexation.php b/ecrire/inc/indexation.php deleted file mode 100644 index 6434137b425654694e2318d19c8c25fded1d8997..0000000000000000000000000000000000000000 --- a/ecrire/inc/indexation.php +++ /dev/null @@ -1,991 +0,0 @@ -<?php - -/***************************************************************************\ - * SPIP, Systeme de publication pour l'internet * - * * - * Copyright (c) 2001-2007 * - * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * - * * - * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * - * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * -\***************************************************************************/ - -if (!defined("_ECRIRE_INC_VERSION")) return; -include_spip('inc/meta'); -include_spip('base/create'); -include_spip('base/abstract_sql'); -include_spip('public/interfaces'); - -// Quels formats sait-on extraire ? -$GLOBALS['extracteur'] = array ( - 'txt' => 'extracteur_txt', - 'pas' => 'extracteur_txt', - 'c' => 'extracteur_txt', - 'css' => 'extracteur_txt', - 'html' => 'extracteur_html' -); - -// tables que l'on ne doit pas indexer -global $INDEX_tables_interdites; -$INDEX_tables_interdites=array(); - -// Indexation des elements de l'objet principal -// 'champ'=>poids, ou 'champ'=>array(poids,min_long) -$reindex = false; -global $INDEX_elements_objet; -$INDEX_elements_objet = FALSE; -if (isset($GLOBALS['meta']['INDEX_elements_objet'])) - $INDEX_elements_objet = unserialize($GLOBALS['meta']['INDEX_elements_objet']); -if (!$INDEX_elements_objet) { - $INDEX_elements_objet['spip_articles'] = array('titre'=>8,'soustitre'=>5,'surtitre'=>5,'descriptif'=>4,'chapo'=>3,'texte'=>1,'ps'=>1,'nom_site'=>1,'extra|unserialize_join'=>1); - $INDEX_elements_objet['spip_breves'] = array('titre'=>8,'texte'=>2,'extra|unserialize_join'=>1); - $INDEX_elements_objet['spip_rubriques'] = array('titre'=>8,'descriptif'=>5,'texte'=>1,'extra|unserialize_join'=>1); - $INDEX_elements_objet['spip_auteurs'] = array('nom'=>array(5,2),'bio'=>1,'extra|unserialize_join'=>1); - $INDEX_elements_objet['spip_mots'] = array('titre'=>8,'descriptif'=>5,'texte'=>1,'extra|unserialize_join'=>1); - $INDEX_elements_objet['spip_signatures'] = array('nom_email'=>array(2,2),'ad_email'=>2,'nom_site'=>2,'url_site'=>1,'message'=>1); - $INDEX_elements_objet['spip_syndic'] = array('nom_site'=>50,'descriptif'=>30,'url_site|contenu_page_accueil'=>1); - $INDEX_elements_objet['spip_syndic_articles'] = array('titre'=>5); - $INDEX_elements_objet['spip_forum'] = array('titre'=>3,'texte'=>2,'auteur'=>array(2,2),'email_auteur'=>2,'nom_site'=>2,'url_site'=>1); - $INDEX_elements_objet['spip_documents'] = array('titre'=>20,'descriptif'=>10,'fichier|nettoie_nom_fichier'=>1); - ecrire_meta('INDEX_elements_objet',serialize($INDEX_elements_objet)); - ecrire_metas(); - $reindex = true; -} - -// Indexation des objets associes -// 'objet'=>poids -global $INDEX_objet_associes; -$INDEX_objet_associes = FALSE; -if (isset($GLOBALS['meta']['INDEX_objet_associes'])) - $INDEX_objet_associes = unserialize($GLOBALS['meta']['INDEX_objet_associes']); -if (!$INDEX_objet_associes) { - $INDEX_objet_associes['spip_articles'] = array('spip_documents'=>1,'spip_auteurs'=>10,'spip_mots'=>3); - $INDEX_objet_associes['spip_breves'] = array('spip_documents'=>1,'spip_mots'=>3); - $INDEX_objet_associes['spip_rubriques'] = array('spip_documents'=>1,'spip_mots'=>3); - $INDEX_objet_associes['spip_documents'] = array('spip_mots'=>3); - ecrire_meta('INDEX_objet_associes',serialize($INDEX_objet_associes)); - ecrire_metas(); - $reindex = true; -} - -// Indexation des elements des objets associes -// 'champ'=>poids, ou 'champ'=>array(poids,min_long) -global $INDEX_elements_associes; -$INDEX_elements_associes = FALSE; -if (isset($GLOBALS['meta']['INDEX_elements_associes'])) - $INDEX_elements_associes = unserialize($GLOBALS['meta']['INDEX_elements_associes']); -if (!$INDEX_elements_associes){ - $INDEX_elements_associes['spip_documents'] = array('titre'=>2,'descriptif'=>1); - $INDEX_elements_associes['spip_auteurs'] = array('nom'=>1); - $INDEX_elements_associes['spip_mots'] = array('titre'=>4,'descriptif'=>1); - ecrire_meta('INDEX_elements_associes',serialize($INDEX_elements_associes)); - ecrire_metas(); - $reindex = true; -} -// Criteres d'indexation -global $INDEX_critere_indexation; -$INDEX_critere_indexation = FALSE; -if (isset($GLOBALS['meta']['INDEX_critere_indexation'])) - $INDEX_critere_indexation = unserialize($GLOBALS['meta']['INDEX_critere_indexation']); -if (!$INDEX_critere_indexation){ - $INDEX_critere_indexation['spip_articles']="statut='publie'"; - $INDEX_critere_indexation['spip_breves']="statut='publie'"; - $INDEX_critere_indexation['spip_rubriques']="statut='publie'"; - $INDEX_critere_indexation['spip_syndic']="statut='publie'"; - $INDEX_critere_indexation['spip_forum']="statut='publie'"; - $INDEX_critere_indexation['spip_signatures']="statut='publie'"; - ecrire_meta('INDEX_critere_indexation',serialize($INDEX_critere_indexation)); - ecrire_metas(); - $reindex = true; -} - -// Criteres de des-indexation (optimisation dans base/optimiser) -global $INDEX_critere_optimisation; -$INDEX_critere_optimisation = FALSE; -if (isset($GLOBALS['meta']['INDEX_critere_optimisation'])) - $INDEX_critere_optimisation = unserialize($GLOBALS['meta']['INDEX_critere_optimisation']); -if (!$INDEX_critere_optimisation) { - $INDEX_critere_optimisation['spip_articles']="statut<>'publie'"; - $INDEX_critere_optimisation['spip_breves']="statut<>'publie'"; - $INDEX_critere_optimisation['spip_rubriques']="statut<>'publie'"; - $INDEX_critere_optimisation['spip_syndic']="statut<>'publie'"; - $INDEX_critere_optimisation['spip_forum']="statut<>'publie'"; - $INDEX_critere_optimisation['spip_signatures']="statut<>'publie'"; - ecrire_meta('INDEX_critere_optimisation',serialize($INDEX_critere_optimisation)); - ecrire_metas(); - $reindex = true; -} - -// Nombre d'elements maxi a indexer a chaque iteration -global $INDEX_iteration_nb_maxi; -$INDEX_iteration_nb_maxi = FALSE; -if (isset($GLOBALS['meta']['INDEX_iteration_nb_maxi'])) - $INDEX_iteration_nb_maxi = unserialize($GLOBALS['meta']['INDEX_iteration_nb_maxi']); -if (!$INDEX_iteration_nb_maxi) { - $INDEX_iteration_nb_maxi['spip_documents']=10; - $INDEX_iteration_nb_maxi['spip_syndic']=1; - ecrire_meta('INDEX_iteration_nb_maxi',serialize($INDEX_iteration_nb_maxi)); - ecrire_metas(); - $reindex = true; -} -if ($reindex) creer_liste_indexation(); - - -// Filtres d'indexation -// http://doc.spip.org/@unserialize_join -function unserialize_join($extra){ - return @join(' ', unserialize($extra)); -} -// http://doc.spip.org/@contenu_page_accueil -function contenu_page_accueil($url){ - $texte = ''; - if ($GLOBALS['meta']["visiter_sites"] == "oui") { - include_spip('inc/distant'); - spip_log ("indexation contenu syndic $url"); - $texte = supprimer_tags(recuperer_page($url, true, false, 50000)); - } - return $texte; -} -// http://doc.spip.org/@nettoie_nom_fichier -function nettoie_nom_fichier($fichier){ - return preg_replace(',^(IMG/|.*://),', '', $fichier); -} - -// Renvoie la liste des "mots" d'un texte (ou d'une requete adressee au moteur) -// http://doc.spip.org/@mots_indexation -function mots_indexation($texte, $min_long = 3) { - include_spip('inc/charsets'); - include_spip('inc/texte'); - - // Recuperer les parametres des modeles - $texte = traiter_modeles($texte, true); - - // Supprimer les tags HTML - $texte = preg_replace(',<.*>,Ums',' ',$texte); - - // Translitterer (supprimer les accents, recuperer les é etc) - // la translitteration complexe (vietnamien, allemand) duplique - // le texte, en mettant bout a bout une translitteration simple + - // une translitteration riche - if ($GLOBALS['translitteration_complexe']) - $texte_c = ' '.translitteration_complexe ($texte, 'AUTO', true); - else - $texte_c = ''; - $texte = translitteration($texte); - if($texte!=trim($texte_c)) $texte .= $texte_c; - # NB. tous les caracteres non translitteres sont retournes en utf-8 - - // OPTIONNEL // Gestion du tiret '-' : - // "vice-president" => "vice"+"president"+"vicepresident" -# $texte = preg_replace(',(\w+)-(\w+),', '\1 \2 \1\2', $texte); - - // Supprimer les caracteres de ponctuation, les guillemets... - $e = "],:;*\"!\r\n\t\\/)}{[|@<>$%'`?\~.^("; - $texte = strtr($texte, $e, preg_replace('/./', ' ', $e)); - - //delete +\- not at the beginning of a word - $texte = preg_replace(",(?:\S)[\-+],"," ",$texte); - // Cas particulier : sigles d'au moins deux lettres - $texte = preg_replace("/ ([A-Z][0-9A-Z]{1,".($min_long - 1)."}) /", - ' \\1___ ', $texte.' '); - - // Tout passer en bas de casse - $texte = strtolower($texte); - - // Retourner sous forme de table - return pipeline('mots_indexation',array('args'=>array('min_long'=>$min_long),'data'=>preg_split("/ +/", trim($texte)))); -} - -// http://doc.spip.org/@indexer_chaine -function indexer_chaine($texte, $val = 1, $min_long = 3) { - global $index, $mots; - global $translitteration_complexe; - - // Point d'entree pour traiter le texte avant indexation - $texte = pipeline('pre_indexation', $texte); - - $table = mots_indexation($texte, $min_long); - - foreach ($table as $mot) { - if (strlen($mot) > $min_long) { - $h = substr(md5($mot), 0, 16); - if (!isset($index[$h])) - $index[$h] = 0; - $index[$h] += $val/(1+$translitteration_complexe); - $mots .= ",(0x$h,'$mot')"; - } - } -} - -// id_table = 1...9 pour les tables spip, et ensuite 100, 101, 102... -// pour les tables additionnelles, selon l'ordre dans lequel -// elles sont reperees. On stocke le tableau de conversion table->id_table -// dans spip_meta -// http://doc.spip.org/@update_index_tables -function update_index_tables(){ - global $tables_principales; - global $INDEX_tables_interdites; - - $old_liste_tables = liste_index_tables(); - $rev_old_liste_tables = array_flip($old_liste_tables); - - $liste_tables = array(); - // les tables SPIP conventionnelles en priorite - $liste_tables[1]='spip_articles'; - $liste_tables[2]='spip_auteurs'; - $liste_tables[3]='spip_breves'; - $liste_tables[4]='spip_documents'; - $liste_tables[5]='spip_forum'; - $liste_tables[6]='spip_mots'; - $liste_tables[7]='spip_rubriques'; - $liste_tables[8]='spip_signatures'; - $liste_tables[9]='spip_syndic'; - - // detection des nouvelles tables - $id_autres = 100; - foreach(array_keys($tables_principales) as $new_table){ - if ( (!in_array($new_table,$INDEX_tables_interdites)) - &&(!in_array($new_table,$liste_tables)) - &&($id_autres<254) ){ - // on utilise abstract_showtable car cela permet d'activer l'indexation - // en ajoutant simplement le champ idx, sans toucher au core - $desc = spip_abstract_showtable($new_table, '', true); - if (isset($desc['field']['idx'])){ - // la table a un champ idx pour gerer l'indexation - if ( (isset($rev_old_liste_tables[$new_table])) - &&(!isset($liste_tables[$rev_old_liste_tables[$new_table]])) ) - $liste_tables[$rev_old_liste_tables[$new_table]] = $new_table; // id conserve - else{ - while (isset($liste_tables[$id_autres])&&($id_autres<254)) $id_autres++; - $liste_tables[$id_autres] = $new_table; - } - } - } - } - - // Cas de l'ajout d'une nouvelle table a indexer : - // mise en coherence de la table d'indexation avec les nouveaux id - $rev_old_liste_tables = array_flip($old_liste_tables); - foreach($liste_tables as $new_id=>$new_table){ - if (isset($rev_old_liste_tables[$new_table])){ - if ( ($old_id = ($rev_old_liste_tables[$new_table])) - &&($old_id!=$new_id)){ - $temp_id = 254; - // liberer le nouvel id - spip_query("UPDATE spip_index SET id_table=$temp_id WHERE id_table=$new_id"); - // deplacer les indexation de l'ancien id sous le nouvel id - spip_query("UPDATE spip_index SET id_table=$new_id WHERE id_table=$old_id"); - // remettre les indexation deplacees sous l'id qui vient d'etre libere - spip_query("UPDATE spip_index SET id_table=$old_id WHERE id_table=$temp_id"); - - $old_liste_tables[$old_id] = $old_liste_tables[$new_id]; - unset($old_liste_tables[$new_id]); - $rev_old_liste_tables = array_flip($old_liste_tables); - } - } - } - - ecrire_meta('index_table',serialize($liste_tables)); - ecrire_metas(); -} - -// http://doc.spip.org/@liste_index_tables -function liste_index_tables() { - $liste_tables = array(); - if (!isset($GLOBALS['meta']['index_table'])) { - lire_metas(); - } - if (isset($GLOBALS['meta']['index_table'])) - $liste_tables = unserialize($GLOBALS['meta']['index_table']); - return $liste_tables; -} - -// http://doc.spip.org/@id_index_table -function id_index_table($table){ - /*global $table_des_tables; - $t = $table_des_tables[$table]; - // pour les tables non Spip - if (!$t) $t = $table; else $t = "spip_$t";*/ - $t = $table; - $id_table = 0; - $l = liste_index_tables(); - $l = @array_flip($l); - if (isset($l[$t])) - $id_table=$l[$t]; - return $id_table; -} - -// http://doc.spip.org/@primary_index_table -function primary_index_table($table){ - global $tables_principales; - /*global $table_des_tables; - $t = $table_des_tables[$table]; - // pour les tables non Spip - if (!$t) $t = $table; else $t = "spip_$t";*/ - $t = $table; - $p = $tables_principales["$t"]['key']["PRIMARY KEY"]; - if (!$p){ - $p = preg_replace("{^spip_}","",$table); - $p = "id_" . $p; - if (substr($p,-1,1)=='s') - $p = substr($p,0,strlen($p)-1); - } - return $p; -} - -// http://doc.spip.org/@deja_indexe -function deja_indexe($table, $id_objet) { - $table_index = 'spip_index'; - $id_table = id_index_table($table); - $n = @spip_num_rows(@spip_query("SELECT id_objet FROM $table_index WHERE id_objet=$id_objet AND id_table=$id_table LIMIT 1")); - return ($n > 0); -} - -// Extracteur des documents 'txt' -// http://doc.spip.org/@extracteur_txt -function extracteur_txt($fichier, &$charset) { - lire_fichier($fichier, $contenu); - - // Reconnaitre le BOM utf-8 (0xEFBBBF) - include_spip('inc/charsets'); - if (bom_utf8($contenu)) - $charset = 'utf-8'; - - return $contenu; -} - -// Extracteur des documents 'html' -// http://doc.spip.org/@extracteur_html -function extracteur_html($fichier, &$charset) { - lire_fichier($fichier, $contenu); - - // Importer dans le charset local - include_spip('inc/charsets'); - $contenu = transcoder_page($contenu); - $charset = $GLOBALS['meta']['charset']; - - return $contenu; -} - - - -// Indexer le contenu d'un document -// http://doc.spip.org/@indexer_contenu_document -function indexer_contenu_document ($row, $min_long=3) { - global $extracteur; - - if ($row['mode'] == 'vignette') return; - $extension = $row['extension']; - - // Voir si on sait lire le contenu (eventuellement en chargeant le - // fichier extract/pdf.php dans find_in_path() ) - include_spip('extract/'.$extension); - if (function_exists($lire = $extracteur[$extension])) { - // Voir si on a deja une copie du doc distant - // Note: si copie_locale() charge le doc, elle demande une reindexation - include_spip('inc/distant'); - if (!$fichier = copie_locale($row['fichier'], 'test')) { - spip_log("pas de copie locale de '$fichier'"); - return; - } - // par defaut, on pense que l'extracteur va retourner ce charset - $charset = 'iso-8859-1'; - // lire le contenu - $contenu = $lire(_DIR_RACINE.$fichier, $charset); - if (!$contenu) { - spip_log("Echec de l'extraction de '$fichier'"); - } else { - // Ne retenir que les 50 premiers ko - $contenu = substr($contenu, 0, 50000); - // importer le charset - $contenu = importer_charset($contenu, $charset); - // Indexer le texte - indexer_chaine($contenu, 1, $min_long); - } - } else { - spip_log("pas d'extracteur '$extension' fonctionnel"); - } -} - - - -// http://doc.spip.org/@indexer_les_champs -function indexer_les_champs(&$row,&$index_desc,$ponderation = 1, $min_long=3){ - reset($index_desc); - while (list($quoi,$poids) = each($index_desc)){ - $pipe=array(); - if (strpos($quoi,"|")){ - $pipe = explode("|",$quoi); - $quoi = array_shift($pipe); - } - if (isset($row[$quoi])){ - $texte = $row[$quoi]; - if (count($pipe)){ - foreach ($pipe as $func){ - $func = trim($func); - if (!function_exists($func)) { - spip_log("Erreur - $func n'est pas definie (indexation)"); - } - else - // appliquer le filtre - $texte = $func($texte); - } - } - //spip_log(":$quoi:$poids:$texte"); - if (is_array($poids)) - indexer_chaine($texte,array_shift($poids) * $ponderation,array_shift($poids)); - else - indexer_chaine($texte,$poids * $ponderation, $min_long); - } - } -} - -// Indexer les documents, auteurs, mots-cles associes a l'objet -// http://doc.spip.org/@indexer_elements_associes -function indexer_elements_associes($table, $id_objet, $table_associe, $valeur, $min_long=3) { - global $INDEX_elements_associes, $tables_jointures, $tables_auxiliaires, $tables_principales; - - if (isset($INDEX_elements_associes[$table_associe])){ - $table_abreg = preg_replace("{^spip_}","",$table); - $col_id = primary_index_table($table); - $col_id_as = primary_index_table($table_associe); - if (is_array($rel = $tables_jointures[$table])) { - foreach($rel as $joint) { - if (@in_array($col_id_as, @array_keys($tables_auxiliaires['spip_' . $joint]['field']))) - {$table_rel = $joint; break;} - if (@in_array($col_id_as, @array_keys($tables_principales['spip_' . $joint]['field']))) - {$table_rel = $joint; break;} - } - if (!$table_rel){ - spip_log("Indexation de $table echouee : element associe $table_associe, jointure sur $col_id_as introuvable"); - return; - } - - $select="assoc.$col_id_as"; - foreach(array_keys($INDEX_elements_associes[$table_associe]) as $quoi) - $select.=',assoc.' . $quoi; - $r = spip_query("SELECT $select FROM $table_associe AS assoc, spip_$table_rel AS lien WHERE lien.$col_id=$id_objet AND assoc.$col_id_as=lien.$col_id_as"); - - while ($row = spip_abstract_fetch($r)) { - indexer_les_champs($row,$INDEX_elements_associes[$table_associe],$valeur); - } - } - } -} - -// http://doc.spip.org/@indexer_objet -function indexer_objet($table, $id_objet, $forcer_reset = true) { - global $index, $mots, $translitteration_complexe; - global $INDEX_elements_objet; - global $INDEX_objet_associes; - - $min_long = isset($GLOBALS['INDEX_mots_min_long'])?intval($GLOBALS['INDEX_mots_min_long']):3; - - $table_index = 'spip_index'; - $col_id = primary_index_table($table); - $id_table = id_index_table($table); - - if (!$id_objet) return; - if (!$forcer_reset AND deja_indexe($table, $id_objet)) { - spip_log ("$table $id_objet deja indexe"); - spip_query("UPDATE $table SET idx='oui' WHERE $col_id=$id_objet"); - return; - } - // marquer "en cours d'indexation" - spip_query("UPDATE $table SET idx='idx' WHERE $col_id=$id_objet"); - - include_spip('inc/texte'); - - spip_log("indexation $table $id_objet"); - $index = ''; - $mots = ''; - - $result = spip_query("SELECT * FROM $table WHERE $col_id=$id_objet"); - - $row = spip_abstract_fetch($result); - - if (!$row) return; - - // translitteration complexe ? - if (!$lang = $row['lang']) $lang = $GLOBALS['meta']['langue_site']; - if ($lang == 'de' OR $lang=='vi') { - $translitteration_complexe = 1; - spip_log ('-> translitteration complexe'); - } else $translitteration_complexe = 0; - - if (isset($INDEX_elements_objet[$table])){ - - // Cas tres particulier du forum : - // on indexe le thread comme un tout - if ($table=='spip_forum') { - - // 1. chercher la racine du thread - $id_forum = $id_objet; - while ($row['id_parent']) { - $id_forum = $row['id_parent']; - $s = spip_query("SELECT id_forum,id_parent FROM spip_forum WHERE id_forum=$id_forum"); - $row = spip_abstract_fetch($s); - } - - // 2. chercher tous les forums du thread - // (attention le forum de depart $id_objet n'appartient pas forcement - // a son propre thread car il peut etre le fils d'un forum non 'publie') - $thread="$id_forum"; - $fini = false; - while (!$fini) { - $s = spip_query("SELECT id_forum FROM spip_forum WHERE id_parent IN ($thread) AND id_forum NOT IN ($thread) AND statut='publie'"); - if (spip_num_rows($s) == 0) $fini = true; - while ($t = spip_abstract_fetch($s)) - $thread.=','.$t['id_forum']; - } - - // 3. marquer le thread comme "en cours d'indexation" - spip_log("-> indexation thread $thread"); - spip_query("UPDATE spip_forum SET idx='idx' WHERE id_forum IN ($thread,$id_objet) AND idx!='non'"); - - // 4. Indexer le thread - $s = spip_query("SELECT * FROM spip_forum WHERE id_forum IN ($thread) AND idx!='non'"); - while ($row = spip_abstract_fetch($s)) { - indexer_les_champs($row,$INDEX_elements_objet[$table],1,$min_long); - if (isset($INDEX_objet_associes[$table])) - foreach($INDEX_objet_associes[$table] as $quoi=>$poids) - indexer_elements_associes($table, $id_objet, $quoi, $poids, $min_long); - break; - } - - // 5. marquer le thread comme "indexe" - spip_query("UPDATE spip_forum SET idx='oui' WHERE id_forum IN ($thread,$id_objet) AND idx!='non'"); - - // 6. Changer l'id_objet en id_forum de la racine du thread - $id_objet = $id_forum; - } else { - indexer_les_champs($row,$INDEX_elements_objet[$table],1,$min_long); - if (isset($INDEX_objet_associes[$table])) - foreach($INDEX_objet_associes[$table] as $quoi=>$poids) - indexer_elements_associes($table, $id_objet, $quoi, $poids, $min_long); - - if ($table=='spip_syndic'){ - // 2. Indexer les articles syndiques - if (($row['syndication'] = "oui")&&(isset($INDEX_elements_objet['syndic_articles']))) { - $result_syndic = spip_query("SELECT titre FROM spip_syndic_articles WHERE id_syndic=$id_objet AND statut='publie' ORDER BY date DESC LIMIT 100"); - - while ($row_syndic = spip_abstract_fetch($result_syndic)) { - indexer_les_champs($row,$INDEX_elements_objet['syndic_articles'],1,$min_long); - } - } - } - if ($table=='spip_documents'){ - // 2. Indexer le contenu si on sait le lire - indexer_contenu_document($row,$min_long); - } - } - } else - spip_log("je ne sais pas indexer '$table'"); - - $result = spip_query("DELETE FROM $table_index WHERE id_objet=$id_objet AND id_table=$id_table"); - - if ($index) { - if ($mots) { - // supprimer la virgule du debut - spip_query("INSERT IGNORE INTO spip_index_dico (hash, dico) VALUES ".substr($mots,1)); - - } - reset($index); - while (list($hash, $points) = each($index)) { - spip_query("INSERT INTO $table_index (hash, points, id_objet, id_table) VALUES (0x$hash,".ceil($points).",$id_objet,$id_table)"); - } - } - - // marquer "indexe" - spip_query("UPDATE $table SET idx='oui' WHERE $col_id=$id_objet"); -} - -/* - Valeurs du champ 'idx' de la table spip_objet(s) - '' ne sait pas - '1' ˆ (re)indexer - 'oui' deja indexe - 'idx' en cours - 'non' ne jamais indexer -*/ - -// API pour l'espace prive pour marquer un objet d'une table a reindexer -// http://doc.spip.org/@marquer_indexer -function marquer_indexer ($table, $id_objet) { - if (!isset($GLOBALS['INDEX_elements_objet'][$table])) - return; - spip_log ("demande indexation $table id=$id_objet"); - $id = primary_index_table($table); - spip_query("UPDATE $table SET idx='1' WHERE $id=$id_objet AND idx!='non'"); -} - -// A garder pour compatibilite bouton memo... -// http://doc.spip.org/@indexer_article -function indexer_article($id_article) { - marquer_indexer('spip_articles', $id_article); -} - -// n'indexer que les objets publies -// http://doc.spip.org/@critere_indexation -function critere_indexation($table) { - global $INDEX_critere_indexation; - if (isset($INDEX_critere_indexation[$table])) - return $INDEX_critere_indexation[$table]; - else - return '1=1'; // indexation par defaut -} - -// ne desindexer que les objets non-publies -// http://doc.spip.org/@critere_optimisation -function critere_optimisation($table) { - global $INDEX_critere_optimisation; - if (isset($INDEX_critere_optimisation[$table])) - return $INDEX_critere_optimisation[$table]; - else - return '1=0'; // pas de indexation par defaut -} - - -// http://doc.spip.org/@effectuer_une_indexation -function effectuer_une_indexation($nombre_indexations = 1) { - global $INDEX_iteration_nb_maxi; - $vu = array(); - - // chercher un objet a indexer dans chacune des tables d'objets - foreach (liste_index_tables() as $table) { - - $table_primary = primary_index_table($table); - $critere = critere_indexation($table); - - $limit = $nombre_indexations; - if (isset($INDEX_iteration_nb_maxi[$table])) - $limit = min($limit,$INDEX_iteration_nb_maxi[$table]); - - // indexer en priorite les '1' (a reindexer), ensuite les '' - // (statut d'indexation inconnu), enfin les 'idx' (ceux dont - // l'indexation a precedemment echoue, p. ex. a cause d'un timeout) - foreach (array('1', '', 'idx') as $mode) { - $s = spip_query("SELECT $table_primary AS id FROM $table WHERE idx='$mode' AND $critere LIMIT $limit"); - while ($t = spip_abstract_fetch($s)) { - $vu[$table] .= $t['id'].", "; - indexer_objet($table, $t['id'], $mode); - } - if ($vu[$table]) break; - } - } - return $vu; -} - -// http://doc.spip.org/@executer_une_indexation_syndic -function executer_une_indexation_syndic() { - $id_syndic = 0; - spip_connect(); - $row = spip_abstract_fetch(spip_abstract_select("id_syndic", "spip_syndic", "statut='publie' AND date_index < DATE_SUB(NOW(), INTERVAL 7 DAY)", '', "date_index", "1")); - if ($row) { - $id_syndic = $row['id_syndic']; - spip_query("UPDATE spip_syndic SET date_index=NOW() WHERE id_syndic=$id_syndic"); - marquer_indexer('spip_syndic', $id_syndic); - } - return $id_syndic; -} - -// http://doc.spip.org/@creer_liste_indexation -function creer_liste_indexation() { - foreach (liste_index_tables() as $table) - spip_query("UPDATE $table SET idx='1' WHERE idx!='non'"); -} - -// http://doc.spip.org/@purger_index -function purger_index() { - spip_query("DELETE FROM spip_index"); - spip_query("DELETE FROM spip_index_dico"); -} - -// rechercher un mot dans le dico -// retourne deux methodes : lache puis strict -// http://doc.spip.org/@requete_dico -function requete_dico($val, $min_long = 3) { - - preg_match(",^([+\-]?)(.*),",$val,$mod); - switch($mod[1]) { - case '': - $mode = "OR"; - break; - case '+': - $mode = "AND"; - break; - case '-': - $mode = "NOT"; - break; - } - //set logical operator between the various where parts - $val = $mod[2]; - // cas normal - $res = array(); - if (strlen($val) > $min_long) - $res = array("dico LIKE "._q($val. "%"), "dico = " . _q($val),$mode); - else - $res = array("dico = "._q($val."___"), "dico = "._q($val."___"),$mode); - return pipeline('requete_dico',array('args'=>array('val'=>$val,'min_long'=>$min_long),'data'=>$res)); -} - - -// decode la chaine recherchee et la traduit en hash -// http://doc.spip.org/@requete_hash -function requete_hash ($rech) { - $min_long = isset($GLOBALS['INDEX_mots_min_long'])?intval($GLOBALS['INDEX_mots_min_long']):3; - - // recupere les mots de la recherche - $GLOBALS['translitteration_complexe'] = true; - $s = mots_indexation($rech,$min_long); - unset($dico); - unset($h); - - // cherche les mots dans le dico - while (list(, $val) = each($s)) { - list($rq, $rq_strict,$mode) = requete_dico ($val,$min_long); - if ($rq) - $dico[$mode][$val] = $rq; - if ($rq_strict) - $dico_strict[$mode][$val] = $rq_strict; - } - - // Attention en MySQL 3.x il faut passer par HEX(hash) - // alors qu'en MySQL 4.1 c'est interdit ! - $vers = spip_query("SELECT VERSION() AS v"); - $vers = spip_abstract_fetch($vers); - if (($vers['v']{0} == 4 AND $vers['v']{2} >= 1) - OR $vers['v']{0} > 4) { - $hex_fmt = ''; - $select_hash = 'hash AS h'; - } else { - $hex_fmt = '0x'; - $select_hash = 'HEX(hash) AS h'; - } - - // compose la recherche dans l'index - $cond = ""; - if ($dico_strict["OR"]) $cond = join(" OR ", $dico_strict["OR"]); - - if ($cond) { - $result2 = spip_query("SELECT $select_hash FROM spip_index_dico WHERE ".$cond); - - while ($row2 = spip_abstract_fetch($result2)) - $h_strict[] = $hex_fmt.$row2['h']; - } - - $cond = ""; - if ($dico_strict["AND"]) $cond = join(" OR ", $dico_strict["AND"]); - if ($cond) { - $result2 = spip_query("SELECT $select_hash FROM spip_index_dico WHERE ".$cond); - - while ($row2 = spip_abstract_fetch($result2)) - $h_strict_and[] = $hex_fmt.$row2['h']; - - } - - $cond = ""; - if ($dico["OR"]) $cond = join(" OR ", $dico["OR"]); - if ($cond) { - $result2 = spip_query("SELECT $select_hash FROM spip_index_dico WHERE ".$cond); - - while ($row2 = spip_abstract_fetch($result2)) - $h[] = $hex_fmt.$row2['h']; - } - - - $cond = ""; - if ($dico["AND"]) $cond = join(" OR ", $dico["AND"]); - if ($cond) { - $result2 = spip_query("SELECT $select_hash,dico FROM spip_index_dico WHERE ".$cond); - - while ($row2 = spip_abstract_fetch($result2)) { - //store the condition that selected the hash (the word typed by the user) - foreach($dico["AND"] as $key=>$val) { - $mot_and = substr($key,1); - if(strpos($row2['dico'],$mot_and)===0) - $h_and[$mot_and][] = $hex_fmt.$row2['h']; - } - } - //store hash 0 for words without any hashes - foreach($dico["AND"] as $key=>$val) { - $mot_and = substr($key,1); - if(!$h_and[$mot_and]) $h_and[$mot_and][] = 0; - } - } - - $cond = ""; - if ($dico["NOT"]) $cond = join(" OR ", $dico["NOT"]); - - if ($cond) { - $result2 = spip_query("SELECT $select_hash FROM spip_index_dico WHERE ".$cond); - - while ($row2 = spip_abstract_fetch($result2)) - $h_not[] = $hex_fmt.$row2['h']; - } - - if ($h_strict) - $hash_recherche_strict = join(",", $h_strict); - else - $hash_recherche_strict = "0"; - - if ($h_strict_and) - $hash_recherche_strict_and = join(",", $h_strict_and); - else - $hash_recherche_strict_and = "0"; - - if ($h) - $hash_recherche = join(",", $h); - else - $hash_recherche = "0"; - - if ($h_and) { - foreach($h_and as $key=>$val) - $hash_recherche_and[$key] = join(",", $h_and[$key]); - } else - $hash_recherche_and = "0"; - - if ($h_not) - $hash_recherche_not = join(",", $h_not); - else - $hash_recherche_not = "0"; - - return array($hash_recherche, $hash_recherche_strict, $hash_recherche_not, $hash_recherche_and, $hash_recherche_strict_and); -} - -// -// Preparer les elements pour le critere {recherche} -// Note : si le critere est optionnel {recherche?}, ne pas s'activer -// si la recherche est vide -// -// http://doc.spip.org/@prepare_recherche -function prepare_recherche($recherche, $primary = 'id_article', $id_table='articles',$nom_table='spip_articles', $cond=false) { - static $cache = array(); - static $fcache = array(); - - // si recherche n'est pas dans le contexte, on va prendre en globals - // ca permet de faire des inclure simple. - if (!isset($recherche) AND isset($GLOBALS['recherche'])) - $recherche = $GLOBALS['recherche']; - - // traiter le cas {recherche?} - if ($cond AND !strlen($recherche)) - return array("''" /* as points */, /* where */ '1'); - - // Premier passage : chercher eventuel un cache des donnees sur le disque - if (!$cache[$recherche]['hash']) { - $dircache = sous_repertoire(_DIR_CACHE,'rech'); - $fcache[$recherche] = - $dircache . substr(md5($recherche),0,10).'.txt'; - if (lire_fichier($fcache[$recherche], $contenu)) - $cache[$recherche] = @unserialize($contenu); - } - - // si on n'a pas encore traite les donnees dans une boucle precedente - if (!$cache[$recherche][$id_table.$primary]) { - if (!$cache[$recherche]['hash']) - $cache[$recherche]['hash'] = requete_hash($recherche); - list($hash_recherche, $hash_recherche_strict, $hash_recherche_not, $hash_recherche_and, $hash_recherche_strict_and) - = $cache[$recherche]['hash']; - - $strict = array(); - if ($hash_recherche_strict) - foreach (split(',',$hash_recherche_strict) as $h) - $strict[$h] = 99; - - if ($hash_recherche_strict_and) - foreach (split(',',$hash_recherche_strict_and) as $h) - $strict[$h] = 99; - - $index_id_table = id_index_table($nom_table); - $points = array(); - - $objet_and = array(); - $object_not = array(); - if($hash_recherche_and) { - //$hash_recherche_and is an array of mots=>comma separated hashes - $list_hashes = join(",",$hash_recherche_and); - $pow = 1; - foreach($hash_recherche_and as $key=>$val) { - $hash_groupes[] = "$pow*".calcul_mysql_in("hash",$val); - $pow *= 2; - } - $count_groupes = join(" + ",$hash_groupes); - - $s = spip_query("SELECT id_objet as id,COUNT(DISTINCT $count_groupes) as count_groupes FROM spip_index WHERE id_table=$index_id_table AND hash IN ($list_hashes) GROUP BY id HAVING count_groupes=".count($hash_recherche_and)); - //if no ids are found, pass at least id = 0 in order to exclude any result - $objet_and[] = 0; - while ($r = spip_abstract_fetch($s)) - $objet_and[]=$r['id']; - } - if($hash_recherche_not) { - $s = spip_query("SELECT DISTINCT id_objet as id FROM spip_index WHERE hash IN ($hash_recherche_not) AND id_table=$index_id_table"); - while ($r = spip_abstract_fetch($s)) - $objet_not[]=$r['id']; - } - if(count($objet_and)) - $list_and = " AND id_objet IN (".join(",",$objet_and).")"; - if(count($objet_not)) - $list_not = " AND id_objet NOT IN (".join(",",$objet_not).")"; - if($hash_recherche) { - $list_hash = " AND hash IN (".$hash_recherche.")"; - } - - if($list_hash || $list_and || $list_not) { - $query = "SELECT hash,points,id_objet as id FROM spip_index WHERE id_table=$index_id_table".$list_and.$list_not.$list_hash; - - $s = spip_query($query); - - while ($r = spip_abstract_fetch($s)) - $points[$r['id']] - += (1 + $strict[$r['hash']]) * $r['points']; - spip_abstract_free($s); - arsort($points, SORT_NUMERIC); - } - - # calculer le {id_article IN()} et le {... as points} - if (!count($points)) { - $cache[$recherche][$id_table.$primary] = array("''", '0'); - } else { - $ids = array(); - $select = '0'; - foreach ($points as $id => $p) - $listes_ids[$p] .= ','.$id; - foreach ($listes_ids as $p => $liste_ids) - $select .= "+$p*(". - calcul_mysql_in("$id_table.$primary", substr($liste_ids, 1)) - .") "; - - $cache[$recherche][$id_table.$primary] = array($select, - '('.calcul_mysql_in("$id_table.$primary", - join(',',array_keys($points))).')' - ); - } - - // ecrire le cache de la recherche sur le disque - ecrire_fichier($fcache[$recherche], serialize($cache[$recherche])); - // purger le petit cache - nettoyer_petit_cache('rech', 300); - } - return $cache[$recherche][$id_table.$primary]; -} - - -// http://doc.spip.org/@cron_indexation -function cron_indexation($t) { - $c = count(effectuer_une_indexation()); - // si des indexations ont ete effectuees, on passe la periode a 0 s - ## note : (time() - 90) correspond en fait a : - ## time() - $taches_generales['indexation'] - if ($c) - return (0 - (time() - 90)); - else - return 0; -} - - -// Si la liste des correspondances tables/id_table n'est pas la, la creer -if ((isset($GLOBALS['meta']))&&(!isset($GLOBALS['meta']['index_table']))) - update_index_tables(); - -?> diff --git a/ecrire/inc/modifier.php b/ecrire/inc/modifier.php index 97f038ff76864116a1e6fc6530830a1ccf5ecd08..ab29aacea3393b3be4823bb0230c915a6df1a11b 100644 --- a/ecrire/inc/modifier.php +++ b/ecrire/inc/modifier.php @@ -83,18 +83,10 @@ function modifier_contenu($type, $id, $options, $c=false) { suivre_invalideur($options['invalideur']); } - // Demander une reindexation ? - if (!isset($options['indexation'])) - $options['indexation'] = ($GLOBALS['meta']['activer_moteur'] == 'oui'); - if ($options['indexation']) { - include_spip('inc/indexation'); - marquer_indexer('spip_'.$table_objet, $id); - } - // marquer les documents vus dans le texte si il y a lieu if (isset($GLOBALS['tables_auxiliaires']["spip_documents_$table_objet"]["field"]["vu"])) marquer_doublons_documents($champs,$id,$id_table_objet,$table_objet); - + // Notifications, gestion des revisions... pipeline('post_edition', array( @@ -130,8 +122,10 @@ function marquer_doublons_documents($champs,$id,$id_table_objet,$table_objet){ spip_query("UPDATE spip_documents_$table_objet SET vu='non' WHERE $id_table_objet=$id"); if (count($GLOBALS['doublons_documents_inclus'])){ // on repasse par une requete sur spip_documents pour verifier que les documents existent bien ! - $in_liste = implode(',',$GLOBALS['doublons_documents_inclus']); - $res = spip_query("SELECT id_document FROM spip_documents WHERE " . calcul_mysql_in('id_document', $in_liste)); + $in_liste = calcul_mysql_in('id_document', + $GLOBALS['doublons_documents_inclus']); + $res = spip_query("SELECT id_document FROM spip_documents WHERE " + . $in_liste); while ($row = spip_abstract_fetch($res)) { spip_query("UPDATE spip_documents_$table_objet SET vu='oui' WHERE $id_table_objet=$id AND id_document=" . $row['id_document']); } @@ -143,7 +137,7 @@ function revision_document($id_document, $c=false) { return modifier_contenu('document', $id_document, array( - 'champs' => array('titre', 'descriptif') + 'champs' => array('titre', 'descriptif', 'date', 'largeur', 'hauteur') //,'nonvide' => array('titre' => _T('info_sans_titre')) ), $c); diff --git a/ecrire/inc/rechercher.php b/ecrire/inc/rechercher.php index f25ef961587ec2f04bb8665cf60ad8047341977b..3c4f69452a5bfb621c7b8c2ce3e3b59f3eae0823 100644 --- a/ecrire/inc/rechercher.php +++ b/ecrire/inc/rechercher.php @@ -317,5 +317,85 @@ function remplace_en_base($recherche='', $remplace=NULL, $tables=NULL, $options= } } +// Preparer les listes id_article IN (...) pour les parties WHERE +// et points = des requetes du moteur de recherche +function prepare_recherche_api($recherche, $primary = 'id_article', $id_table='articles',$nom_table='spip_articles', $cond=false) { + static $cache = array(); + static $fcache = array(); + + // si recherche n'est pas dans le contexte, on va prendre en globals + // ca permet de faire des inclure simple. + if (!isset($recherche) AND isset($GLOBALS['recherche'])) + $recherche = $GLOBALS['recherche']; + + // traiter le cas {recherche?} + if ($cond AND !strlen($recherche)) + return array("''" /* as points */, /* where */ '1'); + + spip_timer("rechapi"); + // Premier passage : chercher eventuel un cache des donnees sur le disque + if (!$cache[$recherche]['hash']) { + $dircache = sous_repertoire(_DIR_CACHE,'rech2'); + $fcache[$recherche] = + $dircache . substr(md5($recherche),0,10).'.txt'; + if (lire_fichier($fcache[$recherche], $contenu)) + $cache[$recherche] = @unserialize($contenu); + } + + // si on n'a pas encore traite les donnees dans une boucle precedente + if (!$cache[$recherche][$primary]) { + include_spip('inc/rechercher'); + + $tables = liste_des_champs(); + $x = preg_replace(',s$,', '', $id_table); + if ($x == 'syndic') $x = 'site'; + $points = recherche_en_base($recherche, + $x, + array( + 'score' => true, + 'toutvoir' => true, + 'jointures' => true + )); + $points = $points[$x]; + + # Pour les forums, unifier par id_thread et forcer statut='publie' + if ($x == 'forum' AND $points) { + $p2 = array(); + $s = spip_query("SELECT id_thread, id_forum FROM spip_forum WHERE statut='publie' AND ".calcul_mysql_in('id_forum', array_keys($points))); + while ($t = spip_fetch_array($s)) + $p2[intval($t['id_thread'])]['score'] + += $points[intval($t['id_forum'])]['score']; + $points = $p2; + } + + # calculer le {id_article IN()} et le {... as points} + if (!count($points)) { + $cache[$recherche][$primary] = array("''", '0'); + } else { + $listes_ids = array(); + $select = '0'; + foreach ($points as $id => $p) + $listes_ids[$p['score']] .= ','.$id; + foreach ($listes_ids as $p => $liste_ids) + $select .= "+$p*(". + calcul_mysql_in("$id_table.$primary", substr($liste_ids, 1)) + .") "; + + $cache[$recherche][$primary] = array($select, + '('.calcul_mysql_in("$id_table.$primary", + array_keys($points)).')' + ); + } + + // ecrire le cache de la recherche sur le disque + ecrire_fichier($fcache[$recherche], serialize($cache[$recherche])); + // purger le petit cache + nettoyer_petit_cache('rech2', 300); + } + + spip_log("recherche api ($recherche) de #$primary# : ".spip_timer("rechapi")); + + return $cache[$recherche][$primary]; +} ?> diff --git a/ecrire/inc/rubriques.php b/ecrire/inc/rubriques.php index 42e0b53d08c1077f422f2c6cb5ef325a511ba71a..33d6eaedf142a606a5d46ff1db1af759c29326fe 100644 --- a/ecrire/inc/rubriques.php +++ b/ecrire/inc/rubriques.php @@ -306,9 +306,7 @@ function calcul_generation ($generation) { $lesfils = array(); $result = spip_abstract_select(array('id_rubrique'), array('spip_rubriques AS rubriques'), - array(calcul_mysql_in('id_parent', - $generation, - ''))); + array(calcul_mysql_in('id_parent', $generation))); while ($row = spip_abstract_fetch($result)) $lesfils[] = $row['id_rubrique']; return join(",",$lesfils); diff --git a/ecrire/inc/syndic.php b/ecrire/inc/syndic.php index 01146882ab4955c0d02871f208d39c91d4591a22..2c2d1ad79cb97d212293a6b731247fb7764b2e00 100644 --- a/ecrire/inc/syndic.php +++ b/ecrire/inc/syndic.php @@ -577,14 +577,7 @@ function my_strtotime($la_date) { // http://doc.spip.org/@cron_syndic function cron_syndic($t) { - $r = executer_une_syndication(); - if (($GLOBALS['meta']['activer_moteur'] == 'oui') && - ($GLOBALS['meta']["visiter_sites"] == 'oui')) { - include_spip("inc/indexation"); - $r2 = executer_une_indexation_syndic(); - $r = $r && $r2; - } - return $r; + return executer_une_syndication(); } ?> diff --git a/ecrire/inc/visites.php b/ecrire/inc/visites.php index 03e861244f97965535171cc37c4275d7985451a1..e53fc5cc9562961430909acf6107e7681d5a5d72 100644 --- a/ecrire/inc/visites.php +++ b/ecrire/inc/visites.php @@ -111,17 +111,17 @@ function calculer_visites($t) { $ar[$num][] = $id_article; $tous[] = $id_article; } - $tous = calcul_mysql_in('id_article', join(',', $tous)); + $tous = calcul_mysql_in('id_article', $tous); $sum = ''; foreach ($ar as $num => $liste) $sum .= ' + '.$num.'*' - . calcul_mysql_in('id_article', join(',',$liste)); + . calcul_mysql_in('id_article', $liste); # pour les popularites ajouter 1 point par referer $sumref = ''; if ($referers_a) $sumref = ' + '.calcul_mysql_in('id_article', - join(',',array_keys($referers_a))); + array_keys($referers_a)); spip_query("UPDATE spip_visites_articles SET visites = visites $sum WHERE date='$date' AND $tous"); @@ -143,7 +143,7 @@ function calculer_visites($t) { // ajouter les visites foreach ($ar as $num => $liste) { - spip_query("UPDATE spip_referers SET visites = visites+$num, visites_jour = visites_jour+$num WHERE ".calcul_mysql_in('referer_md5',join(',',$liste))); + spip_query("UPDATE spip_referers SET visites = visites+$num, visites_jour = visites_jour+$num WHERE ".calcul_mysql_in('referer_md5',$liste)); } } diff --git a/ecrire/inc_version.php b/ecrire/inc_version.php index 7e0424ca9226f132930d6a5b4926cc9b5a25cc31..1677c46be9f76cac45f76fab0f7f37e811dbde54 100644 --- a/ecrire/inc_version.php +++ b/ecrire/inc_version.php @@ -302,7 +302,7 @@ $liste_des_statuts = array( // (utilise pour les modifs de la base de donnees) // version de la base -$spip_version = 1.942; +$spip_version = 1.943; // version de spip en chaine // et en numerique a incrementer sur les evolutions qui cassent la compatibilite descendante diff --git a/ecrire/public/composer.php b/ecrire/public/composer.php index 95f06a0b5244ba63cb37fac7ad68e6ae1036f741..a6e59a4fa2a8ab699b05c2de324de9acc2cce6f0 100644 --- a/ecrire/public/composer.php +++ b/ecrire/public/composer.php @@ -12,7 +12,6 @@ if (!defined("_ECRIRE_INC_VERSION")) return; -include_spip("inc/indexation"); include_spip('inc/texte'); include_spip('inc/documents'); include_spip('inc/forum'); diff --git a/ecrire/public/criteres.php b/ecrire/public/criteres.php index 62ba772bf6b833f64704daf9bfd0c68115504b28..2d45586b111558051cda672d4cacba9db4a3a5a3 100644 --- a/ecrire/public/criteres.php +++ b/ecrire/public/criteres.php @@ -152,7 +152,8 @@ function critere_recherche_dist($idb, &$boucles, $crit) { // Ne pas executer la requete en cas de hash vide $boucle->hash = ' // RECHERCHE - list($rech_select, $rech_where) = prepare_recherche('.$quoi.', "'.$boucle->primary.'", "'.$boucle->id_table.'", "'.$t.'", "'.$crit->cond.'"); + include_spip("inc/rechercher"); + list($rech_select, $rech_where) = prepare_recherche_api('.$quoi.', "'.$boucle->primary.'", "'.$boucle->id_table.'", "'.$t.'", "'.$crit->cond.'"); '; // Sauf si le critere est conditionnel {recherche ?}