本文整理汇总了PHP中blog_get_headers函数的典型用法代码示例。如果您正苦于以下问题:PHP blog_get_headers函数的具体用法?PHP blog_get_headers怎么用?PHP blog_get_headers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了blog_get_headers函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: blog_rss_get_feed
/**
* Generate any blog RSS feed via one function
*
* @param stdClass $context The context of the blog for which the feed it being generated
* @param array $args An array of arguements needed to build the feed (contextid, token, componentname, type, id, tagid)
*/
function blog_rss_get_feed($context, $args)
{
global $CFG, $SITE, $DB;
if (empty($CFG->bloglevel)) {
debugging('Blogging disabled on this site, RSS feeds are not available');
return null;
}
if (empty($CFG->enablerssfeeds)) {
debugging('Sorry, RSS feeds are disabled on this site');
return '';
}
if ($CFG->bloglevel == BLOG_SITE_LEVEL) {
if (isguestuser()) {
debugging(get_string('nopermissiontoshow', 'error'));
return '';
}
}
$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;
//.........这里部分代码省略.........
示例2: print_error
echo $OUTPUT->footer();
die;
}
if ($USER->id == $userid) {
if (!has_capability('moodle/blog:create', $sitecontext) && !has_capability('moodle/blog:view', $sitecontext)) {
print_error('donothaveblog', 'blog');
}
} else {
if (!has_capability('moodle/blog:view', $sitecontext) || !blog_user_can_view_user_entry($userid)) {
print_error('cannotviewcourseblog', 'blog');
}
$PAGE->navigation->extend_for_user($user);
}
}
$courseid = empty($courseid) ? SITEID : $courseid;
$blogheaders = blog_get_headers();
$rsscontext = null;
$filtertype = null;
$thingid = null;
$rsstitle = '';
if ($CFG->enablerssfeeds) {
list($thingid, $rsscontext, $filtertype) = blog_rss_get_params($blogheaders['filters']);
if (empty($rsscontext)) {
$rsscontext = context_system::instance();
}
$rsstitle = $blogheaders['heading'];
// Check we haven't started output by outputting an error message.
if ($PAGE->state == moodle_page::STATE_BEFORE_HEADER) {
blog_rss_add_http_header($rsscontext, $rsstitle, $filtertype, $thingid, $tagid);
}
}
示例3: test_blog_get_headers_case_10
public function test_blog_get_headers_case_10()
{
global $CFG, $PAGE, $OUTPUT;
$blog_headers = blog_get_headers($this->courseid);
$this->assertNotEqual($blog_headers['heading'], '');
}
示例4: print_entries
/**
* Outputs all the blog entries aggregated by this blog listing.
*
* @return void
*/
public function print_entries()
{
global $CFG, $USER, $DB, $OUTPUT;
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
$page = optional_param('blogpage', 0, PARAM_INT);
$limit = optional_param('limit', get_user_preferences('blogpagesize', 10), PARAM_INT);
$start = $page * $limit;
$morelink = '<br /> ';
if ($sqlarray = $this->get_entry_fetch_sql(true)) {
$totalentries = $DB->count_records_sql($sqlarray['sql'], $sqlarray['params']);
} else {
$totalentries = 0;
}
$entries = $this->get_entries($start, $limit);
$pagingbar = new paging_bar($totalentries, $page, $limit, $this->get_baseurl());
$pagingbar->pagevar = 'blogpage';
$blogheaders = blog_get_headers();
echo $OUTPUT->render($pagingbar);
if (has_capability('moodle/blog:create', $sitecontext)) {
//the user's blog is enabled and they are viewing their own blog
$userid = optional_param('userid', null, PARAM_INT);
if (empty($userid) || !empty($userid) && $userid == $USER->id) {
$addurl = new moodle_url("{$CFG->wwwroot}/blog/edit.php");
$urlparams = array('action' => 'add', 'userid' => $userid, 'courseid' => optional_param('courseid', null, PARAM_INT), 'groupid' => optional_param('groupid', null, PARAM_INT), 'modid' => optional_param('modid', null, PARAM_INT), 'tagid' => optional_param('tagid', null, PARAM_INT), 'tag' => optional_param('tag', null, PARAM_INT), 'search' => optional_param('search', null, PARAM_INT));
foreach ($urlparams as $var => $val) {
if (empty($val)) {
unset($urlparams[$var]);
}
}
$addurl->params($urlparams);
$addlink = '<div class="addbloglink">';
$addlink .= '<a href="' . $addurl->out() . '">' . $blogheaders['stradd'] . '</a>';
$addlink .= '</div>';
echo $addlink;
}
}
if ($entries) {
$count = 0;
foreach ($entries as $entry) {
$blogentry = new blog_entry(null, $entry);
$blogentry->print_html();
$count++;
}
echo $OUTPUT->render($pagingbar);
if (!$count) {
print '<br /><div style="text-align:center">' . get_string('noentriesyet', 'blog') . '</div><br />';
}
print $morelink . '<br />' . "\n";
return;
}
}
示例5: print_entries
/**
* Outputs all the blog entries aggregated by this blog listing.
*
* @return void
*/
public function print_entries()
{
global $CFG, $USER, $DB, $OUTPUT, $PAGE;
$sitecontext = context_system::instance();
// Blog renderer.
$output = $PAGE->get_renderer('blog');
$page = optional_param('blogpage', 0, PARAM_INT);
$limit = optional_param('limit', get_user_preferences('blogpagesize', 10), PARAM_INT);
$start = $page * $limit;
$morelink = '<br /> ';
$entries = $this->get_entries($start, $limit);
$totalentries = $this->count_entries();
$pagingbar = new paging_bar($totalentries, $page, $limit, $this->get_baseurl());
$pagingbar->pagevar = 'blogpage';
$blogheaders = blog_get_headers();
echo $OUTPUT->render($pagingbar);
if (has_capability('moodle/blog:create', $sitecontext)) {
// The user's blog is enabled and they are viewing their own blog.
$userid = optional_param('userid', null, PARAM_INT);
if (empty($userid) || !empty($userid) && $userid == $USER->id) {
$courseid = optional_param('courseid', null, PARAM_INT);
$modid = optional_param('modid', null, PARAM_INT);
$addurl = new moodle_url("{$CFG->wwwroot}/blog/edit.php");
$urlparams = array('action' => 'add', 'userid' => $userid, 'courseid' => $courseid, 'groupid' => optional_param('groupid', null, PARAM_INT), 'modid' => $modid, 'tagid' => optional_param('tagid', null, PARAM_INT), 'tag' => optional_param('tag', null, PARAM_INT), 'search' => optional_param('search', null, PARAM_INT));
$urlparams = array_filter($urlparams);
$addurl->params($urlparams);
$addlink = '<div class="addbloglink">';
$addlink .= '<a href="' . $addurl->out() . '">' . $blogheaders['stradd'] . '</a>';
$addlink .= '</div>';
echo $addlink;
}
}
if ($entries) {
$count = 0;
foreach ($entries as $entry) {
$blogentry = new blog_entry(null, $entry);
// Get the required blog entry data to render it.
$blogentry->prepare_render();
echo $output->render($blogentry);
$count++;
}
echo $OUTPUT->render($pagingbar);
if (!$count) {
print '<br /><div style="text-align:center">' . get_string('noentriesyet', 'blog') . '</div><br />';
}
print $morelink . '<br />' . "\n";
return;
}
}