[ Index ] |
|
Code source de SPIP Agora 1.4 |
1 <?php 2 /***************************************************** 3 * This file is part of Agora, web based content management system. 4 * 5 * Agora is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * 9 * Agora is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details (file "COPYING"). 13 * 14 * Copyright © Arnaud Martin, Antoine Pitrou et Philippe Rivière. 15 * List of authors detailed in "copyright_fr.html" file. 16 * E-mail : agora@sig.premier-ministre.gouv.fr 17 * Web site : http://www.agora.gouv.fr 18 *****************************************************/ 19 // Ce fichier ne sera execute qu'une fois 20 if (defined("_ECRIRE_INC_EXPORT")) 21 return; 22 23 define("_ECRIRE_INC_EXPORT", "1"); 24 25 require_once(dirname(__FILE__). '/include/bd/inc_metier_factory.php'); 26 27 $GLOBALS['version_archive'] = '1.2'; 28 29 // Conversion timestamp MySQL (format ascii) en Unix (format integer) 30 function mysql_timestamp_to_time ($maj) { 31 $t_an = substr($maj, 0, 4); 32 $t_mois = substr($maj, 4, 2); 33 $t_jour = substr($maj, 6, 2); 34 $t_h = substr($maj, 8, 2); 35 $t_min = substr($maj, 10, 2); 36 $t_sec = substr($maj, 12, 2); 37 return mktime($t_h, $t_min, $t_sec, $t_mois, $t_jour, $t_an, 0); 38 } 39 40 function build_begin_tag ($tag) { 41 return "<$tag>"; 42 } 43 44 function build_end_tag ($tag) { 45 return "</$tag>"; 46 } 47 48 // Conversion texte -> xml (ajout d'entites) 49 function text_to_xml ($string) { 50 return str_replace('<', '<', str_replace('&', '&', $string)); 51 } 52 53 function computeFieldName ($result, $index) { } 54 55 // 56 // Exportation generique d'objets (fichier ou retour de fonction) 57 // 58 function export_objets ($query, $type, $file = 0, $gz = false, $etape_en_cours = "", $etape_actuelle = "", 59 $nom_etape = "") { 60 global $debut_limit; 61 62 $objetMetier = &recuperer_instance_metier(); 63 $db = &$objetMetier->_getDB(); 64 65 if ($etape_en_cours < 1 OR $etape_en_cours == $etape_actuelle) { 66 if ($etape_en_cours > 0) { 67 echo "<li><strong>$nom_etape</strong>"; 68 } 69 70 $result = $db->query($query); 71 72 if ($etape_en_cours > 0) { 73 if ($type == "forum") { 74 $total = $result->numRows(); 75 76 if ($total > 5000) { 77 $result = $db->limitQuery($query, $debut_limit, 5000); 78 $debut_limit = $debut_limit + 5000; 79 if ($debut_limit > $total) { 80 $debut_limit = 0; 81 echo " " . _T('info_tous_resultats_enregistres'); 82 } 83 else { 84 echo " " . _T('info_premier_resultat', array('debut_limit' => $debut_limit, 'total' => $total)); 85 } 86 } 87 else { 88 $debut_limit = 0; 89 } 90 } 91 if ($type == "article") { 92 $total = $result->numRows(); 93 if ($total > 500) { 94 $result = $db->limitQuery($query, $debut_limit, 500); 95 $debut_limit = $debut_limit + 500; 96 if ($debut_limit > $total) { 97 $debut_limit = 0; 98 echo " " . _T('info_tous_resultats_enregistres'); 99 } 100 else { 101 echo " " . _T('info_premier_resultat_sur', 102 array('debut_limit' => $debut_limit, 'total' => $total)); 103 } 104 } 105 else { 106 $debut_limit = 0; 107 } 108 } 109 } 110 111 $_fputs = ($gz) ? gzputs : fputs; 112 $nfields = $result->numCols(); 113 $fields = null; 114 115 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { 116 if ($fields == null) { 117 $i = 0; 118 while (list($colName, ) = each($row)) { 119 $fields[$i++] = $colName; 120 } 121 } 122 123 reset($row); 124 125 $string .= build_begin_tag($type). "\n"; 126 127 // Exporter les champs de la table 128 for ($i = 0; $i < $nfields; ++$i) { 129 $string .= '<' . $fields[$i]. '>' . text_to_xml($row[$fields[$i]]). '</' . $fields[$i]. '>' . "\n"; 130 } 131 132 // Exporter les relations 133 if ($type == 'article') { 134 $articleMetier = &recuperer_instance_article(); 135 $allAuteurIds = $articleMetier->getAuteurIdsForArticleId($row[$fields[0]]); 136 137 while (list(, $monAuteurId) = each($allAuteurIds)) { 138 $string .= '<lien:auteur>' . $monAuteurId . '</lien:auteur>' . "\n"; 139 } 140 141 $documentMetier = &recuperer_instance_document(); 142 $allDocumentIds = $documentMetier->getAllDocumentIdForLinkId("article", $row[$fields[0]]); 143 144 if (PEAR::isError($allDocumentIds)) { 145 die($allDocumentIds->getMessage()); 146 } 147 while (list(, $monDocumentId) = each($allDocumentIds)) { 148 $string .= '<lien:document>' . $monDocumentId . '</lien:document>' . "\n"; 149 } 150 } 151 else if ($type == 'message') { 152 $messageMetier = &recuperer_instance_message(); 153 $allAuteurIds = $messageMetier->getAuteurIdsForMessageId($row[$fields[0]]); 154 155 if (PEAR::isError($allAuteurIds)) { 156 die($allAuteurIds->getMessage()); 157 } 158 while (list(, $monAuteurId) = each($allAuteurIds)) { 159 $string .= '<lien:auteur>' . $monAuteurId . '</lien:auteur>' . "\n"; 160 } 161 } 162 else if ($type == 'breve') { 163 $documentMetier = &recuperer_instance_document(); 164 $allDocumentIds = $documentMetier->getAllDocumentIdForLinkId("breve", $row[$fields[0]]); 165 166 if (PEAR::isError($allDocumentIds)) { 167 die($allDocumentIds->getMessage()); 168 } 169 while (list(, $monDocumentId) = each($allDocumentIds)) { 170 $string .= '<lien:document>' . $monDocumentId . '</lien:document>' . "\n"; 171 } 172 } 173 else if ($type == 'rubrique') { 174 $documentMetier = &recuperer_instance_document(); 175 $allDocumentIds = $documentMetier->getAllDocumentIdForLinkId("rubrique", $row[$fields[0]]); 176 177 if (PEAR::isError($allDocumentIds)) { 178 die($allDocumentIds->getMessage()); 179 } 180 181 while (list(, $monDocumentId) = each($allDocumentIds)) { 182 $string .= '<lien:document>' . $monDocumentId . '</lien:document>' . "\n"; 183 } 184 $rubriqueMetier = &recuperer_instance_rubrique(); 185 $allAuteurIds = $rubriqueMetier->getAuteurIdsForRubriqueId($row[$fields[0]]); 186 187 if (PEAR::isError($allAuteurIds)) { 188 die($allAuteurIds->getMessage()); 189 } 190 while (list(, $monAuteurId) = each($allAuteurIds)) { 191 $string .= '<lien:auteur>' . $monAuteurId . '</lien:auteur>' . "\n"; 192 } 193 } 194 else if ($type == 'auteur') { 195 $rubriqueMetier = &recuperer_instance_rubrique(); 196 $allRubriqueIds = $rubriqueMetier->getRubriqueIdsForAuteurId($row[$fields[0]]); 197 198 if (PEAR::isError($allRubriqueIds)) { 199 die($allRubriqueIds->getMessage()); 200 } 201 while (list(, $maRubriqueId) = each($allRubriqueIds)) { 202 $string .= '<lien:rubrique>' . $maRubriqueId . '</lien:rubrique>' . "\n"; 203 } 204 } 205 else if ($type == 'mot') { 206 $messageMetier = &recuperer_instance_message(); 207 $allAuteurIds = $messageMetier->getAuteurIdsForMessageId($row[$fields[0]]); 208 209 if (PEAR::isError($allAuteurIds)) { 210 die($allAuteurIds->getMessage()); 211 } 212 213 while (list(, $monAuteurId) = each($allAuteurIds)) { 214 $string .= '<lien:auteur>' . $monAuteurId . '</lien:auteur>' . "\n"; 215 } 216 217 $motMetier = &recuperer_instance_mot(); 218 $allArticleIds = $motMetier->getAllFromAnotherTable('articles', 'id_article', $row[$fields[0]]); 219 220 if (PEAR::isError($allArticleIds)) { 221 die($allArticleIds->getMessage()); 222 } 223 224 while (list(, $monArticleId) = each($allArticleIds)) { 225 $string .= '<lien:article>' . $monArticleId . '</lien:article>' . "\n"; 226 } 227 228 $motMetier = &recuperer_instance_mot(); 229 $allBreveIds = $motMetier->getAllFromAnotherTable('breves', 'id_breve', $row[$fields[0]]); 230 231 if (PEAR::isError($allBreveIds)) { 232 die($allBreveIds->getMessage()); 233 } 234 235 while (list(, $maBreveId) = each($allBreveIds)) { 236 $string .= '<lien:breve>' . $maBreveId . '</lien:breve>' . "\n"; 237 } 238 239 $motMetier = recuperer_instance_mot(); 240 $allForumIds = $motMetier->getAllFromAnotherTable('forum', 'id_forum', $row[$fields[0]]); 241 242 if (PEAR::isError($allForumIds)) { 243 die($allForumIds->getMessage()); 244 } 245 246 while (list(, $monForumId) = each($allForumIds)) { 247 $string .= '<lien:forum>' . $monForumid . '</lien:forum>' . "\n"; 248 } 249 250 $motMetier = &recuperer_instance_mot(); 251 $allRubriqueIds = $motMetier->getAllFromAnotherTable('rubriques', 'id_rubrique', $row[$fields[0]]); 252 253 if (PEAR::isError($allRubriqueIds)) { 254 die($allRubriqueIds->getMessage()); 255 } 256 257 while (list(, $maRubriqueId) = each($allRubriqueIds)) { 258 $string .= '<lien:rubrique>' . $maRubriqueId . '</lien:rubrique>' . "\n"; 259 } 260 261 $motMetier = &recuperer_instance_mot(); 262 $allSyndicIds = $motMetier->getAllFromAnotherTable('syndic', 'id_syndic', $row[$fields[0]]); 263 264 if (PEAR::isError($allSyndicIds)) { 265 die($allSyndicIds->getMessage()); 266 } 267 while (list(, $monSyndicId) = each($allSyndicIds)) { 268 $string .= '<lien:syndic>' . $monSyndicId . '</lien:syndic>' . "\n"; 269 } 270 } 271 272 $string .= build_end_tag($type). "\n\n"; 273 if ($file) { 274 $_fputs($file, $string); 275 $string = ''; 276 } 277 } 278 279 $result->free(); 280 281 if (!$file) 282 return $string; 283 } 284 else if ($etape_actuelle < $etape_en_cours) { 285 echo "<li> $nom_etape"; 286 } 287 else { 288 echo "<li> <font color='#999999'>$nom_etape</font>"; 289 } 290 } 291 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |