[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/includes/domit/ -> xml_domit_rss.php (source)

   1  <?php
   2  /**
   3  * DOMIT! RSS is a DOM based RSS parser
   4  * @package domit-rss
   5  * @subpackage domit-rss-main
   6  * @version 0.51
   7  * @copyright (C) 2004 John Heinstein. All rights reserved
   8  * @license http://www.gnu.org/copyleft/lesser.html LGPL License
   9  * @author John Heinstein <johnkarl@nbnet.nb.ca>
  10  * @link http://www.engageinteractive.com/domitrss/ DOMIT! RSS Home Page
  11  * DOMIT! RSS is Free Software
  12  **/
  13  
  14  if (!defined('DOMIT_RSS_INCLUDE_PATH')) {
  15      define('DOMIT_RSS_INCLUDE_PATH', (dirname(__FILE__) . "/"));
  16  }
  17  
  18  /** current version of DOMIT! RSS */
  19  define ('DOMIT_RSS_VERSION', '0.51');
  20  /** language constant */
  21  define('DOMIT_RSS_ELEMENT_LANGUAGE', 'language');
  22  /** copyright constant */
  23  define('DOMIT_RSS_ELEMENT_COPYRIGHT', 'copyright');
  24  /** managing editor constant */
  25  define('DOMIT_RSS_ELEMENT_MANAGINGEDITOR', 'managingeditor');
  26  /** webmaster constant */
  27  define('DOMIT_RSS_ELEMENT_WEBMASTER', 'webmaster');
  28  /** pubdate constant */
  29  define('DOMIT_RSS_ELEMENT_PUBDATE', 'pubdate');
  30  /** last build date constant */
  31  define('DOMIT_RSS_ELEMENT_LASTBUILDDATE', 'lastbuilddate');
  32  /** category constant */
  33  define('DOMIT_RSS_ELEMENT_CATEGORY', 'category');
  34  /** generator constant */
  35  define('DOMIT_RSS_ELEMENT_GENERATOR', 'generator');
  36  /** docs constant */
  37  define('DOMIT_RSS_ELEMENT_DOCS', 'docs');
  38  /** cloud constant */
  39  define('DOMIT_RSS_ELEMENT_CLOUD', 'cloud');
  40  /** ttl constant */
  41  define('DOMIT_RSS_ELEMENT_TTL', 'ttl');
  42  /** image constant */
  43  define('DOMIT_RSS_ELEMENT_IMAGE', 'image');
  44  /** rating constant */
  45  define('DOMIT_RSS_ELEMENT_RATING', 'rating');
  46  /** textinput constant */
  47  define('DOMIT_RSS_ELEMENT_TEXTINPUT', 'textinput');
  48  /** skiphours constant */
  49  define('DOMIT_RSS_ELEMENT_SKIPHOURS', 'skiphours');
  50  /** skipdays constant */
  51  define('DOMIT_RSS_ELEMENT_SKIPDAYS', 'skipdays');
  52  /** url constant */
  53  define('DOMIT_RSS_ELEMENT_URL', 'url');
  54  /** width constant */
  55  define('DOMIT_RSS_ELEMENT_WIDTH', 'width');
  56  /** height constant */
  57  define('DOMIT_RSS_ELEMENT_HEIGHT', 'height');
  58  /** guid constant */
  59  define('DOMIT_RSS_ELEMENT_GUID', 'guid');
  60  /** enclosure constant */
  61  define('DOMIT_RSS_ELEMENT_ENCLOSURE', 'enclosure');
  62  /** comments constant */
  63  define('DOMIT_RSS_ELEMENT_COMMENTS', 'comments');
  64  /** source constant */
  65  define('DOMIT_RSS_ELEMENT_SOURCE', 'source');
  66  /** name constant */
  67  define('DOMIT_RSS_ELEMENT_NAME', 'name');
  68  /** author constant */
  69  define('DOMIT_RSS_ELEMENT_AUTHOR', 'author');
  70  
  71  /** domain constant */
  72  define('DOMIT_RSS_ATTR_DOMAIN', 'domain');
  73  /** port constant */
  74  define('DOMIT_RSS_ATTR_PORT', 'port');
  75  /** path constant */
  76  define('DOMIT_RSS_ATTR_PATH', 'path');
  77  /** registerProcedure constant */
  78  define('DOMIT_RSS_ATTR_REGISTERPROCEDURE', 'registerProcedure');
  79  /** protocol constant */
  80  define('DOMIT_RSS_ATTR_PROTOCOL', 'protocol');
  81  /** url constant */
  82  define('DOMIT_RSS_ATTR_URL', 'url');
  83  /** length constant */
  84  define('DOMIT_RSS_ATTR_LENGTH', 'length');
  85  /** type constant */
  86  define('DOMIT_RSS_ATTR_TYPE', 'type');
  87  /** isPermaLink constant */
  88  define('DOMIT_RSS_ATTR_ISPERMALINK', 'isPermaLink');
  89  
  90  require_once (DOMIT_RSS_INCLUDE_PATH . 'xml_domit_rss_shared.php');
  91  
  92  /**
  93  * The base DOMIT! RSS document class
  94  *
  95  * @package domit-rss
  96  * @subpackage domit-rss-main
  97  * @author John Heinstein <johnkarl@nbnet.nb.ca>
  98  */
  99  class xml_domit_rss_document extends xml_domit_rss_base_document {
 100      /**
 101      * Constructor
 102      * @param string Path to the rss file
 103      * @param string Directory in which cache files are to be stored
 104      * @param string Expiration time (in seconds) for the cache file
 105      * @return Object A new instance of xml_domit_rss_document
 106      */
 107  	function xml_domit_rss_document($url = '', $cacheDir = './', $cacheTime = '3600') {
 108          $this->parser = 'DOMIT_RSS';
 109          $this->xml_domit_rss_base_document($url, $cacheDir, $cacheTime);
 110      } //xml_domit_rss_document
 111  
 112      /**
 113      * Performs initialization of the RSS document
 114      */
 115  	function _init() {
 116          $total = $this->node->documentElement->childCount;
 117          $itemCounter = 0;
 118          $channelCounter = 0;
 119          $categoryCounter = 0;
 120  
 121          for ($i = 0; $i < $total; $i++) {
 122              $currNode =& $this->node->documentElement->childNodes[$i];
 123              $tagName = strtolower($currNode->nodeName);
 124  
 125              switch ($tagName) {
 126                  case DOMIT_RSS_ELEMENT_ITEM:
 127                      $this->domit_rss_items[$itemCounter] = new xml_domit_rss_item($currNode);
 128                      $itemCounter++;
 129                      break;
 130                  case DOMIT_RSS_ELEMENT_CHANNEL:
 131                      $this->domit_rss_channels[$channelCounter] = new xml_domit_rss_channel($currNode);
 132                      $channelCounter++;
 133                      break;
 134                  case DOMIT_RSS_ELEMENT_CATEGORY:
 135                      $this->domit_rss_categories[$categoryCounter] = new xml_domit_rss_category($currNode);
 136                      $categoryCounter++;
 137                      break;
 138                  case DOMIT_RSS_ELEMENT_IMAGE:
 139                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_image($currNode);
 140                      break;
 141                  case DOMIT_RSS_ELEMENT_CLOUD:
 142                      $this->indexer[$tagName] = new xml_domit_rss_cloud($currNode);
 143                      break;
 144                  case DOMIT_RSS_ELEMENT_TEXTINPUT:
 145                      $this->indexer[$tagName] = new xml_domit_rss_textinput($currNode);
 146                      break;
 147                  case DOMIT_RSS_ELEMENT_TITLE:
 148                  case DOMIT_RSS_ELEMENT_LINK:
 149                  case DOMIT_RSS_ELEMENT_DESCRIPTION:
 150                  case DOMIT_RSS_ELEMENT_LANGUAGE:
 151                  case DOMIT_RSS_ELEMENT_COPYRIGHT:
 152                  case DOMIT_RSS_ELEMENT_MANAGINGEDITOR:
 153                  case DOMIT_RSS_ELEMENT_WEBMASTER:
 154                  case DOMIT_RSS_ELEMENT_PUBDATE:
 155                  case DOMIT_RSS_ELEMENT_LASTBUILDDATE:
 156                  case DOMIT_RSS_ELEMENT_GENERATOR:
 157                  case DOMIT_RSS_ELEMENT_DOCS:
 158                  case DOMIT_RSS_ELEMENT_TTL:
 159                  case DOMIT_RSS_ELEMENT_RATING:
 160                  case DOMIT_RSS_ELEMENT_SKIPHOURS:
 161                  case DOMIT_RSS_ELEMENT_SKIPDAYS:
 162                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_simpleelement($currNode);
 163                      break;
 164                  default:
 165                      $this->addIndexedElement($currNode);
 166                      //$this->indexer[$tagName] =& $currNode;
 167              }
 168          }
 169  
 170          if ($itemCounter != 0) {
 171              $this->DOMIT_RSS_indexer[DOMIT_RSS_ARRAY_ITEMS] =& $this->domit_rss_items;
 172          }
 173  
 174          if ($channelCounter != 0) {
 175              $this->DOMIT_RSS_indexer[DOMIT_RSS_ARRAY_CHANNELS] =& $this->domit_rss_channels;
 176          }
 177  
 178          if ($categoryCounter != 0) {
 179              $this->DOMIT_RSS_indexer[DOMIT_RSS_ARRAY_CATEGORIES] =& $this->domit_rss_categories;
 180          }
 181  
 182          $this->handleChannelElementsEmbedded();
 183      } //_init
 184  
 185      /**
 186      * Returns the current version of DOMIT! RSS
 187      * @return int The current version of DOMIT! RSS
 188      */
 189  	function getVersion() {
 190          return DOMIT_RSS_VERSION;
 191      } //getVersion
 192  } //xml_domit_rss_document
 193  
 194  
 195  /**
 196  * Represents an RSS channel
 197  *
 198  * @package domit-rss
 199  * @subpackage domit-rss-main
 200  * @author John Heinstein <johnkarl@nbnet.nb.ca>
 201  */
 202  class xml_domit_rss_channel extends xml_domit_rss_elementindexer {
 203      /** @var array A list of references to channel items */
 204      var $domit_rss_items = array();
 205      /** @var array A list of references to category items */
 206      var $domit_rss_categories = array();
 207  
 208      /**
 209      * Constructor
 210      * @param Object A DOM node containing channel data
 211      * @param boolean True if channel elements are siblings of the channel rather than children
 212      */
 213  	function xml_domit_rss_channel(&$channel, $externalElements = false) {
 214          $this->node =& $channel;
 215          $this->rssDefinedElements = array('title','link','description','language','copyright',
 216                                              'managingEditor','webmaster','pubDate','lastBuildDate',
 217                                              'generator','docs','cloud','ttl','image', 'rating',
 218                                              'textInput','skipHours','skipDays','domit_rss_channels',
 219                                              'domit_rss_items','domit_rss_categories');
 220          $this->_init();
 221      } //xml_domit_rss_channel
 222  
 223      /**
 224      * Performs initialization of the RSS channel element
 225      */
 226  	function _init() {
 227          $total = $this->node->childCount;
 228          $itemCounter = 0;
 229          $categoryCounter = 0;
 230  
 231          for ($i = 0; $i < $total; $i++) {
 232              $currNode =& $this->node->childNodes[$i];
 233              $tagName = strtolower($currNode->nodeName);
 234  
 235              switch($tagName) {
 236                  case DOMIT_RSS_ELEMENT_ITEM:
 237                      $this->domit_rss_items[$itemCounter] = new xml_domit_rss_item($currNode);
 238                      $itemCounter++;
 239                      break;
 240                  case DOMIT_RSS_ELEMENT_CATEGORY:
 241                      $this->domit_rss_categories[$categoryCounter] = new xml_domit_rss_category($currNode);
 242                      $categoryCounter++;
 243                      break;
 244                  case DOMIT_RSS_ELEMENT_IMAGE:
 245                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_image($currNode);
 246                      break;
 247                  case DOMIT_RSS_ELEMENT_CLOUD:
 248                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_cloud($currNode);
 249                      break;
 250                  case DOMIT_RSS_ELEMENT_TEXTINPUT:
 251                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_textinput($currNode);
 252                      break;
 253                  case DOMIT_RSS_ELEMENT_SKIPHOURS:
 254                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_skiphours($currNode);
 255                      break;
 256                  case DOMIT_RSS_ELEMENT_SKIPDAYS:
 257                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_skipdays($currNode);
 258                      break;
 259                  case DOMIT_RSS_ELEMENT_TITLE:
 260                  case DOMIT_RSS_ELEMENT_LINK:
 261                  case DOMIT_RSS_ELEMENT_DESCRIPTION:
 262                  case DOMIT_RSS_ELEMENT_LANGUAGE:
 263                  case DOMIT_RSS_ELEMENT_COPYRIGHT:
 264                  case DOMIT_RSS_ELEMENT_MANAGINGEDITOR:
 265                  case DOMIT_RSS_ELEMENT_WEBMASTER:
 266                  case DOMIT_RSS_ELEMENT_PUBDATE:
 267                  case DOMIT_RSS_ELEMENT_LASTBUILDDATE:
 268                  case DOMIT_RSS_ELEMENT_GENERATOR:
 269                  case DOMIT_RSS_ELEMENT_DOCS:
 270                  case DOMIT_RSS_ELEMENT_TTL:
 271                  case DOMIT_RSS_ELEMENT_RATING:
 272                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_simpleelement($currNode);
 273                      break;
 274                  default:
 275                      $this->addIndexedElement($currNode);
 276                      //$this->DOMIT_RSS_indexer[$tagName] =& $currNode;
 277              }
 278          }
 279  
 280          if ($itemCounter != 0) {
 281              $this->DOMIT_RSS_indexer[DOMIT_RSS_ARRAY_ITEMS] =& $this->domit_rss_items;
 282          }
 283  
 284          if ($categoryCounter != 0) {
 285              $this->DOMIT_RSS_indexer[DOMIT_RSS_ARRAY_CATEGORIES] =& $this->domit_rss_categories;
 286          }
 287      } //_init
 288  
 289      /**
 290      * Returns the title of the channel
 291      * @return string The title of the channel, or an empty string
 292      */
 293  	function getTitle() {
 294          return $this->getElementText(DOMIT_RSS_ELEMENT_TITLE);
 295      } //getTitle
 296  
 297      /**
 298      * Returns the url of the channel
 299      * @return string The url of the channel, or an empty string
 300      */
 301  	function getLink() {
 302          return $this->getElementText(DOMIT_RSS_ELEMENT_LINK);
 303      } //getLink
 304  
 305      /**
 306      * Returns a description of the channel
 307      * @return string A description of the channel, or an empty string
 308      */
 309  	function getDescription() {
 310          return $this->getElementText(DOMIT_RSS_ELEMENT_DESCRIPTION);
 311      } //getDescription
 312  
 313      /**
 314      * Returns the language of the channel
 315      * @return string The language of the channel, or an empty string
 316      */
 317  	function getLanguage() {
 318          return $this->getElementText(DOMIT_RSS_ELEMENT_LANGUAGE);
 319      } //getLanguage
 320  
 321      /**
 322      * Returns the copyright of the channel
 323      * @return string The copyright of the channel, or an empty string
 324      */
 325  	function getCopyright() {
 326          return $this->getElementText(DOMIT_RSS_ELEMENT_COPYRIGHT);
 327      } //getCopyright
 328  
 329      /**
 330      * Returns the managing editor of the channel
 331      * @return string The managing editor of the channel, or an empty string
 332      */
 333  	function getManagingEditor() {
 334          return $this->getElementText(DOMIT_RSS_ELEMENT_MANAGINGEDITOR);
 335      } //getManagingEditor
 336  
 337      /**
 338      * Returns the webmaster of the channel
 339      * @return string The webmaster of the channel, or an empty string
 340      */
 341  	function getWebMaster() {
 342          return $this->getElementText(DOMIT_RSS_ELEMENT_WEBMASTER);
 343      } //getWebMaster
 344  
 345      /**
 346      * Returns the publication date of the channel
 347      * @return string The publication date of the channel, or an empty string
 348      */
 349  	function getPubDate() {
 350          return $this->getElementText(DOMIT_RSS_ELEMENT_PUBDATE);
 351      } //getPubDate
 352  
 353      /**
 354      * Returns the last build date of the channel
 355      * @return string The last build date of the channel, or an empty string
 356      */
 357  	function getLastBuildDate() {
 358          return $this->getElementText(DOMIT_RSS_ELEMENT_LASTBUILDDATE);
 359      } //getLastBuildDate
 360  
 361      /**
 362      * Returns the generator of the channel
 363      * @return string The generator of the channel, or an empty string
 364      */
 365  	function getGenerator() {
 366          return $this->getElementText(DOMIT_RSS_ELEMENT_GENERATOR);
 367      } //getGenerator
 368  
 369      /**
 370      * Returns the docs of the channel
 371      * @return string The docs of the channel, or an empty string
 372      */
 373  	function getDocs() {
 374          return $this->getElementText(DOMIT_RSS_ELEMENT_DOCS);
 375      } //getDocs
 376  
 377      /**
 378      * Returns the cloud of the channel
 379      * @return object A reference to the cloud object for the channel, or null
 380      */
 381  	function getCloud() {
 382          if ($this->hasElement(DOMIT_RSS_ELEMENT_CLOUD)) {
 383              return $this->getElement(DOMIT_RSS_ELEMENT_CLOUD);
 384          }
 385  
 386          return null;
 387      } //getCloud
 388  
 389      /**
 390      * Returns the ttl of the channel
 391      * @return string The ttl of the channel, or an empty string
 392      */
 393  	function getTTL() {
 394          return $this->getElementText(DOMIT_RSS_ELEMENT_TTL);
 395      } //getTTL
 396  
 397      /**
 398      * Returns the image of the channel
 399      * @return object A reference to an image object for the channel, or null
 400      */
 401  	function getImage() {
 402          if ($this->hasElement(DOMIT_RSS_ELEMENT_IMAGE)) {
 403              return $this->getElement(DOMIT_RSS_ELEMENT_IMAGE);
 404          }
 405  
 406          return null;
 407      } //getImage
 408  
 409      /**
 410      * Returns the rating of the channel
 411      * @return string The rating of the channel, or an empty string
 412      */
 413  	function getRating() {
 414          return $this->getElementText(DOMIT_RSS_ELEMENT_RATING);
 415      } //getRating
 416  
 417      /**
 418      * Returns the text input box of the channel
 419      * @return object A reference to a text input box object for the channel, or null
 420      */
 421  	function getTextInput() {
 422          if ($this->hasElement(DOMIT_RSS_ELEMENT_TEXTINPUT)) {
 423              return $this->getElement(DOMIT_RSS_ELEMENT_TEXTINPUT);
 424          }
 425  
 426          return null;
 427      } //getTextInput
 428  
 429      /**
 430      * Returns the skip days of the channel
 431      * @return object A reference to the skip days object for the channel, or null
 432      */
 433  	function getSkipDays() {
 434          if ($this->hasElement(DOMIT_RSS_ELEMENT_SKIPDAYS)) {
 435              return $this->getElement(DOMIT_RSS_ELEMENT_SKIPDAYS);
 436          }
 437  
 438          return null;
 439      } //getSkipDays
 440  
 441      /**
 442      * Returns the skip hours of the channel
 443      * @return object A reference to the skip hours object for the channel, or null
 444      */
 445  	function getSkipHours() {
 446          if ($this->hasElement(DOMIT_RSS_ELEMENT_SKIPHOURS)) {
 447              return $this->getElement(DOMIT_RSS_ELEMENT_SKIPHOURS);
 448          }
 449  
 450          return null;
 451      } //getSkipHours
 452  
 453      /**
 454      * Returns the number of items in the channel
 455      * @return int The number of items in the channel
 456      */
 457  	function getItemCount() {
 458          return count($this->domit_rss_items);
 459      } //getItemCount
 460  
 461      /**
 462      * Returns a reference to the item at the specified index
 463      * @param int The index of the requested item
 464      * @return Object A reference to the item at the specified index
 465      */
 466      function &getItem($index) {
 467          return $this->domit_rss_items[$index];
 468      } //getItem
 469  
 470      /**
 471      * Returns the number of categories in the channel
 472      * @return int The number of categories in the channel
 473      */
 474  	function getCategoryCount() {
 475          return count($this->domit_rss_categories);
 476      } //getCategoryCount
 477  
 478      /**
 479      * Returns a reference to the category at the specified index
 480      * @param int The index of the requested category
 481      * @return Object A reference to the category at the specified index
 482      */
 483      function &getCategory($index) {
 484          return $this->domit_rss_categories[$index];
 485      } //getCategory
 486  } //xml_domit_rss_channel
 487  
 488  /**
 489  * Represents an RSS item
 490  *
 491  * @package domit-rss
 492  * @subpackage domit-rss-main
 493  * @author John Heinstein <johnkarl@nbnet.nb.ca>
 494  */
 495  class xml_domit_rss_item extends xml_domit_rss_elementindexer {
 496      /** @var array A list of references to category items */
 497      var $domit_rss_categories = array();
 498  
 499      /**
 500      * Constructor
 501      * @param Object A DOM node containing item data
 502      */
 503  	function xml_domit_rss_item(&$item) {
 504          $this->node =& $item;
 505          $this->rssDefinedElements = array('title','link','description','author','comments',
 506                                              'enclosure','guid','pubDate','source','domit_rss_categories');
 507          $this->_init();
 508      } //xml_domit_rss_item
 509  
 510      /**
 511      * Performs initialization of the item element
 512      */
 513  	function _init(){
 514          $total = $this->node->childCount;
 515          $categoryCounter = 0;
 516  
 517          for($i = 0; $i < $total; $i++) {
 518              $currNode =& $this->node->childNodes[$i];
 519              $tagName = strtolower($currNode->nodeName);
 520  
 521              switch ($tagName) {
 522                  case DOMIT_RSS_ELEMENT_CATEGORY:
 523                      $this->categories[$categoryCounter] = new xml_domit_rss_category($currNode);
 524                      $categoryCounter++;
 525                      break;
 526                  case DOMIT_RSS_ELEMENT_ENCLOSURE:
 527                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_enclosure($currNode);
 528                      break;
 529                  case DOMIT_RSS_ELEMENT_SOURCE:
 530                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_source($currNode);
 531                      break;
 532                  case DOMIT_RSS_ELEMENT_GUID:
 533                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_guid($currNode);
 534                      break;
 535                  case DOMIT_RSS_ELEMENT_TITLE:
 536                  case DOMIT_RSS_ELEMENT_LINK:
 537                  case DOMIT_RSS_ELEMENT_DESCRIPTION:
 538                  case DOMIT_RSS_ELEMENT_AUTHOR:
 539                  case DOMIT_RSS_ELEMENT_COMMENTS:
 540                  case DOMIT_RSS_ELEMENT_PUBDATE:
 541                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_simpleelement($currNode);
 542                      break;
 543                  default:
 544                      $this->addIndexedElement($currNode);
 545                      //$this->DOMIT_RSS_indexer[$tagName] =& $currNode;
 546              }
 547          }
 548  
 549          if ($categoryCounter != 0) {
 550              $this->DOMIT_RSS_indexer[DOMIT_RSS_ARRAY_CATEGORIES] =& $this->domit_rss_categories;
 551          }
 552      } //init
 553  
 554      /**
 555      * Returns the title of the item
 556      * @return string The title of the item, or an empty string
 557      */
 558  	function getTitle() {
 559          return $this->getElementText(DOMIT_RSS_ELEMENT_TITLE);
 560      } //getTitle
 561  
 562      /**
 563      * Returns the url of the item
 564      * @return string The url of the item, or an empty string
 565      */
 566  	function getLink() {
 567          return $this->getElementText(DOMIT_RSS_ELEMENT_LINK);
 568      } //getLink
 569  
 570      /**
 571      * Returns a description of the item
 572      * @return string A description of the item, or an empty string
 573      */
 574  	function getDescription() {
 575          return $this->getElementText(DOMIT_RSS_ELEMENT_DESCRIPTION);
 576      } //getDescription
 577  
 578      /**
 579      * Returns the author of the item
 580      * @return string The author of the item, or an empty string
 581      */
 582  	function getAuthor() {
 583          return $this->getElementText(DOMIT_RSS_ELEMENT_AUTHOR);
 584      } //getAuthor
 585  
 586      /**
 587      * Returns the comments of the item
 588      * @return string The comments of the item, or an empty string
 589      */
 590  	function getComments() {
 591          return $this->getElementText(DOMIT_RSS_ELEMENT_COMMENTS);
 592      } //getComments
 593  
 594      /**
 595      * Returns the enclosure of the item
 596      * @return object A reference to the enclosure object for the item, or null
 597      */
 598  	function getEnclosure() {
 599          if ($this->hasElement(DOMIT_RSS_ELEMENT_ENCLOSURE)) {
 600              return $this->getElement(DOMIT_RSS_ELEMENT_ENCLOSURE);
 601          }
 602  
 603          return null;
 604      } //getEnclosure
 605  
 606      /**
 607      * Returns the guid of the item
 608      * @return object A reference to the guid object for the item, or null
 609      */
 610  	function getGUID() {
 611          if ($this->hasElement(DOMIT_RSS_ELEMENT_GUID)) {
 612              return $this->getElement(DOMIT_RSS_ELEMENT_GUID);
 613          }
 614  
 615          return null;
 616      } //getGUID
 617  
 618      /**
 619      * Returns the publication date of the item
 620      * @return string The publication date of the item, or an empty string
 621      */
 622  	function getPubDate() {
 623          return $this->getElementText(DOMIT_RSS_ELEMENT_PUBDATE);
 624      } //getPubDate
 625  
 626      /**
 627      * Returns the source of the item
 628      * @return object A reference to the source object for the item, or null
 629      */
 630  	function getSource() {
 631          if ($this->hasElement(DOMIT_RSS_ELEMENT_SOURCE)) {
 632              return $this->getElement(DOMIT_RSS_ELEMENT_SOURCE);
 633          }
 634  
 635          return null;
 636      } //getSource
 637  
 638      /**
 639      * Returns the number of categories in the item
 640      * @return int The number of categories in the item
 641      */
 642  	function getCategoryCount() {
 643          return count($this->domit_rss_categories);
 644      } //getCategoryCount
 645  
 646      /**
 647      * Returns a reference to the category at the specified index
 648      * @param int The index of the requested category
 649      * @return Object A reference to the category at the specified index
 650      */
 651      function &getCategory($index) {
 652          return $this->domit_rss_categories[$index];
 653      } //getCategory
 654  } //xml_domit_rss_item
 655  
 656  
 657  /**
 658  * Represents an RSS category
 659  *
 660  * @package domit-rss
 661  * @subpackage domit-rss-main
 662  * @author John Heinstein <johnkarl@nbnet.nb.ca>
 663  */
 664  class xml_domit_rss_category extends xml_domit_rss_elementindexer {
 665      /**
 666      * Constructor
 667      * @param Object A DOM node containing category data
 668      */
 669  	function xml_domit_rss_category(&$category) {
 670          $this->node =& $category;
 671          $this->_init();
 672      } //xml_domit_rss_category
 673  
 674      /**
 675      * Returns the category
 676      * @return string The category text
 677      */
 678  	function getCategory() {
 679          return $this->node->firstChild->toString();
 680      } //getCategory
 681  
 682      /**
 683      * Returns the category domain
 684      * @return string The category domain
 685      */
 686  	function getDomain() {
 687          return $this->getAttribute(DOMIT_RSS_ATTR_DOMAIN);
 688      } //getDomain
 689  } //xml_domit_rss_category
 690  
 691  /**
 692  * Represents an RSS image
 693  *
 694  * @package domit-rss
 695  * @subpackage domit-rss-main
 696  * @author John Heinstein <johnkarl@nbnet.nb.ca>
 697  */
 698  class xml_domit_rss_image extends xml_domit_rss_elementindexer {
 699      /**
 700      * Constructor
 701      * @param Object A DOM node containing image data
 702      */
 703  	function xml_domit_rss_image(&$image) {
 704          $this->node =& $image;
 705          $this->rssDefinedElements = array('title','link','description','url',
 706                                              'width', 'height');
 707          $this->_init();
 708      } //xml_domit_rss_image
 709  
 710      /**
 711      * Performs initialization of image element
 712      */
 713  	function _init(){
 714          $total = $this->node->childCount;
 715  
 716          for($i = 0; $i < $total; $i++) {
 717              $currNode =& $this->node->childNodes[$i];
 718              $tagName = strtolower($currNode->nodeName);
 719  
 720              switch ($tagName) {
 721                  case DOMIT_RSS_ELEMENT_TITLE:
 722                  case DOMIT_RSS_ELEMENT_LINK:
 723                  case DOMIT_RSS_ELEMENT_DESCRIPTION:
 724                  case DOMIT_RSS_ELEMENT_URL:
 725                  case DOMIT_RSS_ELEMENT_WIDTH:
 726                  case DOMIT_RSS_ELEMENT_HEIGHT:
 727                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_simpleelement($currNode);
 728                      break;
 729                  default:
 730                      $this->addIndexedElement($currNode);
 731                      //$this->DOMIT_RSS_indexer[$tagName] =& $currNode;
 732              }
 733          }
 734      } //_init
 735  
 736      /**
 737      * Returns the image title
 738      * @return string The image title
 739      */
 740  	function getTitle() {
 741          return $this->getElementText(DOMIT_RSS_ELEMENT_TITLE);
 742      } //getTitle
 743  
 744      /**
 745      * Returns the image link
 746      * @return string The image link
 747      */
 748  	function getLink() {
 749          return $this->getElementText(DOMIT_RSS_ELEMENT_LINK);
 750      } //getLink
 751  
 752      /**
 753      * Returns the image url
 754      * @return string The image url
 755      */
 756  	function getUrl() {
 757          return $this->getElementText(DOMIT_RSS_ELEMENT_URL);
 758      } //getUrl
 759  
 760      /**
 761      * Returns the image width in pixels
 762      * @return string The image width (maximum 144, default 88)
 763      */
 764  	function getWidth() {
 765          $myWidth = $this->getElementText(DOMIT_RSS_ELEMENT_WIDTH);
 766  
 767          if ($myWidth == '') {
 768              $myWidth = '88';
 769          }
 770          else if (intval($myWidth) > 144) {
 771              $myWidth = '144';
 772          }
 773  
 774          return $myWidth;
 775      } //getWidth
 776  
 777      /**
 778      * Returns the image height in pixels
 779      * @return string The image height (maximum 400, default 31)
 780      */
 781  	function getHeight() {
 782          $myHeight = $this->getElementText(DOMIT_RSS_ELEMENT_HEIGHT);
 783  
 784          if ($myHeight == '') {
 785              $myHeight = '31';
 786          }
 787          else if (intval($myHeight) > 400) {
 788              $myHeight = '400';
 789          }
 790  
 791          return $myHeight;
 792      } //getHeight
 793  
 794      /**
 795      * Returns the image description
 796      * @return string The image description
 797      */
 798  	function getDescription() {
 799          return $this->getElementText(DOMIT_RSS_ELEMENT_DESCRIPTION);
 800      } //getDescription
 801  } //xml_domit_rss_image
 802  
 803  /**
 804  * Represents an RSS text input form
 805  *
 806  * @package domit-rss
 807  * @subpackage domit-rss-main
 808  * @author John Heinstein <johnkarl@nbnet.nb.ca>
 809  */
 810  class xml_domit_rss_textinput extends xml_domit_rss_elementindexer {
 811      /**
 812      * Constructor
 813      * @param Object A DOM node containing text input data
 814      */
 815  	function xml_domit_rss_textinput(&$textinput) {
 816          $this->node =& $textinput;
 817          $this->rssDefinedElements = array('title','link','description','name');
 818          $this->_init();
 819      } //xml_domit_rss_textinput
 820  
 821      /**
 822      * Performs initialization of textInput element
 823      */
 824  	function _init(){
 825          $total = $this->node->childCount;
 826  
 827          for($i = 0; $i < $total; $i++) {
 828              $currNode =& $this->node->childNodes[$i];
 829              $tagName = strtolower($currNode->nodeName);
 830  
 831              switch ($tagName) {
 832                  case DOMIT_RSS_ELEMENT_TITLE:
 833                  case DOMIT_RSS_ELEMENT_LINK:
 834                  case DOMIT_RSS_ELEMENT_DESCRIPTION:
 835                  case DOMIT_RSS_ELEMENT_NAME:
 836                      $this->DOMIT_RSS_indexer[$tagName] = new xml_domit_rss_simpleelement($currNode);
 837                      break;
 838                  default:
 839                      $this->addIndexedElement($currNode);
 840                      //$this->DOMIT_RSS_indexer[$tagName] =& $currNode;
 841              }
 842          }
 843      } //_init
 844  
 845      /**
 846      * Returns the title of the text input
 847      * @return string The title of the text input, or an empty string
 848      */
 849  	function getTitle() {
 850          return $this->getElementText(DOMIT_RSS_ELEMENT_TITLE);
 851      } //getTitle
 852  
 853      /**
 854      * Returns a description of the text input
 855      * @return string A description of the text input, or an empty string
 856      */
 857  	function getDescription() {
 858          return $this->getElementText(DOMIT_RSS_ELEMENT_DESCRIPTION);
 859      } //getDescription
 860  
 861      /**
 862      * Returns the name of the text input
 863      * @return string The name of the text input, or an empty string
 864      */
 865  	function getName() {
 866          return $this->getElementText(DOMIT_RSS_ELEMENT_NAME);
 867      } //getName
 868  
 869      /**
 870      * Returns the url of the text input
 871      * @return string The url of the text input, or an empty string
 872      */
 873  	function getLink() {
 874          return $this->getElementText(DOMIT_RSS_ELEMENT_LINK);
 875      } //getLink
 876  } //xml_domit_rss_textinput
 877  
 878  /**
 879  * Represents an RSS cloud
 880  *
 881  * @package domit-rss
 882  * @subpackage domit-rss-main
 883  * @author John Heinstein <johnkarl@nbnet.nb.ca>
 884  */
 885  class xml_domit_rss_cloud extends xml_domit_rss_elementindexer {
 886      /**
 887      * Constructor
 888      * @param Object A DOM node containing cloud data
 889      */
 890  	function xml_domit_rss_cloud(&$cloud) {
 891          $this->node =& $cloud;
 892          $this->_init();
 893      } //xml_domit_rss_cloud
 894  
 895      /**
 896      * Returns the domain of the cloud
 897      * @return string The domain of the cloud
 898      */
 899  	function getDomain() {
 900          return $this->getAttribute(DOMIT_RSS_ATTR_DOMAIN);
 901      } //getDomain
 902  
 903      /**
 904      * Returns the port of the cloud
 905      * @return string The port of the cloud
 906      */
 907  	function getPort() {
 908          return $this->getAttribute(DOMIT_RSS_ATTR_PORT);
 909      } //getPort
 910  
 911      /**
 912      * Returns the path of the cloud
 913      * @return string The path of the cloud
 914      */
 915  	function getPath() {
 916          return $this->getAttribute(DOMIT_RSS_ATTR_PATH);
 917      } //getPath
 918  
 919      /**
 920      * Returns the register procedure value of the cloud
 921      * @return string The register procedure value of the cloud
 922      */
 923  	function getRegisterProcedure() {
 924          return $this->getAttribute(DOMIT_RSS_ATTR_REGISTERPROCEDURE);
 925      } //getRegisterProcedure
 926  
 927      /**
 928      * Returns the protocol used by the cloud
 929      * @return string The protocol used by the cloud
 930      */
 931  	function getProtocol() {
 932          return $this->getAttribute(DOMIT_RSS_ATTR_PROTOCOL);
 933      } //getProtocol
 934  } //xml_domit_rss_cloud
 935  
 936  /**
 937  * Represents an RSS enclosure
 938  *
 939  * @package domit-rss
 940  * @subpackage domit-rss-main
 941  * @author John Heinstein <johnkarl@nbnet.nb.ca>
 942  */
 943  class xml_domit_rss_enclosure extends xml_domit_rss_elementindexer {
 944      /**
 945      * Constructor
 946      * @param Object A DOM node containing enclosure data
 947      */
 948  	function xml_domit_rss_enclosure(&$enclosure) {
 949          $this->node =& $enclosure;
 950          $this->_init();
 951      } //xml_domit_rss_enclosure
 952  
 953      /**
 954      * Returns the url of the enclosure
 955      * @return string The url of the enclosure
 956      */
 957  	function getUrl() {
 958          return $this->getAttribute(DOMIT_RSS_ATTR_URL);
 959      } //getUrl
 960  
 961      /**
 962      * Returns the length of the enclosure
 963      * @return string The length of the enclosure
 964      */
 965  	function getLength() {
 966          return $this->getAttribute(DOMIT_RSS_ATTR_LENGTH);
 967      } //getLength
 968  
 969      /**
 970      * Returns the type of the enclosure
 971      * @return string The type of the enclosure
 972      */
 973  	function getType() {
 974          return $this->getAttribute(DOMIT_RSS_ATTR_TYPE);
 975      } //getType
 976  } //xml_domit_rss_enclosure
 977  
 978  /**
 979  * Represents an RSS guid
 980  *
 981  * @package domit-rss
 982  * @subpackage domit-rss-main
 983  * @author John Heinstein <johnkarl@nbnet.nb.ca>
 984  */
 985  class xml_domit_rss_guid extends xml_domit_rss_elementindexer {
 986      /**
 987      * Constructor
 988      * @param Object A DOM node containing guid data
 989      */
 990  	function xml_domit_rss_guid(&$guid) {
 991          $this->node =& $guid;
 992          $this->_init();
 993      } //xml_domit_rss_guid
 994  
 995      /**
 996      * Returns the guid text
 997      * @return string The guid text
 998      */
 999  	function getGuid() {
1000          return $this->node->getText();
1001      } //getGuid
1002  
1003      /**
1004      * Determines whether the guid is a permalink
1005      * @return boolean True if the guid is a permalink (default true)
1006      */
1007  	function isPermaLink() {
1008          if (!$this->node->hasAttribute(DOMIT_RSS_ATTR_ISPERMALINK)) {
1009              return true;
1010          }
1011          else {
1012              return (strtolower($this->node->getAttribute(DOMIT_RSS_ATTR_ISPERMALINK)) == "true");
1013          }
1014      } //isPermaLink
1015  } //xml_domit_rss_guid
1016  
1017  /**
1018  * Represents an RSS source
1019  *
1020  * @package domit-rss
1021  * @subpackage domit-rss-main
1022  * @author John Heinstein <johnkarl@nbnet.nb.ca>
1023  */
1024  class xml_domit_rss_source extends xml_domit_rss_elementindexer {
1025      /**
1026      * Constructor
1027      * @param Object A DOM node containing source data
1028      */
1029  	function xml_domit_rss_source(&$source) {
1030          $this->node =& $source;
1031          $this->_init();
1032      } //xml_domit_rss_source
1033  
1034      /**
1035      * Returns the source text
1036      * @return string The source text
1037      */
1038  	function getSource() {
1039          return $this->node->getText();
1040      } //getSource
1041  
1042      /**
1043      * Returns the url of the source
1044      * @return string The url of the source
1045      */
1046  	function getUrl() {
1047          return $this->getAttribute(DOMIT_RSS_ATTR_URL);
1048      } //getUrl
1049  } //xml_domit_rss_source
1050  
1051  /**
1052  * Represents an RSS skipDays element
1053  *
1054  * @package domit-rss
1055  * @subpackage domit-rss-main
1056  * @author John Heinstein <johnkarl@nbnet.nb.ca>
1057  */
1058  class xml_domit_rss_skipdays extends xml_domit_rss_elementindexer {
1059      /**
1060      * Constructor
1061      * @param Object A DOM node containing source data
1062      */
1063  	function xml_domit_rss_skipdays(&$skipdays) {
1064          $this->node =& $skipdays;
1065          $this->_init();
1066      } //xml_domit_rss_skipdays
1067  
1068      /**
1069      * Returns the number of skip day items
1070      * @return int The number of skip day items
1071      */
1072  	function getSkipDayCount() {
1073          return $this->node->childCount;
1074      } //getSkipDayCount
1075  
1076      /**
1077      * Returns the day of the specified index (Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday)
1078      * @param int The index of the requested day
1079      * @return string The day of the specified index (Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday)
1080      */
1081  	function getSkipDay($index) {
1082          return $this->node->childNodes[$index]->getText();
1083      } //getSkipDay
1084  } //xml_domit_rss_skipdays
1085  
1086  /**
1087  * Represents an RSS skipHours element
1088  *
1089  * @package domit-rss
1090  * @subpackage domit-rss-main
1091  * @author John Heinstein <johnkarl@nbnet.nb.ca>
1092  */
1093  class xml_domit_rss_skiphours extends xml_domit_rss_elementindexer {
1094      /**
1095      * Constructor
1096      * @param Object A DOM node containing source data
1097      */
1098  	function xml_domit_rss_skiphours(&$skiphours) {
1099          $this->node =& $skiphours;
1100          $this->_init();
1101      } //xml_domit_rss_skiphours
1102  
1103      /**
1104      * Returns the number of skip hour items
1105      * @return int The number of skip hour items
1106      */
1107  	function getSkipHourCount() {
1108          return $this->node->childCount;
1109      } //getSkipHourCount
1110  
1111      /**
1112      * Returns the hour of the specified index (0-23)
1113      * @param int The index of the requested hour
1114      * @return string The hour of the specified index (0-23)
1115      */
1116  	function getSkipHour($index) {
1117          return $this->node->childNodes[$index]->getText();
1118      } //getSkipHour
1119  } //xml_domit_rss_skiphours
1120  
1121  ?>


Généré le : Wed Nov 21 14:43:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics