Trans
This commit is contained in:
parent
25a6276563
commit
25a5a7ee30
@ -19,7 +19,7 @@
|
|||||||
* \file htdocs/core/class/rssparser.class.php
|
* \file htdocs/core/class/rssparser.class.php
|
||||||
* \ingroup core
|
* \ingroup core
|
||||||
* \brief File of class to parse rss feeds
|
* \brief File of class to parse rss feeds
|
||||||
* \version $Id: rssparser.class.php,v 1.3 2011/08/26 19:09:02 eldy Exp $
|
* \version $Id: rssparser.class.php,v 1.2 2011/08/26 17:59:14 eldy Exp $
|
||||||
*/
|
*/
|
||||||
class RssParser
|
class RssParser
|
||||||
{
|
{
|
||||||
@ -116,14 +116,8 @@ class RssParser
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
ini_set("user_agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
|
|
||||||
ini_set("max_execution_time", 10);
|
|
||||||
if (! empty($conf->global->MAIN_SIMPLEXMLLOAD_DEBUG)) $rss = simplexml_load_file($this->_urlRSS);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//libxml_use_internal_errors(false);
|
|
||||||
$rss = @simplexml_load_file($this->_urlRSS);
|
$rss = @simplexml_load_file($this->_urlRSS);
|
||||||
}
|
var_dump($this->_urlRSS);
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
print 'Error retrieving URL '.$this->urlRSS.' - '.$e->getMessage();
|
print 'Error retrieving URL '.$this->urlRSS.' - '.$e->getMessage();
|
||||||
@ -133,8 +127,6 @@ class RssParser
|
|||||||
// If $rss loaded
|
// If $rss loaded
|
||||||
if ($rss)
|
if ($rss)
|
||||||
{
|
{
|
||||||
$items=array();
|
|
||||||
|
|
||||||
// Save file into cache
|
// Save file into cache
|
||||||
if (empty($foundintocache) && $cachedir)
|
if (empty($foundintocache) && $cachedir)
|
||||||
{
|
{
|
||||||
@ -149,12 +141,7 @@ class RssParser
|
|||||||
$this->_lastfetchdate=$nowgmt;
|
$this->_lastfetchdate=$nowgmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rss->_format='rss';
|
|
||||||
if (empty($rss->channel)) $rss->_format='atom';
|
|
||||||
|
|
||||||
// Save description entries
|
// Save description entries
|
||||||
if ($rss->_format == 'rss')
|
|
||||||
{
|
|
||||||
if (!empty($rss->channel->language)) $this->_language = (string) $rss->channel->language;
|
if (!empty($rss->channel->language)) $this->_language = (string) $rss->channel->language;
|
||||||
if (!empty($rss->channel->generator)) $this->_generator = (string) $rss->channel->generator;
|
if (!empty($rss->channel->generator)) $this->_generator = (string) $rss->channel->generator;
|
||||||
if (!empty($rss->channel->copyright)) $this->_copyright = (string) $rss->channel->copyright;
|
if (!empty($rss->channel->copyright)) $this->_copyright = (string) $rss->channel->copyright;
|
||||||
@ -163,30 +150,17 @@ class RssParser
|
|||||||
if (!empty($rss->channel->link)) $this->_link = (string) $rss->channel->link;
|
if (!empty($rss->channel->link)) $this->_link = (string) $rss->channel->link;
|
||||||
if (!empty($rss->channel->title)) $this->_title = (string) $rss->channel->title;
|
if (!empty($rss->channel->title)) $this->_title = (string) $rss->channel->title;
|
||||||
if (!empty($rss->channel->description)) $this->_description = (string) $rss->channel->description;
|
if (!empty($rss->channel->description)) $this->_description = (string) $rss->channel->description;
|
||||||
$items=$rss->channel->item;
|
// TODO imageurl
|
||||||
}
|
|
||||||
else if ($rss->_format == 'atom')
|
|
||||||
{
|
|
||||||
if (!empty($rss->generator)) $this->_generator = (string) $rss->generator;
|
|
||||||
if (!empty($rss->lastbuilddate)) $this->_lastbuilddate = (string) $rss->modified;
|
|
||||||
if (!empty($rss->link->href)) $this->_link = (string) $rss->link->href;
|
|
||||||
if (!empty($rss->title)) $this->_title = (string) $rss->title;
|
|
||||||
if (!empty($rss->description)) $this->_description = (string) $rss->description;
|
|
||||||
$tmprss=xml2php($rss);
|
|
||||||
$items=$tmprss['entry'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
// Loop on each record
|
// Loop on each record
|
||||||
foreach($items as $item)
|
foreach($rss->channel->item as $item)
|
||||||
{
|
|
||||||
if ($rss->_format == 'rss')
|
|
||||||
{
|
{
|
||||||
$itemLink = (string) $item->link;
|
$itemLink = (string) $item->link;
|
||||||
$itemTitle = (string) $item->title;
|
$itemTitle = (string) $item->title;
|
||||||
$itemDescription = (string) $item->description;
|
$itemDescription = (string) $item->description;
|
||||||
$itemPubDate = (string) $item->pubDate;
|
$itemPubDate = (string) $item->pubDate;
|
||||||
$itemId = '';
|
|
||||||
|
|
||||||
// Loop on each category
|
// Loop on each category
|
||||||
$itemCategory=array();
|
$itemCategory=array();
|
||||||
@ -194,15 +168,6 @@ class RssParser
|
|||||||
{
|
{
|
||||||
$itemCategory[] = (string) $cat;
|
$itemCategory[] = (string) $cat;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if ($rss->_format == 'atom')
|
|
||||||
{
|
|
||||||
$itemLink = (string) $item['link']['href'];
|
|
||||||
$itemTitle = (string) $item['title'];
|
|
||||||
$itemDescription = (string) $item['summary'];
|
|
||||||
$itemPubDate = (string) $item['created'];
|
|
||||||
$itemId = (string) $item['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add record to result array
|
// Add record to result array
|
||||||
$this->_rssarray[$i] = array(
|
$this->_rssarray[$i] = array(
|
||||||
@ -210,8 +175,7 @@ class RssParser
|
|||||||
'title'=>$itemTitle,
|
'title'=>$itemTitle,
|
||||||
'description'=>$itemDescription,
|
'description'=>$itemDescription,
|
||||||
'pubDate'=>$itemPubDate,
|
'pubDate'=>$itemPubDate,
|
||||||
'category'=>$itemCategory,
|
'category'=>$itemCategory);
|
||||||
'id'=>$itemId);
|
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
@ -228,59 +192,4 @@ class RssParser
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to convert an XML object into an array
|
|
||||||
*/
|
|
||||||
function xml2php($xml)
|
|
||||||
{
|
|
||||||
$fils = 0;
|
|
||||||
$tab = false;
|
|
||||||
$array = array();
|
|
||||||
foreach($xml->children() as $key => $value)
|
|
||||||
{
|
|
||||||
$child = xml2php($value);
|
|
||||||
|
|
||||||
//To deal with the attributes
|
|
||||||
foreach($value->attributes() as $ak=>$av)
|
|
||||||
{
|
|
||||||
$child[$ak] = (string)$av;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Let see if the new child is not in the array
|
|
||||||
if($tab==false && in_array($key,array_keys($array)))
|
|
||||||
{
|
|
||||||
//If this element is already in the array we will create an indexed array
|
|
||||||
$tmp = $array[$key];
|
|
||||||
$array[$key] = NULL;
|
|
||||||
$array[$key][] = $tmp;
|
|
||||||
$array[$key][] = $child;
|
|
||||||
$tab = true;
|
|
||||||
}
|
|
||||||
elseif($tab == true)
|
|
||||||
{
|
|
||||||
//Add an element in an existing array
|
|
||||||
$array[$key][] = $child;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Add a simple element
|
|
||||||
$array[$key] = $child;
|
|
||||||
}
|
|
||||||
|
|
||||||
$fils++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if($fils==0)
|
|
||||||
{
|
|
||||||
return (string)$xml;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $array;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -877,7 +877,6 @@ DocumentModelOdt=Generate documents from OpenDocuments templates (.ODT files for
|
|||||||
WatermarkOnDraft=Watermark on draft document
|
WatermarkOnDraft=Watermark on draft document
|
||||||
CompanyIdProfChecker=Professional Id unique
|
CompanyIdProfChecker=Professional Id unique
|
||||||
MustBeUnique=Must be unique ?
|
MustBeUnique=Must be unique ?
|
||||||
Miscellanous=Miscellanous
|
|
||||||
##### Webcal setup #####
|
##### Webcal setup #####
|
||||||
WebCalSetup=Webcalendar link setup
|
WebCalSetup=Webcalendar link setup
|
||||||
WebCalSyncro=Add Dolibarr events to WebCalendar
|
WebCalSyncro=Add Dolibarr events to WebCalendar
|
||||||
|
|||||||
@ -885,7 +885,6 @@ DocumentModelOdt=Genération depuis des modèles OpenDocument (Fichier .ODT Open
|
|||||||
WatermarkOnDraft=Filigrane sur les documents brouillons
|
WatermarkOnDraft=Filigrane sur les documents brouillons
|
||||||
CompanyIdProfChecker=Id professionel unique
|
CompanyIdProfChecker=Id professionel unique
|
||||||
MustBeUnique=Doit être unique ?
|
MustBeUnique=Doit être unique ?
|
||||||
Miscellanous=Miscellanous
|
|
||||||
##### Webcal setup #####
|
##### Webcal setup #####
|
||||||
WebCalSetup= Configuration du lien vers le calendrier Webcalendar
|
WebCalSetup= Configuration du lien vers le calendrier Webcalendar
|
||||||
WebCalSyncro= Intégrer les événements Dolibarr dans WebCalendar
|
WebCalSyncro= Intégrer les événements Dolibarr dans WebCalendar
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user