Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
297
Merge Requests
297
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
0fef1502
Commit
0fef1502
authored
Jul 17, 2006
by
Steven Wittens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#74109
: format_rss_channel() does not allow attributes (+ clean up code)
parent
4dbaaefd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
10 deletions
+27
-10
includes/common.inc
includes/common.inc
+27
-10
No files found.
includes/common.inc
View file @
0fef1502
...
...
@@ -717,9 +717,7 @@ function format_rss_channel($title, $link, $description, $items, $language = 'en
// escaped source data (such as & becoming &).
$output
.
=
' <description>'
.
check_plain
(
decode_entities
(
strip_tags
(
$description
)))
.
"</description>
\n
"
;
$output
.
=
' <language>'
.
check_plain
(
$language
)
.
"</language>
\n
"
;
foreach
(
$args
as
$key
=>
$value
)
{
$output
.
=
' <'
.
$key
.
'>'
.
check_plain
(
$value
)
.
"</
$key
>
\n
"
;
}
$output
.
=
format_xml_elements
(
$args
);
$output
.
=
$items
;
$output
.
=
"</channel>
\n
"
;
...
...
@@ -736,16 +734,37 @@ function format_rss_item($title, $link, $description, $args = array()) {
$output
.
=
' <title>'
.
check_plain
(
$title
)
.
"</title>
\n
"
;
$output
.
=
' <link>'
.
check_url
(
$link
)
.
"</link>
\n
"
;
$output
.
=
' <description>'
.
check_plain
(
$description
)
.
"</description>
\n
"
;
foreach
(
$args
as
$key
=>
$value
)
{
if
(
is_array
(
$value
))
{
$output
.
=
format_xml_elements
(
$args
);
$output
.
=
"</item>
\n
"
;
return
$output
;
}
/**
* Format XML elements.
*
* @param $array
* An array where each item represent an element and is either a:
* - (key => value) pair (<key>value</key>)
* - Associative array with fields:
* - 'key': element name
* - 'value': element contents
* - 'attributes': associative array of element attributes
*
* In both cases, 'value' can be a simple string, or it can be another array
* with the same format as $array itself for nesting.
*/
function
format_xml_elements
(
$array
)
{
foreach
(
$array
as
$key
=>
$value
)
{
if
(
is_numeric
(
$key
))
{
if
(
$value
[
'key'
])
{
$output
.
=
' <'
.
$value
[
'key'
];
if
(
isset
(
$value
[
'attributes'
])
&&
is_array
(
$value
[
'attributes'
]))
{
$output
.
=
drupal_attributes
(
$value
[
'attributes'
]);
}
if
(
$value
[
'value'
])
{
$output
.
=
'>'
.
$value
[
'value'
]
.
'</'
.
$value
[
'key'
]
.
">
\n
"
;
if
(
$value
[
'value'
]
!=
''
)
{
$output
.
=
'>'
.
(
is_array
(
$value
[
'value'
])
?
format_xml_tags
(
$value
[
'value'
])
:
check_plain
(
$value
[
'value'
]))
.
'</'
.
$value
[
'key'
]
.
">
\n
"
;
}
else
{
$output
.
=
" />
\n
"
;
...
...
@@ -753,11 +772,9 @@ function format_rss_item($title, $link, $description, $args = array()) {
}
}
else
{
$output
.
=
' <'
.
$key
.
'>'
.
check_plain
(
$value
)
.
"</
$key
>
\n
"
;
$output
.
=
' <'
.
$key
.
'>'
.
(
is_array
(
$value
)
?
format_xml_tags
(
$value
)
:
check_plain
(
$value
)
)
.
"</
$key
>
\n
"
;
}
}
$output
.
=
"</item>
\n
"
;
return
$output
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment