[ Index ]
 

Code source de SPIP Agora 1.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Agora1-4/ecrire/include/dxs/ -> article.php (source)

   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  require_once(dirname(__FILE__). "/dxs_object.php");
  20  
  21  require_once(dirname(__FILE__). "/item.php");
  22  require_once(dirname(__FILE__). "/../bd/inc_article_factory.php");
  23  
  24  /**
  25   * The DXS representation of a SPIP-Agora article.
  26   * @package    DXS
  27   * @author Maciek Borowka <maciek@clever-age.com>
  28   * @access    public
  29   */
  30  class DXS_Article extends DXS_Object {
  31  
  32      // {{{ properties
  33  
  34      /**
  35      * The corresponding agora article business object.
  36      * @var     BD_article
  37      * @access  private
  38      */
  39      var $agoraArticle;
  40  
  41      /**
  42      * The list of items pointing to all the attachements
  43          * of this article.
  44          * XXX TODO We will probably need to inherit the DXS_Item
  45          * class with the data proper to an article attachement (think size of vignette)
  46      * @var     array of DXS_Item
  47      * @access  private
  48      */
  49      var $attachements;
  50  
  51      // }}}
  52  
  53      // {{{ constructor
  54  
  55      /**
  56      * DXS_Article constructor.
  57      * @access public
  58      */
  59  	function DXS_Article () {
  60          $this->attachements = array();
  61      }
  62  
  63      // }}}
  64  
  65      // {{{ getAgoraEntity()
  66      /**
  67      * Fetches, parses and constructs an object BD_Article 
  68      * using the data found at the URL $url.
  69      * @access public    
  70      */
  71  	function getAgoraEntity ($url) {
  72          if ($this->initFromFile($url, new DXS_TrivialValidatorData("http://www.clever-age.com/DXS:1.2", "article"))) {
  73              $this->parseArticle();
  74          }
  75  
  76          return $this->agoraArticle;
  77      }
  78  
  79      // }}}
  80  
  81      // {{{ parseArticle()
  82      /**
  83      * Helper function to parse the tree, create
  84      * the article buisiness object and extract the actual data.
  85      * Warning, no error checking is performed in this method.
  86      * @access  private
  87      */
  88  	function parseArticle () {
  89          $this->agoraArticle = &recuperer_instance_article();
  90          //$this->agoraArticle->setArticleId($this->xmlTree->root->getAttribute("id"));
  91          $this->agoraArticle->setLang($this->xmlTree->root->getAttribute("lang"));
  92  
  93          $max_child = count($this->xmlTree->root->children);
  94          //echo "<p>DXS_Article:parseArticle we have $max_child children</p>";
  95  
  96          for ($i = 0; $i < $max_child; $i++) {
  97              //echo '<p>DXS_Article: child: '.$this->xmlTree->root->children[$i]->name.' Value: ';
  98              //echo $this->xmlTree->root->children[$i]->content.'</p>';
  99              switch ($this->xmlTree->root->children[$i]->name) {
 100                  case "item":
 101                      {
 102                          $anItem = new DXS_Item();
 103  
 104                          if ($anItem->initItem($this->xmlTree->root->children[$i])) {
 105                              if ($anItem->_itemType == "spipdocument")
 106                                  array_push($this->attachements, $anItem);
 107                              else
 108                                  echo "<p>Item type '" . $anItem->_itemType . "' not supported yet!</p>";
 109                          }
 110  
 111                          break;
 112                      }
 113  
 114                  case "source":
 115                      {
 116                          echo "<p> source child tag not supported yet!</p>";
 117                          break;
 118                      }
 119  
 120                  case "pubDate":
 121                      {
 122                          $this->agoraArticle->setDate($this->xmlTree->root->children[$i]->content);
 123                          break;
 124                      }
 125  
 126                  case "updateDate":
 127                      {
 128                          $this->agoraArticle->setModificationDate($this->xmlTree->root->children[$i]->content);
 129                          break;
 130                      }
 131  
 132                  case "surtitre":
 133                      {
 134                          $this->agoraArticle->setSurtitre($this->xmlTree->root->children[$i]->content);
 135                          break;
 136                      }
 137  
 138                  case "titre":
 139                      {
 140                          $this->agoraArticle->setTitre($this->xmlTree->root->children[$i]->content);
 141                          break;
 142                      }
 143  
 144                  case "soustitre":
 145                      {
 146                          $this->agoraArticle->setSoustitre($this->xmlTree->root->children[$i]->content);
 147                          break;
 148                      }
 149  
 150                  case "descriptif":
 151                      {
 152                          $this->agoraArticle->setDescriptif($this->xmlTree->root->children[$i]->content);
 153                          break;
 154                      }
 155  
 156                  case "chapo":
 157                      {
 158                          $this->agoraArticle->setChapo($this->xmlTree->root->children[$i]->content);
 159                          break;
 160                      }
 161  
 162                  case "texte":
 163                      {
 164                          $this->agoraArticle->setTexte($this->xmlTree->root->children[$i]->content);
 165                          break;
 166                      }
 167  
 168                  case "postscriptum":
 169                      {
 170                          $this->agoraArticle->setPs($this->xmlTree->root->children[$i]->content);
 171                          break;
 172                      }
 173  
 174                  case "":
 175                      break; //XXX BUG in the xml parser
 176  
 177                  default:
 178                      {
 179                          echo "<p> '" . $this->xmlTree->root->children[$i]->name . "' not supported yet!</p>";
 180                          break;
 181                      }
 182              }
 183          }
 184      }
 185  
 186  // }}}
 187  
 188  }
 189  ?>


Généré le : Sat Feb 24 14:40:03 2007 par Balluche grâce à PHPXref 0.7