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

Source for file entry.php

Documentation is available at entry.php

  1. <?php
  2. /**
  3.  * File containing the ezcFeedEntryElement 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.  * Class defining a feed entry.
  30.  *
  31.  * @property array(ezcFeedPersonElement) $author 
  32.  *            The authors of the entry. Equivalents:
  33.  *            ATOM-author (required, multiple),
  34.  *            RSS1-none,
  35.  *            RSS2-author (optional, recommended, single).
  36.  * @property array(ezcFeedCategoryElement) $category 
  37.  *            The categories of the entry. Equivalents:
  38.  *            ATOM-author (optional, multiple),
  39.  *            RSS1-none,
  40.  *            RSS2-category (optional, multiple).
  41.  * @property ezcFeedTextElement $comments 
  42.  *            The comments of the entry. Equivalents:
  43.  *            ATOM-none,
  44.  *            RSS1-none,
  45.  *            RSS2-author (optional, single).
  46.  * @property ezcFeedContentElement $content 
  47.  *            The complex text content of the entry. Equivalents:
  48.  *            ATOM-content (optional, single),
  49.  *            RSS1-none,
  50.  *            RSS2-none.
  51.  * @property array(ezcFeedPersonElement) $contributor 
  52.  *            The contributors of the entry. Equivalents:
  53.  *            ATOM-contributor (optional, not recommended, multiple),
  54.  *            RSS1-none,
  55.  *            RSS2-none.
  56.  * @property ezcFeedTextElement $copyright 
  57.  *            The copyright of the entry. Equivalents:
  58.  *            ATOM-rights (optional, single),
  59.  *            RSS1-none,
  60.  *            RSS2-none.
  61.  * @property ezcFeedTextElement $description 
  62.  *            The description of the entry. Equivalents:
  63.  *            ATOM-summary (required, single),
  64.  *            RSS1-description (required, single),
  65.  *            RSS2-description (required, single).
  66.  * @property array(ezcFeedEnclosureElement) $enclosure 
  67.  *            The enclosures of the entry. Equivalents:
  68.  *            ATOM-link@rel="enclosure" (optional, multiple),
  69.  *            RSS1-none,
  70.  *            RSS2-enclosure (optional, single).
  71.  * @property ezcFeedTextElement $id 
  72.  *            The id of the entry. Equivalents:
  73.  *            ATOM-id (required, single),
  74.  *            RSS1-about (required, single),
  75.  *            RSS2-guid (optional, single).
  76.  * @property array(ezcFeedLinkElement) $link 
  77.  *            The links of the entry. Equivalents:
  78.  *            ATOM-link (required, multiple),
  79.  *            RSS1-link (required, single),
  80.  *            RSS2-link (required, single).
  81.  * @property ezcFeedDateElement $published 
  82.  *            The published date of the entry. Equivalents:
  83.  *            ATOM-published (optional, single),
  84.  *            RSS1-none,
  85.  *            RSS2-pubDate (optional, single).
  86.  * @property ezcFeedTextElement $title 
  87.  *            The title of the entry. Equivalents:
  88.  *            ATOM-title (required, single),
  89.  *            RSS1-title (required, single),
  90.  *            RSS2-title (required, single).
  91.  * @property ezcFeedDateElement $updated 
  92.  *            The updated date of the entry. Equivalents:
  93.  *            ATOM-updated (required, single),
  94.  *            RSS1-none,
  95.  *            RSS2-none.
  96.  * @property ezcFeedSourceElement $source 
  97.  *            The source of the entry. Equivalents:
  98.  *            ATOM-source (optional, not recommended, single),
  99.  *            RSS1-none,
  100.  *            RSS2-source (optional, not recommended, single).
  101.  * @property ezcFeedTextElement $language 
  102.  *            The language of the entry. Equivalents:
  103.  *            ATOM-source (optional, not recommended, single ),
  104.  *            RSS1-none,
  105.  *            RSS2-none.
  106. *
  107.  * @package Feed
  108.  * @version //autogentag//
  109.  * @mainclass
  110.  */
  111. {
  112.     /**
  113.      * Holds the modules used by this feed item.
  114.      *
  115.      * @var array(string=>ezcFeedModule) 
  116.      */
  117.     private $modules array();
  118.  
  119.     /**
  120.      * Sets the property $name to $value.
  121.      *
  122.      * @param string $name The property name
  123.      * @param mixed $value The property value
  124.      * @ignore
  125.      */
  126.     public function __set$name$value )
  127.     {
  128.         switch $name )
  129.         {
  130.             case 'title':
  131.             case 'description':
  132.             case 'comments':
  133.             case 'copyright':
  134.             case 'language':
  135.                 $element $this->add$name );
  136.                 $element->text $value;
  137.                 break;
  138.  
  139.             case 'content':
  140.                 $element $this->add$name );
  141.                 $element->text $value;
  142.                 break;
  143.  
  144.             case 'author':
  145.             case 'contributor':
  146.                 $element $this->add$name );
  147.                 $element->name $value;
  148.                 break;
  149.  
  150.             case 'updated':
  151.             case 'published':
  152.                 $element $this->add$name );
  153.                 $element->date $value;
  154.                 break;
  155.  
  156.             case 'id':
  157.                 $element $this->add$name );
  158.                 $element->id $value;
  159.                 break;
  160.  
  161.             case 'link':
  162.                 $element $this->add$name );
  163.                 $element->href $value;
  164.                 break;
  165.  
  166.             case 'enclosure':
  167.                 $element $this->add$name );
  168.                 $element->url $value;
  169.                 break;
  170.  
  171.             case 'source':
  172.                 $element $this->add$name );
  173.                 $element->source $value;
  174.                 break;
  175.  
  176.             default:
  177.                 $supportedModules ezcFeed::getSupportedModules();
  178.                 if isset$supportedModules[$name) )
  179.                 {
  180.                     $this->modules[$name$value;
  181.                 }
  182.                 break;
  183.         }
  184.     }
  185.  
  186.     /**
  187.      * Returns the value of property $name.
  188.      *
  189.      * @throws ezcFeedUndefinedModuleException
  190.      *          if trying to fetch a module not defined yet
  191.      *
  192.      * @param string $name The property name
  193.      * @return mixed 
  194.      * @ignore
  195.      */
  196.     public function __get$name )
  197.     {
  198.         switch $name )
  199.         {
  200.             case 'author':
  201.             case 'category':
  202.             case 'comments':
  203.             case 'content':
  204.             case 'contributor':
  205.             case 'copyright':
  206.             case 'description':
  207.             case 'enclosure':
  208.             case 'id':
  209.             case 'link':
  210.             case 'published':
  211.             case 'title':
  212.             case 'updated':
  213.             case 'source':
  214.             case 'language':
  215.                 if isset$this->properties[$name) )
  216.                 {
  217.                     return $this->properties[$name];
  218.                 }
  219.                 break;
  220.  
  221.             default:
  222.                 $supportedModules ezcFeed::getSupportedModules();
  223.                 if isset$supportedModules[$name) )
  224.                 {
  225.                     if isset$this->$name ) )
  226.                     {
  227.                         return $this->modules[$name];
  228.                     }
  229.                     else
  230.                     {
  231.                         throw new ezcFeedUndefinedModuleException$name );
  232.                     }
  233.                 }
  234.                 break;
  235.         }
  236.     }
  237.  
  238.     /**
  239.      * Returns if the property $name is set.
  240.      *
  241.      * @param string $name The property name
  242.      * @return bool 
  243.      * @ignore
  244.      */
  245.     public function __isset$name )
  246.     {
  247.         switch $name )
  248.         {
  249.             case 'author':
  250.             case 'category':
  251.             case 'comments':
  252.             case 'content':
  253.             case 'contributor':
  254.             case 'copyright':
  255.             case 'description':
  256.             case 'enclosure':
  257.             case 'id':
  258.             case 'link':
  259.             case 'published':
  260.             case 'title':
  261.             case 'updated':
  262.             case 'source':
  263.             case 'language':
  264.                 return isset$this->properties[$name);
  265.  
  266.             default:
  267.                 $supportedModules ezcFeed::getSupportedModules();
  268.                 if isset$supportedModules[$name) )
  269.                 {
  270.                     return isset$this->modules[$name);
  271.                 }
  272.         }
  273.     }
  274.  
  275.     /**
  276.      * Adds a new element with name $name to the feed item and returns it.
  277.      *
  278.      * Example:
  279.      * <code>
  280.      * // $item is an ezcFeedEntryElement object
  281.      * $link = $item->add( 'link' );
  282.      * $link->href = 'http://ez.no/';
  283.      * </code>
  284.      *
  285.      * @throws ezcFeedUnsupportedElementException
  286.      *          if the element $name is not supported
  287.      *
  288.      * @apichange All items are not encoded at all, in future versions this
  289.      *             should be done in one of the ways as described in
  290.      *             http://issues.ez.no/14093
  291.      *
  292.      * @param string $name The name of the element to add
  293.      * @return ezcFeedElement 
  294.      */
  295.     public function add$name )
  296.     {
  297.         switch $name )
  298.         {
  299.             case 'author':
  300.             case 'contributor':
  301.                 $element new ezcFeedPersonElement();
  302.                 $this->properties[$name][$element;
  303.                 break;
  304.  
  305.             case 'id':
  306.                 $element new ezcFeedIdElement();
  307.                 $this->properties[$name$element;
  308.                 break;
  309.  
  310.             case 'category':
  311.                 $element new ezcFeedCategoryElement();
  312.                 $this->properties[$name][$element;
  313.                 break;
  314.  
  315.             case 'title':
  316.             case 'description':
  317.             case 'comments':
  318.             case 'copyright':
  319.             case 'language':
  320.                 $element new ezcFeedTextElement();
  321.                 $this->properties[$name$element;
  322.                 break;
  323.  
  324.             case 'content':
  325.                 $element new ezcFeedContentElement();
  326.                 $this->properties[$name$element;
  327.                 break;
  328.  
  329.             case 'updated':
  330.             case 'published':
  331.                 $element new ezcFeedDateElement();
  332.                 $this->properties[$name$element;
  333.                 break;
  334.  
  335.             case 'link':
  336.                 $element new ezcFeedLinkElement();
  337.                 $this->properties[$name][$element;
  338.                 break;
  339.  
  340.             case 'enclosure':
  341.                 $element new ezcFeedEnclosureElement();
  342.                 $this->properties[$name][$element;
  343.                 break;
  344.  
  345.             case 'source':
  346.                 $element new ezcFeedSourceElement();
  347.                 $this->properties[$name$element;
  348.                 break;
  349.  
  350.             default:
  351.                 throw new ezcFeedUnsupportedElementException$name );
  352.         }
  353.  
  354.         return $element;
  355.     }
  356.  
  357.     /**
  358.      * Adds a new module to this item and returns it.
  359.      *
  360.      * @param string $name The name of the module to add
  361.      * @return ezcFeedModule 
  362.      */
  363.     public function addModule$name )
  364.     {
  365.         $this->$name ezcFeedModule::create$name'item' );
  366.         return $this->$name;
  367.     }
  368.  
  369.     /**
  370.      * Returns true if the module $name is loaded, false otherwise.
  371.      *
  372.      * @param string $name The name of the module to check if loaded for this item
  373.      * @return bool 
  374.      */
  375.     public function hasModule$name )
  376.     {
  377.         return isset$this->modules[$name);
  378.     }
  379.  
  380.     /**
  381.      * Returns an array with all the modules defined for this feed item.
  382.      *
  383.      * @return array(ezcFeedModule) 
  384.      */
  385.     public function getModules()
  386.     {
  387.         return $this->modules;
  388.     }
  389. }
  390. ?>
Documentation generated by phpDocumentor 1.4.3