function patterns_feed in Patterns 6.2
Same name and namespace in other branches
- 6 patterns.module \patterns_feed()
- 7.2 includes/feed.inc \patterns_feed()
- 7 includes/feed.inc \patterns_feed()
Prints XML Feed of published (public) patterns
1 string reference to 'patterns_feed'
- patterns_menu in ./
patterns.module - Implementation of hook_menu().
File
- ./
patterns.module, line 279 - Enables extremely simple adding/removing features to your site with minimal to no configuration
Code
function patterns_feed() {
global $base_url;
if (!variable_get('patterns_allow_publish', FALSE)) {
return drupal_not_found();
}
$patterns = variable_get('patterns_allow_publish', FALSE) ? patterns_get_patterns() : array();
foreach ($patterns as $pattern) {
if (!$pattern->public) {
continue;
}
preg_match('/[^\\.]*$/', $pattern->file, $matches);
$extension = $matches[0];
$item = " <pattern>\n";
$item .= " <pid>" . $pattern->pid . "</pid>\n";
$item .= " <name>" . $pattern->name . "</name>\n";
$item .= " <title>" . $pattern->title . "</title>\n";
$item .= " <description>" . $pattern->description . "</description>\n";
$item .= " <category>" . $pattern->pattern['info']['category'] . "</category>\n";
$item .= " <file_type>" . $extension . "</file_type>\n";
$item .= " </pattern>\n";
$items .= $item;
}
$header = " <info>\n";
$header .= " <url>" . $base_url . "</url>\n";
// $header .= " <description>". $description ."</description>\n";
$header .= " </info>\n";
$feed = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$feed .= "<patterns_feed>\n";
$feed .= $header;
$feed .= " <patterns>\n";
$feed .= $items;
$feed .= " </patterns>\n";
$feed .= "</patterns_feed>\n";
drupal_set_header('Content-Type: text/xml; charset=utf-8');
print $feed;
exit;
}