Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Feeds
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MickGe
Feeds
Commits
d4992d6b
Commit
d4992d6b
authored
11 years ago
by
Andrew Dolgov
Browse files
Options
Downloads
Patches
Plain Diff
add support for dc:subject and slash:comments
parent
ee78f81c
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
classes/feeditem/atom.php
+23
-1
23 additions, 1 deletion
classes/feeditem/atom.php
classes/feeditem/rss.php
+10
-3
10 additions, 3 deletions
classes/feeditem/rss.php
classes/feedparser.php
+3
-0
3 additions, 0 deletions
classes/feedparser.php
include/rssfuncs.php
+1
-7
1 addition, 7 deletions
include/rssfuncs.php
with
37 additions
and
11 deletions
classes/feeditem/atom.php
+
23
−
1
View file @
d4992d6b
<?php
<?php
class
FeedItem_Atom
{
class
FeedItem_Atom
{
private
$elem
;
private
$elem
;
private
$xpath
;
function
__construct
(
$elem
,
$doc
,
$xpath
)
{
function
__construct
(
$elem
,
$doc
,
$xpath
)
{
$this
->
elem
=
$elem
;
$this
->
elem
=
$elem
;
$this
->
xpath
=
$xpath
;
}
}
function
get_id
()
{
function
get_id
()
{
...
@@ -63,9 +65,12 @@ class FeedItem_Atom {
...
@@ -63,9 +65,12 @@ class FeedItem_Atom {
}
}
// todo
function
get_comments_count
()
{
function
get_comments_count
()
{
$comments
=
$this
->
xpath
->
query
(
"slash:comments"
,
$this
->
elem
)
->
item
(
0
);
if
(
$comments
)
{
return
$comments
->
nodeValue
;
}
}
}
function
get_categories
()
{
function
get_categories
()
{
...
@@ -77,6 +82,11 @@ class FeedItem_Atom {
...
@@ -77,6 +82,11 @@ class FeedItem_Atom {
array_push
(
$cats
,
$cat
->
getAttribute
(
"term"
));
array_push
(
$cats
,
$cat
->
getAttribute
(
"term"
));
}
}
$categories
=
$this
->
xpath
->
query
(
"dc:subject"
,
$this
->
elem
);
foreach
(
$categories
as
$cat
)
{
array_push
(
$cats
,
$cat
->
nodeValue
);
}
return
$cats
;
return
$cats
;
}
}
...
@@ -100,6 +110,18 @@ class FeedItem_Atom {
...
@@ -100,6 +110,18 @@ class FeedItem_Atom {
}
}
}
}
$enclosures
=
$this
->
xpath
->
query
(
"media:content"
,
$this
->
elem
);
foreach
(
$enclosures
as
$enclosure
)
{
$enc
=
new
FeedEnclosure
();
$enc
->
type
=
$enclosure
->
getAttribute
(
"type"
);
$enc
->
link
=
$enclosure
->
getAttribute
(
"url"
);
$enc
->
length
=
$enclosure
->
getAttribute
(
"length"
);
array_push
(
$encs
,
$enc
);
}
return
$encs
;
return
$encs
;
}
}
...
...
This diff is collapsed.
Click to expand it.
classes/feeditem/rss.php
+
10
−
3
View file @
d4992d6b
...
@@ -63,9 +63,12 @@ class FeedItem_RSS {
...
@@ -63,9 +63,12 @@ class FeedItem_RSS {
}
}
// todo
function
get_comments_count
()
{
function
get_comments_count
()
{
$comments
=
$this
->
xpath
->
query
(
"slash:comments"
,
$this
->
elem
)
->
item
(
0
);
if
(
$comments
)
{
return
$comments
->
nodeValue
;
}
}
}
function
get_categories
()
{
function
get_categories
()
{
...
@@ -76,6 +79,12 @@ class FeedItem_RSS {
...
@@ -76,6 +79,12 @@ class FeedItem_RSS {
array_push
(
$cats
,
$cat
->
nodeValue
);
array_push
(
$cats
,
$cat
->
nodeValue
);
}
}
$categories
=
$this
->
xpath
->
query
(
"dc:subject"
,
$this
->
elem
);
foreach
(
$categories
as
$cat
)
{
array_push
(
$cats
,
$cat
->
nodeValue
);
}
return
$cats
;
return
$cats
;
}
}
...
@@ -96,8 +105,6 @@ class FeedItem_RSS {
...
@@ -96,8 +105,6 @@ class FeedItem_RSS {
$enclosures
=
$this
->
xpath
->
query
(
"media:content"
,
$this
->
elem
);
$enclosures
=
$this
->
xpath
->
query
(
"media:content"
,
$this
->
elem
);
$encs
=
array
();
foreach
(
$enclosures
as
$enclosure
)
{
foreach
(
$enclosures
as
$enclosure
)
{
$enc
=
new
FeedEnclosure
();
$enc
=
new
FeedEnclosure
();
...
...
This diff is collapsed.
Click to expand it.
classes/feedparser.php
+
3
−
0
View file @
d4992d6b
...
@@ -29,6 +29,9 @@ class FeedParser {
...
@@ -29,6 +29,9 @@ class FeedParser {
$xpath
->
registerNamespace
(
'atom'
,
'http://www.w3.org/2005/Atom'
);
$xpath
->
registerNamespace
(
'atom'
,
'http://www.w3.org/2005/Atom'
);
$xpath
->
registerNamespace
(
'media'
,
'http://search.yahoo.com/mrss/'
);
$xpath
->
registerNamespace
(
'media'
,
'http://search.yahoo.com/mrss/'
);
$xpath
->
registerNamespace
(
'rdf'
,
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
);
$xpath
->
registerNamespace
(
'rdf'
,
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
);
$xpath
->
registerNamespace
(
'slash'
,
'http://purl.org/rss/1.0/modules/slash/'
);
$xpath
->
registerNamespace
(
'dc'
,
'http://purl.org/dc/elements/1.1/'
);
$this
->
xpath
=
$xpath
;
$this
->
xpath
=
$xpath
;
$root
=
$xpath
->
query
(
"(//atom:feed|//channel|//rdf:rdf|//rdf:RDF)"
)
->
item
(
0
);
$root
=
$xpath
->
query
(
"(//atom:feed|//channel|//rdf:rdf|//rdf:RDF)"
)
->
item
(
0
);
...
...
This diff is collapsed.
Click to expand it.
include/rssfuncs.php
+
1
−
7
View file @
d4992d6b
...
@@ -581,13 +581,7 @@
...
@@ -581,13 +581,7 @@
$entry_comments
=
db_escape_string
(
mb_substr
(
trim
(
$entry_comments
),
0
,
245
));
$entry_comments
=
db_escape_string
(
mb_substr
(
trim
(
$entry_comments
),
0
,
245
));
$entry_author
=
db_escape_string
(
mb_substr
(
trim
(
$entry_author
),
0
,
245
));
$entry_author
=
db_escape_string
(
mb_substr
(
trim
(
$entry_author
),
0
,
245
));
$num_comments
=
$item
->
get_comments_count
();
$num_comments
=
(
int
)
$item
->
get_comments_count
();
if
(
is_array
(
$num_comments
)
&&
is_array
(
$num_comments
[
0
]))
{
$num_comments
=
(
int
)
$num_comments
[
0
][
"data"
];
}
else
{
$num_comments
=
0
;
}
_debug
(
"author
$entry_author
"
,
$debug_enabled
);
_debug
(
"author
$entry_author
"
,
$debug_enabled
);
_debug
(
"num_comments:
$num_comments
"
,
$debug_enabled
);
_debug
(
"num_comments:
$num_comments
"
,
$debug_enabled
);
...
...
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