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

Source for file source.php

Documentation is available at source.php

  1. <?php
  2. /**
  3.  * File containing the ezcFeedSourceElement 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 source element.
  30.  *
  31.  * @property string $source 
  32.  *            The name of the source feed (RSS2 only).
  33.  * @property string $url 
  34.  *            The url of the source feed (RSS2 only).
  35.  * @property array(ezcFeedAuthorElement) $author 
  36.  *            The authors from the source feed (ATOM only).
  37.  * @property ezcFeedCategoryElement $category 
  38.  *            The categories from the source feed (ATOM only).
  39.  * @property array(ezcFeedAuthorElement) $contributor 
  40.  *            The contributors from the source feed (ATOM only).
  41.  * @property ezcFeedTextElement $copyright 
  42.  *            The copyright information from the source feed (ATOM only).
  43.  * @property ezcFeedTextElement $description 
  44.  *            The description from the source feed (ATOM only).
  45.  * @property ezcFeedGeneratorElement $generator 
  46.  *            The generator information from the source feed (ATOM only).
  47.  * @property ezcFeedImageElement $icon 
  48.  *            The icon from the source feed (ATOM only).
  49.  * @property ezcFeedIdElement $id 
  50.  *            The id from the source feed (ATOM only).
  51.  * @property ezcFeedImageElement $image 
  52.  *            The image from the source feed (ATOM only).
  53.  * @property array(ezcFeedLinkElement) $link 
  54.  *            The links from the source feed (ATOM only).
  55.  * @property ezcFeedTextElement $title 
  56.  *            The title from the source feed (ATOM only).
  57.  * @property ezcFeedDateElement $updated 
  58.  *            The date and time of the last update from the source feed (ATOM only).
  59.  *
  60.  * @package Feed
  61.  * @version //autogentag//
  62.  */
  63. {
  64.     /**
  65.      * The name of the source feed (RSS2 only).
  66.      *
  67.      * @var string 
  68.      */
  69.     public $source;
  70.  
  71.     /**
  72.      * The url of the source feed (RSS2 only).
  73.      *
  74.      * @var string 
  75.      */
  76.     public $url;
  77.  
  78.     /**
  79.      * Sets the property $name to $value.
  80.      *
  81.      * @param string $name The property name
  82.      * @param mixed $value The property value
  83.      * @ignore
  84.      */
  85.     public function __set$name$value )
  86.     {
  87.         switch $name )
  88.         {
  89.             case 'title':
  90.             case 'description':
  91.             case 'copyright':
  92.                 $element new ezcFeedTextElement();
  93.                 $element->text $value;
  94.                 $this->properties[$name$element;
  95.                 break;
  96.  
  97.             case 'author':
  98.             case 'contributor':
  99.                 $element new ezcFeedPersonElement();
  100.                 $element->name $value;
  101.                 $this->properties[$name$element;
  102.                 break;
  103.  
  104.             case 'updated':
  105.                 $element new ezcFeedDateElement();
  106.                 $element->date $value;
  107.                 $this->properties[$name$element;
  108.                 break;
  109.  
  110.             case 'generator':
  111.                 $element new ezcFeedGeneratorElement();
  112.                 $element->name $value;
  113.                 $this->properties[$name$element;
  114.                 break;
  115.  
  116.             case 'image':
  117.             case 'icon':
  118.                 $element new ezcFeedImageElement();
  119.                 $element->link $value;
  120.                 $this->properties[$name$element;
  121.                 break;
  122.  
  123.             case 'id':
  124.                 $element new ezcFeedIdElement();
  125.                 $element->id $value;
  126.                 $this->properties[$name$element;
  127.                 break;
  128.  
  129.             case 'link':
  130.                 $element new ezcFeedLinkElement();
  131.                 $element->href $value;
  132.                 $this->properties[$name$element;
  133.                 break;
  134.  
  135.             case 'category':
  136.                 $element new ezcFeedCategoryElement();
  137.                 $element->term $value;
  138.                 $this->properties[$name$element;
  139.                 break;
  140.  
  141.             default:
  142.                 parent::__set$name$value );
  143.                 break;
  144.         }
  145.     }
  146.  
  147.     /**
  148.      * Returns the value of property $name.
  149.      *
  150.      * @param string $name The property name
  151.      * @return mixed 
  152.      * @ignore
  153.      */
  154.     public function __get$name )
  155.     {
  156.         switch $name )
  157.         {
  158.             case 'title':
  159.             case 'description':
  160.             case 'copyright':
  161.             case 'author':
  162.             case 'contributor':
  163.             case 'updated':
  164.             case 'generator':
  165.             case 'image':
  166.             case 'icon':
  167.             case 'id':
  168.             case 'link':
  169.             case 'category':
  170.                 if isset$this->properties[$name) )
  171.                 {
  172.                     return $this->properties[$name];
  173.                 }
  174.                 break;
  175.  
  176.             default:
  177.                 return parent::__get$name );
  178.                 break;
  179.         }
  180.     }
  181.  
  182.     /**
  183.      * Returns if the property $name is set.
  184.      *
  185.      * @param string $name The property name
  186.      * @return bool 
  187.      * @ignore
  188.      */
  189.     public function __isset$name )
  190.     {
  191.         switch $name )
  192.         {
  193.             case 'title':
  194.             case 'description':
  195.             case 'copyright':
  196.             case 'author':
  197.             case 'contributor':
  198.             case 'updated':
  199.             case 'generator':
  200.             case 'image':
  201.             case 'icon':
  202.             case 'id':
  203.             case 'link':
  204.             case 'category':
  205.                 return isset$this->properties[$name);
  206.  
  207.             default:
  208.                 return parent::__isset$name );
  209.         }
  210.     }
  211.  
  212.     /**
  213.      * Adds a new element with name $name to the source element and returns it.
  214.      *
  215.      * Example:
  216.      * <code>
  217.      * // $source is an ezcFeedSourceElement object
  218.      * $link = $source->add( 'link' );
  219.      * $link->href = 'http://ez.no/';
  220.      * </code>
  221.      *
  222.      * @param string $name The name of the element to add
  223.      * @return ezcFeedElement 
  224.      */
  225.     public function add$name )
  226.     {
  227.         switch $name )
  228.         {
  229.             case 'author':
  230.             case 'contributor':
  231.                 $element new ezcFeedPersonElement();
  232.                 $this->properties[$name][$element;
  233.                 break;
  234.  
  235.             case 'id':
  236.                 $element new ezcFeedIdElement();
  237.                 $this->properties[$name$element;
  238.                 break;
  239.  
  240.             case 'category':
  241.                 $element new ezcFeedCategoryElement();
  242.                 $this->properties[$name][$element;
  243.                 break;
  244.  
  245.             case 'title':
  246.             case 'description':
  247.             case 'copyright':
  248.                 $element new ezcFeedTextElement();
  249.                 $this->properties[$name$element;
  250.                 break;
  251.  
  252.             case 'generator':
  253.                 $element new ezcFeedGeneratorElement();
  254.                 $this->properties[$name$element;
  255.                 break;
  256.  
  257.             case 'image':
  258.             case 'icon':
  259.                 $element new ezcFeedImageElement();
  260.                 $this->properties[$name$element;
  261.                 break;
  262.  
  263.             case 'updated':
  264.                 $element new ezcFeedDateElement();
  265.                 $this->properties[$name$element;
  266.                 break;
  267.  
  268.             case 'link':
  269.                 $element new ezcFeedLinkElement();
  270.                 $this->properties[$name][$element;
  271.                 break;
  272.  
  273.             default:
  274.                 throw new ezcFeedUnsupportedElementException$name );
  275.         }
  276.  
  277.         return $element;
  278.     }
  279.  
  280.     /**
  281.      * Returns the source attribute.
  282.      *
  283.      * @return string 
  284.      */
  285.     public function __toString()
  286.     {
  287.         return $this->source . '';
  288.     }
  289. }
  290. ?>
Documentation generated by phpDocumentor 1.4.3