本文整理汇总了PHP中rss_standard_footer函数的典型用法代码示例。如果您正苦于以下问题:PHP rss_standard_footer函数的具体用法?PHP rss_standard_footer怎么用?PHP rss_standard_footer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rss_standard_footer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lightboxgallery_rss_feed
function lightboxgallery_rss_feed($gallery)
{
global $CFG;
$result = "";
$images = lightboxgallery_directory_images($CFG->dataroot . '/' . $gallery->course . '/' . $gallery->folder);
$captions = array();
if ($cobjs = get_records_select('lightboxgallery_image_meta', "metatype = 'caption' AND gallery = {$gallery->id}")) {
foreach ($cobjs as $cobj) {
$captions[$cobj->image] = $cobj->description;
}
}
if (!empty($images)) {
$webroot = lightboxgallery_get_image_url($gallery->id);
$dataroot = $CFG->dataroot . '/' . $gallery->course . '/' . $gallery->folder;
$result .= "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
$result .= "<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss\" xmlns:atom=\"http://www.w3.org/2005/Atom\">";
$result .= rss_start_tag('channel', 1, true);
$result .= rss_full_tag('title', 2, false, strip_tags(format_string($gallery->name, true)));
$result .= rss_full_tag('link', 2, false, $CFG->wwwroot . '/mod/lightboxgallery/view.php?l=' . $gallery->id);
$result .= rss_full_tag('description', 2, false, format_string($gallery->description, true));
$result .= rss_start_tag('image', 2, true);
$result .= rss_full_tag('url', 3, false, $CFG->pixpath . '/i/rsssitelogo.gif');
$result .= rss_full_tag('title', 3, false, 'moodle');
$result .= rss_full_tag('link', 3, false, $CFG->wwwroot);
$result .= rss_full_tag('width', 3, false, '140');
$result .= rss_full_tag('height', 3, false, '35');
$result .= rss_end_tag('image', 2, true);
$counter = 1;
foreach ($images as $image) {
$description = isset($captions[$image]) ? $captions[$image] : $image;
$result .= rss_start_tag('item', 2, true);
$result .= rss_full_tag('title', 3, false, strip_tags($image));
$result .= rss_full_tag('link', 3, false, $webroot . '/' . $image);
$result .= rss_full_tag('guid', 3, false, 'img' . $counter);
$result .= rss_full_tag('media:description', 3, false, $description);
$result .= rss_full_tag('media:thumbnail', 3, false, '', array('url' => lightboxgallery_get_image_url($gallery->id, $image, true)));
$result .= rss_full_tag('media:content', 3, false, '', array('url' => $webroot . '/' . $image, 'type' => mime_content_type($dataroot . '/' . $image)));
$result .= rss_end_tag('item', 2, true);
$counter++;
}
$result .= rss_standard_footer();
}
return $result;
}
示例2: blog_rss_get_feed
//.........这里部分代码省略.........
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
if (!has_capability('moodle/blog:view', $sitecontext)) {
return null;
}
$type = clean_param($args[3], PARAM_ALPHA);
$id = clean_param($args[4], PARAM_INT);
// could be groupid / courseid / userid depending on $type
$tagid = 0;
if ($args[5] != 'rss.xml') {
$tagid = clean_param($args[5], PARAM_INT);
} else {
$tagid = 0;
}
$filename = blog_rss_file_name($type, $id, $tagid);
if (file_exists($filename)) {
if (filemtime($filename) + 3600 > time()) {
return $filename;
// It's already done so we return cached version
}
}
$courseid = $groupid = $userid = null;
switch ($type) {
case 'site':
//$siteid = $id;
break;
case 'course':
$courseid = $id;
break;
case 'group':
$groupid = $id;
break;
case 'user':
$userid = $id;
break;
}
// Get all the entries from the database
require_once $CFG->dirroot . '/blog/locallib.php';
$blogheaders = blog_get_headers($courseid, $groupid, $userid, $tagid);
$bloglisting = new blog_listing($blogheaders['filters']);
$blogentries = $bloglisting->get_entries();
// Now generate an array of RSS items
if ($blogentries) {
$items = array();
foreach ($blogentries as $blog_entry) {
$item = NULL;
$item->author = fullname($DB->get_record('user', array('id' => $blog_entry->userid)));
// TODO: this is slow
$item->title = $blog_entry->subject;
$item->pubdate = $blog_entry->lastmodified;
$item->link = $CFG->wwwroot . '/blog/index.php?entryid=' . $blog_entry->id;
$summary = file_rewrite_pluginfile_urls($blog_entry->summary, 'pluginfile.php', $sitecontext->id, 'blog', 'post', $blog_entry->id);
$item->description = format_text($summary, $blog_entry->format);
if (!empty($CFG->usetags) && ($blogtags = tag_get_tags_array('post', $blog_entry->id))) {
if ($blogtags) {
$item->tags = $blogtags;
}
$item->tagscheme = $CFG->wwwroot . '/tag';
}
$items[] = $item;
}
$articles = rss_add_items($items);
/// Change structure to XML
} else {
$articles = '';
}
/// Get header and footer information
switch ($type) {
case 'user':
$info = fullname($DB->get_record('user', array('id' => $id), 'firstname,lastname'));
break;
case 'course':
$info = $DB->get_field('course', 'fullname', array('id' => $id));
$info = format_string($info, true, array('context' => get_context_instance(CONTEXT_COURSE, $id)));
break;
case 'site':
$info = format_string($SITE->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
break;
case 'group':
$group = groups_get_group($id);
$info = $group->name;
//TODO: $DB->get_field('groups', 'name', array('id'=>$id))
break;
default:
$info = '';
break;
}
if ($tagid) {
$info .= ': ' . $DB->get_field('tags', 'text', array('id' => $tagid));
}
$header = rss_standard_header(get_string($type . 'blog', 'blog', $info), $CFG->wwwroot . '/blog/index.php', get_string('intro', 'blog'));
$footer = rss_standard_footer();
// Save the XML contents to file.
$rssdata = $header . $articles . $footer;
if (blog_rss_save_file($type, $id, $tagid, $rssdata)) {
return $filename;
} else {
return false;
// Couldn't find it or make it
}
}
示例3: blog_generate_rss_feed
function blog_generate_rss_feed($type, $id, $tagid = 0)
{
global $CFG, $SITE;
if (empty($CFG->enablerssfeeds)) {
debugging('Sorry, RSS feeds are disabled on this site');
return '';
}
$filename = blog_rss_file_name($type, $id, $tagid);
if (file_exists($filename)) {
if (filemtime($filename) + 3600 > time()) {
return $filename;
/// It's already done so we return cached version
}
}
/// Get all the posts from the database
$blogposts = blog_fetch_entries('', 20, '', $type, $id, $tagid);
/// Now generate an array of RSS items
if ($blogposts) {
$items = array();
foreach ($blogposts as $blogpost) {
$item = NULL;
$item->author = fullname(get_record('user', 'id', $blogpost->userid));
$item->title = $blogpost->subject;
$item->pubdate = $blogpost->lastmodified;
$item->link = $CFG->wwwroot . '/blog/index.php?postid=' . $blogpost->id;
$item->description = format_text($blogpost->summary, $blogpost->format);
$items[] = $item;
}
$articles = rss_add_items($items);
/// Change structure to XML
} else {
$articles = '';
}
/// Get header and footer information
switch ($type) {
case 'user':
$info = fullname(get_record('user', 'id', $id, '', '', '', '', 'firstname,lastname'));
break;
case 'course':
$info = get_field('course', 'fullname', 'id', $id);
break;
case 'site':
$info = $SITE->fullname;
break;
case 'group':
$group = groups_get_group($id, false);
$info = $group->name;
//TODO: get_field('groups', 'name', 'id', $id)
break;
default:
$info = '';
break;
}
if ($tagid) {
$info .= ': ' . get_field('tags', 'text', 'id', $tagid);
}
$header = rss_standard_header(get_string($type . 'blog', 'blog', $info), $CFG->wwwroot . '/blog/index.php', get_string('intro', 'blog'));
$footer = rss_standard_footer();
/// Save the XML contents to file.
$rssdata = $header . $articles . $footer;
if (blog_rss_save_file($type, $id, $tagid, $rssdata)) {
return $filename;
} else {
return false;
// Couldn't find it or make it
}
}
示例4: data_rss_get_feed
function data_rss_get_feed($context, $args)
{
global $CFG, $DB;
// Check CFG->data_enablerssfeeds.
if (empty($CFG->data_enablerssfeeds)) {
debugging("DISABLED (module configuration)");
return null;
}
$dataid = clean_param($args[3], PARAM_INT);
$cm = get_coursemodule_from_instance('data', $dataid, 0, false, MUST_EXIST);
if ($cm) {
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
//context id from db should match the submitted one
if ($context->id != $modcontext->id || !has_capability('mod/data:viewentry', $modcontext)) {
return null;
}
}
$data = $DB->get_record('data', array('id' => $dataid), '*', MUST_EXIST);
if (!rss_enabled_for_mod('data', $data, false, true)) {
return null;
}
$sql = data_rss_get_sql($data);
//get the cache file info
$filename = rss_get_file_name($data, $sql);
$cachedfilepath = rss_get_file_full_name('mod_data', $filename);
//Is the cache out of date?
$cachedfilelastmodified = 0;
if (file_exists($cachedfilepath)) {
$cachedfilelastmodified = filemtime($cachedfilepath);
}
//if the cache is more than 60 seconds old and there's new stuff
$dontrecheckcutoff = time() - 60;
if ($dontrecheckcutoff > $cachedfilelastmodified && data_rss_newstuff($data, $cachedfilelastmodified)) {
require_once $CFG->dirroot . '/mod/data/lib.php';
// Get the first field in the list (a hack for now until we have a selector)
if (!($firstfield = $DB->get_record_sql('SELECT id,name FROM {data_fields} WHERE dataid = ? ORDER by id', array($data->id), true))) {
return null;
}
if (!($records = $DB->get_records_sql($sql, array(), 0, $data->rssarticles))) {
return null;
}
$firstrecord = array_shift($records);
// Get the first and put it back
array_unshift($records, $firstrecord);
// Now create all the articles
$items = array();
foreach ($records as $record) {
$recordarray = array();
array_push($recordarray, $record);
$item = null;
// guess title or not
if (!empty($data->rsstitletemplate)) {
$item->title = data_print_template('rsstitletemplate', $recordarray, $data, '', 0, true);
} else {
// else we guess
$item->title = strip_tags($DB->get_field('data_content', 'content', array('fieldid' => $firstfield->id, 'recordid' => $record->id)));
}
$item->description = data_print_template('rsstemplate', $recordarray, $data, '', 0, true);
$item->pubdate = $record->timecreated;
$item->link = $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id . '&rid=' . $record->id;
array_push($items, $item);
}
$course = $DB->get_record('course', array('id' => $data->course));
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
// First all rss feeds common headers.
$header = rss_standard_header($courseshortname . ': ' . format_string($data->name, true, array('context' => $context)), $CFG->wwwroot . "/mod/data/view.php?d=" . $data->id, format_text($data->intro, $data->introformat, array('context' => $context)));
if (!empty($header)) {
$articles = rss_add_items($items);
}
// Now all rss feeds common footers.
if (!empty($header) && !empty($articles)) {
$footer = rss_standard_footer();
}
// Now, if everything is ok, concatenate it.
if (!empty($header) && !empty($articles) && !empty($footer)) {
$rss = $header . $articles . $footer;
//Save the XML contents to file.
$status = rss_save_file('mod_data', $filename, $rss);
}
}
return $cachedfilepath;
}
示例5: forum_rss_feed
function forum_rss_feed($forum)
{
global $CFG;
$status = true;
//Check CFG->enablerssfeeds
if (empty($CFG->enablerssfeeds)) {
debugging("DISABLED (admin variables)");
//Check CFG->forum_enablerssfeeds
} else {
if (empty($CFG->forum_enablerssfeeds)) {
debugging("DISABLED (module configuration)");
//It's working so we start...
} else {
//Check the forum has rss activated
if (!empty($forum->rsstype) && !empty($forum->rssarticles)) {
//Depending of the forum->rsstype, we are going to execute, different sqls
if ($forum->rsstype == 1) {
//Discussion RSS
$items = forum_rss_feed_discussions($forum);
} else {
//Post RSS
$items = forum_rss_feed_posts($forum);
}
//Now, if items, we begin building the structure
if (!empty($items)) {
//First all rss feeds common headers
$header = rss_standard_header(strip_tags(format_string($forum->name, true)), $CFG->wwwroot . "/mod/forum/view.php?f=" . $forum->id, format_string($forum->intro, true));
// TODO: fix format
//Now all the rss items
if (!empty($header)) {
$articles = rss_add_items($items);
}
//Now all rss feeds common footers
if (!empty($header) && !empty($articles)) {
$footer = rss_standard_footer();
}
//Now, if everything is ok, concatenate it
if (!empty($header) && !empty($articles) && !empty($footer)) {
$status = $header . $articles . $footer;
} else {
$status = false;
}
} else {
$status = false;
}
}
}
}
return $status;
}
示例6: forum_rss_feed_contents
//.........这里部分代码省略.........
$status = true;
$recs = $DB->get_recordset_sql($sql, $params, 0, $forum->rssarticles);
//set a flag. Are we displaying discussions or posts?
$isdiscussion = true;
if (!empty($forum->rsstype) && $forum->rsstype!=1) {
$isdiscussion = false;
}
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) {
print_error('invalidcoursemodule');
}
$formatoptions = new stdClass();
$items = array();
foreach ($recs as $rec) {
$item = new stdClass();
$user = new stdClass();
$discussion = new stdClass();
$discussion->id = $rec->discussionid;
$discussion->groupid = $rec->groupid;
$discussion->timestart = $rec->timestart;
$discussion->timeend = $rec->timeend;
$post = null;
if (!$isdiscussion) {
$post = new stdClass();
$post->id = $rec->postid;
$post->parent = $rec->postparent;
$post->userid = $rec->userid;
}
if ($isdiscussion && !forum_user_can_see_discussion($forum, $discussion, $context)) {
// This is a discussion which the user has no permission to view
$item->title = get_string('forumsubjecthidden', 'forum');
$message = get_string('forumbodyhidden', 'forum');
$item->author = get_string('forumauthorhidden', 'forum');
} else if (!$isdiscussion && !forum_user_can_see_post($forum, $discussion, $post, $USER, $cm)) {
// This is a post which the user has no permission to view
$item->title = get_string('forumsubjecthidden', 'forum');
$message = get_string('forumbodyhidden', 'forum');
$item->author = get_string('forumauthorhidden', 'forum');
} else {
// The user must have permission to view
if ($isdiscussion && !empty($rec->discussionname)) {
$item->title = format_string($rec->discussionname);
} else if (!empty($rec->postsubject)) {
$item->title = format_string($rec->postsubject);
} else {
//we should have an item title by now but if we dont somehow then substitute something somewhat meaningful
$item->title = format_string($forum->name.' '.userdate($rec->postcreated,get_string('strftimedatetimeshort', 'langconfig')));
}
$user->firstname = $rec->userfirstname;
$user->lastname = $rec->userlastname;
$item->author = fullname($user);
$message = file_rewrite_pluginfile_urls($rec->postmessage, 'pluginfile.php', $context->id,
'mod_forum', 'post', $rec->postid);
$formatoptions->trusted = $rec->posttrust;
}
if ($isdiscussion) {
$item->link = $CFG->wwwroot."/mod/forum/discuss.php?d=".$rec->discussionid;
} else {
$item->link = $CFG->wwwroot."/mod/forum/discuss.php?d=".$rec->discussionid."&parent=".$rec->postid;
}
$formatoptions->trusted = $rec->posttrust;
$item->description = format_text($message, $rec->postformat, $formatoptions, $forum->course);
//TODO: MDL-31129 implement post attachment handling
/*if (!$isdiscussion) {
$post_file_area_name = str_replace('//', '/', "$forum->course/$CFG->moddata/forum/$forum->id/$rec->postid");
$post_files = get_directory_list("$CFG->dataroot/$post_file_area_name");
if (!empty($post_files)) {
$item->attachments = array();
}
}*/
$item->pubdate = $rec->postcreated;
$items[] = $item;
}
$recs->close();
// Create the RSS header.
$header = rss_standard_header(strip_tags(format_string($forum->name,true)),
$CFG->wwwroot."/mod/forum/view.php?f=".$forum->id,
format_string($forum->intro,true)); // TODO: fix format
// Now all the RSS items, if there are any.
$articles = '';
if (!empty($items)) {
$articles = rss_add_items($items);
}
// Create the RSS footer.
$footer = rss_standard_footer();
return $header . $articles . $footer;
}
示例7: rss_geterrorxmlfile
/**
* This function return an error xml file (string) to be sent when a rss is required (file.php) and something goes wrong
*
* @param string $errortype Type of error to send, default is rsserror
* @return stdClass returns a XML Feed with an error message in it
*/
function rss_geterrorxmlfile($errortype = 'rsserror')
{
global $CFG;
$return = '';
//XML Header
$return = rss_standard_header();
//XML item
if ($return) {
$item = new stdClass();
$item->title = "RSS Error";
$item->link = $CFG->wwwroot;
$item->pubdate = time();
$item->description = get_string($errortype);
$return .= rss_add_items(array($item));
}
//XML Footer
if ($return) {
$return .= rss_standard_footer();
}
return $return;
}
示例8: glossary_rss_get_feed
function glossary_rss_get_feed($context, $args)
{
global $CFG, $DB;
$status = true;
if (empty($CFG->glossary_enablerssfeeds)) {
debugging("DISABLED (module configuration)");
return null;
}
$glossaryid = clean_param($args[3], PARAM_INT);
$cm = get_coursemodule_from_instance('glossary', $glossaryid, 0, false, MUST_EXIST);
if ($cm) {
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
//context id from db should match the submitted one
//no specific capability required to view glossary entries so just check user is enrolled
if ($context->id != $modcontext->id || !is_enrolled($context)) {
return null;
}
}
$glossary = $DB->get_record('glossary', array('id' => $glossaryid), '*', MUST_EXIST);
if (!rss_enabled_for_mod('glossary', $glossary)) {
return null;
}
$sql = glossary_rss_get_sql($glossary);
//get the cache file info
$filename = rss_get_file_name($glossary, $sql);
$cachedfilepath = rss_get_file_full_name('mod_glossary', $filename);
//Is the cache out of date?
$cachedfilelastmodified = 0;
if (file_exists($cachedfilepath)) {
$cachedfilelastmodified = filemtime($cachedfilepath);
}
//if the cache is more than 60 seconds old and there's new stuff
$dontrecheckcutoff = time() - 60;
if ($dontrecheckcutoff > $cachedfilelastmodified && glossary_rss_newstuff($glossary, $cachedfilelastmodified)) {
if (!($recs = $DB->get_records_sql($sql, array(), 0, $glossary->rssarticles))) {
return null;
}
$items = array();
$formatoptions = new stdClass();
$formatoptions->trusttext = true;
foreach ($recs as $rec) {
$item = new stdClass();
$user = new stdClass();
$item->title = $rec->entryconcept;
if ($glossary->rsstype == 1) {
//With author
$user->firstname = $rec->userfirstname;
$user->lastname = $rec->userlastname;
$item->author = fullname($user);
}
$item->pubdate = $rec->entrytimecreated;
$item->link = $CFG->wwwroot . "/mod/glossary/showentry.php?courseid=" . $glossary->course . "&eid=" . $rec->entryid;
$item->description = format_text($rec->entrydefinition, $rec->entryformat, $formatoptions, $glossary->course);
$items[] = $item;
}
//First all rss feeds common headers
$header = rss_standard_header(format_string($glossary->name, true), $CFG->wwwroot . "/mod/glossary/view.php?g=" . $glossary->id, format_string($glossary->intro, true));
//Now all the rss items
if (!empty($header)) {
$articles = rss_add_items($items);
}
//Now all rss feeds common footers
if (!empty($header) && !empty($articles)) {
$footer = rss_standard_footer();
}
//Now, if everything is ok, concatenate it
if (!empty($header) && !empty($articles) && !empty($footer)) {
$rss = $header . $articles . $footer;
//Save the XML contents to file.
$status = rss_save_file('mod_glossary', $filename, $rss);
}
}
if (!$status) {
$cachedfilepath = null;
}
return $cachedfilepath;
}
示例9: data_rss_feeds
function data_rss_feeds()
{
global $CFG, $DB;
$status = true;
// Check CFG->enablerssfeeds.
if (empty($CFG->enablerssfeeds)) {
debugging("DISABLED (admin variables)");
} else {
if (empty($CFG->data_enablerssfeeds)) {
debugging("DISABLED (module configuration)");
} else {
// Iterate over all data.
if ($datas = $DB->get_records('data')) {
foreach ($datas as $data) {
if ($data->rssarticles > 0) {
// Get the first field in the list (a hack for now until we have a selector)
if (!($firstfield = $DB->get_record_sql('SELECT id,name FROM {data_fields} WHERE dataid = ? ORDER by id', array($data->id), true))) {
continue;
}
// Get the data_records out.
$approved = $data->approval ? ' AND dr.approved = 1 ' : ' ';
$sql = "SELECT dr.*, u.firstname, u.lastname\n FROM {data_records} dr, {user} u\n WHERE dr.dataid = ? {$approved}\n AND dr.userid = u.id\n ORDER BY dr.timecreated DESC";
if (!($records = $DB->get_records_sql($sql, array($data->id), 0, $data->rssarticles))) {
continue;
}
$firstrecord = array_shift($records);
// Get the first and put it back
array_unshift($records, $firstrecord);
$filename = rss_file_name('data', $data);
if (file_exists($filename)) {
if (filemtime($filename) >= $firstrecord->timemodified) {
continue;
}
}
// Now create all the articles
mtrace('Creating feed for ' . $data->name);
$items = array();
foreach ($records as $record) {
$recordarray = array();
array_push($recordarray, $record);
$item = null;
// guess title or not
if (!empty($data->rsstitletemplate)) {
$item->title = data_print_template('rsstitletemplate', $recordarray, $data, '', 0, true);
} else {
// else we guess
$item->title = strip_tags($DB->get_field('data_content', 'content', array('fieldid' => $firstfield->id, 'recordid' => $record->id)));
}
$item->description = data_print_template('rsstemplate', $recordarray, $data, '', 0, true);
$item->pubdate = $record->timecreated;
$item->link = $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id . '&rid=' . $record->id;
array_push($items, $item);
}
$course = $DB->get_record('course', array('id' => $data->course));
// First all rss feeds common headers.
$header = rss_standard_header($course->shortname . ': ' . format_string($data->name, true), $CFG->wwwroot . "/mod/data/view.php?d=" . $data->id, format_string($data->intro, true));
//TODO: fix format
if (!empty($header)) {
$articles = rss_add_items($items);
}
// Now all rss feeds common footers.
if (!empty($header) && !empty($articles)) {
$footer = rss_standard_footer();
}
// Now, if everything is ok, concatenate it.
if (!empty($header) && !empty($articles) && !empty($footer)) {
$rss = $header . $articles . $footer;
//Save the XML contents to file.
$status = rss_save_file('data', $data, $rss);
} else {
$status = false;
}
}
}
}
}
}
return $status;
}
示例10: lightboxgallery_rss_get_feed
/**
* Returns the path to the cached rss feed contents. Creates/updates the cache if necessary.
* @global object $CFG
* @global object $DB
* @param object $context the context
* @param array $args the arguments received in the url
* @return string the full path to the cached RSS feed directory. Null if there is a problem.
*/
function lightboxgallery_rss_get_feed($context, $args)
{
global $CFG, $DB;
$config = get_config('lightboxgallery');
$status = true;
// Are RSS feeds enabled?
if (empty($config->enablerssfeeds)) {
debugging('DISABLED (module configuration)');
return null;
}
$galleryid = clean_param($args[3], PARAM_INT);
$cm = get_coursemodule_from_instance('lightboxgallery', $galleryid, 0, false, MUST_EXIST);
if ($cm) {
$modcontext = context_module::instance($cm->id);
// Context id from db should match the submitted one.
if ($context->id != $modcontext->id) {
return null;
}
}
$gallery = $DB->get_record('lightboxgallery', array('id' => $galleryid), '*', MUST_EXIST);
$captions = array();
if ($cobjs = $DB->get_records('lightboxgallery_image_meta', array('metatype' => 'caption', 'gallery' => $gallery->id))) {
foreach ($cobjs as $cobj) {
$captions[$cobj->image] = $cobj->description;
}
}
$fs = get_file_storage();
$storedfiles = $fs->get_area_files($context->id, 'mod_lightboxgallery', 'gallery_images');
$items = array();
$counter = 1;
$articles = '';
foreach ($storedfiles as $file) {
$filename = $file->get_filename();
if ($filename == '.') {
continue;
}
$description = isset($captions[$filename]) ? $captions[$filename] : $filename;
$image = new lightboxgallery_image($file, $gallery, $cm);
$item = new stdClass();
$item->{"media:description"} = $description;
$articles .= rss_start_tag('item', 2, true);
$articles .= rss_full_tag('title', 3, false, $filename);
$articles .= rss_full_tag('link', 3, false, $image->get_image_url());
$articles .= rss_full_tag('guid', 3, false, 'img' . $counter);
$articles .= rss_full_tag('media:description', 3, false, $description);
$articles .= rss_full_tag('media:thumbnail', 3, false, '', array('url' => $image->get_thumbnail_url()));
$articles .= rss_full_tag('media:content', 3, false, '', array('url' => $image->get_image_url(), 'type' => $file->get_mimetype()));
$articles .= rss_end_tag('item', 2, true);
}
// Get the cache file info.
$filename = rss_get_file_name($gallery, $sql);
$cachedfilepath = rss_get_file_full_name('mod_lightboxgallery', $filename);
// Is the cache out of date?
$cachedfilelastmodified = 0;
if (file_exists($cachedfilepath)) {
$cachedfilelastmodified = filemtime($cachedfilepath);
}
// First all rss feeds common headers.
$header = lightboxgallery_rss_header(format_string($gallery->name, true), $CFG->wwwroot . "/mod/lightboxgallery/view.php?id=" . $cm->id, format_string($gallery->intro, true));
// Now all rss feeds common footers.
if (!empty($header) && !empty($articles)) {
$footer = rss_standard_footer();
}
// Now, if everything is ok, concatenate it.
if (!empty($header) && !empty($articles) && !empty($footer)) {
$rss = $header . $articles . $footer;
// Save the XML contents to file.
$status = rss_save_file('mod_lightboxgallery', $filename, $rss);
}
if (!$status) {
$cachedfilepath = null;
}
return $cachedfilepath;
}
示例11: dataform_rss_get_feed
/**
* Generates the RSS Feed
*
* @param strClass $context the context the feed should be created under
* @param array $args array of arguments to be used in the creation of the RSS Feed
* @return NULL|string NULL if there is nothing to return, or the file path of the cached file if there is
*/
function dataform_rss_get_feed($context, $args)
{
global $CFG, $DB;
// Check CFG->data_enablerssfeeds.
if (empty($CFG->dataform_enablerssfeeds)) {
debugging("DISABLED (module configuration)");
return null;
}
// Validate context.
$dataformid = clean_param($args[3], PARAM_INT);
$cm = get_coursemodule_from_instance('dataform', $dataformid, 0, false, MUST_EXIST);
if ($cm) {
$modcontext = context_module::instance($cm->id);
// Context id from db should match the submitted one.
if ($context->id != $modcontext->id) {
return null;
}
}
// Check RSS enbabled for instance.
$dataform = $DB->get_record('dataform', array('id' => $dataformid), '*', MUST_EXIST);
if (!rss_enabled_for_mod('dataform', $dataform, false, false)) {
return null;
}
// Get the target view.
$viewid = clean_param($args[4], PARAM_INT);
$viewdata = $DB->get_record('dataform_views', array('id' => $viewid), '*', MUST_EXIST);
$viewman = mod_dataform_view_manager::instance($dataformid);
$view = $viewman->get_view_by_id($viewid);
// If (!($view instanceof 'mod_dataform\interfaces\rss')) {
// return null;
// }.
// Get the cache file info
// The cached file name is formatted dfid_viewid_contentstamp,
// where contentstamp is provided by the view.
$componentid = $dataformid . "_{$viewid}";
$cachedfilepath = dataform_rss_get_cached_file_path($componentid);
$contentstamp = $cachedfilepath ? dataform_rss_get_cached_content_stamp($cachedfilepath) : null;
$newcontentstamp = $view->get_content_stamp();
$hasnewcontent = $newcontentstamp !== $contentstamp;
// Neither existing nor new.
if (!$cachedfilepath and !$hasnewcontent) {
return null;
}
if ($cachedfilepath) {
// Use cache under 60 seconds.
$cachetime = filemtime($cachedfilepath);
if (time() - $cachetime < 60) {
return $cachedfilepath;
}
// Use cache if there is nothing new.
if (!$hasnewcontent) {
return $cachedfilepath;
}
// Cached file is outdated so delete it.
$instance = (object) array('id' => $componentid);
rss_delete_file('mod_dataform', $instance);
}
// Still here, fetch new content.
// Each article is an stdclass {title, descrition, pubdate, entrylink}.
if (!($items = $view->get_rss_items())) {
return null;
}
// First all rss feeds common headers.
$headertitle = $view->get_rss_header_title();
$headerlink = $view->get_rss_header_link();
$headerdescription = $view->get_rss_header_description();
$header = rss_standard_header($headertitle, $headerlink, $headerdescription);
if (empty($header)) {
return null;
}
// Now all rss feeds common footers.
$footer = rss_standard_footer();
if (empty($footer)) {
return null;
}
// All's good, save the content to file.
$articles = rss_add_items($items);
$rss = $header . $articles . $footer;
$filename = $componentid . "_{$newcontentstamp}";
$status = rss_save_file('mod_dataform', $filename, $rss);
$dirpath = dataform_rss_get_cache_dir_path();
return "{$dirpath}/{$filename}.xml";
}
示例12: glossary_rss_feed
function glossary_rss_feed($glossary)
{
global $CFG;
$status = true;
//Check CFG->enablerssfeeds
if (empty($CFG->enablerssfeeds)) {
debugging("DISABLED (admin variables)");
//Check CFG->glossary_enablerssfeeds
} else {
if (empty($CFG->glossary_enablerssfeeds)) {
debugging("DISABLED (module configuration)");
//It's working so we start...
} else {
//Check the glossary has rss activated
if (!empty($glossary->rsstype) && !empty($glossary->rssarticles)) {
//Depending of the glossary->rsstype, we are going to execute, different sqls
if ($glossary->rsstype == 1) {
//With author RSS
$items = glossary_rss_feed_withauthor($glossary);
} else {
//Without author RSS
$items = glossary_rss_feed_withoutauthor($glossary);
}
//Now, if items, we begin building the structure
if (!empty($items)) {
//First all rss feeds common headers
$header = rss_standard_header(format_string($glossary->name, true), $CFG->wwwroot . "/mod/glossary/view.php?g=" . $glossary->id, format_string($glossary->intro, true));
//Now all the rss items
if (!empty($header)) {
$articles = rss_add_items($items);
}
//Now all rss feeds common footers
if (!empty($header) && !empty($articles)) {
$footer = rss_standard_footer();
}
//Now, if everything is ok, concatenate it
if (!empty($header) && !empty($articles) && !empty($footer)) {
$status = $header . $articles . $footer;
} else {
$status = false;
}
} else {
$status = false;
}
}
}
}
return $status;
}
示例13: format_string
if ($data->title === null) {
$data->title = '';
}
// ...plus discussion subject (but not for discussion feed)
if (!$d) {
$data->title = format_string($post->get_discussion()->get_subject()) . ': ' . $data->title;
}
// Remaining details straightforward
$data->description = format_text($post->get_message(), $post->get_format());
$data->author = $forum->display_user_name($post->get_user());
$data->link = $post->get_url();
$data->pubdate = $post->get_modified();
$feeddata[] = $data;
}
}
// Now output all posts
if ($rss) {
header('Content-type: application/rss+xml');
echo rss_standard_header($feedname, $url, $feedsummary);
echo rss_add_items($feeddata);
echo rss_standard_footer();
} else {
header('Content-type: application/atom+xml');
$updated = count($feeddata) == 0 ? time() : reset($feeddata)->pubdate;
echo atom_standard_header($FULLME, $FULLME, $updated, $feedname, $feedsummary);
echo atom_add_items($feeddata);
echo atom_standard_footer();
}
} catch (forum_exception $e) {
forum_utils::handle_exception($e);
}
示例14: forum_rss_feed_contents
/**
* This function return the XML rss contents about the forum
* It returns false if something is wrong
*
* @param stdClass $forum the forum object
* @param string $sql The SQL used to retrieve the contents from the database
* @param object $context the context this forum relates to
* @return bool|string false if the contents is empty, otherwise the contents of the feed is returned
*
* @Todo MDL-31129 implement post attachment handling
*/
function forum_rss_feed_contents($forum, $sql, $context)
{
global $CFG, $DB;
$status = true;
$params = array();
//$params['forumid'] = $forum->id;
$recs = $DB->get_recordset_sql($sql, $params, 0, $forum->rssarticles);
//set a flag. Are we displaying discussions or posts?
$isdiscussion = true;
if (!empty($forum->rsstype) && $forum->rsstype != 1) {
$isdiscussion = false;
}
$formatoptions = new stdClass();
$items = array();
foreach ($recs as $rec) {
$item = new stdClass();
$user = new stdClass();
if ($isdiscussion && !empty($rec->discussionname)) {
$item->title = format_string($rec->discussionname);
} else {
if (!empty($rec->postsubject)) {
$item->title = format_string($rec->postsubject);
} else {
//we should have an item title by now but if we dont somehow then substitute something somewhat meaningful
$item->title = format_string($forum->name . ' ' . userdate($rec->postcreated, get_string('strftimedatetimeshort', 'langconfig')));
}
}
$user->firstname = $rec->userfirstname;
$user->lastname = $rec->userlastname;
$item->author = fullname($user);
$item->pubdate = $rec->postcreated;
if ($isdiscussion) {
$item->link = $CFG->wwwroot . "/mod/forum/discuss.php?d=" . $rec->discussionid;
} else {
$item->link = $CFG->wwwroot . "/mod/forum/discuss.php?d=" . $rec->discussionid . "&parent=" . $rec->postid;
}
$formatoptions->trusted = $rec->posttrust;
$message = file_rewrite_pluginfile_urls($rec->postmessage, 'pluginfile.php', $context->id, 'mod_forum', 'post', $rec->postid);
$item->description = format_text($message, $rec->postformat, $formatoptions, $forum->course);
//TODO: MDL-31129 implement post attachment handling
/*if (!$isdiscussion) {
$post_file_area_name = str_replace('//', '/', "$forum->course/$CFG->moddata/forum/$forum->id/$rec->postid");
$post_files = get_directory_list("$CFG->dataroot/$post_file_area_name");
if (!empty($post_files)) {
$item->attachments = array();
}
}*/
$items[] = $item;
}
$recs->close();
if (!empty($items)) {
//First the RSS header
$header = rss_standard_header(strip_tags(format_string($forum->name, true)), $CFG->wwwroot . "/mod/forum/view.php?f=" . $forum->id, format_string($forum->intro, true));
// TODO: fix format
//Now all the rss items
if (!empty($header)) {
$articles = rss_add_items($items);
}
//Now the RSS footer
if (!empty($header) && !empty($articles)) {
$footer = rss_standard_footer();
}
//Now, if everything is ok, concatenate it
if (!empty($header) && !empty($articles) && !empty($footer)) {
$status = $header . $articles . $footer;
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例15: hub_rss_get_feed
/**
* Returns the path to the cached rss feed contents. Creates/updates the cache if necessary.
* The RSS feed content is a course search result.
* @param array $args the arguments received in the url
* $args[0] => context id = 2 (Front page) - not used
* $args[1] => token
* $args[2] => module name (it was needed by the rss/file.php to call this function) - not used
* $args[3] => downloadable - PARAM_INT
* $args[4] => audience - PARAM_ALPHA
* $args[5] => educationallevel - PARAM_ALPHA
* $args[6] => subject - PARAM_ALPHA
* $args[7] => licence - PARAM_ALPHA
* $args[8] => language - PARAM_ALPHANUMEXT
* $args[9] => search - PARAM_TEXT (url encoded)
* $args[10] => orderby - PARAM_ALPHA
* @return string the full path to the cached RSS feed directory. Null if there is a problem.
*/
function hub_rss_get_feed($context, $args)
{
global $CFG, $DB;
require_once $CFG->dirroot . '/local/hub/lib.php';
//are RSS feeds enabled?
$enablerssfeeds = get_config('local_hub', 'enablerssfeeds');
if (empty($enablerssfeeds)) {
debugging('DISABLED (module configuration)');
return null;
}
//check capabilities
if (!has_capability('local/hub:view', $context)) {
return null;
}
//TODO: cache
$filename = 'rsssearch_' . $args[3] . '_' . $args[4] . '_' . $args[5] . '_' . $args[6] . '_' . $args[7] . '_' . $args[8] . '_' . $args[9] . '_' . $args[10];
$cachedfilepath = rss_get_file_full_name('local_hub', $filename);
//get the courses from the search
if ($args[7] != 'all') {
$options['licenceshortname'] = $args[7];
}
if ($args[6] != 'all') {
$options['subject'] = $args[6];
}
if ($args[4] != 'all') {
$options['audience'] = $args[4];
}
if ($args[5] != 'all') {
$options['educationallevel'] = $args[5];
}
if ($args[8] != 'all') {
$options['language'] = $args[8];
}
if ($args[3] != 'all') {
$options['downloadable'] = $args[3];
$options['enrollable'] = !$args[3];
} else {
$options['downloadable'] = true;
$options['enrollable'] = true;
}
$options['search'] = empty($args[9]) ? '' : urldecode($args[9]);
//if the RSS invisible secret is passed as parameter, display not visible course
$rsssecret = get_config('local_hub', 'rsssecret');
if (!empty($rsssecret) and $rsssecret == optional_param('rsssecret', false, PARAM_RAW)) {
$options['visibility'] = COURSEVISIBILITY_NOTVISIBLE;
} else {
$options['visibility'] = COURSEVISIBILITY_VISIBLE;
}
//order by
switch ($args[10]) {
case 'newest':
$options['orderby'] = 'timemodified DESC';
break;
case 'eldest':
$options['orderby'] = 'timemodified ASC';
break;
case 'publisher':
$options['orderby'] = 'publishername ASC';
break;
case 'fullname':
$options['orderby'] = 'fullname ASC';
break;
case 'ratingaverage':
$options['orderby'] = 'ratingaverage DESC';
break;
default:
break;
}
$hub = new local_hub();
$courses = $hub->get_courses($options, 0, 10);
//generate the information for rss
$rssfeedinfo = local_hub_rss_generate_feed_info($courses);
//generate the rss content
require_once $CFG->libdir . "/rsslib.php";
//First the RSS header
$searchurl = new moodle_url($CFG->wwwroot . '/', array('downloadable' => $args[3], 'audience' => $args[4], 'educationallevel' => $args[5], 'subject' => $args[6], 'licence' => $args[7], 'language' => $args[8], 'search' => $args[9], 'orderby' => $args[10], 'submitbutton' => 'Search+for+courses'));
$rsscontent = rss_standard_header(get_config('local_hub', 'name'), $searchurl->out(), get_string('hubcoursessearch', 'local_hub'));
$rsscontent .= rss_add_items($rssfeedinfo);
//Now the RSS footer
$rsscontent .= rss_standard_footer();
if (!empty($rsscontent)) {
rss_save_file('local_hub', $filename, $rsscontent);
}
//.........这里部分代码省略.........