Commit 953a5eab authored by Lisa Seeto's avatar Lisa Seeto
Browse files

Bug 1827811: Resume Icons



- get attachment comment counts for bh icons
- display plain text for titles in editing mode
- change the way the commentlink is targetted via js
- add blockid's to resume attachments
- for folder block: add comment count, change titles from
	links to plain text when editing
- change notes attachment file titles from links to plain
	text when editing
- get rid of the single artefact block title links for html exports
---------------------------------------------------------
Add fixes:
- blocks that have set types but no artefacts attached don't have modal links
- pdf block is now using block header and comment count is loaded
- block headers are above titles
- tagged journals have icons when in full and matches recent posts styling
- deleting all comments produces correct icon on block header
- html exports should not hang on opening modal
- get rid of warning error re: dock.show() when redirecting from &modal=1 style url
- code review fixes for all previous patches + fix issue with folders block
- added in viewdetailsfilter.json.php file to save details mode to user account prefs table
- make the details btn mode "sticky" so it stays the save value over multiple pages etc...
- Image Gallery blocks: if displaying a folder of images will get the bar block header and
will have a the fancy box image preview displaying on image click

Change-Id: I425cc5a634e176d580aacdb60a20f869f7cb7496
Signed-off-by: default avatarLisa Seeto <lisaseeto@catalyst.net.nz>
parent f8d9ec0a
......@@ -16,6 +16,10 @@ class PluginBlocktypeAnnotation extends MaharaCoreBlocktype {
return false;
}
public static function single_artefact_per_block() {
return false;
}
public static function get_title() {
return get_string('title', 'blocktype.annotation/annotation');
}
......
......@@ -17,6 +17,11 @@ class PluginBlocktypeBlogpost extends MaharaCoreBlocktype {
return get_string('title', 'blocktype.blog/blogpost');
}
//The block only allows one artefact
public static function single_artefact_per_block() {
return true;
}
/**
* Optional method. If exists, allows this class to decide the title for
* all blockinstances of this type
......@@ -47,7 +52,6 @@ class PluginBlocktypeBlogpost extends MaharaCoreBlocktype {
if ($artefactid) {
require_once(get_config('docroot') . 'artefact/lib.php');
$artefact = $instance->get_artefact_instance($artefactid);
$smarty->assign('artefactid', $artefactid);
$configdata['hidetitle'] = true;
$configdata['countcomments'] = true;
$configdata['viewid'] = $instance->get('view');
......@@ -57,14 +61,7 @@ class PluginBlocktypeBlogpost extends MaharaCoreBlocktype {
$result = $result['html'];
require_once(get_config('docroot') . 'artefact/comment/lib.php');
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
$smarty->assign('commentcount', $commentcount);
$smarty->assign('allowcomments', $artefact->get('allowcomments'));
}
$smarty->assign('editing', $editing);
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:blogpost:blogpost.tpl');
}
......
......@@ -135,7 +135,7 @@ class PluginBlocktypeRecentposts extends MaharaCoreBlocktype {
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('editing', $editing);
$smarty->assign('licensemetadata', get_config('licensemetadata') ? true : false);
$smarty->assign('canviewblog', $data->owner == $USER->get('id'));
$smarty->assign('canviewblog', $data->owner == $USER->can_view_artefact($blog));
if ($editing) {
// Get id and title of configued blogs
......
......@@ -21,6 +21,10 @@ class PluginBlocktypeComment extends MaharaCoreBlocktype {
return true;
}
public static function single_artefact_per_block() {
return false;
}
public static function get_title() {
return get_string('title', 'blocktype.comment/comment');
......
......@@ -1055,7 +1055,7 @@ class ArtefactTypeComment extends ArtefactType {
);
}
public static function delete_comment_form($id, $blockid=null, $artefactid=null, $threaded=null) {
public static function delete_comment_form($id, $blockid=null, $artefactid=null, $threaded=false) {
global $THEME;
$form = array(
......
......@@ -44,6 +44,7 @@ class PluginBlocktypeFolder extends MaharaCoreBlocktype {
$configdata['viewid'] = $instance->get('view');
$configdata['simpledisplay'] = true;
$configdata['blockid'] = $instance->get('id');
$configdata['editing'] = $editing;
// This can be either an image or profileicon. They both implement
// render_self
......
......@@ -19,6 +19,14 @@ class PluginBlocktypeGallery extends MaharaCoreBlocktype {
return get_string('title', 'blocktype.file/gallery');
}
/** When the Image Gallery is displayed from a folder it will have a single
** artefact and warrant a details block header. No header will display if
** individual images (with multiple artefacts) were selected instead.
**/
public static function single_artefact_per_block() {
return true;
}
public static function get_description() {
return get_string('description1', 'blocktype.file/gallery');
}
......@@ -396,6 +404,7 @@ class PluginBlocktypeGallery extends MaharaCoreBlocktype {
}
$images[] = array(
'id' => $image->get('id'),
'link' => $link,
'source' => $src,
'height' => $height,
......@@ -409,15 +418,12 @@ class PluginBlocktypeGallery extends MaharaCoreBlocktype {
}
$smarty = smarty_core();
$smarty->assign('instanceid', $instance->get('id'));
if (isset($configdata['artefactid'])) {
$smarty->assign('artefactid', $configdata['artefactid']);
}
$smarty->assign('count', count($images));
$smarty->assign('images', $images);
$smarty->assign('showdescription', (!empty($configdata['showdescription'])) ? $configdata['showdescription'] : false);
$smarty->assign('width', $width);
$smarty->assign('editing', $editing);
$smarty->assign('blockid', $instance->get('id'));
if (isset($height)) {
$smarty->assign('height', $height);
}
......
......@@ -25,6 +25,10 @@ class PluginBlocktypeHtml extends MaharaCoreBlocktype {
return array('fileimagevideo' => 9000);
}
public static function single_artefact_per_block() {
return true;
}
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata'); // this will make sure to unserialize it for us
$configdata['viewid'] = $instance->get('view');
......
......@@ -32,6 +32,10 @@ class PluginBlocktypeImage extends MaharaCoreBlocktype {
return array('shortcut' => 2000);
}
public static function single_artefact_per_block() {
return true;
}
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata'); // this will make sure to unserialize it for us
......
......@@ -26,6 +26,10 @@ class PluginBlocktypeInternalmedia extends MaharaCoreBlocktype {
return get_string('title', 'blocktype.file/internalmedia');
}
public static function single_artefact_per_block() {
return true;
}
public static function get_description() {
return get_string('description', 'blocktype.file/internalmedia');
}
......@@ -68,9 +72,7 @@ class PluginBlocktypeInternalmedia extends MaharaCoreBlocktype {
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
$blockheader = $smarty->fetch('header/block-comments-details-header.tpl');
$result = $blockheader;
$result .= '<div class="mediaplayer-container card-body flush"><div class="mediaplayer">';
$result = '<div class="mediaplayer-container card-body flush"><div class="mediaplayer">';
$result .= call_static_method($playerclass, 'get_html', $artefact, $instance, $width, $height);
$result .= '</div></div>';
......
......@@ -17,6 +17,10 @@ class PluginBlocktypePdf extends MaharaCoreBlocktype {
return false;
}
public static function single_artefact_per_block() {
return true;
}
public static function get_title() {
return get_string('title', 'blocktype.file/pdf');
}
......@@ -81,12 +85,16 @@ class PluginBlocktypePdf extends MaharaCoreBlocktype {
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
}
$smarty = smarty_core();
if ($artefactid) {
$smarty->assign('artefactid', $artefactid);
$artefact = $instance->get_artefact_instance($configdata['artefactid']);
$smarty->assign('allowcomments', $artefact->get('allowcomments'));
if ($commentcount) {
$smarty->assign('commentcount', $commentcount);
}
}
$smarty->assign('html', $result);
$smarty->assign('editing', $editing);
......
......@@ -2170,6 +2170,9 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
$smarty->assign('simpledisplay', isset($options['simpledisplay']) ? $options['simpledisplay'] : false);
$smarty->assign('folderid', $this->get('id'));
$smarty->assign('downloadfolderzip', get_config_plugin('blocktype', 'folder', 'folderdownloadzip') ? !empty($options['folderdownloadzip']) : false);
if (isset($options['editing'])) {
$smarty->assign('editing', $options['editing']);
}
$childrecords = false;
if (!empty($options['existing_artefacts'])) {
......@@ -2180,6 +2183,7 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
}
if ($childrecords) {
safe_require('artefact', 'comment');
$sortorder = (isset($options['sortorder']) && $options['sortorder'] == 'desc') ? 'my_files_cmp_desc' : 'my_files_cmp';
usort($childrecords, array('ArtefactTypeFileBase', $sortorder));
$children = array();
......@@ -2188,6 +2192,13 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
$child->title = $child->hovertitle = $c->get('title');
$child->date = format_date(strtotime($child->mtime), 'strftimedaydatetime');
$child->iconsrc = call_static_method(generate_artefact_class_name($child->artefacttype), 'get_icon', array('id' => $child->id, 'viewid' => isset($options['viewid']) ? $options['viewid'] : 0));
$count = ArtefactTypeComment::count_comments(null, array($child->id));
if ($count) {
$child->commentcount = $count[$child->id]->comments;
}
else {
$child->commentcount = 0;
}
}
$smarty->assign('children', $childrecords);
}
......
......@@ -29,6 +29,10 @@ class PluginBlocktypeTextbox extends MaharaCoreBlocktype {
return true;
}
public static function single_artefact_per_block() {
return true;
}
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata');
if (!empty($configdata['artefactid'])) {
......@@ -69,6 +73,7 @@ class PluginBlocktypeTextbox extends MaharaCoreBlocktype {
$smarty->assign('license', (int)get_config('licensemetadata'));
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('artefactid', $artefact->get('id'));
$smarty->assign('editing', $editing);
return $smarty->fetch('blocktype:textbox:content.tpl');
}
......
......@@ -21,6 +21,10 @@ class PluginBlocktypePeerassessment extends MaharaCoreBlocktype {
return false;
}
public static function single_artefact_per_block() {
return false;
}
public static function get_title() {
return get_string('title', 'blocktype.peerassessment/peerassessment');
......
......@@ -25,6 +25,10 @@ class PluginBlocktypeSignoff extends MaharaCoreBlocktype {
return true;
}
public static function single_artefact_per_block() {
return false;
}
public static function get_title() {
return get_string('title', 'blocktype.peerassessment/signoff');
......
......@@ -32,6 +32,10 @@ class PluginBlocktypeEntireresume extends MaharaCoreBlocktype {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
$configdata = $instance->get('configdata');
$configdata['showcommentcount'] = true;
$configdata['viewid'] = $instance->get('view');
$configdata['editing'] = $editing;
// Get data about the resume fields the user has
if ($artefacts = get_records_sql_array('
SELECT va.artefact, a.artefacttype
......@@ -41,7 +45,7 @@ class PluginBlocktypeEntireresume extends MaharaCoreBlocktype {
AND va.block = ?', array($instance->get('view'), $instance->get('id')))) {
foreach ($artefacts as $artefact) {
$resumefield = $instance->get_artefact_instance($artefact->artefact);
$rendered = $resumefield->render_self(array('viewid' => $instance->get('view')));
$rendered = $resumefield->render_self($configdata);
$result = $rendered['html'];
if (!empty($rendered['javascript'])) {
$result .= '<script>' . $rendered['javascript'] . '</script>';
......
......@@ -47,6 +47,9 @@ class PluginBlocktypeResumefield extends MaharaCoreBlocktype {
$smarty = smarty_core();
$configdata = $instance->get('configdata');
$configdata['viewid'] = $instance->get('view');
$configdata['showcommentcount'] = true;
$configdata['editing'] = $editing;
$configdata['blockid'] = $instance->get('id');
// Get data about the resume field in this blockinstance
if (!empty($configdata['artefactid'])) {
......
......@@ -879,6 +879,14 @@ abstract class ArtefactTypeResumeComposite extends ArtefactTypeResume implements
$smarty->assign('artefactid', $options['artefactid']);
}
if (!empty($options['editing'])) {
$smarty->assign('editing', $options['editing']);
}
if (!empty($options['blockid'])) {
$smarty->assign('blockid', $options['blockid']);
}
if (!$data = get_records_sql_array($sql, array($owner, $type))) {
$data = array();
}
......@@ -901,6 +909,7 @@ abstract class ArtefactTypeResumeComposite extends ArtefactTypeResume implements
ORDER BY a.title';
$attachments = get_records_sql_array($sql, array($record->artefact, $record->id));
if ($attachments) {
safe_require('artefact', 'comment');
foreach ($attachments as &$attachment) {
$f = artefact_instance_from_id($attachment->id);
$attachment->size = $f->describe_size();
......@@ -908,6 +917,16 @@ abstract class ArtefactTypeResumeComposite extends ArtefactTypeResume implements
$attachment->artefacttype = $f->get_artefact_type($attachment->id);
$attachment->downloadpath = get_config('wwwroot') . 'artefact/file/download.php?file=' . $attachment->id;
$attachment->description = $f->description;
$attachment->allowcomments = $f->get('allowcomments');
if (!empty($options['showcommentcount'])) {
$count = ArtefactTypeComment::count_comments(null, array($attachment->id));
if ($count) {
$attachment->commentcount = $count[$attachment->id]->comments;
}
else {
$attachment->commentcount = 0;
}
}
}
}
$record->attachments = $attachments;
......@@ -1988,15 +2007,29 @@ class ArtefactTypeResumeGoalAndSkill extends ArtefactTypeResume {
if (!empty($options['artefactid'])) {
$smarty->assign('artefactid', $options['artefactid']);
}
if (!empty($options['editing'])) {
$smarty->assign('editing', $options['editing']);
}
$attachments = $this->get_attachments();
if ($attachments) {
safe_require('artefact', 'comment');
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->downloadpath = get_config('wwwroot') . 'artefact/file/download.php?file=' . $attachment->id;
$attachment->description = $f->description;
$attachment->allowcomments = $f->get('allowcomments');
if (!empty($options['showcommentcount'])) {
$count = ArtefactTypeComment::count_comments(null, array($attachment->id));
if ($count) {
$attachment->commentcount = $count[$attachment->id]->comments;
}
else {
$attachment->commentcount = 0;
}
}
}
$smarty->assign('attachments', $attachments);
$smarty->assign('count', count($attachments));
......
......@@ -23,6 +23,10 @@ class PluginBlocktypeCreativecommons extends MaharaCoreBlocktype {
return true;
}
public static function single_artefact_per_block() {
return false;
}
public static function get_title() {
return get_string('title', 'blocktype.creativecommons');
}
......
......@@ -31,6 +31,10 @@ class PluginBlocktypeGroupInfo extends MaharaCoreBlocktype {
return true;
}
public static function single_artefact_per_block() {
return false;
}
public static function get_categories() {
return array('general' => 16000);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment