| 7 | 
           david | 
           1 | 
           <?php
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           /***************************************************************************\
  | 
        
        
            | 
            | 
           4 | 
            *  SPIP, Systeme de publication pour l'internet                           *
  | 
        
        
            | 
            | 
           5 | 
            *                                                                         *
  | 
        
        
            | 
            | 
           6 | 
            *  Copyright (c) 2001-2005                                                *
  | 
        
        
            | 
            | 
           7 | 
            *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
  | 
        
        
            | 
            | 
           8 | 
            *                                                                         *
  | 
        
        
            | 
            | 
           9 | 
            *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
  | 
        
        
            | 
            | 
           10 | 
            *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
  | 
        
        
            | 
            | 
           11 | 
           \***************************************************************************/
  | 
        
        
            | 
            | 
           12 | 
              | 
        
        
            | 
            | 
           13 | 
              | 
        
        
            | 
            | 
           14 | 
           // Ce fichier ne sera execute qu'une fois
  | 
        
        
            | 
            | 
           15 | 
           if (defined("_INC_COMPILO_API")) return;
  | 
        
        
            | 
            | 
           16 | 
           define("_INC_COMPILO_API", "1");
  | 
        
        
            | 
            | 
           17 | 
              | 
        
        
            | 
            | 
           18 | 
              | 
        
        
            | 
            | 
           19 | 
           // Definition des noeuds de l'arbre de syntaxe abstraite
  | 
        
        
            | 
            | 
           20 | 
              | 
        
        
            | 
            | 
           21 | 
           class Texte {
  | 
        
        
            | 
            | 
           22 | 
           	var $type = 'texte';
  | 
        
        
            | 
            | 
           23 | 
           	var $texte;
  | 
        
        
            | 
            | 
           24 | 
           	var $avant, $apres = ""; // s'il y avait des guillemets autour
  | 
        
        
            | 
            | 
           25 | 
           	var $ligne = 0;
  | 
        
        
            | 
            | 
           26 | 
           }
  | 
        
        
            | 
            | 
           27 | 
              | 
        
        
            | 
            | 
           28 | 
           class Inclure {
  | 
        
        
            | 
            | 
           29 | 
           	var $type = 'include';
  | 
        
        
            | 
            | 
           30 | 
           	var $texte;
  | 
        
        
            | 
            | 
           31 | 
           	var $avant, $apres; // inutilises mais generiques
  | 
        
        
            | 
            | 
           32 | 
           	var $ligne = 0;
  | 
        
        
            | 
            | 
           33 | 
           	var $param = array();  //  valeurs des params
  | 
        
        
            | 
            | 
           34 | 
           }
  | 
        
        
            | 
            | 
           35 | 
              | 
        
        
            | 
            | 
           36 | 
           //
  | 
        
        
            | 
            | 
           37 | 
           // encodage d'une boucle SPIP en un objet PHP
  | 
        
        
            | 
            | 
           38 | 
           //
  | 
        
        
            | 
            | 
           39 | 
           class Boucle {
  | 
        
        
            | 
            | 
           40 | 
           	var $type = 'boucle';
  | 
        
        
            | 
            | 
           41 | 
           	var $id_boucle;
  | 
        
        
            | 
            | 
           42 | 
           	var $id_parent ='';
  | 
        
        
            | 
            | 
           43 | 
           	var $avant, $milieu, $apres, $altern;
  | 
        
        
            | 
            | 
           44 | 
           	var $lang_select;
  | 
        
        
            | 
            | 
           45 | 
           	var $type_requete;
  | 
        
        
            | 
            | 
           46 | 
           	var $sql_serveur;
  | 
        
        
            | 
            | 
           47 | 
           	var $param = array();
  | 
        
        
            | 
            | 
           48 | 
           	var $criteres = array();
  | 
        
        
            | 
            | 
           49 | 
           	var $separateur = array();
  | 
        
        
            | 
            | 
           50 | 
           	var $doublons;
  | 
        
        
            | 
            | 
           51 | 
           	var $partie, $total_parties,$mode_partie;
  | 
        
        
            | 
            | 
           52 | 
           	var $externe = ''; # appel a partir d'une autre boucle (recursion)
  | 
        
        
            | 
            | 
           53 | 
           	// champs pour la construction de la requete SQL
  | 
        
        
            | 
            | 
           54 | 
           	var $tout = false;
  | 
        
        
            | 
            | 
           55 | 
           	var $plat = false;
  | 
        
        
            | 
            | 
           56 | 
           	var $select = array();
  | 
        
        
            | 
            | 
           57 | 
           	var $from = array();
  | 
        
        
            | 
            | 
           58 | 
           	var $where = array();
  | 
        
        
            | 
            | 
           59 | 
           	var $having = 0;
  | 
        
        
            | 
            | 
           60 | 
           	var $limit;
  | 
        
        
            | 
            | 
           61 | 
           	var $group = '';
  | 
        
        
            | 
            | 
           62 | 
           	var $order = array();
  | 
        
        
            | 
            | 
           63 | 
           	var $default_order = '';
  | 
        
        
            | 
            | 
           64 | 
           	var $date = 'date' ;
  | 
        
        
            | 
            | 
           65 | 
           	var $hash = "" ;
  | 
        
        
            | 
            | 
           66 | 
           	var $lien = false;
  | 
        
        
            | 
            | 
           67 | 
           	var $sous_requete = false;
  | 
        
        
            | 
            | 
           68 | 
           	var $hierarchie = '';
  | 
        
        
            | 
            | 
           69 | 
           	// champs pour la construction du corps PHP
  | 
        
        
            | 
            | 
           70 | 
           	var $id_table;
  | 
        
        
            | 
            | 
           71 | 
           	var $primary;
  | 
        
        
            | 
            | 
           72 | 
           	var $return;
  | 
        
        
            | 
            | 
           73 | 
           	var $numrows = false;
  | 
        
        
            | 
            | 
           74 | 
           	var $ligne = 0;
  | 
        
        
            | 
            | 
           75 | 
           }
  | 
        
        
            | 
            | 
           76 | 
              | 
        
        
            | 
            | 
           77 | 
           // sous-noeud du precedent
  | 
        
        
            | 
            | 
           78 | 
              | 
        
        
            | 
            | 
           79 | 
           class Critere {
  | 
        
        
            | 
            | 
           80 | 
           	var $op;
  | 
        
        
            | 
            | 
           81 | 
           	var $not;
  | 
        
        
            | 
            | 
           82 | 
           	var $param = array();
  | 
        
        
            | 
            | 
           83 | 
           	var $ligne = 0;
  | 
        
        
            | 
            | 
           84 | 
           }
  | 
        
        
            | 
            | 
           85 | 
              | 
        
        
            | 
            | 
           86 | 
           class Champ {
  | 
        
        
            | 
            | 
           87 | 
           	var $type = 'champ';
  | 
        
        
            | 
            | 
           88 | 
           	var $nom_champ;
  | 
        
        
            | 
            | 
           89 | 
           	var $nom_boucle= ''; // seulement si boucle explicite
  | 
        
        
            | 
            | 
           90 | 
           	var $avant, $apres; // tableaux d'objets
  | 
        
        
            | 
            | 
           91 | 
           	var $etoile;
  | 
        
        
            | 
            | 
           92 | 
           	var $param = array();  // filtre explicites
  | 
        
        
            | 
            | 
           93 | 
           	var $fonctions = array();  // source des filtres (compatibilite)
  | 
        
        
            | 
            | 
           94 | 
           	// champs pour la production de code
  | 
        
        
            | 
            | 
           95 | 
           	var $id_boucle;
  | 
        
        
            | 
            | 
           96 | 
           	var $boucles;
  | 
        
        
            | 
            | 
           97 | 
           	var $type_requete;
  | 
        
        
            | 
            | 
           98 | 
           	var $code;	// code du calcul
  | 
        
        
            | 
            | 
           99 | 
           	var $statut;	// 'numerique, 'h'=texte (html) ou 'p'=script (php) ?
  | 
        
        
            | 
            | 
           100 | 
           			// -> definira les pre et post-traitements obligatoires
  | 
        
        
            | 
            | 
           101 | 
           	// champs pour la production de code dependant du contexte
  | 
        
        
            | 
            | 
           102 | 
           	// $id_mere;  pour TOTAL_BOUCLE hors du corps
  | 
        
        
            | 
            | 
           103 | 
           	// $document; pour embed et img dans les textes
  | 
        
        
            | 
            | 
           104 | 
           	// sourcefile; pour DOSSIER_SQUELETTE
  | 
        
        
            | 
            | 
           105 | 
           	var $descr = array();
  | 
        
        
            | 
            | 
           106 | 
           	var $ligne = 0;
  | 
        
        
            | 
            | 
           107 | 
           }
  | 
        
        
            | 
            | 
           108 | 
              | 
        
        
            | 
            | 
           109 | 
              | 
        
        
            | 
            | 
           110 | 
           class Idiome {
  | 
        
        
            | 
            | 
           111 | 
           	var $type = 'idiome';
  | 
        
        
            | 
            | 
           112 | 
           	var $nom_champ = ""; // la chaine a traduire
  | 
        
        
            | 
            | 
           113 | 
           	var $module = ""; // son module de definition
  | 
        
        
            | 
            | 
           114 | 
           	var $param = array(); // les filtres a appliquer au resultat
  | 
        
        
            | 
            | 
           115 | 
           	var $fonctions = array(); // source des filtres  (compatibilite)
  | 
        
        
            | 
            | 
           116 | 
           	var $avant, $apres; // inutilises mais faut = ci-dessus
  | 
        
        
            | 
            | 
           117 | 
           	// champs pour la production de code, cf ci-dessus
  | 
        
        
            | 
            | 
           118 | 
           	var $id_boucle;
  | 
        
        
            | 
            | 
           119 | 
           	var $boucles;
  | 
        
        
            | 
            | 
           120 | 
           	var $type_requete;
  | 
        
        
            | 
            | 
           121 | 
           	var $code;
  | 
        
        
            | 
            | 
           122 | 
           	var $statut;
  | 
        
        
            | 
            | 
           123 | 
           	var $descr = array();
  | 
        
        
            | 
            | 
           124 | 
           	var $ligne = 0;
  | 
        
        
            | 
            | 
           125 | 
           }
  | 
        
        
            | 
            | 
           126 | 
              | 
        
        
            | 
            | 
           127 | 
           class Polyglotte {
  | 
        
        
            | 
            | 
           128 | 
           	var $type = 'polyglotte';
  | 
        
        
            | 
            | 
           129 | 
           	var $traductions = array(); // les textes ou choisir
  | 
        
        
            | 
            | 
           130 | 
           	var $ligne = 0;
  | 
        
        
            | 
            | 
           131 | 
           }
  | 
        
        
            | 
            | 
           132 | 
           //
  | 
        
        
            | 
            | 
           133 | 
           // Globales de description de la base
  | 
        
        
            | 
            | 
           134 | 
              | 
        
        
            | 
            | 
           135 | 
           //ces variabales ne sont pas initialisees par "$var = array()"
  | 
        
        
            | 
            | 
           136 | 
           // afin de permettre leur extension dans mes_options.php etc
  | 
        
        
            | 
            | 
           137 | 
              | 
        
        
            | 
            | 
           138 | 
           global $tables_des_serveurs_sql, $tables_principales; // (voir inc_serialbase)
  | 
        
        
            | 
            | 
           139 | 
           global $exceptions_des_tables, $table_des_tables;
  | 
        
        
            | 
            | 
           140 | 
           global $tables_relations,  $table_primary, $table_date;
  | 
        
        
            | 
            | 
           141 | 
              | 
        
        
            | 
            | 
           142 | 
            // champ principal des tables SQL
  | 
        
        
            | 
            | 
           143 | 
           $table_primary['articles']="id_article";
  | 
        
        
            | 
            | 
           144 | 
           $table_primary['auteurs']="id_auteur";
  | 
        
        
            | 
            | 
           145 | 
           $table_primary['breves']="id_breve";
  | 
        
        
            | 
            | 
           146 | 
           $table_primary['documents']="id_document";
  | 
        
        
            | 
            | 
           147 | 
           $table_primary['forums']="id_forum";
  | 
        
        
            | 
            | 
           148 | 
           $table_primary['groupes_mots']="id_groupe";
  | 
        
        
            | 
            | 
           149 | 
           $table_primary['hierarchie']="id_rubrique";
  | 
        
        
            | 
            | 
           150 | 
           $table_primary['mots']="id_mot";
  | 
        
        
            | 
            | 
           151 | 
           $table_primary['rubriques']="id_rubrique";
  | 
        
        
            | 
            | 
           152 | 
           $table_primary['signatures']="id_signature";
  | 
        
        
            | 
            | 
           153 | 
           $table_primary['syndication']="id_syndic";
  | 
        
        
            | 
            | 
           154 | 
           $table_primary['syndic_articles']="id_syndic_article";
  | 
        
        
            | 
            | 
           155 | 
           $table_primary['types_documents']="id_type";
  | 
        
        
            | 
            | 
           156 | 
              | 
        
        
            | 
            | 
           157 | 
            # cf. fonction table_objet dans inc_version
  | 
        
        
            | 
            | 
           158 | 
           $table_des_tables['articles']='articles';
  | 
        
        
            | 
            | 
           159 | 
           $table_des_tables['auteurs']='auteurs';
  | 
        
        
            | 
            | 
           160 | 
           $table_des_tables['breves']='breves';
  | 
        
        
            | 
            | 
           161 | 
           $table_des_tables['forums']='forum';
  | 
        
        
            | 
            | 
           162 | 
           $table_des_tables['signatures']='signatures';
  | 
        
        
            | 
            | 
           163 | 
           $table_des_tables['documents']='documents';
  | 
        
        
            | 
            | 
           164 | 
           $table_des_tables['types_documents']='types_documents';
  | 
        
        
            | 
            | 
           165 | 
           $table_des_tables['mots']='mots';
  | 
        
        
            | 
            | 
           166 | 
           $table_des_tables['groupes_mots']='groupes_mots';
  | 
        
        
            | 
            | 
           167 | 
           $table_des_tables['rubriques']='rubriques';
  | 
        
        
            | 
            | 
           168 | 
           $table_des_tables['syndication']='syndic';
  | 
        
        
            | 
            | 
           169 | 
           $table_des_tables['syndic_articles']='syndic_articles';
  | 
        
        
            | 
            | 
           170 | 
           $table_des_tables['hierarchie']='rubriques';
  | 
        
        
            | 
            | 
           171 | 
              | 
        
        
            | 
            | 
           172 | 
           $exceptions_des_tables['breves']['id_secteur']='id_rubrique';
  | 
        
        
            | 
            | 
           173 | 
           $exceptions_des_tables['breves']['date']='date_heure';
  | 
        
        
            | 
            | 
           174 | 
           $exceptions_des_tables['breves']['nom_site']='lien_titre';
  | 
        
        
            | 
            | 
           175 | 
           $exceptions_des_tables['breves']['url_site']='lien_url';
  | 
        
        
            | 
            | 
           176 | 
              | 
        
        
            | 
            | 
           177 | 
           $exceptions_des_tables['forums']['date']='date_heure';
  | 
        
        
            | 
            | 
           178 | 
           $exceptions_des_tables['forums']['nom']='auteur';
  | 
        
        
            | 
            | 
           179 | 
           $exceptions_des_tables['forums']['email']='email_auteur';
  | 
        
        
            | 
            | 
           180 | 
              | 
        
        
            | 
            | 
           181 | 
           $exceptions_des_tables['signatures']['date']='date_time';
  | 
        
        
            | 
            | 
           182 | 
           $exceptions_des_tables['signatures']['nom']='nom_email';
  | 
        
        
            | 
            | 
           183 | 
           $exceptions_des_tables['signatures']['email']='ad_email';
  | 
        
        
            | 
            | 
           184 | 
              | 
        
        
            | 
            | 
           185 | 
           $exceptions_des_tables['documents']['type_document']=array('types_documents'
  | 
        
        
            | 
            | 
           186 | 
           , 'titre');
  | 
        
        
            | 
            | 
           187 | 
           $exceptions_des_tables['documents']['extension_document']=array('types_docum
  | 
        
        
            | 
            | 
           188 | 
           ents', 'extension');
  | 
        
        
            | 
            | 
           189 | 
           $exceptions_des_tables['documents']['mime_type']=array('types_documents'
  | 
        
        
            | 
            | 
           190 | 
           , 'mime_type');
  | 
        
        
            | 
            | 
           191 | 
              | 
        
        
            | 
            | 
           192 | 
           # ne sert plus ? verifier balise_URL_ARTICLE
  | 
        
        
            | 
            | 
           193 | 
           $exceptions_des_tables['syndic_articles']['url_article']='url';
  | 
        
        
            | 
            | 
           194 | 
           # ne sert plus ? verifier balise_LESAUTEURS
  | 
        
        
            | 
            | 
           195 | 
           $exceptions_des_tables['syndic_articles']['lesauteurs']='lesauteurs';
  | 
        
        
            | 
            | 
           196 | 
           $exceptions_des_tables['syndic_articles']['url_site']=array('syndic',
  | 
        
        
            | 
            | 
           197 | 
           'url_site');
  | 
        
        
            | 
            | 
           198 | 
           $exceptions_des_tables['syndic_articles']['nom_site']=array('syndic',
  | 
        
        
            | 
            | 
           199 | 
           'nom_site');
  | 
        
        
            | 
            | 
           200 | 
              | 
        
        
            | 
            | 
           201 | 
           $table_date['articles']='date';
  | 
        
        
            | 
            | 
           202 | 
           $table_date['auteurs']='date';
  | 
        
        
            | 
            | 
           203 | 
           $table_date['breves']='date_heure';
  | 
        
        
            | 
            | 
           204 | 
           $table_date['forums']='date_heure';
  | 
        
        
            | 
            | 
           205 | 
           $table_date['signatures']='date_time';
  | 
        
        
            | 
            | 
           206 | 
           $table_date['documents']='date';
  | 
        
        
            | 
            | 
           207 | 
           $table_date['types_documents']='date';
  | 
        
        
            | 
            | 
           208 | 
           $table_date['groupes_mots']='date';
  | 
        
        
            | 
            | 
           209 | 
           $table_date['mots']='date';
  | 
        
        
            | 
            | 
           210 | 
           $table_date['rubriques']='date';
  | 
        
        
            | 
            | 
           211 | 
           $table_date['syndication']='date';
  | 
        
        
            | 
            | 
           212 | 
           $table_date['syndic_articles']='date';
  | 
        
        
            | 
            | 
           213 | 
              | 
        
        
            | 
            | 
           214 | 
           //
  | 
        
        
            | 
            | 
           215 | 
           // tableau des tables de relations,
  | 
        
        
            | 
            | 
           216 | 
           // Ex: gestion du critere {id_mot} dans la boucle(ARTICLES)
  | 
        
        
            | 
            | 
           217 | 
           //
  | 
        
        
            | 
            | 
           218 | 
           $tables_relations['articles']['id_mot']='mots_articles';
  | 
        
        
            | 
            | 
           219 | 
           $tables_relations['articles']['id_auteur']='auteurs_articles';
  | 
        
        
            | 
            | 
           220 | 
           $tables_relations['articles']['id_document']='documents_articles';
  | 
        
        
            | 
            | 
           221 | 
              | 
        
        
            | 
            | 
           222 | 
           $tables_relations['auteurs']['id_article']='auteurs_articles';
  | 
        
        
            | 
            | 
           223 | 
              | 
        
        
            | 
            | 
           224 | 
           $tables_relations['breves']['id_mot']='mots_breves';
  | 
        
        
            | 
            | 
           225 | 
           $tables_relations['breves']['id_document']='documents_breves';
  | 
        
        
            | 
            | 
           226 | 
              | 
        
        
            | 
            | 
           227 | 
           $tables_relations['documents']['id_article']='documents_articles';
  | 
        
        
            | 
            | 
           228 | 
           $tables_relations['documents']['id_rubrique']='documents_rubriques';
  | 
        
        
            | 
            | 
           229 | 
           $tables_relations['documents']['id_breve']='documents_breves';
  | 
        
        
            | 
            | 
           230 | 
           $tables_relations['documents']['id_syndic']='documents_syndic';
  | 
        
        
            | 
            | 
           231 | 
           $tables_relations['documents']['id_syndic_article']='documents_syndic';
  | 
        
        
            | 
            | 
           232 | 
           $tables_relations['documents']['id_mot']='mots_documents';
  | 
        
        
            | 
            | 
           233 | 
              | 
        
        
            | 
            | 
           234 | 
           $tables_relations['forums']['id_mot']='mots_forum';
  | 
        
        
            | 
            | 
           235 | 
              | 
        
        
            | 
            | 
           236 | 
           $tables_relations['mots']['id_article']='mots_articles';
  | 
        
        
            | 
            | 
           237 | 
           $tables_relations['mots']['id_breve']='mots_breves';
  | 
        
        
            | 
            | 
           238 | 
           $tables_relations['mots']['id_forum']='mots_forum';
  | 
        
        
            | 
            | 
           239 | 
           $tables_relations['mots']['id_rubrique']='mots_rubriques';
  | 
        
        
            | 
            | 
           240 | 
           $tables_relations['mots']['id_syndic']='mots_syndic';
  | 
        
        
            | 
            | 
           241 | 
           $tables_relations['mots']['id_document']='mots_documents';
  | 
        
        
            | 
            | 
           242 | 
              | 
        
        
            | 
            | 
           243 | 
           $tables_relations['groupes_mots']['id_groupe']='mots';
  | 
        
        
            | 
            | 
           244 | 
              | 
        
        
            | 
            | 
           245 | 
           $tables_relations['rubriques']['id_mot']='mots_rubriques';
  | 
        
        
            | 
            | 
           246 | 
           $tables_relations['rubriques']['id_document']='documents_rubriques';
  | 
        
        
            | 
            | 
           247 | 
              | 
        
        
            | 
            | 
           248 | 
           $tables_relations['syndication']['id_mot']='mots_syndic';
  | 
        
        
            | 
            | 
           249 | 
           $tables_relations['syndication']['id_document']='documents_syndic';
  | 
        
        
            | 
            | 
           250 | 
           $tables_relations['syndic_articles']['id_document']='documents_syndic';
  | 
        
        
            | 
            | 
           251 | 
              | 
        
        
            | 
            | 
           252 | 
           ?>
  |