[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZRSSExport class 4 // 5 // Created on: <18-Sep-2003 11:13:56 kk> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file ezrssexport.php 30 */ 31 32 /*! 33 \class eZRSSExport ezrssexport.php 34 \brief Handles RSS Export in eZ publish 35 36 RSSExport is used to create RSS feeds from published content. See kernel/rss for more files. 37 */ 38 39 include_once ( 'kernel/classes/ezpersistentobject.php' ); 40 include_once ( 'kernel/classes/ezrssexportitem.php' ); 41 include_once ( "lib/ezdb/classes/ezdb.php" ); 42 43 define( "EZ_RSSEXPORT_STATUS_VALID", 1 ); 44 define( "EZ_RSSEXPORT_STATUS_DRAFT", 0 ); 45 46 class eZRSSExport extends eZPersistentObject 47 { 48 /*! 49 Initializes a new RSSExport. 50 */ 51 function eZRSSExport( $row ) 52 { 53 $this->eZPersistentObject( $row ); 54 } 55 56 /*! 57 \reimp 58 */ 59 function definition() 60 { 61 return array( "fields" => array( "id" => array( 'name' => 'ID', 62 'datatype' => 'integer', 63 'default' => 0, 64 'required' => true ), 65 'title' => array( 'name' => 'Title', 66 'datatype' => 'string', 67 'default' => ezi18n( 'kernel/rss', 'New RSS Export' ), 68 'required' => true ), 69 'url' => array( 'name' => 'URL', 70 'datatype' => 'string', 71 'default' => '', 72 'required' => true ), 73 'site_access' => array( 'name' => 'SiteAccess', 74 'datatype' => 'string', 75 'default' => '', 76 'required' => true ), 77 'modified' => array( 'name' => 'Modified', 78 'datatype' => 'integer', 79 'default' => 0, 80 'required' => true ), 81 'modifier_id' => array( 'name' => 'ModifierID', 82 'datatype' => 'integer', 83 'default' => 0, 84 'required' => true, 85 'foreign_class' => 'eZUser', 86 'foreign_attribute' => 'contentobject_id', 87 'multiplicity' => '1..*' ), 88 'created' => array( 'name' => 'Created', 89 'datatype' => 'integer', 90 'default' => 0, 91 'required' => true ), 92 'creator_id' => array( 'name' => 'CreatorID', 93 'datatype' => 'integer', 94 'default' => 0, 95 'required' => true, 96 'foreign_class' => 'eZUser', 97 'foreign_attribute' => 'contentobject_id', 98 'multiplicity' => '1..*' ), 99 'description' => array( 'name' => 'Description', 100 'datatype' => 'string', 101 'default' => '', 102 'required' => false ), 103 'image_id' => array( 'name' => 'ImageID', 104 'datatype' => 'integer', 105 'default' => 0, 106 'required' => false ), 107 'rss_version' => array( 'name' => 'RSSVersion', 108 'datatype' => 'string', 109 'default' => 0, 110 'required' => true ), 111 'active' => array( 'name' => 'Active', 112 'datatype' => 'integer', 113 'default' => 0, 114 'required' => true ), 115 'status' => array( 'name' => 'Status', 116 'datatype' => 'integer', 117 'default' => 0, 118 'required' => true ), 119 'access_url' => array( 'name' => 'AccessURL', 120 'datatype' => 'string', 121 'default' => 'rss_feed', 122 'required' => false ), 123 'number_of_objects' => array( 'name' => 'NumberOfObjects', 124 'datatype' => 'integer', 125 'default' => 0, 126 'required' => true ), 127 'main_node_only' => array( 'name' => 'MainNodeOnly', 128 'datatype' => 'integer', 129 'default' => 0, 130 'required' => true ) ), 131 "keys" => array( "id", 'status' ), 132 'function_attributes' => array( 'item_list' => 'itemList', 133 'modifier' => 'modifier', 134 'rss-xml' => 'rssXml', 135 'image_path' => 'imagePath', 136 'image_node' => 'imageNode' ), 137 "increment_key" => "id", 138 "sort" => array( "title" => "asc" ), 139 "class_name" => "eZRSSExport", 140 "name" => "ezrss_export" ); 141 142 } 143 144 /*! 145 \static 146 Creates a new RSS Export with the new RSS Export 147 \param User ID 148 149 \return the URL alias object 150 */ 151 function create( $user_id ) 152 { 153 $config =& eZINI::instance( 'site.ini' ); 154 $dateTime = time(); 155 $row = array( 'id' => null, 156 'title' => ezi18n( 'kernel/classes', 'New RSS Export' ), 157 'site_access' => '', 158 'modifier_id' => $user_id, 159 'modified' => $dateTime, 160 'creator_id' => $user_id, 161 'created' => $dateTime, 162 'status' => 0, 163 'url' => 'http://'. $config->variable( 'SiteSettings', 'SiteURL' ), 164 'description' => '', 165 'image_id' => 0, 166 'active' => 1, 167 'access_url' => '' ); 168 return new eZRSSExport( $row ); 169 } 170 171 /*! 172 Store Object to database 173 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 174 the calls within a db transaction; thus within db->begin and db->commit. 175 */ 176 function store( $storeAsValid = false ) 177 { 178 include_once ( "kernel/classes/datatypes/ezuser/ezuser.php" ); 179 $dateTime = time(); 180 $user =& eZUser::currentUser(); 181 if ( $this->ID == null ) 182 { 183 eZPersistentObject::store(); 184 return; 185 } 186 187 $db =& eZDB::instance(); 188 $db->begin(); 189 if ( $storeAsValid ) 190 { 191 $oldStatus = $this->attribute( 'status' ); 192 $this->setAttribute( 'status', EZ_RSSEXPORT_STATUS_VALID ); 193 } 194 $this->setAttribute( 'modified', $dateTime ); 195 $this->setAttribute( 'modifier_id', $user->attribute( "contentobject_id" ) ); 196 eZPersistentObject::store(); 197 $db->commit(); 198 if ( $storeAsValid ) 199 { 200 $this->setAttribute( 'status', $oldStatus ); 201 } 202 } 203 204 /*! 205 Remove the RSS Export. 206 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 207 the calls within a db transaction; thus within db->begin and db->commit. 208 */ 209 function remove() 210 { 211 $exportItems = $this->fetchItems(); 212 213 $db =& eZDB::instance(); 214 $db->begin(); 215 foreach ( $exportItems as $item ) 216 { 217 $item->remove(); 218 } 219 eZPersistentObject::remove(); 220 $db->commit(); 221 } 222 223 /*! 224 \static 225 Fetches the RSS Export by ID. 226 227 \param RSS Export ID 228 */ 229 function fetch( $id, $asObject = true, $status = EZ_RSSEXPORT_STATUS_VALID ) 230 { 231 return eZPersistentObject::fetchObject( eZRSSExport::definition(), 232 null, 233 array( "id" => $id, 234 'status' => $status ), 235 $asObject ); 236 } 237 238 /*! 239 \static 240 Fetches the RSS Export by feed access url and is active. 241 242 \param RSS Export access url 243 */ 244 function fetchByName( $access_url, $asObject = true ) 245 { 246 return eZPersistentObject::fetchObject( eZRSSExport::definition(), 247 null, 248 array( 'access_url' => $access_url, 249 'active' => 1, 250 'status' => 1 ), 251 $asObject ); 252 } 253 254 /*! 255 \static 256 Fetches complete list of RSS Exports. 257 */ 258 function fetchList( $asObject = true ) 259 { 260 return eZPersistentObject::fetchObjectList( eZRSSExport::definition(), 261 null, array( 'status' => 1 ), null, null, 262 $asObject ); 263 } 264 265 function &itemList() 266 { 267 $items = $this->fetchItems(); 268 return $items; 269 } 270 271 function &imageNode() 272 { 273 if ( isset( $this->ImageID ) and $this->ImageID ) 274 { 275 include_once ( "kernel/classes/ezcontentobjecttreenode.php" ); 276 $node = eZContentObjectTreeNode::fetch( $this->ImageID ); 277 } 278 else 279 $node = null; 280 return $node; 281 } 282 283 function &imagePath() 284 { 285 if ( isset( $this->ImageID ) and $this->ImageID ) 286 { 287 include_once ( "kernel/classes/ezcontentobjecttreenode.php" ); 288 $objectNode = eZContentObjectTreeNode::fetch( $this->ImageID ); 289 if ( isset( $objectNode ) ) 290 { 291 $path_array = $objectNode->attribute( 'path_array' ); 292 for ( $i = 0; $i < count( $path_array ); $i++ ) 293 { 294 $treenode = eZContentObjectTreeNode::fetch( $path_array[$i] ); 295 if( $i == 0 ) 296 $retValue = $treenode->attribute( 'name' ); 297 else 298 $retValue .= '/'.$treenode->attribute( 'name' ); 299 } 300 } 301 else 302 $retValue = null; 303 } 304 else 305 $retValue = null; 306 307 return $retValue; 308 } 309 310 function &modifier() 311 { 312 if ( isset( $this->ModifierID ) and $this->ModifierID ) 313 { 314 include_once ( "kernel/classes/datatypes/ezuser/ezuser.php" ); 315 $user = eZUser::fetch( $this->ModifierID ); 316 } 317 else 318 $user = null; 319 return $user; 320 } 321 322 function &rssXml() 323 { 324 switch( $this->attribute( 'rss_version' ) ) 325 { 326 case '1.0': 327 { 328 $retRSSXml = $this->fetchRSS1_0(); 329 } break; 330 331 case '2.0': 332 { 333 $retRSSXml = $this->fetchRSS2_0(); 334 } break; 335 default: 336 { 337 $retRSSXml = null; 338 } break; 339 } 340 341 return $retRSSXml; 342 } 343 344 /*! 345 Fetches RSS Items related to this RSS Export. The RSS Export Items contain information about which nodes to export information from 346 347 \param RSSExport ID (optional). Uses current RSSExport's ID as default 348 349 \return RSSExportItem list. null if no RSS Export items found 350 */ 351 function fetchItems( $id = false, $status = EZ_RSSEXPORT_STATUS_VALID ) 352 { 353 if ( $id === false ) 354 { 355 if ( isset( $this ) ) 356 { 357 $id = $this->ID; 358 $status = $this->Status; 359 } 360 else 361 { 362 $itemList = null; 363 return $itemList; 364 } 365 } 366 if ( $id !== null ) 367 $itemList = eZRSSExportItem::fetchFilteredList( array( 'rssexport_id' => $id, 'status' => $status ) ); 368 else 369 $itemList = null; 370 return $itemList; 371 } 372 373 function getObjectListFilter() 374 { 375 if ( $this->MainNodeOnly == 1 ) 376 { 377 $this->MainNodeOnly = true; 378 } 379 else 380 { 381 $this->MainNodeOnly = false; 382 } 383 384 return array( 'number_of_objects' => intval($this->NumberOfObjects), 385 'main_node_only' => $this->MainNodeOnly 386 ); 387 } 388 389 /*! 390 Get a RSS xml document based on the RSS 2.0 standard based on the RSS Export settings defined by this object 391 392 \param 393 394 \return RSS 2.0 XML document 395 */ 396 function fetchRSS2_0( $id = null ) 397 { 398 if ( $id != null ) 399 { 400 $rssExport = eZRSSExport::fetch( $id ); 401 return $rssExport->fetchRSS2_0(); 402 } 403 404 include_once ( 'lib/ezxml/classes/ezdomdocument.php' ); 405 406 $locale = eZLocale::instance(); 407 408 // Get URL Translation settings. 409 $config =& eZINI::instance(); 410 if ( $config->variable( 'URLTranslator', 'Translation' ) == 'enabled' ) 411 { 412 $useURLAlias = true; 413 } 414 else 415 { 416 $useURLAlias = false; 417 } 418 419 $baseItemURL = $this->attribute( 'url' ).'/'; //.$this->attribute( 'site_access' ).'/'; 420 421 $doc = new eZDOMDocument(); 422 $doc->setName( 'eZ publish RSS Export' ); 423 $root = $doc->createElementNode( 'rss', array( 'version' => '2.0' ) ); 424 $doc->setRoot( $root ); 425 426 $channel = $doc->createElementNode( 'channel' ); 427 $root->appendChild( $channel ); 428 429 $channelTitle = $doc->createElementTextNode( 'title', $this->attribute( 'title' ) ); 430 $channel->appendChild( $channelTitle ); 431 432 $channelLink = $doc->createElementTextNode( 'link', $this->attribute( 'url' ) ); 433 $channel->appendChild( $channelLink ); 434 435 $channelDescription = $doc->createElementTextNode( 'description', $this->attribute( 'description' ) ); 436 $channel->appendChild( $channelDescription ); 437 438 $channel->appendChild( $doc->createElementTextNode( 'language', $locale->httpLocaleCode() ) ); 439 $channel->appendChild( $channelLanguage ); 440 441 $imageURL = $this->fetchImageURL(); 442 if ( $imageURL !== false ) 443 { 444 $image = $doc->createElementNode( 'image' ); 445 446 $imageUrlNode = $doc->createElementTextNode( 'url', $imageURL ); 447 $image->appendChild( $imageUrlNode ); 448 449 $imageTitle = $doc->createElementTextNode( 'title', $this->attribute( 'title' ) ); 450 $image->appendChild( $imageTitle ); 451 452 $imageLink = $doc->createElementTextNode( 'link', $this->attribute( 'url' ) ); 453 $image->appendChild( $imageLink ); 454 455 $channel->appendChild( $image ); 456 } 457 458 $cond = array( 459 'rssexport_id' => $this->ID, 460 'status' => $this->Status 461 ); 462 $rssSources = eZRSSExportItem::fetchFilteredList( $cond ); 463 464 $nodeArray = eZRSSExportItem::fetchNodeList( $rssSources, $this->getObjectListFilter() ); 465 466 if( is_array( $nodeArray ) && count( $nodeArray ) ) 467 { 468 $attributeMappings = eZRSSExportItem::getAttributeMappings( $rssSources ); 469 } 470 471 foreach ( $nodeArray as $node ) 472 { 473 $object = $node->attribute( 'object' ); 474 $dataMap = $object->dataMap(); 475 if ( $useURLAlias === true ) 476 { 477 $nodeURL = $baseItemURL . $node->urlAlias(); 478 } 479 else 480 { 481 $nodeURL = $baseItemURL . 'content/view/full/'.$object->attribute( 'id' ); 482 } 483 484 // keep track if there's any match 485 $doesMatch = false; 486 // start mapping the class attribute to the respective RSS field 487 foreach ( $attributeMappings as $attributeMapping ) 488 { 489 // search for correct mapping by path 490 if ( $attributeMapping[0]->attribute( 'class_id' ) == $object->attribute( 'contentclass_id' ) and 491 in_array( $attributeMapping[0]->attribute( 'source_node_id' ), $node->attribute( 'path_array' ) ) ) 492 { 493 // found it 494 $doesMatch = true; 495 // now fetch the attributes 496 $title = $dataMap[$attributeMapping[0]->attribute( 'title' )]; 497 $description = $dataMap[$attributeMapping[0]->attribute( 'description' )]; 498 break; 499 } 500 } 501 502 if( !$doesMatch ) 503 { 504 // no match 505 eZDebug::writeWarning( __CLASS__.'::'.__FUNCTION__.': Cannot find matching RSS source node for content object in '.__FILE__.', Line '.__LINE__ ); 506 $retValue = null; 507 return $retValue; 508 } 509 510 // title RSS element with respective class attribute content 511 unset( $itemTitle ); 512 $itemTitle = $doc->createElementNode( 'title' ); 513 $titleContent = $title->attribute( 'content' ); 514 if ( get_class( $titleContent ) == 'ezxmltext' ) 515 { 516 $outputHandler = $titleContent->attribute( 'output' ); 517 unset( $itemTitleText ); 518 $itemTitleText = $doc->createTextNode( $outputHandler->attribute( 'output_text' ) ); 519 $itemTitle->appendChild( $itemTitleText ); 520 } 521 else 522 { 523 unset( $itemTitleText ); 524 $itemTitleText = $doc->createTextNode( $titleContent ); 525 $itemTitle->appendChild( $itemTitleText ); 526 } 527 528 // title RSS element with respective class attribute content 529 unset( $itemDescription ); 530 $itemDescription = $doc->createElementNode( 'description' ); 531 $descriptionContent = $description->attribute( 'content' ); 532 if ( get_class( $descriptionContent ) == 'ezxmltext' ) 533 { 534 $outputHandler = $descriptionContent->attribute( 'output' ); 535 unset( $itemDescriptionText ); 536 $itemDescriptionText = $doc->createTextNode( $outputHandler->attribute( 'output_text' ) ); 537 $itemDescription->appendChild( $itemDescriptionText ); 538 } 539 else 540 { 541 unset( $itemDescriptionText ); 542 $itemDescriptionText = $doc->createTextNode( $descriptionContent ); 543 $itemDescription->appendChild( $itemDescriptionText ); 544 } 545 546 unset( $itemLink ); 547 $itemLink = $doc->createElementNode( 'link' ); 548 549 unset( $itemLinkUrl ); 550 $itemLinkUrl = $doc->createTextNode( $nodeURL ); 551 $itemLink->appendChild( $itemLinkUrl ); 552 553 unset( $item ); 554 $item = $doc->createElementNode( 'item' ); 555 556 unset( $itemPubDate ); 557 $itemPubDate = $doc->createElementTextNode( 'pubDate', gmdate( 'D, d M Y H:i:s', $object->attribute( 'published' ) ) .' GMT' ); 558 559 $item->appendChild( $itemPubDate ); 560 $item->appendChild( $itemTitle ); 561 $item->appendChild( $itemLink ); 562 $item->appendChild( $itemDescription ); 563 564 $channel->appendChild( $item ); 565 } 566 567 return $doc; 568 } 569 570 /*! 571 Get a RSS xml document based on the RSS 1.0 standard based on the RSS Export settings defined by this object 572 573 \param object ID 574 575 \return RSS 1.0 XML document 576 */ 577 function fetchRSS1_0( $id = null ) 578 { 579 if ( $id != null ) 580 { 581 $rssExport = eZRSSExport::fetch( $id ); 582 return $rssExport->fetchRSS1_0(); 583 } 584 585 include_once ( 'lib/ezxml/classes/ezdomdocument.php' ); 586 587 $imageURL = $this->fetchImageURL(); 588 589 // Get URL Translation settings. 590 $config =& eZINI::instance( 'site.ini' ); 591 if ( $config->variable( 'URLTranslator', 'Translation' ) == 'enabled' ) 592 { 593 $useURLAlias = true; 594 } 595 else 596 { 597 $useURLAlias = false; 598 } 599 600 $baseItemURL = $this->attribute( 'url' ).'/'; //.$this->attribute( 'site_access' ).'/'; 601 602 $doc = new eZDOMDocument(); 603 $doc->setName( 'eZ publish RSS Export' ); 604 $root = $doc->createElementNode( 'rdf:RDF', array( 'xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 605 'xmlns:rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', 606 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 607 'xmlns' => 'http://purl.org/rss/1.0/' ) ); 608 $doc->setRoot( $root ); 609 610 $channel = $doc->createElementNode( 'channel', array( 'rdf:about' => $this->attribute( 'url' ) ) ); 611 $root->appendChild( $channel ); 612 613 $channelTitle = $doc->createElementTextNode( 'title', $this->attribute( 'title' ) ); 614 $channel->appendChild( $channelTitle ); 615 616 $channelUrl = $doc->createElementTextNode( 'link', $this->attribute( 'url' ) ); 617 $channel->appendChild( $channelUrl ); 618 619 $channelDescription = $doc->createElementTextNode( 'description', $this->attribute( 'description' ) ); 620 $channel->appendChild( $channelDescription ); 621 622 if ( $imageURL !== false ) 623 { 624 $channelImage = $doc->createElementNode( 'image', array( 'rdf:resource' => $imageURL ) ); 625 $channel->appendChild( $channelImage ); 626 627 $image = $doc->createElementNode( 'image', array( 'rdf:about' => $imageURL ) ); 628 629 $imageTitle = $doc->createElementTextNode( 'title', $this->attribute( 'title' ) ); 630 $image->appendChild( $imageTitle ); 631 632 $imageLink = $doc->createElementTextNode( 'link', $this->attribute( 'url' ) ); 633 $image->appendChild( $imageLink ); 634 635 $imageUrlNode = $doc->createElementTextNode( 'url', $imageURL ); 636 $image->appendChild( $imageUrlNode ); 637 638 $root->appendChild( $image ); 639 } 640 641 $items = $doc->createElementNode( 'items' ); 642 $channel->appendChild( $items ); 643 644 $rdfSeq = $doc->createElementNode( 'rdf:Seq' ); 645 $items->appendChild( $rdfSeq ); 646 647 $cond = array( 648 'rssexport_id' => $this->ID, 649 'status' => $this->Status 650 ); 651 $rssSources = eZRSSExportItem::fetchFilteredList( $cond ); 652 653 $nodeArray = eZRSSExportItem::fetchNodeList( $rssSources, $this->getObjectListFilter() ); 654 655 if( is_array( $nodeArray ) && count( $nodeArray ) ) 656 { 657 $attributeMappings = eZRSSExportItem::getAttributeMappings( $rssSources ); 658 } 659 660 foreach ( $nodeArray as $node ) 661 { 662 $object = $node->attribute( 'object' ); 663 $dataMap = $object->dataMap(); 664 if ( $useURLAlias === true ) 665 { 666 $nodeURL = $baseItemURL.$node->urlAlias(); 667 } 668 else 669 { 670 $nodeURL = $baseItemURL.'content/view/full/'.$object->attribute( 'id' ); 671 } 672 673 unset( $rdfSeqLi ); 674 $rdfSeqLi = $doc->createElementNode( 'rdf:li', array( 'rdf:resource' => $nodeURL ) ); 675 $rdfSeq->appendChild( $rdfSeqLi ); 676 677 // keep track if there's any match 678 $doesMatch = false; 679 // start mapping the class attribute to the respective RSS field 680 foreach ( $attributeMappings as $attributeMapping ) 681 { 682 // search for correct mapping by path 683 if ( $attributeMapping[0]->attribute( 'class_id' ) == $object->attribute( 'contentclass_id' ) and 684 in_array( $attributeMapping[0]->attribute( 'source_node_id' ), $node->attribute( 'path_array' ) ) ) 685 { 686 // found it 687 $doesMatch = true; 688 // now fetch the attributes 689 $title = $dataMap[$attributeMapping[0]->attribute( 'title' )]; 690 $description = $dataMap[$attributeMapping[0]->attribute( 'description' )]; 691 break; 692 } 693 } 694 695 if( !$doesMatch ) 696 { 697 // no match 698 eZDebug::writeWarning( __CLASS__.'::'.__FUNCTION__.': Cannot find matching RSS source node for content object in '.__FILE__.', Line '.__LINE__ ); 699 $retValue = null; 700 return $retValue; 701 } 702 703 // title RSS element with respective class attribute content 704 unset( $itemTitle ); 705 $itemTitle = $doc->createElementNode( 'title' ); 706 $titleContent = $title->attribute( 'content' ); 707 if ( get_class( $titleContent ) == 'ezxmltext' ) 708 { 709 $outputHandler = $titleContent->attribute( 'output' ); 710 711 unset( $itemTitleText ); 712 $itemTitleText = $doc->createTextNode( $outputHandler->attribute( 'output_text' ) ); 713 $itemTitle->appendChild( $itemTitleText ); 714 } 715 else 716 { 717 unset( $itemTitleText ); 718 $itemTitleText = $doc->createTextNode( $titleContent ); 719 $itemTitle->appendChild( $itemTitleText ); 720 } 721 722 // description RSS element with respective class attribute content 723 unset( $itemDescription ); 724 $itemDescription = $doc->createElementNode( 'description' ); 725 $descriptionContent = $description->attribute( 'content' ); 726 if ( get_class( $descriptionContent ) == 'ezxmltext' ) 727 { 728 $outputHandler = $descriptionContent->attribute( 'output' ); 729 730 unset( $itemDescriptionText ); 731 $itemDescriptionText = $doc->createTextNode( $outputHandler->attribute( 'output_text' ) ); 732 $itemDescription->appendChild( $itemDescriptionText ); 733 } 734 else 735 { 736 unset( $itemDescriptionText ); 737 $itemDescriptionText = $doc->createTextNode( $descriptionContent ); 738 $itemDescription->appendChild( $itemDescriptionText ); 739 } 740 741 unset( $itemLink ); 742 $itemLink = $doc->createElementNode( 'link' ); 743 744 unset( $itemLinkText ); 745 $itemLinkText = $doc->createTextNode( $nodeURL ); 746 $itemLink->appendChild( $itemLinkText ); 747 748 unset( $item ); 749 $item = $doc->createElementNode( 'item', array ( 'rdf:about' => $nodeURL ) ); 750 751 $item->appendChild( $itemTitle ); 752 $item->appendChild( $itemLink ); 753 $item->appendChild( $itemDescription ); 754 755 $root->appendChild( $item ); 756 } 757 758 return $doc; 759 } 760 761 /*! 762 \private 763 764 Fetch Image from current ezrss export object. If non exist, or invalid, return false 765 766 \return valid image url 767 */ 768 function fetchImageURL() 769 { 770 771 $imageNode = $this->attribute( 'image_node' ); 772 if ( !$imageNode ) 773 return false; 774 775 $imageObject = $imageNode->attribute( 'object' ); 776 if ( !$imageObject ) 777 return false; 778 779 $dataMap = $imageObject->attribute( 'data_map' ); 780 if ( !$dataMap ) 781 return false; 782 783 $imageAttribute = $dataMap['image']; 784 if ( !$imageAttribute ) 785 return false; 786 787 $imageHandler = $imageAttribute->attribute( 'content' ); 788 if ( !$imageHandler ) 789 return false; 790 791 $imageAlias = $imageHandler->imageAlias( 'rss' ); 792 if( !$imageAlias ) 793 return false; 794 795 $url = eZSys::hostname() . eZSys::wwwDir() .'/'. $imageAlias['url']; 796 $url = preg_replace( "#^(//)#", "/", $url ); 797 798 return 'http://'.$url; 799 } 800 } 801 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |