public static function render_instance(BlockInstance $instance, $editing = false) { $configdata = $instance->get('configdata'); $text = isset($configdata['text']) ? $configdata['text'] : ''; safe_require('artefact', 'file'); $text = ArtefactTypeFolder::append_view_url($text, $instance->get('view')); return clean_html($text); }
public static function render_instance(BlockInstance $instance, $editing = false) { safe_require('artefact', 'file'); $configdata = $instance->get('configdata'); $smarty = smarty_core(); if (array_key_exists('text', $configdata)) { $newtext = ArtefactTypeFolder::append_view_url($configdata['text'], $instance->get('view')); $smarty->assign('text', $newtext); } else { $smarty->assign('text', ''); } return $smarty->fetch('blocktype:text:content.tpl'); }
public static function render_instance(BlockInstance $instance, $editing = false) { $configdata = $instance->get('configdata'); if (!empty($configdata['artefactid'])) { safe_require('artefact', 'file'); safe_require('artefact', 'comment'); $artefact = $instance->get_artefact_instance($configdata['artefactid']); $viewid = $instance->get('view'); $text = ArtefactTypeFolder::append_view_url($artefact->get('note'), $viewid); $information = ArtefactTypeFolder::append_view_url($artefact->get('description'), $viewid); $literature = $configdata['literature']; $smarty = smarty_core(); $smarty->assign('text', $text); $smarty->assign('information', $information); $smarty->assign('literature', $literature); $attachments = $artefact->get_attachments(); if ($attachments) { require_once get_config('docroot') . 'artefact/lib.php'; foreach ($attachments as &$attachment) { $f = artefact_instance_from_id($attachment->id); $attachment->size = $f->describe_size(); $attachment->iconpath = $f->get_icon(array('id' => $attachment->id, 'viewid' => isset($options['viewid']) ? $options['viewid'] : 0)); $attachment->viewpath = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $attachment->id . '&view=' . (isset($viewid) ? $viewid : 0); $attachment->downloadpath = get_config('wwwroot') . 'artefact/file/download.php?file=' . $attachment->id; if (isset($viewid)) { $attachment->downloadpath .= '&view=' . $viewid; } } $smarty->assign('attachments', $attachments); $smarty->assign('count', count($attachments)); } require_once get_config('docroot') . 'lib/view.php'; $view = new View($viewid); list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing); $smarty->assign('commentcount', $commentcount); $smarty->assign('comments', $comments); $smarty->assign('blockid', $instance->get('id')); return $smarty->fetch('blocktype:eselmagraduation:content.tpl'); } return ''; }
public static function render_instance(BlockInstance $instance, $editing = false) { $configdata = $instance->get('configdata'); if (!empty($configdata['artefactid'])) { safe_require('artefact', 'file'); safe_require('artefact', 'comment'); $artefact = $instance->get_artefact_instance($configdata['artefactid']); $viewid = $instance->get('view'); $text = ArtefactTypeFolder::append_view_url($artefact->get('description'), $viewid); $smarty = smarty_core(); $smarty->assign('text', $text); $attachments = $artefact->get_attachments(); if ($attachments) { require_once get_config('docroot') . 'artefact/lib.php'; foreach ($attachments as &$attachment) { $f = artefact_instance_from_id($attachment->id); $attachment->size = $f->describe_size(); $attachment->iconpath = $f->get_icon(array('id' => $attachment->id, 'viewid' => isset($options['viewid']) ? $options['viewid'] : 0)); $attachment->viewpath = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $attachment->id . '&view=' . (isset($viewid) ? $viewid : 0); $attachment->downloadpath = get_config('wwwroot') . 'artefact/file/download.php?file=' . $attachment->id; if (isset($viewid)) { $attachment->downloadpath .= '&view=' . $viewid; } } $smarty->assign('attachments', $attachments); $smarty->assign('count', count($attachments)); } if ($artefact->get('allowcomments')) { $commentcount = ArtefactTypeComment::count_comments(null, array($configdata['artefactid'])); $commentcount = isset($commentcount[$configdata['artefactid']]) ? $commentcount[$configdata['artefactid']]->comments : 0; $artefacturl = get_config('wwwroot') . 'artefact/artefact.php?view=' . $viewid . '&artefact=' . $configdata['artefactid']; $smarty->assign('artefacturl', $artefacturl); $smarty->assign('commentcount', $commentcount); } return $smarty->fetch('blocktype:textbox:content.tpl'); } return ''; }
// in the initial call to smarty() $smarty->assign('sitelogo', $THEME->header_logo($skindata['header_logo_image'])); } } } // Provide a link for roaming teachers to return if ($mnetviewlist = $SESSION->get('mnetviewaccess')) { if (isset($mnetviewlist[$view->get('id')])) { $returnurl = $SESSION->get('mnetuserfrom'); require_once get_config('docroot') . 'api/xmlrpc/lib.php'; if ($peer = get_peer_from_instanceid($SESSION->get('authinstance'))) { $smarty->assign('mnethost', array('name' => $peer->name, 'url' => $returnurl ? $returnurl : $peer->wwwroot)); } } } $smarty->assign('viewdescription', ArtefactTypeFolder::append_view_url($view->get('description'), $view->get('id'))); $smarty->assign('viewcontent', $viewcontent); $smarty->assign('releaseform', $releaseform); if (isset($addfeedbackform)) { $smarty->assign('enablecomments', 1); $smarty->assign('addfeedbackform', $addfeedbackform); } if (isset($objectionform)) { $smarty->assign('objectionform', $objectionform); $smarty->assign('notrudeform', $notrudeform); } $smarty->assign('viewbeingwatched', $viewbeingwatched); if ($viewgroupform) { $smarty->assign('view_group_submission_form', $viewgroupform); } if ($titletext !== $title) {
/** * This function returns a list of posts in a given blog. * * @param integer * @param integer * @param integer * @param array */ public static function get_posts($id, $limit, $offset, $viewoptions = null) { $results = array('limit' => $limit, 'offset' => $offset); // If viewoptions is null, we're getting posts for the my blogs area, // and we should get all posts & show drafts first. Otherwise it's a // blog in a view, and we should only get published posts. $from = "\n FROM {artefact} a LEFT JOIN {artefact_blog_blogpost} bp ON a.id = bp.blogpost\n WHERE a.artefacttype = 'blogpost' AND a.parent = ?"; if (!is_null($viewoptions)) { if (isset($viewoptions['before'])) { $from .= " AND a.ctime < '{$viewoptions['before']}'"; } $from .= ' AND bp.published = 1'; } $results['count'] = count_records_sql('SELECT COUNT(*) ' . $from, array($id)); $data = get_records_sql_assoc(' SELECT a.id, a.title, a.description, a.author, a.authorname, ' . db_format_tsfield('a.ctime', 'ctime') . ', ' . db_format_tsfield('a.mtime', 'mtime') . ', a.locked, bp.published, a.allowcomments ' . $from . ' ORDER BY bp.published ASC, a.ctime DESC, a.id DESC', array($id), $offset, $limit); if (!$data) { $results['data'] = array(); return $results; } // Get the attached files. $postids = array_map(create_function('$a', 'return $a->id;'), $data); $files = ArtefactType::attachments_from_id_list($postids); if ($files) { safe_require('artefact', 'file'); foreach ($files as &$file) { $params = array('id' => $file->attachment); if (!empty($viewoptions['viewid'])) { $params['viewid'] = $viewoptions['viewid']; } $file->icon = call_static_method(generate_artefact_class_name($file->artefacttype), 'get_icon', $params); $data[$file->artefact]->files[] = $file; } } if ($tags = ArtefactType::tags_from_id_list($postids)) { foreach ($tags as &$at) { $data[$at->artefact]->tags[] = $at->tag; } } foreach ($data as &$post) { // Format dates properly if (is_null($viewoptions)) { // My Blogs area: create forms for changing post status & deleting posts. $post->changepoststatus = ArtefactTypeBlogpost::changepoststatus_form($post->id, $post->published); $post->delete = ArtefactTypeBlogpost::delete_form($post->id, $post->title); } else { $by = $post->author ? display_default_name($post->author) : $post->authorname; $post->postedby = get_string('postedbyon', 'artefact.blog', $by, format_date($post->ctime)); // Get comment counts if (!empty($viewoptions['countcomments'])) { safe_require('artefact', 'comment'); require_once get_config('docroot') . 'lib/view.php'; $view = new View($viewoptions['viewid']); $artefact = artefact_instance_from_id($post->id); list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, null, false); $post->commentcount = $commentcount; $post->comments = $comments; } } $post->ctime = format_date($post->ctime, 'strftimedaydatetime'); $post->mtime = format_date($post->mtime); // Ensure images in the post have the right viewid associated with them if (!empty($viewoptions['viewid'])) { safe_require('artefact', 'file'); $post->description = ArtefactTypeFolder::append_view_url($post->description, $viewoptions['viewid']); } } $results['data'] = array_values($data); return $results; }
/** * Dumps all views into the PDF ready HTML format */ private function create_html() { global $THEME; $progressstart = 55; $progressend = 75; $i = 0; $viewcount = count($this->views); // multiple views append header with standard theme if (!$this->exportingoneview) { $smarty = $this->get_smarty(); $header = $smarty->fetch('export:pdf:head.tpl'); if (!file_put_contents("{$this->exportdir}/{$this->rootdir}/" . "index.html", $header, FILE_APPEND | LOCK_EX)) { throw new SystemException("Could not write view page for pdf export"); } } foreach ($this->views as $id => $view) { $this->notify_progress_callback(intval($progressstart + ++$i / $viewcount * ($progressend - $progressstart)), get_string('exportingviewsprogress', 'export', $i, $viewcount)); // Set up view theme if we're just exporting a single view if (!isset($smarty) && $this->exportingoneview) { $viewtheme = $view->get('theme'); if ($viewtheme && $THEME->basename != $viewtheme) { $THEME = new Theme($viewtheme); } $smarty = $this->get_smarty(); $header = $smarty->fetch('export:pdf:head.tpl'); if (!file_put_contents("{$this->exportdir}/{$this->rootdir}/" . "index.html", $header, FILE_APPEND | LOCK_EX)) { throw new SystemException("Could not write view page for pdf export"); } } $owner = $view->get('owner'); $viewtype = $view->get('type'); if (get_config('viewmicroheaders')) { $smarty->assign('microheadertitle', $view->display_title(true, false)); } // fetch the html for a single view $smarty->assign('viewtitle', $view->get('title')); $smarty->assign('ownername', $view->formatted_owner()); $smarty->assign('viewdescription', ArtefactTypeFolder::append_view_url($view->get('description'), $view->get('id'))); $smarty->assign('viewcontent', $view->build_rows(false, true)); $smarty->assign('tags', $view->get('tags')); $viewcontent = $smarty->fetch('export:pdf:view.tpl'); // include a pagebreak into the pdf if we are exporting multiple views if (!$this->exportingoneview && $i < $viewcount) { $viewcontent .= $smarty->fetch('export:pdf:pagebreak.tpl'); } // append any new views to the end of the main html for a bulk export if (!file_put_contents("{$this->exportdir}/{$this->rootdir}/" . "index.html", $viewcontent, FILE_APPEND | LOCK_EX)) { throw new SystemException("Could not write view page for pdf export"); } } // append footer $footer = $smarty->fetch('export:pdf:foot.tpl'); if (!file_put_contents("{$this->exportdir}/{$this->rootdir}/" . "index.html", $footer, FILE_APPEND | LOCK_EX)) { throw new SystemException("Could not write view page for pdf export"); } }
public function render_self($options) { $smarty = smarty_core(); $artefacturl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $this->get('id'); if (isset($options['viewid'])) { $artefacturl .= '&view=' . $options['viewid']; } $smarty->assign('artefacturl', $artefacturl); if (empty($options['hidetitle'])) { if (isset($options['viewid'])) { $smarty->assign('artefacttitle', '<a href="' . $artefacturl . '">' . hsc($this->get('title')) . '</a>'); } else { $smarty->assign('artefacttitle', hsc($this->get('title'))); } } // We need to make sure that the images in the post have the right viewid associated with them $postcontent = $this->get('description'); if (isset($options['viewid'])) { safe_require('artefact', 'file'); $postcontent = ArtefactTypeFolder::append_view_url($postcontent, $options['viewid']); if (isset($options['countcomments']) && $this->allowcomments) { safe_require('artefact', 'comment'); $empty = array(); $ids = array($this->id); $commentcount = ArtefactTypeComment::count_comments($empty, $ids); $smarty->assign('commentcount', $commentcount ? $commentcount[$this->id]->comments : 0); } } $smarty->assign('artefactdescription', $postcontent); $smarty->assign('artefact', $this); $attachments = $this->get_attachments(); if ($attachments) { $this->add_to_render_path($options); require_once get_config('docroot') . 'artefact/lib.php'; foreach ($attachments as &$attachment) { $f = artefact_instance_from_id($attachment->id); $attachment->size = $f->describe_size(); $attachment->iconpath = $f->get_icon(array('id' => $attachment->id, 'viewid' => isset($options['viewid']) ? $options['viewid'] : 0)); $attachment->viewpath = get_config('wwwroot') . 'view/artefact.php?artefact=' . $attachment->id . '&view=' . (isset($options['viewid']) ? $options['viewid'] : 0); $attachment->downloadpath = get_config('wwwroot') . 'artefact/file/download.php?file=' . $attachment->id; if (isset($options['viewid'])) { $attachment->downloadpath .= '&view=' . $options['viewid']; } } $smarty->assign('attachments', $attachments); } $smarty->assign('postedbyon', get_string('postedbyon', 'artefact.blog', display_name($this->owner), format_date($this->ctime))); return array('html' => $smarty->fetch('artefact:blog:render/blogpost_renderfull.tpl'), 'javascript' => ''); }