Apache Zeta Components Manual :: File Source for module.php

Source for file module.php

Documentation is available at module.php

  1. <?php
  2. /**
  3.  * File containing the ezcFeedModule class.
  4.  *
  5.  * Licensed to the Apache Software Foundation (ASF) under one
  6.  * or more contributor license agreements.  See the NOTICE file
  7.  * distributed with this work for additional information
  8.  * regarding copyright ownership.  The ASF licenses this file
  9.  * to you under the Apache License, Version 2.0 (the
  10.  * "License"); you may not use this file except in compliance
  11.  * with the License.  You may obtain a copy of the License at
  12.  * 
  13.  *   http://www.apache.org/licenses/LICENSE-2.0
  14.  * 
  15.  * Unless required by applicable law or agreed to in writing,
  16.  * software distributed under the License is distributed on an
  17.  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18.  * KIND, either express or implied.  See the License for the
  19.  * specific language governing permissions and limitations
  20.  * under the License.
  21.  *
  22.  * @package Feed
  23.  * @version //autogentag//
  24.  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  25.  * @filesource
  26.  */
  27.  
  28. /**
  29.  * Container for feed module data.
  30.  *
  31.  * Currently implemented by these feed modules:
  32.  *  - Content ({@link ezcFeedContentModule}) -
  33.  *    {@link http://purl.org/rss/1.0/modules/content/ Specifications}
  34.  *  - DublinCore ({@link ezcFeedDublinCoreModule}) -
  35.  *    {@link http://dublincore.org/documents/dces/ Specifications}
  36.  *  - iTunes ({@link ezcFeedITunesModule}) -
  37.  *    {@link http://www.apple.com/itunes/store/podcaststechspecs.html Specifications}
  38.  *  - Geo ({@link ezcFeedGeoModule}) -
  39.  *    {@link http://www.w3.org/2003/01/geo/ Specifications}
  40.  *  - GeoRss ({@link ezcFeedGeoModule}) -
  41.  *    {@link http://www.georss.org/georss/ Specifications}
  42.  *  - CreativeCommons ({@link ezcFeedCreativeCommonsModule}) -
  43.  *    {@link http://backend.userland.com/creativeCommonsRssModule Specifications}
  44.  *
  45.  * The child classes must implement these static methods:
  46.  * - isElementAllowed() - Returns true if an element can be added to the module.
  47.  * - add() - Adds an element to the module.
  48.  * - getModuleName() - Returns the module name (eg. 'DublinCore')
  49.  * - getNamespace() - Returns the namespace for the module
  50.  *   (eg. 'http://purl.org/dc/elements/1.1/').
  51.  * - getNamespacePrefix() - Returns the namespace prefix for the module (eg. 'dc').
  52.  *
  53.  * @package Feed
  54.  * @version //autogentag//
  55.  */
  56. abstract class ezcFeedModule
  57. {
  58.     /**
  59.      * The level of the module data container. Possible values are 'feed' or 'item'.
  60.      *
  61.      * @var string 
  62.      */
  63.     protected $level;
  64.  
  65.     /**
  66.      * Holds the properties of this class.
  67.      *
  68.      * @var array(string=>mixed) 
  69.      */
  70.     protected $properties = array();
  71.  
  72.     /**
  73.      * Constructs a new ezcFeedModule object.
  74.      *
  75.      * @param string $level The level of the data container ('feed' or 'item')
  76.      */
  77.     public function __construct$level 'feed' )
  78.     {
  79.         $this->level = $level;
  80.     }
  81.  
  82.     /**
  83.      * Sets the property $name to $value.
  84.      *
  85.      * @throws ezcBasePropertyNotFoundException
  86.      *          if the property $name is not defined
  87.      *
  88.      * @param string $name The property name
  89.      * @param mixed $value The property value
  90.      * @ignore
  91.      */
  92.     public function __set$name$value )
  93.     {
  94.         throw new ezcBasePropertyNotFoundException$name );
  95.     }
  96.  
  97.     /**
  98.      * Returns the value of property $name.
  99.      *
  100.      * @throws ezcBasePropertyNotFoundException
  101.      *          if the property $name is not defined
  102.      *
  103.      * @param string $name The property name
  104.      * @return mixed 
  105.      * @ignore
  106.      */
  107.     public function __get$name )
  108.     {
  109.         throw new ezcBasePropertyNotFoundException$name );
  110.     }
  111.  
  112.     /**
  113.      * Returns if the property $name is set.
  114.      *
  115.      * @param string $name The property name
  116.      * @return bool 
  117.      * @ignore
  118.      */
  119.     public function __isset$name )
  120.     {
  121.         return false;
  122.     }
  123.  
  124.     /**
  125.      * Returns a new instance of the $name module with data container level $level.
  126.      *
  127.      * @param string $name The name of the module to create
  128.      * @param string $level The level of the data container ('feed' or 'item')
  129.      * @return ezcFeedModule 
  130.      */
  131.     public static function create$name$level 'feed' )
  132.     {
  133.         $supportedModules ezcFeed::getSupportedModules();
  134.  
  135.         if !isset$supportedModules[$name) )
  136.         {
  137.             throw new ezcFeedUnsupportedModuleException$name );
  138.         }
  139.  
  140.         return new $supportedModules[$name]$level );
  141.     }
  142.  
  143.     /**
  144.      * Adds an attribute to the XML node $node.
  145.      *
  146.      * @param DOMDocument $xml The XML document where the node is stored
  147.      * @param DOMNode $node The node to add the attribute to
  148.      * @param string $attribute The name of the attribute to add
  149.      * @param mixed $value The value of the attribute
  150.      * @ignore
  151.      */
  152.     protected function addAttributeDOMDocument $xmlDOMNode $node$attribute$value )
  153.     {
  154.         $attr $xml->createAttribute$attribute );
  155.         $val $xml->createTextNode$value );
  156.         $attr->appendChild$val );
  157.         $node->appendChild$attr );
  158.     }
  159.  
  160.     /**
  161.      * Returns true if the element $name is allowed in the current module at the
  162.      * current level (feed or item), and false otherwise.
  163.      *
  164.      * @param string $name The element name to check if allowed in the current module and level (feed or item)
  165.      * @return bool 
  166.      */
  167.     abstract public function isElementAllowed$name );
  168.  
  169.     /**
  170.      * Adds a new ezcFeedElement element with name $name to this module and
  171.      * returns it.
  172.      *
  173.      * @throws ezcFeedUnsupportedElementException
  174.      *          if trying to add an element which is not supported.
  175.      *
  176.      * @param string $name The element name
  177.      * @return ezcFeedElement 
  178.      */
  179.     abstract public function add$name );
  180.  
  181.     /**
  182.      * Adds the module elements to the $xml XML document, in the container $root.
  183.      *
  184.      * @param DOMDocument $xml The XML document in which to add the module elements
  185.      * @param DOMNode $root The parent node which will contain the module elements
  186.      */
  187.     abstract public function generateDOMDocument $xmlDOMNode $root );
  188.  
  189.     /**
  190.      * Parses the XML element $node and creates a feed element in the current
  191.      * module with name $name.
  192.      *
  193.      * @param string $name The name of the element belonging to the module
  194.      * @param DOMElement $node The XML child from which to take the values for $name
  195.      */
  196.     abstract public function parse$nameDOMElement $node );
  197. }
  198. ?>
Documentation generated by phpDocumentor 1.4.3