MDL-32344 blog Replacing tables for div containers
This commit is contained in:
+2
-2
@@ -105,7 +105,7 @@ if ($id) {
|
||||
}
|
||||
$returnurl->param('userid', $userid);
|
||||
|
||||
// Blog renderer
|
||||
// Blog renderer.
|
||||
$output = $PAGE->get_renderer('blog');
|
||||
|
||||
$strblogs = get_string('blogs','blog');
|
||||
@@ -129,7 +129,7 @@ if ($action === 'delete'){
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Output the entry
|
||||
// Output the entry.
|
||||
$entry->prepare_render();
|
||||
echo $output->render($entry);
|
||||
|
||||
|
||||
+46
-50
@@ -66,7 +66,7 @@ class blog_entry implements renderable {
|
||||
public $form;
|
||||
public $tags = array();
|
||||
|
||||
// Data needed to render the entry
|
||||
/** @var StdClass Data needed to render the entry */
|
||||
public $renderable;
|
||||
|
||||
// Methods
|
||||
@@ -104,12 +104,12 @@ class blog_entry implements renderable {
|
||||
|
||||
$this->renderable->user = $DB->get_record('user', array('id'=>$this->userid));
|
||||
|
||||
// Entry comments
|
||||
// Entry comments.
|
||||
if (!empty($CFG->usecomments) and $CFG->blogusecomments) {
|
||||
require_once($CFG->dirroot . '/comment/lib.php');
|
||||
|
||||
$cmt = new stdClass();
|
||||
$cmt->context = get_context_instance(CONTEXT_USER, $this->userid);
|
||||
$cmt->context = context_user::instance($this->userid);
|
||||
$cmt->courseid = $PAGE->course->id;
|
||||
$cmt->area = 'format_blog';
|
||||
$cmt->itemid = $this->id;
|
||||
@@ -117,74 +117,70 @@ class blog_entry implements renderable {
|
||||
$cmt->component = 'blog';
|
||||
$this->renderable->comment = new comment($cmt);
|
||||
}
|
||||
|
||||
// Post data
|
||||
$this->summary = file_rewrite_pluginfile_urls($this->summary, 'pluginfile.php', SYSCONTEXTID, 'blog', 'post', $this->id);
|
||||
|
||||
$options = array('overflowdiv'=>true);
|
||||
$this->renderable->body = format_text($this->summary, $this->summaryformat, $options);
|
||||
$this->renderable->title = format_string($this->subject);
|
||||
$this->renderable->userid = $this->userid;
|
||||
$this->renderable->author = fullname($this->renderable->user);
|
||||
$this->renderable->created = userdate($this->created);
|
||||
if ($this->created != $this->lastmodified) {
|
||||
$this->renderable->lastmod = userdate($this->lastmodified);
|
||||
}
|
||||
$this->renderable->publishstate = $this->publishstate;
|
||||
$this->summary = file_rewrite_pluginfile_urls($this->summary, 'pluginfile.php', SYSCONTEXTID, 'blog', 'post', $this->id);
|
||||
|
||||
// External blog
|
||||
// External blog link.
|
||||
if ($this->uniquehash && $this->content) {
|
||||
if ($externalblog = $DB->get_record('blog_external', array('id' => $this->content))) {
|
||||
$urlparts = parse_url($externalblog->url);
|
||||
$this->renderable->externalblogtext = get_string('retrievedfrom', 'blog').get_string('labelsep', 'langconfig').html_writer::link($urlparts['scheme'].'://'.$urlparts['host'], $externalblog->name);
|
||||
$this->renderable->externalblogtext = get_string('retrievedfrom', 'blog') . get_string('labelsep', 'langconfig');
|
||||
$this->renderable->externalblogtext .= html_writer::link($urlparts['scheme'] . '://'.$urlparts['host'], $externalblog->name);
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve associations
|
||||
$this->renderable->unassociatedentry = false;
|
||||
if (!empty($CFG->useblogassociations)) {
|
||||
|
||||
// Adding the entry associations data.
|
||||
if ($associations = $associations = $DB->get_records('blog_association', array('blogid' => $this->id))) {
|
||||
|
||||
// Check to see if the entry is unassociated with group/course level access.
|
||||
if ($this->publishstate == 'group' || $this->publishstate == 'course') {
|
||||
$this->renderable->unassociatedentry = true;
|
||||
}
|
||||
|
||||
// Check to see if the entry is unassociated with group/course level access
|
||||
$this->renderable->unassociatedentry = false;
|
||||
if (!empty($CFG->useblogassociations) && ($this->publishstate == 'group' || $this->publishstate == 'course')) {
|
||||
if (!$DB->record_exists('blog_association', array('blogid' => $this->id))) {
|
||||
$this->renderable->unassociatedentry = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve associations in case they're needed early
|
||||
if (!empty($CFG->useblogassociations)) {
|
||||
$associations = $DB->get_records('blog_association', array('blogid' => $this->id));
|
||||
|
||||
// Adding the entry associations data
|
||||
if ($associations) {
|
||||
foreach ($associations as $key => $assocrec) {
|
||||
$context = get_context_instance_by_id($assocrec->contextid);
|
||||
|
||||
if (!$context = context::instance_by_id($assocrec->contextid, IGNORE_MISSING)) {
|
||||
unset($associations[$key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// The renderer will need the contextlevel of the association.
|
||||
$associations[$key]->contextlevel = $context->contextlevel;
|
||||
|
||||
// Course associations
|
||||
// Course associations.
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
$instancename = $DB->get_field('course', 'shortname', array('id' => $context->instanceid)); //TODO: performance!!!!
|
||||
|
||||
$associations[$key]->type = get_string('course');
|
||||
|
||||
$associations[$key]->url = $assocurl = new moodle_url('/course/view.php', array('id' => $context->instanceid));
|
||||
$associations[$key]->text = $instancename;
|
||||
$associations[$key]->icon = new pix_icon('i/course', $associations[$key]->text);
|
||||
}
|
||||
|
||||
// Mod associations
|
||||
// Mod associations.
|
||||
if ($context->contextlevel == CONTEXT_MODULE) {
|
||||
|
||||
$modinfo = $DB->get_record('course_modules', array('id' => $context->instanceid));
|
||||
$modname = $DB->get_field('modules', 'name', array('id' => $modinfo->module));
|
||||
$instancename = $DB->get_field($modname, 'name', array('id' => $modinfo->instance)); //TODO: performance!!!!
|
||||
// Getting the activity type and the activity instance id
|
||||
$sql = 'SELECT cm.instance, m.name FROM {course_modules} cm
|
||||
JOIN {modules} m ON m.id = cm.module
|
||||
WHERE cm.id = :cmid';
|
||||
$modinfo = $DB->get_record_sql($sql, array('cmid' => $context->instanceid));
|
||||
$instancename = $DB->get_field($modinfo->name, 'name', array('id' => $modinfo->instance)); //TODO: performance!!!!
|
||||
|
||||
$associations[$key]->type = get_string('modulename', $modname);
|
||||
$associations[$key]->url = new moodle_url('/mod/'.$modname.'/view.php', array('id' => $modinfo->id));
|
||||
$associations[$key]->type = get_string('modulename', $modinfo->name);
|
||||
$associations[$key]->url = new moodle_url('/mod/' . $modinfo->name . '/view.php', array('id' => $context->instanceid));
|
||||
$associations[$key]->text = $instancename;
|
||||
$associations[$key]->icon = new pix_icon('icon', $associations[$key]->text, $modname);
|
||||
$associations[$key]->icon = new pix_icon('icon', $associations[$key]->text, $modinfo->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->renderable->blogassociations = $associations;
|
||||
}
|
||||
|
||||
// Entry attachments
|
||||
// Entry attachments.
|
||||
$this->renderable->attachments = $this->get_attachments();
|
||||
|
||||
$this->renderable->usercanedit = blog_user_can_edit_entry($this);
|
||||
@@ -201,12 +197,12 @@ class blog_entry implements renderable {
|
||||
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
$syscontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$syscontext = context_system::instance();
|
||||
|
||||
$fs = get_file_storage();
|
||||
$files = $fs->get_area_files($syscontext->id, 'blog', 'attachment', $this->id);
|
||||
|
||||
// Adding a blog_entry_attachment for each non-directory file
|
||||
// Adding a blog_entry_attachment for each non-directory file.
|
||||
$attachments = array();
|
||||
foreach ($files as $file) {
|
||||
if ($file->is_directory()) {
|
||||
@@ -1010,18 +1006,18 @@ class blog_entry_attachment implements renderable {
|
||||
public $file;
|
||||
|
||||
/**
|
||||
* Gets the file data
|
||||
*
|
||||
* @param stored_file $file
|
||||
* @param int $entryid Attachment entry id
|
||||
*/
|
||||
public function __construct($file, $entryid) {
|
||||
|
||||
global $OUTPUT, $CFG;
|
||||
|
||||
$syscontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
global $CFG;
|
||||
|
||||
$this->file = $file;
|
||||
$this->filename = $file->get_filename();
|
||||
$this->url = file_encode_url($CFG->wwwroot.'/pluginfile.php', '/'.SYSCONTEXTID.'/blog/attachment/'.$entryid.'/'.$this->filename);
|
||||
$this->url = file_encode_url($CFG->wwwroot.'/pluginfile.php', '/'.SYSCONTEXTID.'/blog/attachment/'.$entryid.'/'.$this->filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+114
-134
@@ -22,7 +22,7 @@
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
@@ -40,136 +40,128 @@ class core_blog_renderer extends plugin_renderer_base {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
|
||||
$stredit = get_string('edit');
|
||||
$strdelete = get_string('delete');
|
||||
|
||||
// Start printing of the blog
|
||||
$table = new html_table();
|
||||
$table->cellspacing = 0;
|
||||
$table->attributes['class'] = 'forumpost blog_entry blog'. ($entry->renderable->unassociatedentry ? 'draft' : $entry->renderable->publishstate);
|
||||
$table->attributes['id'] = 'b'.$entry->id;
|
||||
$table->width = '100%';
|
||||
// Header.
|
||||
$mainclass = 'forumpost blog_entry blog clearfix ';
|
||||
if ($entry->renderable->unassociatedentry) {
|
||||
$mainclass .= 'draft';
|
||||
} else {
|
||||
$mainclass .= $entry->publishstate;
|
||||
}
|
||||
$o = $this->output->container_start($mainclass, 'b' . $entry->id);
|
||||
$o .= $this->output->container_start('row header clearfix');
|
||||
|
||||
$picturecell = new html_table_cell();
|
||||
$picturecell->attributes['class'] = 'picture left';
|
||||
$picturecell->text = $this->output->user_picture($entry->renderable->user);
|
||||
// User picture.
|
||||
$o .= $this->output->container_start('left picture header');
|
||||
$o .= $this->output->user_picture($entry->renderable->user);
|
||||
$o .= $this->output->container_end();
|
||||
|
||||
$table->head[] = $picturecell;
|
||||
$o .= $this->output->container_start('topic starter header clearfix');
|
||||
|
||||
$topiccell = new html_table_cell();
|
||||
$topiccell->attributes['class'] = 'topic starter';
|
||||
$titlelink = html_writer::link(new moodle_url('/blog/index.php', array('entryid' => $entry->id)), $entry->renderable->title);
|
||||
$topiccell->text = $this->output->container($titlelink, 'subject');
|
||||
$topiccell->text .= $this->output->container_start('author');
|
||||
|
||||
// Post by
|
||||
// Title.
|
||||
$titlelink = html_writer::link(new moodle_url('/blog/index.php', array('entryid' => $entry->id)), format_string($entry->subject));
|
||||
$o .= $this->output->container($titlelink, 'subject');
|
||||
|
||||
// Post by.
|
||||
$by = new stdClass();
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $this->page->course->id);
|
||||
$fullname = fullname($entry->renderable->user, has_capability('moodle/site:viewfullnames', $coursecontext));
|
||||
$fullname = fullname($entry->renderable->user, has_capability('moodle/site:viewfullnames', $syscontext));
|
||||
$userurlparams = array('id' => $entry->renderable->user->id, 'course' => $this->page->course->id);
|
||||
$by->name = html_writer::link(new moodle_url('/user/view.php', $userurlparams), $fullname);
|
||||
$by->date = $entry->renderable->created;
|
||||
$by->name = html_writer::link(new moodle_url('/user/view.php', $userurlparams), $fullname);
|
||||
|
||||
$topiccell->text .= get_string('bynameondate', 'forum', $by);
|
||||
$topiccell->text .= $this->output->container_end();
|
||||
$by->date = userdate($entry->created);
|
||||
$o .= $this->output->container(get_string('bynameondate', 'forum', $by), 'author');
|
||||
|
||||
// Adding external blog link
|
||||
// Adding external blog link.
|
||||
if (!empty($entry->renderable->externalblogtext)) {
|
||||
$topiccell->text .= $this->output->container($entry->renderable->externalblogtext, 'externalblog');
|
||||
$o .= $this->output->container($entry->renderable->externalblogtext, 'externalblog');
|
||||
}
|
||||
|
||||
$topiccell->header = false;
|
||||
$table->head[] = $topiccell;
|
||||
// Closing subject tag and header tag.
|
||||
$o .= $this->output->container_end();
|
||||
$o .= $this->output->container_end();
|
||||
|
||||
// Actual content
|
||||
$mainrow = new html_table_row();
|
||||
// Post content.
|
||||
$o .= $this->output->container_start('row maincontent clearfix');
|
||||
|
||||
$leftsidecell = new html_table_cell();
|
||||
$leftsidecell->attributes['class'] = 'left side';
|
||||
$mainrow->cells[] = $leftsidecell;
|
||||
// Entry.
|
||||
$o .= $this->output->container_start('no-overflow content ');
|
||||
|
||||
$contentcell = new html_table_cell();
|
||||
$contentcell->attributes['class'] = 'content';
|
||||
|
||||
// Determine text for publish state
|
||||
switch ($entry->renderable->publishstate) {
|
||||
case 'draft':
|
||||
$blogtype = get_string('publishtonoone', 'blog');
|
||||
break;
|
||||
case 'site':
|
||||
$blogtype = get_string('publishtosite', 'blog');
|
||||
break;
|
||||
case 'public':
|
||||
$blogtype = get_string('publishtoworld', 'blog');
|
||||
break;
|
||||
default:
|
||||
$blogtype = '';
|
||||
break;
|
||||
|
||||
}
|
||||
$contentcell->text .= $this->output->container($blogtype, 'audience');
|
||||
// Determine text for publish state.
|
||||
switch ($entry->publishstate) {
|
||||
case 'draft':
|
||||
$blogtype = get_string('publishtonoone', 'blog');
|
||||
break;
|
||||
case 'site':
|
||||
$blogtype = get_string('publishtosite', 'blog');
|
||||
break;
|
||||
case 'public':
|
||||
$blogtype = get_string('publishtoworld', 'blog');
|
||||
break;
|
||||
default:
|
||||
$blogtype = '';
|
||||
break;
|
||||
|
||||
// Entry body
|
||||
$contentcell->text .= $entry->renderable->body;
|
||||
}
|
||||
$o .= $this->output->container($blogtype, 'audience');
|
||||
|
||||
// Entry attachments
|
||||
// Attachments.
|
||||
$attachmentsoutputs = array();
|
||||
if ($entry->renderable->attachments) {
|
||||
foreach ($entry->renderable->attachments as $attachment) {
|
||||
$attachmentsoutputs[] = $this->render($attachment, false);
|
||||
$o .= $this->render($attachment, false);
|
||||
}
|
||||
$contentcell->text .= $this->output->container(implode(', ', $attachmentsoutputs), 'attachments');
|
||||
}
|
||||
|
||||
// Uniquehash is used as a link to an external blog
|
||||
// Body.
|
||||
$o .= format_text($entry->summary, $entry->summaryformat, array('overflowdiv' => true));
|
||||
|
||||
// Uniquehash is used as a link to an external blog.
|
||||
if (!empty($entry->uniquehash)) {
|
||||
$contentcell->text .= $this->output->container_start('externalblog');
|
||||
$contentcell->text .= html_writer::link($entry->uniquehash, get_string('linktooriginalentry', 'blog'));
|
||||
$contentcell->text .= $this->output->container_end();
|
||||
$o .= $this->output->container_start('externalblog');
|
||||
$o .= html_writer::link($entry->uniquehash, get_string('linktooriginalentry', 'blog'));
|
||||
$o .= $this->output->container_end();
|
||||
}
|
||||
|
||||
// Links to tags
|
||||
// Links to tags.
|
||||
$officialtags = tag_get_tags_csv('post', $entry->id, TAG_RETURN_HTML, 'official');
|
||||
$defaulttags = tag_get_tags_csv('post', $entry->id, TAG_RETURN_HTML, 'default');
|
||||
|
||||
if (!empty($CFG->usetags) && ($officialtags || $defaulttags) ) {
|
||||
$contentcell->text .= $this->output->container_start('tags');
|
||||
$o .= $this->output->container_start('tags');
|
||||
|
||||
if ($officialtags) {
|
||||
$contentcell->text .= get_string('tags', 'tag') .': '. $this->output->container($officialtags, 'officialblogtags');
|
||||
$o .= get_string('tags', 'tag') .': '. $this->output->container($officialtags, 'officialblogtags');
|
||||
if ($defaulttags) {
|
||||
$contentcell->text .= ', ';
|
||||
$o .= ', ';
|
||||
}
|
||||
}
|
||||
$contentcell->text .= $defaulttags;
|
||||
$contentcell->text .= $this->output->container_end();
|
||||
$o .= $defaulttags;
|
||||
$o .= $this->output->container_end();
|
||||
}
|
||||
|
||||
// Add associations
|
||||
// Add associations.
|
||||
if (!empty($CFG->useblogassociations) && !empty($entry->renderable->blogassociations)) {
|
||||
$contentcell->text .= $this->output->container_start('tags');
|
||||
$hascourseassocs = false;
|
||||
|
||||
// First find and show the associated course
|
||||
$coursesstr = '';
|
||||
|
||||
// First find and show the associated course.
|
||||
$assocstr = '';
|
||||
$coursesarray = array();
|
||||
foreach ($entry->renderable->blogassociations as $assocrec) {
|
||||
$context = get_context_instance_by_id($assocrec->contextid);
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
if ($assocrec->contextlevel == CONTEXT_COURSE) {
|
||||
$coursesarray[] = $this->output->action_icon($assocrec->url, $assocrec->icon, null, array(), true);
|
||||
}
|
||||
}
|
||||
if (!empty($coursesarray)) {
|
||||
$coursesstr .= get_string('associated', 'blog', $assocrec->type) . ': ' . implode(', ', $coursesarray);
|
||||
$assocstr .= get_string('associated', 'blog', get_string('course')) . ': ' . implode(', ', $coursesarray);
|
||||
}
|
||||
|
||||
// Now show mod association
|
||||
$modulesstr = '';
|
||||
// Now show mod association.
|
||||
$modulesarray = array();
|
||||
foreach ($entry->renderable->blogassociations as $assocrec) {
|
||||
$context = get_context_instance_by_id($assocrec->contextid);
|
||||
|
||||
if ($context->contextlevel == CONTEXT_MODULE) {
|
||||
if ($assocrec->contextlevel == CONTEXT_MODULE) {
|
||||
$str = get_string('associated', 'blog', $assocrec->type) . ': ';
|
||||
$str .= $this->output->action_icon($assocrec->url, $assocrec->icon, null, array(), true);
|
||||
$modulesarray[] = $str;
|
||||
@@ -177,96 +169,84 @@ class core_blog_renderer extends plugin_renderer_base {
|
||||
}
|
||||
if (!empty($modulesarray)) {
|
||||
if (!empty($coursesarray)) {
|
||||
$modulesstr .= '<br/>';
|
||||
$assocstr .= '<br/>';
|
||||
}
|
||||
$modulesstr .= implode('<br/>', $modulesarray);
|
||||
$assocstr .= implode('<br/>', $modulesarray);
|
||||
}
|
||||
|
||||
$contentcell->text .= $coursesstr.$modulesstr;
|
||||
$contentcell->text .= $this->output->container_end();
|
||||
// Adding the asociations to the output.
|
||||
$o .= $this->output->container($assocstr, 'tags');
|
||||
}
|
||||
|
||||
if ($entry->renderable->unassociatedentry) {
|
||||
$contentcell->text .= $this->output->container(get_string('associationunviewable', 'blog'), 'noticebox');
|
||||
$o .= $this->output->container(get_string('associationunviewable', 'blog'), 'noticebox');
|
||||
}
|
||||
|
||||
/// Commands
|
||||
$contentcell->text .= $this->output->container_start('commands');
|
||||
// Commands.
|
||||
$o .= $this->output->container_start('commands');
|
||||
if ($entry->renderable->usercanedit) {
|
||||
|
||||
// External blog entries should not be edited.
|
||||
if (empty($entry->uniquehash)) {
|
||||
//External blog entries should not be edited
|
||||
$contentcell->text .= html_writer::link(new moodle_url('/blog/edit.php',
|
||||
$o .= html_writer::link(new moodle_url('/blog/edit.php',
|
||||
array('action' => 'edit', 'entryid' => $entry->id)),
|
||||
$stredit) . ' | ';
|
||||
}
|
||||
$contentcell->text .= html_writer::link(new moodle_url('/blog/edit.php',
|
||||
$o .= html_writer::link(new moodle_url('/blog/edit.php',
|
||||
array('action' => 'delete', 'entryid' => $entry->id)),
|
||||
$strdelete) . ' | ';
|
||||
}
|
||||
|
||||
$entryurl = new moodle_url('/blog/index.php', array('entryid' => $entry->id));
|
||||
$contentcell->text .= html_writer::link($entryurl, get_string('permalink', 'blog'));
|
||||
$o .= html_writer::link($entryurl, get_string('permalink', 'blog'));
|
||||
|
||||
$contentcell->text .= $this->output->container_end();
|
||||
$o .= $this->output->container_end();
|
||||
|
||||
if (isset($entry->renderable->lastmod) ) {
|
||||
$contentcell->text .= '<div>';
|
||||
$contentcell->text .= ' [ '.get_string('modified').': '.$entry->renderable->lastmod.' ]';
|
||||
$contentcell->text .= '</div>';
|
||||
// Last modification.
|
||||
if ($entry->created != $entry->lastmodified) {
|
||||
$o .= $this->output->container(' [ '.get_string('modified').': '.userdate($entry->lastmodified).' ]');
|
||||
}
|
||||
|
||||
//add comments under everything
|
||||
// Comments.
|
||||
if (!empty($entry->renderable->comment)) {
|
||||
$contentcell->text .= $entry->renderable->comment->output(true);
|
||||
$o .= $entry->renderable->comment->output(true);
|
||||
}
|
||||
|
||||
$mainrow->cells[] = $contentcell;
|
||||
$table->data = array($mainrow);
|
||||
$o .= $this->output->container_end();
|
||||
|
||||
return html_writer::table($table);
|
||||
// Closing maincontent div.
|
||||
$o .= $this->output->container(' ', 'side options');
|
||||
$o .= $this->output->container_end();
|
||||
|
||||
$o .= $this->output->container_end();
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an entry attachment
|
||||
*
|
||||
* if return=html, then return a html string.
|
||||
* if return=text, then return a text-only string.
|
||||
* otherwise, print HTML for non-images, and return image HTML
|
||||
* Print link for non-images and returns images as HTML
|
||||
*
|
||||
* @param blog_entry_attachment $attachment
|
||||
* @param bool $return Whether to return or print the generated code
|
||||
* @return string List of attachments depending on the $return input
|
||||
*/
|
||||
public function render_blog_entry_attachment(blog_entry_attachment $attachment, $return = false) {
|
||||
public function render_blog_entry_attachment(blog_entry_attachment $attachment) {
|
||||
|
||||
$syscontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$strattachment = get_string("attachment", "forum");
|
||||
|
||||
$image = $this->output->pix_icon(file_file_icon($attachment->file), $attachment->filename, 'moodle', array('class'=>'icon'));
|
||||
|
||||
$o = '';
|
||||
$imagereturn = '';
|
||||
|
||||
if ($return == "html") {
|
||||
$o .= html_writer::link($attachment->url, $image);
|
||||
$o .= html_writer::link($attachment->url, $attachment->filename);
|
||||
|
||||
} else if ($return == "text") {
|
||||
$o .= "$strattachment $attachment->filename:\n$attachment->url\n";
|
||||
$syscontext = context_system::instance();
|
||||
|
||||
// Image attachments don't get printed as links.
|
||||
if (file_mimetype_in_typegroup($attachment->file->get_mimetype(), 'web_image')) {
|
||||
$attrs = array('src' => $attachment->url, 'alt' => '');
|
||||
$o = html_writer::empty_tag('img', $attrs);
|
||||
$class = 'attachedimages';
|
||||
} else {
|
||||
if (file_mimetype_in_typegroup($attachment->file->get_mimetype(), 'web_image')) { // Image attachments don't get printed as links
|
||||
$imagereturn .= '<br /><img src="'.$attachment->url.'" alt="" />';
|
||||
} else {
|
||||
$imagereturn .= html_writer::link($attachment->url, $image);
|
||||
$imagereturn .= format_text(html_writer::link($attachment->url, $attachment->filename), FORMAT_HTML, array('context'=>$syscontext));
|
||||
}
|
||||
$image = $this->output->pix_icon(file_file_icon($attachment->file), $attachment->filename, 'moodle', array('class'=>'icon'));
|
||||
$o = html_writer::link($attachment->url, $image);
|
||||
$o .= format_text(html_writer::link($attachment->url, $attachment->filename), FORMAT_HTML, array('context' => $syscontext));
|
||||
$class = 'attachments';
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
return $o;
|
||||
}
|
||||
|
||||
return $imagereturn;
|
||||
|
||||
return $this->output->container($o, $class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,6 +191,10 @@ h2.headingblock {
|
||||
padding: 5px 10px 10px;
|
||||
}
|
||||
|
||||
/* Blogs */
|
||||
|
||||
.blog_entry .content {margin-left: 43px;}
|
||||
|
||||
/* Dock */
|
||||
|
||||
#dock {
|
||||
@@ -298,4 +302,4 @@ h2.headingblock {
|
||||
}
|
||||
#custommenu .custom_menu_submenu .custom_menu_submenu .yui3-menu-content {
|
||||
border-top:1px solid #DDD;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,8 +252,9 @@ input#id_externalurl {direction:ltr;}
|
||||
* Blogs
|
||||
*/
|
||||
.addbloglink {text-align: center;}
|
||||
.blog_entry .audience {text-align: right;}
|
||||
.blog_entry .audience {text-align: right;padding-right: 4px;}
|
||||
.blog_entry .tags {margin-top: 15px;}
|
||||
.blog_entry .content {margin-left: 43px;}
|
||||
|
||||
/**
|
||||
* Group
|
||||
|
||||
Reference in New Issue
Block a user