function patterns_get_source in Patterns 6
Same name and namespace in other branches
- 6.2 patterns.module \patterns_get_source()
Menu callback - returns source code of the requested pattern if the pattern is public
Parameters
$pid: pattern id
Return value
source code of the requested pattern
1 string reference to 'patterns_get_source'
- patterns_menu in ./
patterns.module - Implementation of hook_menu().
File
- ./
patterns.module, line 248 - Enables extremely simple adding/removing features to your site with minimal to no configuration
Code
function patterns_get_source($pid) {
if (!is_numeric($pid)) {
exit;
}
$pattern = patterns_get_pattern($pid);
// make sure pattern is public (published)
if (!$pattern->public) {
exit;
}
$content_type = 'text/plain';
if (substr($pattern->file, -4) == '.xml') {
$content_type = 'text/xml';
}
drupal_set_header('Content-Type: ' . $content_type . '; charset=utf-8');
print file_get_contents($pattern->file);
exit;
}