forked from Wavyzz/dolibarr
Fix php8
This commit is contained in:
@@ -51,6 +51,12 @@ class RssParser
|
||||
|
||||
private $current_namespace;
|
||||
|
||||
private $initem;
|
||||
private $intextinput;
|
||||
private $incontent;
|
||||
private $inimage;
|
||||
private $inchannel;
|
||||
|
||||
// For parsing with xmlparser
|
||||
public $stack = array(); // parser stack
|
||||
private $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright');
|
||||
@@ -254,21 +260,26 @@ class RssParser
|
||||
return -1;
|
||||
}
|
||||
|
||||
$xmlparser = xml_parser_create('');
|
||||
try {
|
||||
$xmlparser = xml_parser_create(null);
|
||||
|
||||
if (!is_resource($xmlparser) && !is_object($xmlparser)) {
|
||||
$this->error = "ErrorFailedToCreateParser";
|
||||
return -1;
|
||||
if (!is_resource($xmlparser) && !is_object($xmlparser)) {
|
||||
$this->error = "ErrorFailedToCreateParser";
|
||||
return -1;
|
||||
}
|
||||
|
||||
xml_set_object($xmlparser, $this);
|
||||
xml_set_element_handler($xmlparser, 'feed_start_element', 'feed_end_element');
|
||||
xml_set_character_data_handler($xmlparser, 'feed_cdata');
|
||||
|
||||
$status = xml_parse($xmlparser, $str, false);
|
||||
|
||||
xml_parser_free($xmlparser);
|
||||
$rss = $this;
|
||||
//var_dump($status.' '.$rss->_format);exit;
|
||||
} catch (Exception $e) {
|
||||
$rss = null;
|
||||
}
|
||||
|
||||
xml_set_object($xmlparser, $this);
|
||||
xml_set_element_handler($xmlparser, 'feed_start_element', 'feed_end_element');
|
||||
xml_set_character_data_handler($xmlparser, 'feed_cdata');
|
||||
|
||||
$status = xml_parse($xmlparser, $str);
|
||||
xml_parser_free($xmlparser);
|
||||
$rss = $this;
|
||||
//var_dump($status.' '.$rss->_format);exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,7 +454,7 @@ class RssParser
|
||||
|
||||
// Loop on each category
|
||||
$itemCategory = array();
|
||||
if (is_array($item->category)) {
|
||||
if (!empty($item->category) && is_array($item->category)) {
|
||||
foreach ($item->category as $cat) {
|
||||
$itemCategory[] = (string) $cat;
|
||||
}
|
||||
@@ -514,7 +525,7 @@ class RssParser
|
||||
* @param array $attrs Attributes of tags
|
||||
* @return void
|
||||
*/
|
||||
public function feed_start_element($p, $element, &$attrs)
|
||||
public function feed_start_element($p, $element, $attrs)
|
||||
{
|
||||
// phpcs:enable
|
||||
$el = $element = strtolower($element);
|
||||
@@ -681,9 +692,9 @@ class RssParser
|
||||
public function append_content($text)
|
||||
{
|
||||
// phpcs:enable
|
||||
if ($this->initem) {
|
||||
if (!empty($this->initem)) {
|
||||
$this->concat($this->current_item[$this->incontent], $text);
|
||||
} elseif ($this->inchannel) {
|
||||
} elseif (!empty($this->inchannel)) {
|
||||
$this->concat($this->channel[$this->incontent], $text);
|
||||
}
|
||||
}
|
||||
@@ -700,24 +711,24 @@ class RssParser
|
||||
if (!$el) {
|
||||
return;
|
||||
}
|
||||
if ($this->current_namespace) {
|
||||
if ($this->initem) {
|
||||
if (!empty($this->current_namespace)) {
|
||||
if (!empty($this->initem)) {
|
||||
$this->concat($this->current_item[$this->current_namespace][$el], $text);
|
||||
} elseif ($this->inchannel) {
|
||||
} elseif (!empty($this->inchannel)) {
|
||||
$this->concat($this->channel[$this->current_namespace][$el], $text);
|
||||
} elseif ($this->intextinput) {
|
||||
} elseif (!empty($this->intextinput)) {
|
||||
$this->concat($this->textinput[$this->current_namespace][$el], $text);
|
||||
} elseif ($this->inimage) {
|
||||
} elseif (!empty($this->inimage)) {
|
||||
$this->concat($this->image[$this->current_namespace][$el], $text);
|
||||
}
|
||||
} else {
|
||||
if ($this->initem) {
|
||||
if (!empty($this->initem)) {
|
||||
$this->concat($this->current_item[$el], $text);
|
||||
} elseif ($this->intextinput) {
|
||||
} elseif (!empty($this->intextinput)) {
|
||||
$this->concat($this->textinput[$el], $text);
|
||||
} elseif ($this->inimage) {
|
||||
} elseif (!empty($this->inimage)) {
|
||||
$this->concat($this->image[$el], $text);
|
||||
} elseif ($this->inchannel) {
|
||||
} elseif (!empty($this->inchannel)) {
|
||||
$this->concat($this->channel[$el], $text);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user