コード例 #1
0
ファイル: lib.php プロジェクト: kienv/mahara
 /**
  * A dummy method, giving graceful output, if this method is not implemented in the relevant child class
  */
 public function render_self($options)
 {
     $smarty = smarty_core();
     $smarty->assign('title', $this->get('title'));
     $smarty->assign('owner', $this->get('owner'));
     $smarty->assign('tags', $this->get('tags'));
     $smarty->assign('description', $this->get('description'));
     if (!empty($options['details']) and get_config('licensemetadata')) {
         $smarty->assign('license', render_license($this));
     } else {
         $smarty->assign('license', false);
     }
     return array('html' => $smarty->fetch('artefact.tpl'), 'javascript' => '');
 }
コード例 #2
0
ファイル: lib.php プロジェクト: sarahjcotton/mahara
 public function render_self($options)
 {
     $smarty = smarty_core();
     $smarty->assign('title', $this->get('title'));
     $smarty->assign('owner', $this->get('owner'));
     $smarty->assign('tags', $this->get('tags'));
     $smarty->assign('description', $this->get('description'));
     if (!empty($options['details']) and get_config('licensemetadata')) {
         $smarty->assign('license', render_license($this));
     } else {
         $smarty->assign('license', false);
     }
     $attachments = $this->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($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);
     }
     return array('html' => $smarty->fetch('artefact.tpl'), 'javascript' => '');
 }
コード例 #3
0
ファイル: lib.php プロジェクト: banterweb/mahara
 public static function instance_config_form(BlockInstance $instance)
 {
     global $USER;
     require_once 'license.php';
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'internal');
     $configdata = $instance->get('configdata');
     if (!($height = get_config('blockeditorheight'))) {
         $cfheight = param_integer('cfheight', 0);
         $height = $cfheight ? $cfheight * 0.7 : 150;
     }
     $otherblockcount = 0;
     $readonly = false;
     $text = '';
     $tags = '';
     $view = $instance->get_view();
     if (!empty($configdata['artefactid'])) {
         $artefactid = $configdata['artefactid'];
         try {
             $artefact = $instance->get_artefact_instance($artefactid);
             $readonly = $artefact->get('owner') !== $view->get('owner') || $artefact->get('group') !== $view->get('group') || $artefact->get('institution') !== $view->get('institution') || $artefact->get('locked') || !$USER->can_edit_artefact($artefact);
             $text = $artefact->get('description');
             $tags = $artefact->get('tags');
             if ($blocks = get_column('view_artefact', 'block', 'artefact', $artefactid)) {
                 $blocks = array_unique($blocks);
                 $otherblockcount = count($blocks) - 1;
             }
         } catch (ArtefactNotFoundException $e) {
             unset($artefactid);
         }
     }
     $otherblocksmsg = '<span id="textbox_blockcount">' . $otherblockcount . '</span>';
     $otherblocksmsg = get_string('textusedinotherblocks', 'blocktype.internal/textbox', $otherblocksmsg);
     $manageurl = get_config('wwwroot') . 'artefact/internal/notes.php';
     if ($group = $view->get('group')) {
         $manageurl .= '?group=' . $group;
     } else {
         if ($institution = $view->get('institution')) {
             $manageurl .= '?institution=' . $institution;
         }
     }
     // Update the attached files in block configdata as
     // it may change when attached files have been deleted
     $attachmentids = isset($artefact) ? $artefact->attachment_id_list() : false;
     if ($attachmentids !== false && isset($configdata['artefactids']) && $configdata['artefactids'] != $attachmentids) {
         $configdata['artefactids'] = $attachmentids;
         $instance->set('configdata', $configdata);
         $instance->commit();
     }
     $elements = array('otherblocksmsg' => array('type' => 'html', 'class' => 'message info' . ($otherblockcount && !$readonly ? '' : ' hidden'), 'value' => '<p class="alert alert-info">' . $otherblocksmsg . ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a></p>', 'help' => true), 'readonlymsg' => array('type' => 'html', 'class' => 'message info' . ($readonly ? '' : ' hidden'), 'value' => '<p class="alert alert-info">' . get_string('readonlymessage', 'blocktype.internal/textbox') . ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a></p>', 'help' => true), 'text' => array('type' => 'wysiwyg', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('blockcontent', 'blocktype.internal/textbox'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $text, 'rules' => array('maxlength' => 65536)), 'textreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('blockcontent', 'blocktype.internal/textbox'), 'value' => '<div id="instconf_textreadonly_display" class="well text-midtone">' . $text . '</div>'), 'makecopy' => array('type' => 'checkbox', 'class' => 'hidden', 'defaultvalue' => false), 'chooseartefact' => array('type' => 'html', 'value' => '<a id="chooseartefactlink" href="#" class="btn btn-default">' . get_string('usecontentfromanothertextbox1', 'blocktype.internal/textbox') . '</a>'), 'managenotes' => array('type' => 'html', 'class' => 'hidden text-right', 'value' => '<a href="' . $manageurl . '" target="_blank" class="pull-right">' . get_string('managealltextboxcontent1', 'blocktype.internal/textbox') . ' <span class="icon icon-arrow-right right"></span></a>'), 'artefactid' => self::artefactchooser_element(isset($artefactid) ? $artefactid : null), 'license' => license_form_el_basic(isset($artefact) ? $artefact : null), 'license_advanced' => license_form_el_advanced(isset($artefact) ? $artefact : null), 'licensereadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('license'), 'value' => '<div id="instconf_licensereadonly_display">' . (isset($artefact) ? render_license($artefact) : get_string('licensenone')) . '</div>'), 'allowcomments' => array('type' => 'switchbox', 'title' => get_string('allowcomments', 'artefact.comment'), 'defaultvalue' => !empty($artefact) ? $artefact->get('allowcomments') : 1), 'tags' => array('type' => 'tags', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('tags'), 'description' => get_string('tagsdescprofile'), 'defaultvalue' => $tags), 'tagsreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('tags'), 'value' => '<div id="instconf_tagsreadonly_display">' . (is_array($tags) ? hsc(join(', ', $tags)) : '') . '</div>'), 'artefactfieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('attachments', 'artefact.blog'), 'class' => 'last with-formgroup', 'elements' => array('artefactids' => self::filebrowser_element($instance, isset($configdata['artefactids']) ? $configdata['artefactids'] : null))));
     if ($readonly) {
         $elements['license']['class'] = 'hidden';
         $elements['license_advanced']['class'] = 'hidden';
     }
     return $elements;
 }
コード例 #4
0
ファイル: lib.php プロジェクト: vohung96/mahara
 public function render_license($options, &$smarty)
 {
     if (!empty($options['details']) and get_config('licensemetadata')) {
         $smarty->assign('license', render_license($this->get_license_artefact()));
     } else {
         $smarty->assign('license', false);
     }
 }
コード例 #5
0
ファイル: lib.php プロジェクト: vohung96/mahara
 public function render_self($options)
 {
     require_once 'license.php';
     $options['id'] = $this->get('id');
     $downloadpath = get_config('wwwroot') . 'artefact/file/download.php?file=' . $this->get('id');
     if (isset($options['viewid'])) {
         $downloadpath .= '&view=' . $options['viewid'];
     }
     $filetype = get_string($this->get('oldextension'), 'artefact.file');
     if (substr($filetype, 0, 2) == '[[') {
         $filetype = $this->get('oldextension') . ' ' . get_string('file', 'artefact.file');
     }
     $smarty = smarty_core();
     $smarty->assign('iconpath', $this->get_icon($options));
     $smarty->assign('downloadpath', $downloadpath);
     $smarty->assign('filetype', $filetype);
     $smarty->assign('ownername', $this->display_owner());
     $smarty->assign('created', strftime(get_string('strftimedaydatetime'), $this->get('ctime')));
     $smarty->assign('modified', strftime(get_string('strftimedaydatetime'), $this->get('mtime')));
     $smarty->assign('size', $this->describe_size() . ' (' . $this->get('size') . ' ' . get_string('bytes', 'artefact.file') . ')');
     if (get_config('licensemetadata')) {
         $smarty->assign('license', render_license($this));
     } else {
         $smarty->assign('license', false);
     }
     foreach (array('title', 'description', 'artefacttype', 'owner', 'tags') as $field) {
         $smarty->assign($field, $this->get($field));
     }
     return array('html' => $smarty->fetch('artefact:file:file_render_self.tpl'), 'javascript' => '');
 }
コード例 #6
0
 public function render_self($options)
 {
     $limit = !isset($options['limit']) ? 10 : (int) $options['limit'];
     $offset = isset($options['offset']) ? intval($options['offset']) : 0;
     $tasks = ArtefactTypeTask::get_tasks($this->id, $offset, $limit);
     $template = 'artefact:plans:taskrows.tpl';
     $baseurl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $this->id;
     if (!empty($options['viewid'])) {
         $baseurl .= '&view=' . $options['viewid'];
     }
     $pagination = array('baseurl' => $baseurl, 'id' => 'task_pagination', 'datatable' => 'tasktable', 'jsonscript' => 'artefact/plans/viewtasks.json.php');
     ArtefactTypeTask::render_tasks($tasks, $template, $options, $pagination);
     $smarty = smarty_core();
     $smarty->assign_by_ref('tasks', $tasks);
     if (isset($options['viewid'])) {
         $smarty->assign('artefacttitle', '<a href="' . $baseurl . '">' . hsc($this->get('title')) . '</a>');
     } else {
         $smarty->assign('artefacttitle', hsc($this->get('title')));
     }
     $smarty->assign('plan', $this);
     if (!empty($options['details']) and get_config('licensemetadata')) {
         $smarty->assign('license', render_license($this));
     } else {
         $smarty->assign('license', false);
     }
     $smarty->assign('owner', $this->get('owner'));
     $smarty->assign('tags', $this->get('tags'));
     return array('html' => $smarty->fetch('artefact:plans:viewplan.tpl'), 'javascript' => '');
 }
コード例 #7
0
ファイル: lib.php プロジェクト: sarahjcotton/mahara
 public function render_self($options)
 {
     global $USER;
     $smarty = smarty_core();
     $smarty->assign('published', $this->get('published'));
     if (!$this->get('published')) {
         $notpublishedblogpoststr = get_string('notpublishedblogpost', 'artefact.blog');
         if ($this->get('owner') == $USER->get('id')) {
             $notpublishedblogpoststr .= ' <a href="' . get_config('wwwroot') . 'artefact/blog/post.php?id=' . $this->get('id') . '">' . get_string('publishit', 'artefact.blog') . '</a>';
         }
         $smarty->assign('notpublishedblogpost', $notpublishedblogpoststr);
     }
     $artefacturl = get_config('wwwroot') . 'artefact/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']);
     }
     $smarty->assign('artefactdescription', $postcontent);
     $smarty->assign('artefacttags', $this->get('tags'));
     $smarty->assign('artefactowner', $this->get('owner'));
     if (!empty($options['details']) and get_config('licensemetadata')) {
         $smarty->assign('license', render_license($this));
     } else {
         $smarty->assign('license', false);
     }
     $attachments = $this->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($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);
         if (isset($options['blockid'])) {
             $smarty->assign('blockid', $options['blockid']);
         }
         $smarty->assign('postid', $this->get('id'));
     }
     $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' => '');
 }