Dev/15442 Adaptation des flux RSS pour intégration des carrousels sur yonne-biblio.fr
Merge request reports
Activity
Filter activity
529 542 return($flux); 530 543 } 531 544 545 protected function getMediaContentsFromHTMLDescription($description) { 546 $media_contents = []; 547 548 if (preg_match('/<img/', $description)) { 549 $description = preg_replace('/<!\[CDATA\[(.*)\]\]>/s', '$1', $description); 550 $doc = new DOMDocument(); 551 $doc->loadHTML($description); 552 $imgs = $doc->getElementsByTagName('img'); 553 554 foreach ($imgs as $img) { 555 $url = $img->attributes->getNamedItem('src')->nodeValue; 556 if ($url[0] == '/') { 557 $url = 'http://' . $_SERVER['SERVER_NAME'] . $url; 508 <rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/"> 509 509 <channel> 510 510 <title>'.$data_array["titre"].'</title> 511 <link>'.$data_array["lien"].'</link> 512 <description>'.$data_array["description"].'</description> 513 <image> 511 <link>'.$data_array["lien"].'</link>'; 512 if (isset($data_array['description'])) { 513 $flux .= '<description>'.$data_array["description"].'</description>'; 514 } 515 if (isset($data_array['lastBuildDate'])) { 516 $lastBuildDate = date(DATE_RSS, $data_array['lastBuildDate']); 517 $flux .= '<lastBuildDate>' . $lastBuildDate . '</lastBuildDate>'; 518 } 519 $flux .= '<image> 514 520 <url>http://'.$_SERVER['SERVER_NAME'].URL_IMG.'site/logo.jpg</url> 353 352 } 354 353 355 354 356 $entries = array(); 355 $items = []; 357 356 foreach($notices as $notice) { 358 $entries []= array( 359 'title' => $notice["titre"].', '.$notice["auteur"], 360 'link' => 'http://' . $_SERVER['SERVER_NAME'].BASE_URL.'/recherche/viewnotice/id/'.$notice['id_notice'], 361 'description' => $this->_noticeRssDescription($notice), 362 'lastUpdate' => strtotime($notice['date_maj'])); 357 $items[] = [ 358 'titre' => $notice["titre"] . ', ' . $notice["auteur"], 359 'lien' => 'http://' . $_SERVER['SERVER_NAME'] . BASE_URL . '/recherche/viewnotice/id/' . $notice['id_notice'], 530 . '<description>'.$item["desc"].'</description>'; 531 if (isset($item['pubDate'])) { 532 $pubDate = date(DATE_RSS, $item['pubDate']); 533 $flux .= '<pubDate>' . $pubDate . '</pubDate>'; 534 } 535 foreach ($media_contents as $mc) { 536 $flux .= '<media:content url="' . $mc['url'] . '"/>'; 526 537 } 538 $flux .= '</item>'; 539 } 527 540 528 541 $flux.='</channel></rss>'; 529 542 return($flux); 530 543 } 531 544 545 protected function getMediaContentsFromHTMLDescription($description) {
Please register or sign in to reply