dolibarr  16.0.5
rssparser.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2011-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
27 class RssParser
28 {
32  public $db;
33 
37  public $error = '';
38 
39  private $_format = '';
40  private $_urlRSS;
41  private $_language;
42  private $_generator;
43  private $_copyright;
44  private $_lastbuilddate;
45  private $_imageurl;
46  private $_link;
47  private $_title;
48  private $_description;
49  private $_lastfetchdate; // Last successful fetch
50  private $_rssarray = array();
51 
52  private $current_namespace;
53 
54  private $initem;
55  private $intextinput;
56  private $incontent;
57  private $inimage;
58  private $inchannel;
59 
60  // For parsing with xmlparser
61  public $stack = array(); // parser stack
62  private $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright');
63 
64 
70  public function __construct($db)
71  {
72  $this->db = $db;
73  }
74 
80  public function getFormat()
81  {
82  return $this->_format;
83  }
84 
90  public function getUrlRss()
91  {
92  return $this->_urlRSS;
93  }
99  public function getLanguage()
100  {
101  return $this->_language;
102  }
108  public function getGenerator()
109  {
110  return $this->_generator;
111  }
117  public function getCopyright()
118  {
119  return $this->_copyright;
120  }
126  public function getLastBuildDate()
127  {
128  return $this->_lastbuilddate;
129  }
135  public function getImageUrl()
136  {
137  return $this->_imageurl;
138  }
144  public function getLink()
145  {
146  return $this->_link;
147  }
153  public function getTitle()
154  {
155  return $this->_title;
156  }
162  public function getDescription()
163  {
164  return $this->_description;
165  }
171  public function getLastFetchDate()
172  {
173  return $this->_lastfetchdate;
174  }
180  public function getItems()
181  {
182  return $this->_rssarray;
183  }
184 
185 
195  public function parser($urlRSS, $maxNb = 0, $cachedelay = 60, $cachedir = '')
196  {
197  global $conf;
198 
199  include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
200  include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
201 
202  $rss = '';
203  $str = ''; // This will contain content of feed
204 
205  // Check parameters
206  if (!dol_is_url($urlRSS)) {
207  $this->error = "ErrorBadUrl";
208  return -1;
209  }
210 
211  $this->_urlRSS = $urlRSS;
212  $newpathofdestfile = $cachedir.'/'.dol_hash($this->_urlRSS, 3); // Force md5 hash (does not contains special chars)
213  $newmask = '0644';
214 
215  //dol_syslog("RssPArser::parser parse url=".$urlRSS." => cache file=".$newpathofdestfile);
216  $nowgmt = dol_now();
217 
218  // Search into cache
219  $foundintocache = 0;
220  if ($cachedelay > 0 && $cachedir) {
221  $filedate = dol_filemtime($newpathofdestfile);
222  if ($filedate >= ($nowgmt - $cachedelay)) {
223  //dol_syslog("RssParser::parser cache file ".$newpathofdestfile." is not older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we use it.");
224  $foundintocache = 1;
225 
226  $this->_lastfetchdate = $filedate;
227  } else {
228  dol_syslog(get_class($this)."::parser cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it.");
229  }
230  }
231 
232  // Load file into $str
233  if ($foundintocache) { // Cache file found and is not too old
234  $str = file_get_contents($newpathofdestfile);
235  } else {
236  try {
237  $result = getURLContent($this->_urlRSS, 'GET', '', 1, array(), array('http', 'https'), 0);
238 
239  if (!empty($result['content'])) {
240  $str = $result['content'];
241  } elseif (!empty($result['curl_error_msg'])) {
242  $this->error = 'Error retrieving URL '.$this->_urlRSS.' - '.$result['curl_error_msg'];
243  return -1;
244  }
245  } catch (Exception $e) {
246  $this->error = 'Error retrieving URL '.$this->_urlRSS.' - '.$e->getMessage();
247  return -2;
248  }
249  }
250 
251  if ($str !== false) {
252  // Convert $str into xml
253  if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) {
254  //print 'xx'.LIBXML_NOCDATA;
255  libxml_use_internal_errors(false);
256  $rss = simplexml_load_string($str, "SimpleXMLElement", LIBXML_NOCDATA|LIBXML_NOCDATA);
257  } else {
258  if (!function_exists('xml_parser_create')) {
259  $this->error = 'Function xml_parser_create are not supported by your PHP';
260  return -1;
261  }
262 
263  try {
264  $xmlparser = xml_parser_create(null);
265 
266  if (!is_resource($xmlparser) && !is_object($xmlparser)) {
267  $this->error = "ErrorFailedToCreateParser";
268  return -1;
269  }
270 
271  xml_set_object($xmlparser, $this);
272  xml_set_element_handler($xmlparser, 'feed_start_element', 'feed_end_element');
273  xml_set_character_data_handler($xmlparser, 'feed_cdata');
274 
275  $status = xml_parse($xmlparser, $str, false);
276 
277  xml_parser_free($xmlparser);
278  $rss = $this;
279  //var_dump($status.' '.$rss->_format);exit;
280  } catch (Exception $e) {
281  $rss = null;
282  }
283  }
284  }
285 
286  // If $rss loaded
287  if ($rss) {
288  // Save file into cache
289  if (empty($foundintocache) && $cachedir) {
290  dol_syslog(get_class($this)."::parser cache file ".$newpathofdestfile." is saved onto disk.");
291  if (!dol_is_dir($cachedir)) {
292  dol_mkdir($cachedir);
293  }
294  $fp = fopen($newpathofdestfile, 'w');
295  if ($fp) {
296  fwrite($fp, $str);
297  fclose($fp);
298  if (!empty($conf->global->MAIN_UMASK)) {
299  $newmask = $conf->global->MAIN_UMASK;
300  }
301  @chmod($newpathofdestfile, octdec($newmask));
302 
303  $this->_lastfetchdate = $nowgmt;
304  } else {
305  print 'Error, failed to open file '.$newpathofdestfile.' for write';
306  }
307  }
308 
309  unset($str); // Free memory
310 
311  if (empty($rss->_format)) { // If format not detected automatically
312  $rss->_format = 'rss';
313  if (empty($rss->channel)) {
314  $rss->_format = 'atom';
315  }
316  }
317 
318  $items = array();
319 
320  // Save description entries
321  if ($rss->_format == 'rss') {
322  //var_dump($rss);
323  if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) {
324  if (!empty($rss->channel->language)) {
325  $this->_language = (string) $rss->channel->language;
326  }
327  if (!empty($rss->channel->generator)) {
328  $this->_generator = (string) $rss->channel->generator;
329  }
330  if (!empty($rss->channel->copyright)) {
331  $this->_copyright = (string) $rss->channel->copyright;
332  }
333  if (!empty($rss->channel->lastbuilddate)) {
334  $this->_lastbuilddate = (string) $rss->channel->lastbuilddate;
335  }
336  if (!empty($rss->channel->image->url[0])) {
337  $this->_imageurl = (string) $rss->channel->image->url[0];
338  }
339  if (!empty($rss->channel->link)) {
340  $this->_link = (string) $rss->channel->link;
341  }
342  if (!empty($rss->channel->title)) {
343  $this->_title = (string) $rss->channel->title;
344  }
345  if (!empty($rss->channel->description)) {
346  $this->_description = (string) $rss->channel->description;
347  }
348  } else {
349  //var_dump($rss->channel);
350  if (!empty($rss->channel['language'])) {
351  $this->_language = (string) $rss->channel['language'];
352  }
353  if (!empty($rss->channel['generator'])) {
354  $this->_generator = (string) $rss->channel['generator'];
355  }
356  if (!empty($rss->channel['copyright'])) {
357  $this->_copyright = (string) $rss->channel['copyright'];
358  }
359  if (!empty($rss->channel['lastbuilddate'])) {
360  $this->_lastbuilddate = (string) $rss->channel['lastbuilddate'];
361  }
362  if (!empty($rss->image['url'])) {
363  $this->_imageurl = (string) $rss->image['url'];
364  }
365  if (!empty($rss->channel['link'])) {
366  $this->_link = (string) $rss->channel['link'];
367  }
368  if (!empty($rss->channel['title'])) {
369  $this->_title = (string) $rss->channel['title'];
370  }
371  if (!empty($rss->channel['description'])) {
372  $this->_description = (string) $rss->channel['description'];
373  }
374  }
375 
376  if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) {
377  $items = $rss->channel->item; // With simplexml
378  } else {
379  $items = $rss->items; // With xmlparse
380  }
381  //var_dump($items);exit;
382  } elseif ($rss->_format == 'atom') {
383  //var_dump($rss);
384  if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) {
385  if (!empty($rss->generator)) {
386  $this->_generator = (string) $rss->generator;
387  }
388  if (!empty($rss->lastbuilddate)) {
389  $this->_lastbuilddate = (string) $rss->modified;
390  }
391  if (!empty($rss->link->href)) {
392  $this->_link = (string) $rss->link->href;
393  }
394  if (!empty($rss->title)) {
395  $this->_title = (string) $rss->title;
396  }
397  if (!empty($rss->description)) {
398  $this->_description = (string) $rss->description;
399  }
400  } else {
401  //if (!empty($rss->channel['rss_language'])) $this->_language = (string) $rss->channel['rss_language'];
402  if (!empty($rss->channel['generator'])) {
403  $this->_generator = (string) $rss->channel['generator'];
404  }
405  //if (!empty($rss->channel['rss_copyright'])) $this->_copyright = (string) $rss->channel['rss_copyright'];
406  if (!empty($rss->channel['modified'])) {
407  $this->_lastbuilddate = (string) $rss->channel['modified'];
408  }
409  //if (!empty($rss->image['rss_url'])) $this->_imageurl = (string) $rss->image['rss_url'];
410  if (!empty($rss->channel['link'])) {
411  $this->_link = (string) $rss->channel['link'];
412  }
413  if (!empty($rss->channel['title'])) {
414  $this->_title = (string) $rss->channel['title'];
415  }
416  //if (!empty($rss->channel['rss_description'])) $this->_description = (string) $rss->channel['rss_description'];
417 
418  if (!empty($rss->channel)) {
419  $this->_imageurl = $this->getAtomImageUrl($rss->channel);
420  }
421  }
422  if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) {
423  $tmprss = xml2php($rss);
424  $items = $tmprss['entry'];
425  } else {
426  // With simplexml
427  $items = $rss->items; // With xmlparse
428  }
429  //var_dump($items);exit;
430  }
431 
432  $i = 0;
433 
434  // Loop on each record
435  if (is_array($items)) {
436  foreach ($items as $item) {
437  //var_dump($item);exit;
438  if ($rss->_format == 'rss') {
439  if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) {
440  $itemLink = (string) $item->link;
441  $itemTitle = (string) $item->title;
442  $itemDescription = (string) $item->description;
443  $itemPubDate = (string) $item->pubDate;
444  $itemId = '';
445  $itemAuthor = '';
446  } else {
447  $itemLink = (string) $item['link'];
448  $itemTitle = (string) $item['title'];
449  $itemDescription = (string) $item['description'];
450  $itemPubDate = (string) $item['pubdate'];
451  $itemId = (string) $item['guid'];
452  $itemAuthor = (string) $item['author'];
453  }
454 
455  // Loop on each category
456  $itemCategory = array();
457  if (!empty($item->category) && is_array($item->category)) {
458  foreach ($item->category as $cat) {
459  $itemCategory[] = (string) $cat;
460  }
461  }
462  } elseif ($rss->_format == 'atom') {
463  if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) {
464  $itemLink = (isset($item['link']) ? (string) $item['link'] : '');
465  $itemTitle = (string) $item['title'];
466  $itemDescription = $this->getAtomItemDescription($item);
467  $itemPubDate = (string) $item['created'];
468  $itemId = (string) $item['id'];
469  $itemAuthor = (string) ($item['author'] ? $item['author'] : $item['author_name']);
470  } else {
471  $itemLink = (isset($item['link']) ? (string) $item['link'] : '');
472  $itemTitle = (string) $item['title'];
473  $itemDescription = $this->getAtomItemDescription($item);
474  $itemPubDate = (string) $item['created'];
475  $itemId = (string) $item['id'];
476  $itemAuthor = (string) ($item['author'] ? $item['author'] : $item['author_name']);
477  }
478  $itemCategory = array();
479  } else {
480  $itemCategory = array();
481  $itemLink = '';
482  $itemTitle = '';
483  $itemDescription = '';
484  $itemPubDate = '';
485  $itemId = '';
486  $itemAuthor = '';
487  print 'ErrorBadFeedFormat';
488  }
489 
490  // Add record to result array
491  $this->_rssarray[$i] = array(
492  'link'=>$itemLink,
493  'title'=>$itemTitle,
494  'description'=>$itemDescription,
495  'pubDate'=>$itemPubDate,
496  'category'=>$itemCategory,
497  'id'=>$itemId,
498  'author'=>$itemAuthor
499  );
500  //var_dump($this->_rssarray);
501 
502  $i++;
503 
504  if ($i > $maxNb) {
505  break; // We get all records we want
506  }
507  }
508  }
509 
510  return 1;
511  } else {
512  $this->error = 'ErrorFailedToLoadRSSFile';
513  return -1;
514  }
515  }
516 
517 
518 
519  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
528  public function feed_start_element($p, $element, $attrs)
529  {
530  // phpcs:enable
531  $el = $element = strtolower($element);
532  $attrs = array_change_key_case($attrs, CASE_LOWER);
533 
534  // check for a namespace, and split if found
535  $ns = false;
536  if (strpos($element, ':')) {
537  list($ns, $el) = explode(':', $element, 2);
538  }
539  if ($ns and $ns != 'rdf') {
540  $this->current_namespace = $ns;
541  }
542 
543  // if feed type isn't set, then this is first element of feed identify feed from root element
544  if (empty($this->_format)) {
545  if ($el == 'rdf') {
546  $this->_format = 'rss';
547  $this->feed_version = '1.0';
548  } elseif ($el == 'rss') {
549  $this->_format = 'rss';
550  $this->feed_version = $attrs['version'];
551  } elseif ($el == 'feed') {
552  $this->_format = 'atom';
553  $this->feed_version = $attrs['version'];
554  $this->inchannel = true;
555  }
556  return;
557  }
558 
559  if ($el == 'channel') {
560  $this->inchannel = true;
561  } elseif ($el == 'item' || $el == 'entry') {
562  $this->initem = true;
563  if (isset($attrs['rdf:about'])) {
564  $this->current_item['about'] = $attrs['rdf:about'];
565  }
566  } elseif ($this->_format == 'rss' && $this->current_namespace == '' && $el == 'textinput') {
567  // if we're in the default namespace of an RSS feed,
568  // record textinput or image fields
569  $this->intextinput = true;
570  } elseif ($this->_format == 'rss' && $this->current_namespace == '' && $el == 'image') {
571  $this->inimage = true;
572  } elseif ($this->_format == 'atom' && in_array($el, $this->_CONTENT_CONSTRUCTS)) {
573  // handle atom content constructs
574  // avoid clashing w/ RSS mod_content
575  if ($el == 'content') {
576  $el = 'atom_content';
577  }
578 
579  $this->incontent = $el;
580  } elseif ($this->_format == 'atom' && $this->incontent) {
581  // if inside an Atom content construct (e.g. content or summary) field treat tags as text
582  // if tags are inlined, then flatten
583  $attrs_str = join(' ', array_map('map_attrs', array_keys($attrs), array_values($attrs)));
584 
585  $this->append_content("<$element $attrs_str>");
586 
587  array_unshift($this->stack, $el);
588  } elseif ($this->_format == 'atom' && $el == 'link') {
589  // Atom support many links per containging element.
590  // Magpie treats link elements of type rel='alternate'
591  // as being equivalent to RSS's simple link element.
592  if (isset($attrs['rel']) && $attrs['rel'] == 'alternate') {
593  $link_el = 'link';
594  } elseif (!isset($attrs['rel'])) {
595  $link_el = 'link';
596  } else {
597  $link_el = 'link_'.$attrs['rel'];
598  }
599 
600  $this->append($link_el, $attrs['href']);
601  } else {
602  // set stack[0] to current element
603  array_unshift($this->stack, $el);
604  }
605  }
606 
607 
608  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
616  public function feed_cdata($p, $text)
617  {
618  // phpcs:enable
619  if ($this->_format == 'atom' and $this->incontent) {
620  $this->append_content($text);
621  } else {
622  $current_el = join('_', array_reverse($this->stack));
623  $this->append($current_el, $text);
624  }
625  }
626 
627  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
635  public function feed_end_element($p, $el)
636  {
637  // phpcs:enable
638  $el = strtolower($el);
639 
640  if ($el == 'item' or $el == 'entry') {
641  $this->items[] = $this->current_item;
642  $this->current_item = array();
643  $this->initem = false;
644  } elseif ($this->_format == 'rss' and $this->current_namespace == '' and $el == 'textinput') {
645  $this->intextinput = false;
646  } elseif ($this->_format == 'rss' and $this->current_namespace == '' and $el == 'image') {
647  $this->inimage = false;
648  } elseif ($this->_format == 'atom' and in_array($el, $this->_CONTENT_CONSTRUCTS)) {
649  $this->incontent = false;
650  } elseif ($el == 'channel' or $el == 'feed') {
651  $this->inchannel = false;
652  } elseif ($this->_format == 'atom' and $this->incontent) {
653  // balance tags properly
654  // note: i don't think this is actually neccessary
655  if ($this->stack[0] == $el) {
656  $this->append_content("</$el>");
657  } else {
658  $this->append_content("<$el />");
659  }
660 
661  array_shift($this->stack);
662  } else {
663  array_shift($this->stack);
664  }
665 
666  $this->current_namespace = false;
667  }
668 
669 
677  public function concat(&$str1, $str2 = "")
678  {
679  if (!isset($str1)) {
680  $str1 = "";
681  }
682  $str1 .= $str2;
683  }
684 
685  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
692  public function append_content($text)
693  {
694  // phpcs:enable
695  if (!empty($this->initem)) {
696  $this->concat($this->current_item[$this->incontent], $text);
697  } elseif (!empty($this->inchannel)) {
698  $this->concat($this->channel[$this->incontent], $text);
699  }
700  }
701 
709  public function append($el, $text)
710  {
711  if (!$el) {
712  return;
713  }
714  if (!empty($this->current_namespace)) {
715  if (!empty($this->initem)) {
716  $this->concat($this->current_item[$this->current_namespace][$el], $text);
717  } elseif (!empty($this->inchannel)) {
718  $this->concat($this->channel[$this->current_namespace][$el], $text);
719  } elseif (!empty($this->intextinput)) {
720  $this->concat($this->textinput[$this->current_namespace][$el], $text);
721  } elseif (!empty($this->inimage)) {
722  $this->concat($this->image[$this->current_namespace][$el], $text);
723  }
724  } else {
725  if (!empty($this->initem)) {
726  $this->concat($this->current_item[$el], $text);
727  } elseif (!empty($this->intextinput)) {
728  $this->concat($this->textinput[$el], $text);
729  } elseif (!empty($this->inimage)) {
730  $this->concat($this->image[$el], $text);
731  } elseif (!empty($this->inchannel)) {
732  $this->concat($this->channel[$el], $text);
733  }
734  }
735  }
736 
744  private function getAtomItemDescription(array $item, $maxlength = 500)
745  {
746  $result = "";
747 
748  if (isset($item['summary'])) {
749  $result = $item['summary'];
750  } elseif (isset($item['atom_content'])) {
751  $result = $item['atom_content'];
752  }
753 
754  // remove all HTML elements that can possible break the maximum size of a tooltip,
755  // like headings, image, video etc. and allow only simple style elements
756  $result = strip_tags($result, "<br><p><ul><ol><li>");
757 
758  $result = str_replace("\n", "", $result);
759 
760  if (strlen($result) > $maxlength) {
761  $result = substr($result, 0, $maxlength);
762  $result .= "...";
763  }
764 
765  return $result;
766  }
767 
774  private function getAtomImageUrl(array $feed)
775  {
776  if (isset($feed['icon'])) {
777  return $feed['logo'];
778  }
779 
780  if (isset($feed['icon'])) {
781  return $feed['logo'];
782  }
783 
784  if (isset($feed['webfeeds:logo'])) {
785  return $feed['webfeeds:logo'];
786  }
787 
788  if (isset($feed['webfeeds:icon'])) {
789  return $feed['webfeeds:icon'];
790  }
791 
792  if (isset($feed['webfeeds:wordmark'])) {
793  return $feed['webfeeds:wordmark'];
794  }
795 
796  return "";
797  }
798 }
799 
800 
807 function xml2php($xml)
808 {
809  $fils = 0;
810  $tab = false;
811  $array = array();
812  foreach ($xml->children() as $key => $value) {
813  $child = xml2php($value);
814 
815  //To deal with the attributes
816  foreach ($value->attributes() as $ak => $av) {
817  $child[$ak] = (string) $av;
818  }
819 
820  //Let see if the new child is not in the array
821  if ($tab === false && in_array($key, array_keys($array))) {
822  //If this element is already in the array we will create an indexed array
823  $tmp = $array[$key];
824  $array[$key] = null;
825  $array[$key][] = $tmp;
826  $array[$key][] = $child;
827  $tab = true;
828  } elseif ($tab === true) {
829  //Add an element in an existing array
830  $array[$key][] = $child;
831  } else {
832  //Add a simple element
833  $array[$key] = $child;
834  }
835 
836  $fils++;
837  }
838 
839 
840  if ($fils == 0) {
841  return (string) $xml;
842  }
843 
844  return $array;
845 }
dol_is_url
dol_is_url($url)
Return if path is an URL.
Definition: files.lib.php:501
db
$conf db
API class for accounts.
Definition: inc.php:41
RssParser\feed_start_element
feed_start_element($p, $element, $attrs)
Triggered when opened tag is found.
Definition: rssparser.class.php:528
xml2php
xml2php($xml)
Function to convert an XML object into an array.
Definition: rssparser.class.php:807
dol_filemtime
dol_filemtime($pathoffile)
Return time of a file.
Definition: files.lib.php:593
RssParser\concat
concat(&$str1, $str2="")
To concat 2 string with no warning if an operand is not defined.
Definition: rssparser.class.php:677
RssParser\getItems
getItems()
getItems
Definition: rssparser.class.php:180
RssParser\feed_end_element
feed_end_element($p, $el)
Triggered when closed tag is found.
Definition: rssparser.class.php:635
getURLContent
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1)
Function to get a content from an URL (use proxy if proxy defined).
Definition: geturl.lib.php:41
RssParser\getAtomItemDescription
getAtomItemDescription(array $item, $maxlength=500)
Return a description/summary for one item from a ATOM feed.
Definition: rssparser.class.php:744
RssParser\append
append($el, $text)
smart append - field and namespace aware
Definition: rssparser.class.php:709
dol_hash
dol_hash($chain, $type='0')
Returns a hash of a string.
Definition: security.lib.php:104
Exception
RssParser\__construct
__construct($db)
Constructor.
Definition: rssparser.class.php:70
RssParser\getLanguage
getLanguage()
getLanguage
Definition: rssparser.class.php:99
RssParser\getFormat
getFormat()
getFormat
Definition: rssparser.class.php:80
RssParser\getAtomImageUrl
getAtomImageUrl(array $feed)
Return a URL to a image of the given ATOM feed.
Definition: rssparser.class.php:774
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
RssParser
Class to parse RSS files.
Definition: rssparser.class.php:27
RssParser\getImageUrl
getImageUrl()
getImageUrl
Definition: rssparser.class.php:135
RssParser\getCopyright
getCopyright()
getCopyright
Definition: rssparser.class.php:117
RssParser\getGenerator
getGenerator()
getGenerator
Definition: rssparser.class.php:108
RssParser\getDescription
getDescription()
getDescription
Definition: rssparser.class.php:162
RssParser\getLink
getLink()
getLink
Definition: rssparser.class.php:144
RssParser\getLastFetchDate
getLastFetchDate()
getLastFetchDate
Definition: rssparser.class.php:171
RssParser\append_content
append_content($text)
Enter description here ...
Definition: rssparser.class.php:692
RssParser\feed_cdata
feed_cdata($p, $text)
Triggered when CDATA is found.
Definition: rssparser.class.php:616
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
dol_is_dir
dol_is_dir($folder)
Test if filename is a directory.
Definition: files.lib.php:447
RssParser\parser
parser($urlRSS, $maxNb=0, $cachedelay=60, $cachedir='')
Parse rss URL.
Definition: rssparser.class.php:195
dol_mkdir
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Definition: functions.lib.php:6603
RssParser\getTitle
getTitle()
getTitle
Definition: rssparser.class.php:153
RssParser\getLastBuildDate
getLastBuildDate()
getLastBuildDate
Definition: rssparser.class.php:126
RssParser\getUrlRss
getUrlRss()
getUrlRss
Definition: rssparser.class.php:90