[ 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/ -> inc_dxs_factory.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__). "/article.php");
  23  require_once(dirname(__FILE__). "/../bd/inc_article_factory.php");
  24  
  25  //XXX BUG dans Agora:
  26  //require_once (dirname(__FILE__)."../../../mes_options.php");
  27  
  28  /**
  29   * The factory class aims at become the central point
  30   * of the DXS API.
  31   * Its usage is meant to be quite simple: 
  32   * 1. You must have an initial item treeNode from somewhere else
  33   * (for example from a prodig rss channel)
  34   * 2. With the xml node, you get an real DXS Item object
  35   * 3. With the item object, you get the real DXS Object pointed
  36   * by the item. 
  37   * @package    DXS
  38   * @author Maciek Borowka <maciek@clever-age.com>
  39   * @access    public
  40   */
  41  class DXS_Factory {
  42  
  43      // {{{ properties
  44      /** The validator data used to verify the object.s
  45      * @access private
  46      */
  47      var $xmlValidator;
  48  
  49      // }}}
  50  
  51      // {{{ constructor
  52  
  53      /**
  54      * DXS_Article constructor.
  55      * @access public
  56      */
  57  	function DXS_Factory () {
  58          $this->xmlValidator = new DXS_TrivialValidatorData("http://www.clever-age.com/DXS:1.1", "XXX");
  59      }
  60  
  61      // }}}
  62  
  63      // {{{ createItem()
  64      /** Creates the item from the xml tree node.
  65      * @access public
  66      */
  67  	function createItem ($itemNode) {
  68          $item = new DXS_Item();
  69  
  70          if ($item->initItem($itemNode)) {
  71              return $item;
  72          }
  73          else {
  74              return NULL;
  75          }
  76      }
  77  
  78      // }}}
  79  
  80      // {{{ itemTypeSupported()
  81      /** Returns true if this factory is able
  82      * to handle the object type referenced
  83      * by the item.
  84      * XXX This function could also handle namespaces, but how?
  85      * @access public
  86      */
  87  	function itemTypeSupported ($item) {
  88          switch ($item->_itemType) {
  89              case "container":
  90              case "spiparticle":
  91                  {
  92                      return TRUE;
  93                  }
  94          }
  95  
  96          return FALSE;
  97      }
  98  
  99      // {{{ createObject()
 100      /** Creates and initializes the object of appropriate type
 101      * Downloads the data pointed by the item.
 102      * If anything goes wrong, returns an unset pointer.
 103      * @access public
 104      */
 105  	function createObject ($item) {
 106          $object = NULL;
 107  
 108          switch ($item->_itemType) {
 109              case "spiparticle":
 110                  {
 111                      $object = new DXS_Article();
 112                      $object->getAgoraEntity($item->_url);
 113  
 114                      if (!$object->getInitOK()) {
 115                          //var_dump($object);
 116                          unset($object);
 117                      }
 118  
 119                      break;
 120                  }
 121  
 122              case "container":
 123                  {
 124                      $object = new DXS_Container();
 125                      $object->getAgoraEntity($item->_url);
 126  
 127                      if (!$object->getInitOK()) {
 128                          //var_dump($object);
 129                          unset($object);
 130                      }
 131  
 132                      break;
 133                  }
 134          }
 135  
 136          return $object;
 137      }
 138  // }}}
 139  
 140  }
 141  ?>


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