Пример #1
0
 /**
  * Tests the JFeed::setAuthor method.
  *
  * @return  void
  *
  * @since   3.0
  *
  * @covers  JFeed::setAuthor
  */
 public function testSetAuthor()
 {
     $this->object->setAuthor('Sir John A. Macdonald', '*****@*****.**');
     $properties = TestReflection::getValue($this->object, 'properties');
     $this->assertInstanceOf('JFeedPerson', $properties['author']);
     $this->assertEquals('Sir John A. Macdonald', $properties['author']->name);
     $this->assertEquals('*****@*****.**', $properties['author']->email);
 }
Пример #2
0
 /**
  * Method to parse a specific feed element.
  *
  * @param   JFeed             $feed        The JFeed object being built from the parsed feed.
  * @param   SimpleXMLElement  $el          The current XML element object to handle.
  * @param   array             $namespaces  The array of relevant namespace objects to process for the element.
  *
  * @return  void
  *
  * @since   12.3
  */
 protected function processElement(JFeed $feed, SimpleXMLElement $el, array $namespaces)
 {
     // Build the internal method name.
     $method = 'handle' . ucfirst($el->getName());
     // If we are dealing with an item then it is feed entry time.
     if ($el->getName() == $this->entryElementName) {
         // Create a new feed entry for the item.
         $entry = new JFeedEntry();
         // First call the internal method.
         $this->processFeedEntry($entry, $el);
         foreach ($namespaces as $namespace) {
             if ($namespace instanceof JFeedParserNamespace) {
                 $namespace->processElementForFeedEntry($entry, $el);
             }
         }
         // Add the new entry to the feed.
         $feed->addEntry($entry);
         return;
     }
     // Otherwise we treat it like any other element.
     // First call the internal method.
     if (is_callable(array($this, $method))) {
         $this->{$method}($feed, $el);
     }
     foreach ($namespaces as $namespace) {
         if ($namespace instanceof JFeedParserNamespace) {
             $namespace->processElementForFeed($feed, $el);
         }
     }
 }
Пример #3
0
 /**
  * Method to handle the <webmaster> element for the feed.
  *
  * @param   JFeed             $feed  The JFeed object being built from the parsed feed.
  * @param   SimpleXMLElement  $el    The current XML element object to handle.
  *
  * @return  void
  *
  * @since   12.3
  */
 protected function handleWebmaster(JFeed $feed, SimpleXMLElement $el)
 {
     // Get the tag contents and split it over the first space.
     $tmp = (string) $el;
     $tmp = explode(' ', $tmp, 2);
     // This is really cheap parsing.  Probably need to create a method to do this more robustly.
     $name = null;
     if (isset($tmp[1])) {
         $name = trim($tmp[1], ' ()');
     }
     $email = trim($tmp[0]);
     $feed->addContributor($name, $email, null, 'webmaster');
 }
Пример #4
0
 /**
  * Method to handle the <contributor> element for the feed.
  *
  * @param   JFeed             $feed  The JFeed object being built from the parsed feed.
  * @param   SimpleXMLElement  $el    The current XML element object to handle.
  *
  * @return  void
  *
  * @since   12.3
  */
 protected function handleContributor(JFeed $feed, SimpleXMLElement $el)
 {
     $feed->addContributor((string) $el->name, (string) $el->email, (string) $el->uri);
 }