Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
546f1441
Commit
546f1441
authored
13 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
New: rss pasrer now support atom feeds
parent
933c59c4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/core/class/rssparser.class.php
+23
-22
23 additions, 22 deletions
htdocs/core/class/rssparser.class.php
with
23 additions
and
22 deletions
htdocs/core/class/rssparser.class.php
+
23
−
22
View file @
546f1441
...
@@ -19,14 +19,14 @@
...
@@ -19,14 +19,14 @@
* \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.
4
2011/08/26 2
2:38:27
eldy Exp $
* \version $Id: rssparser.class.php,v 1.
5
2011/08/26 2
3:06:16
eldy Exp $
*/
*/
class
RssParser
class
RssParser
{
{
var
$db
;
var
$db
;
var
$error
;
var
$error
;
protected
$_format
=
'
rss
'
;
protected
$_format
=
''
;
protected
$_urlRSS
;
protected
$_urlRSS
;
protected
$_language
;
protected
$_language
;
protected
$_generator
;
protected
$_generator
;
...
@@ -56,6 +56,7 @@ class RssParser
...
@@ -56,6 +56,7 @@ class RssParser
// For parsing with xmlparser
// For parsing with xmlparser
var
$stack
=
array
();
// parser stack
var
$stack
=
array
();
// parser stack
var
$_CONTENT_CONSTRUCTS
=
array
(
'content'
,
'summary'
,
'info'
,
'title'
,
'tagline'
,
'copyright'
);
/**
/**
...
@@ -212,6 +213,7 @@ class RssParser
...
@@ -212,6 +213,7 @@ class RssParser
}
}
else
if
(
$rss
->
_format
==
'atom'
)
else
if
(
$rss
->
_format
==
'atom'
)
{
{
//var_dump($rss);
if
(
!
empty
(
$conf
->
global
->
EXTERNALRSS_USE_SIMPLEXML
))
if
(
!
empty
(
$conf
->
global
->
EXTERNALRSS_USE_SIMPLEXML
))
{
{
if
(
!
empty
(
$rss
->
generator
))
$this
->
_generator
=
(
string
)
$rss
->
generator
;
if
(
!
empty
(
$rss
->
generator
))
$this
->
_generator
=
(
string
)
$rss
->
generator
;
...
@@ -222,14 +224,14 @@ class RssParser
...
@@ -222,14 +224,14 @@ class RssParser
}
}
else
else
{
{
if
(
!
empty
(
$rss
->
channel
[
'rss_language'
]))
$this
->
_language
=
(
string
)
$rss
->
channel
[
'rss_language'
];
//
if (!empty($rss->channel['rss_language'])) $this->_language = (string) $rss->channel['rss_language'];
if
(
!
empty
(
$rss
->
channel
[
'
rss_
generator'
]))
$this
->
_generator
=
(
string
)
$rss
->
channel
[
'
rss_
generator'
];
if
(
!
empty
(
$rss
->
channel
[
'generator'
]))
$this
->
_generator
=
(
string
)
$rss
->
channel
[
'generator'
];
if
(
!
empty
(
$rss
->
channel
[
'rss_copyright'
]))
$this
->
_copyright
=
(
string
)
$rss
->
channel
[
'rss_copyright'
];
//
if (!empty($rss->channel['rss_copyright'])) $this->_copyright = (string) $rss->channel['rss_copyright'];
if
(
!
empty
(
$rss
->
channel
[
'
rss_lastbuilddate
'
]))
$this
->
_lastbuilddate
=
(
string
)
$rss
->
channel
[
'
rss_lastbuilddate
'
];
if
(
!
empty
(
$rss
->
channel
[
'
modified
'
]))
$this
->
_lastbuilddate
=
(
string
)
$rss
->
channel
[
'
modified
'
];
if
(
!
empty
(
$rss
->
image
[
'rss_url'
]))
$this
->
_imageurl
=
(
string
)
$rss
->
image
[
'rss_url'
];
//
if (!empty($rss->image['rss_url'])) $this->_imageurl = (string) $rss->image['rss_url'];
if
(
!
empty
(
$rss
->
channel
[
'
rss_
link'
]))
$this
->
_link
=
(
string
)
$rss
->
channel
[
'
rss_
link'
];
if
(
!
empty
(
$rss
->
channel
[
'link'
]))
$this
->
_link
=
(
string
)
$rss
->
channel
[
'link'
];
if
(
!
empty
(
$rss
->
channel
[
'
rss_
title'
]))
$this
->
_title
=
(
string
)
$rss
->
channel
[
'
rss_
title'
];
if
(
!
empty
(
$rss
->
channel
[
'title'
]))
$this
->
_title
=
(
string
)
$rss
->
channel
[
'title'
];
if
(
!
empty
(
$rss
->
channel
[
'rss_description'
]))
$this
->
_description
=
(
string
)
$rss
->
channel
[
'rss_description'
];
//
if (!empty($rss->channel['rss_description'])) $this->_description = (string) $rss->channel['rss_description'];
}
}
if
(
!
empty
(
$conf
->
global
->
EXTERNALRSS_USE_SIMPLEXML
))
{
$tmprss
=
xml2php
(
$rss
);
$items
=
$tmprss
[
'entry'
];}
// With simplexml
if
(
!
empty
(
$conf
->
global
->
EXTERNALRSS_USE_SIMPLEXML
))
{
$tmprss
=
xml2php
(
$rss
);
$items
=
$tmprss
[
'entry'
];}
// With simplexml
else
$items
=
$rss
->
items
;
// With xmlparse
else
$items
=
$rss
->
items
;
// With xmlparse
...
@@ -281,16 +283,16 @@ class RssParser
...
@@ -281,16 +283,16 @@ class RssParser
$itemDescription
=
(
string
)
$item
[
'summary'
];
$itemDescription
=
(
string
)
$item
[
'summary'
];
$itemPubDate
=
(
string
)
$item
[
'created'
];
$itemPubDate
=
(
string
)
$item
[
'created'
];
$itemId
=
(
string
)
$item
[
'id'
];
$itemId
=
(
string
)
$item
[
'id'
];
$itemAuthor
=
''
;
$itemAuthor
=
(
string
)
(
$item
[
'author'
]
?
$item
[
'author'
]
:
$item
[
'author_name'
])
;
}
}
else
else
{
{
$itemLink
=
(
string
)
$item
[
'
rss_
link'
];
$itemLink
=
(
string
)
$item
[
'link
'
][
'href
'
];
$itemTitle
=
(
string
)
$item
[
'
rss_
title'
];
$itemTitle
=
(
string
)
$item
[
'title'
];
$itemDescription
=
(
string
)
$item
[
'
rss_description
'
];
$itemDescription
=
(
string
)
$item
[
'
summary
'
];
$itemPubDate
=
(
string
)
$item
[
'
rss_pubd
ate'
];
$itemPubDate
=
(
string
)
$item
[
'
cre
ate
d
'
];
$itemId
=
(
string
)
$item
[
'
rss_gu
id'
];
$itemId
=
(
string
)
$item
[
'id'
];
$itemAuthor
=
(
string
)
$item
[
'
rss_
author'
];
$itemAuthor
=
(
string
)
(
$item
[
'
author'
]
?
$item
[
'author'
]
:
$item
[
'
author
_name
'
]
)
;
}
}
}
}
else
print
'ErrorBadFeedFormat'
;
else
print
'ErrorBadFeedFormat'
;
...
@@ -342,10 +344,9 @@ class RssParser
...
@@ -342,10 +344,9 @@ class RssParser
$this
->
current_namespace
=
$ns
;
$this
->
current_namespace
=
$ns
;
}
}
# if feed type isn't set, then this is first element of feed
// if feed type isn't set, then this is first element of feed identify feed from root element
# identify feed from root element
if
(
empty
(
$this
->
_format
))
#
{
if
(
!
isset
(
$this
->
_format
)
)
{
if
(
$el
==
'rdf'
)
{
if
(
$el
==
'rdf'
)
{
$this
->
_format
=
'rss'
;
$this
->
_format
=
'rss'
;
$this
->
feed_version
=
'1.0'
;
$this
->
feed_version
=
'1.0'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment