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