Commit 2c5c70c3 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge changes from topic 'WR 326221'

* changes:
  Bug 1857379: Add tooltip to file download icon
  Bug 1857379: Add attachment panel to recent posts block
  Bug 1857379: File attachment display consolidation
  Bug 1857401 Consolidating list-group outer-links in theme
parents 88ffc6cc b4bac92e
......@@ -127,6 +127,23 @@ class PluginBlocktypeRecentposts extends MaharaCoreBlocktype {
$data->tags = $tags;
}
$data->owner = $blog->get('owner');
$sql = 'SELECT a.title, a.id, a.artefacttype, af.size, a.description
FROM {artefact} a
JOIN {artefact_file_files} af ON af.artefact = a.id
JOIN {artefact_attachment} at ON at.attachment = a.id
WHERE at.artefact = ?
ORDER BY a.title';
if ($attachments = get_records_sql_array($sql, array($data->id))) {
foreach ($attachments as &$attachment) {
$f = artefact_instance_from_id($attachment->id);
$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;
if (isset($options['viewid'])) {
$attachment->downloadpath .= '&view=' . $options['viewid'];
}
}
$data->attachments = $attachments;
}
}
$smarty = smarty_core();
......
......@@ -826,7 +826,7 @@ var FileBrowser = (function($) {
$('#' + self.id + '_filelist button.editable').each(function () {
var id = this.name.replace(/.*_edit\[(\d+)\]$/, '$1');
var row = $(this).closest('tr');
var newtitle = row.find('a').first();
var newtitle = row.find('.filename a').first();
var newdescription = row.find('td.filedescription').first();
if (self.selecteddata[id]) {
var hiddeninput = $('#' + self.id + '_selected\\[' + id + '\\]');
......@@ -839,7 +839,7 @@ var FileBrowser = (function($) {
if (filetitle.length) {
filetitle.html(newtitle.html());
}
var filedesc = row2update.find('td.filedescription');
var filedesc = row2update.find('div.filedescription');
if (filedesc) {
filedesc.html(newdescription.html());
}
......@@ -905,8 +905,10 @@ var FileBrowser = (function($) {
}
}
if (!existed) {
var remove = $('<button>', {'class': 'btn btn-link text-small button submit unselect',
'type': 'submit', 'name': self.id+'_unselect[' + id + ']', 'title': get_string('remove')});
var remove = $('<button>', {'class': 'btn btn-secondary btn-sm text-small button submit unselect',
'type': 'submit',
'name': self.id+'_unselect[' + id + ']',
'title': get_string('remove')});
remove.append(
$('<span>', {'class': 'icon icon-times icon-lg text-danger left'}),
$('<span>', { 'text': get_string('remove')})
......@@ -1012,6 +1014,10 @@ var FileBrowser = (function($) {
else {
var hiddeninput = r.find('input.d-none').first();
if (hiddeninput.length) {
var legend2update = hiddeninput.closest('fieldset').find('legend h4 span.file-name');
if (legend2update.length) {
legend2update.html('');
}
hiddeninput.remove();
}
r.addClass('d-none');
......
......@@ -81,6 +81,7 @@ $string['Details'] = 'Details';
$string['View'] = 'View';
$string['Download'] = 'Download';
$string['downloadfile'] = 'Download %s';
$string['downloadfilesize'] = 'Download %s [%s]';
$string['downloadoriginalversion'] = 'Download the original version';
$string['dragdrophere'] = 'Drop files here to upload';
$string['editfile'] = 'Edit file';
......
......@@ -2196,6 +2196,7 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
$children = array();
foreach ($childrecords as &$child) {
$c = artefact_instance_from_id($child->id);
$child->size = $c->describe_size();
$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));
......
......@@ -1073,15 +1073,17 @@ EOF;
jQuery('<div>', {'class': 'detail text-midtone'}).append({$extrastring})
)[0];
}
var link = jQuery('<a>', {'class': 'toggle textonly', 'href': ''}).append({$titlestring})[0];
jQuery(link).on('click', function (e) {
e.preventDefault();
return showhideComposite(row, {$bodystring}, {$attachstring}, {$addressstring});
});
var extra = jQuery('<div>', {'class': 'detail text-midtone'}).append({$extrastring});
return jQuery('<td>', {'id': 'composite-' + row.artefact + '-' + row.id}).append(
jQuery('<div>', {'class': 'expandable-head'}).append(link, extra)
)[0];
else {
var link = jQuery('<a>', {'class': 'toggle textonly', 'href': ''}).append({$titlestring})[0];
jQuery(link).on('click', function (e) {
e.preventDefault();
return showhideComposite(row, {$bodystring}, {$attachstring}, {$addressstring});
});
var extra = jQuery('<div>', {'class': 'detail text-midtone'}).append({$extrastring});
return jQuery('<div>', {'id': 'composite-' + row.artefact + '-' + row.id}).append(
jQuery('<div>', {'class': 'expandable-head'}).append(link, extra)
)[0];
}
},
EOF;
}
......@@ -1096,11 +1098,10 @@ EOF;
bodyNode.toggleClass('d-none');
return false;
}
var newNode = jQuery('<div>', {'id': 'composite-body-' + row.artefact + '-' + row.id}).append(
jQuery('<div>', {'class':'content-text'}).append(content),
address,
attachments
);
var newNode = jQuery('<div>', {'id': 'composite-body-' + row.artefact + '-' + row.id}).append(
jQuery('<div>', {'class':'content-text'}).append(content).append(address).append(attachments)
);
newNode.insertAfter(titleTD.find('.expandable-head').first());
}
EOF;
......@@ -1220,11 +1221,13 @@ function listAttachments(attachments) {
for (var i=0; i < attachments.length; i++) {
var item = attachments[i];
var href = self.config.wwwroot + 'artefact/file/download.php?file=' + attachments[i].id;
var link = jQuery('<a>', {'href': href, 'text': '{$downloadstr}' });
var linkcontent = '<span class="sr-only">' + {$downloadstr} + item.title + '</span>';
linkcontent += '<span class="icon icon-download icon-lg float-right text-watermark icon-action" role="presentation" aria-hidden="true"></span>';
var link = jQuery('<a href="' + href + '">' + linkcontent + '</a>');
tbody.append(
jQuery('<tr>').append(
jQuery('<td>').append(
item.title + ' (' + formatSize(item.size) + ') - ',
item.title,
jQuery('<span>').append(link)
)
)
......
......@@ -45,7 +45,7 @@
</div>
{else}
<div class="content-text">
{$item->description|safe|clean_html}
{$item->description|clean_html|safe}
</div>
{if $item->attachmessage}
......
......@@ -39,19 +39,20 @@
displayiconsonly=true}
{/if}
<div class="list-group-item">
<a class="outer-link collapsed" data-toggle="collapse" href="#recent_post_{$post->id}" aria-expanded="false">
<span class="sr-only">{$post->title}</span>
</a>
<h4 class="list-group-item-heading">
{if !($editing)}
<a class="modal_link inner-link text-left" data-toggle="modal-docked" data-target="#configureblock" href="#" data-blockid="{$blockid}" data-artefactid="{$post->id}">
<a class="modal_link text-left" data-toggle="modal-docked" data-target="#configureblock" href="#" data-blockid="{$blockid}" data-artefactid="{$post->id}">
{$post->title}
</a>
{else}
<span class="list-group-item-heading no-link">{$post->title}</span>
{/if}
</h4>
<span class="icon icon-chevron-up collapse-indicator float-right" role="presentation" aria-hidden="true"></span>
<a class="collapsed" data-toggle="collapse" href="#recent_post_{$post->id}" aria-expanded="false">
<span class="sr-only">{$post->title}</span>
<span class="icon icon-chevron-down collapse-indicator float-right" role="presentation" aria-hidden="true"></span>
</a>
<div>
<span class="text-small">
{str tag='postedin' section='blocktype.blog/recentposts'}
......@@ -75,7 +76,12 @@
</div>
<div id="recent_post_{$post->id}" class="collapse content-text">
<span>{$post->description|safe}</span>
{if isset($post->attachments) && !$modal}
{include file="artefact:blog:render/blogpost_renderattachments.tpl" attachments=$post->attachments postid=$post->id}
{/if}
</div>
</div>
{/foreach}
</div>
......@@ -59,7 +59,7 @@
<div class="post list-group-item flush">
<h4 class="title">
{if !($editing)}
<a class="modal_link inner-link" data-toggle="modal-docked" data-target="#configureblock" href="#" data-blockid="{$blockid}" data-artefactid="{$post->id}">
<a class="modal_link" data-toggle="modal-docked" data-target="#configureblock" href="#" data-blockid="{$blockid}" data-artefactid="{$post->id}">
{$post->title}
</a>
{else}
......@@ -103,19 +103,21 @@
displayiconsonly=true}
{/if}
<div class="list-group-item">
<a class="outer-link collapsed" data-toggle="collapse" href="#tagged_post_{$post->id}" aria-expanded="false">
<span class="sr-only">{$post->title}</span>
</a>
<h4 class="list-group-item-heading">
{if !($editing)}
<a class="modal_link inner-link list-group-item-heading" data-toggle="modal-docked" data-target="#configureblock" href="#" data-blockid="{$blockid}" data-artefactid="{$post->id}">
<a class="modal_link list-group-item-heading" data-toggle="modal-docked" data-target="#configureblock" href="#" data-blockid="{$blockid}" data-artefactid="{$post->id}">
{$post->title}
</a>
{else}
<span class="list-group-item-heading no-link">{$post->title}</span>
{/if}
</h4>
<span class="icon icon-chevron-up collapse-indicator float-right" role="presentation" aria-hidden="true"></span>
<a class="collapsed" data-toggle="collapse" href="#tagged_post_{$post->id}" aria-expanded="false">
<span class="sr-only">{$post->title}</span>
<span class="icon icon-chevron-down collapse-indicator float-right" role="presentation" aria-hidden="true"></span>
</a>
<div>
<span class="metadata">
{str tag='postedon' section='blocktype.blog/taggedposts'}
......
......@@ -13,28 +13,31 @@
<ul class="list-unstyled list-group">
{foreach from=$attachments item=item}
<li class="list-group-item">
<a href="{$item->downloadpath}" class="outer-link icon-on-hover" {if $item->description} title="{$item->description}" data-toggle="tooltip"{/if}>
<span class="sr-only">
{str tag=Download section=artefact.file} {$item->title}
</span>
</a>
{if $item->iconpath}
{if $item->iconpath}
<img class="file-icon" src="{$item->iconpath}" alt="">
{else}
{else}
<span class="icon icon-{$item->artefacttype} icon-lg text-default left" role="presentation" aria-hidden="true"></span>
{/if}
{/if}
{if !$editing}
<span class="title">
<a class="modal_link" data-toggle="modal-docked" data-target="#configureblock" href="#" data-blockid="{$blockid}" data-artefactid="{$item->id}">
<span class="text-small">{$item->title}</span>
</a>
</span>
{else}
<span class="title">
<span class="inner-link text-small">
{$item->title}
</span>
<span class="metadata"> -
[{$item->size|display_size}]
</span>
<span class="text-small">{$item->title}</span>
</span>
<span class="icon icon-download icon-lg float-right text-watermark icon-action" role="presentation" aria-hidden="true"></span>
{/if}
<a href="{$item->downloadpath}">
<span class="sr-only">{str tag=downloadfilesize section=artefact.file arg1=$item->title arg2=$item->size|display_size}</span>
<span class="icon icon-download icon-lg float-right text-watermark icon-action" role="presentation" aria-hidden="true" data-toggle="tooltip" title="{str tag=downloadfilesize section=artefact.file arg1=$item->title arg2=$item->size|display_size}"></span>
</a>
{if $item->description}
<div class="file-description text-small">
{$item->description|clean_html|safe}
</div>
{/if}
</li>
{/foreach}
</ul>
......
......@@ -61,23 +61,31 @@
<ul class="list-group list-unstyled">
{foreach from=$post->files item=file}
<li class="list-group-item">
<a href="{$WWWROOT}artefact/file/download.php?file={$file->attachment}&amp;view={$options.viewid}" class="outer-link icon-on-hover">
<span class="sr-only">
{str tag=Download section=artefact.file} {$file->title}
</span>
</a>
{if $file->icon}
{if $file->icon}
<img class="file-icon" src="{$file->icon}" alt="">
{else}
{else}
<span class="icon icon-{$file->artefacttype} icon-lg text-default left" role="presentation" aria-hidden="true"></span>
{/if}
{/if}
{if !$options.editing}
<span class="title">
<a class="modal_link" data-toggle="modal-docked" data-target="#configureblock" href="#" data-blockid="{$options.blockid}" data-artefactid="{$file->attachment}">
<span class="text-small">{$file->title}</span>
</a>
</span>
{else}
<span class="title">
<span class="text-small">{$file->title}</span>
<span class="metadata"> -
[{$file->size|display_size}]
</span>
</span>
<span class="icon icon-download icon-lg float-right text-watermark icon-action" role="presentation" aria-hidden="true"></span>
{/if}
<a href="{$WWWROOT}artefact/file/download.php?file={$file->attachment}&amp;view={$options.viewid}">
<span class="sr-only">{str tag=downloadfilesize section=artefact.file arg1=$file->title arg2=$file->size|display_size}</span>
<span class="icon icon-download icon-lg float-right text-watermark icon-action" role="presentation" aria-hidden="true" data-toggle="tooltip" title="{str tag=downloadfilesize section=artefact.file arg1=$file->title arg2=$file->size|display_size}"></span>
</a>
{if $file->description}
<div class="file-description text-small">
{$file->description|clean_html|safe}
</div>
{/if}
</li>
{/foreach}
</ul>
......
......@@ -5,12 +5,12 @@
<div class="usericon-heading">
<span class="user-icon user-icon-30 float-left" role="presentation" aria-hidden="true">
{if $item->author && !$item->author->deleted}
<img src="{profile_icon_url user=$item->author maxheight=30 maxwidth=30}" valign="middle" alt="{str tag=profileimagetext arg1=$item->author|display_default_name}"/>
<a href="{$item->author->profileurl}"><img src="{profile_icon_url user=$item->author maxheight=30 maxwidth=30}" valign="middle" alt="{str tag=profileimagetext arg1=$item->author|display_default_name}"/></a>
{else}
<img src="{profile_icon_url user=null maxheight=30 maxwidth=30}" valign="middle" alt="{str tag=profileimagetextanonymous}"/>
{/if}
</span>
<h5 class="float-left list-group-item-heading">
<h4 class="float-left list-group-item-heading">
{if $item->author && !$item->author->deleted}
<a href="{$item->author->profileurl}">
<span>{$item->author|display_name}</span>
......@@ -38,7 +38,7 @@
{/for}
</span>
{/if}
</h5>
</h4>
<!-- The "comment-item-buttons" class is used as an identifier by Javascript -->
<div class="btn-group btn-group-top comment-item-buttons">
{if !$onview}
......@@ -68,7 +68,7 @@
</span>
{else}
{if $item->author}
{$item->description|safe|clean_html}
{$item->description|clean_html|safe}
{else}
{$item->description|safe}
{/if}
......@@ -105,20 +105,17 @@
</a>
</h4>
<div id="attachments_{$item->id}" class="collapse" aria-expanded="false">
<ul class=" list-group list-group-unbordered">
<ul class="list-unstyled list-group">
{strip}
{foreach $item->attachments item=a name=attachments}
<li class="list-group-item">
<a href="{$WWWROOT}artefact/file/download.php?file={$a->attachid}&comment={$item->id}&view={$viewid}" class="outer-link icon-on-hover">
<span class="sr-only">{$a->attachtitle}</span>
</a>
<span class="title">
{$a->attachtitle}
<span class="attachsize metadata">
[{$a->attachsize}]
</span>
<span class="text-small">{$a->attachtitle}</span>
<span class="metadata"> [{$a->attachsize}]</span>
</span>
<span class="icon icon-download icon-lg float-right text-watermark icon-action" role="presentation" aria-hidden="true"></span>
<a href="{$WWWROOT}artefact/file/download.php?file={$a->attachid}&comment={$item->id}&view={$viewid}">
<span class="icon icon-download icon-lg float-right text-watermark icon-action" role="presentation" aria-hidden="true"></span>
</a>
</li>
{/foreach}
{/strip}
......
......@@ -13,53 +13,42 @@
justdetails=$justdetails
displayiconsonly = true}
<li class="filedownload-item list-group-item">
<a href="{$file.downloadurl}" class="outer-link icon-on-hover">
<span class="sr-only">
{str tag=Download section=artefact.file} {$file.title}
</span>
{if !$editing}
<a class="modal_link" data-toggle="modal-docked" data-target="#configureblock" href="#" data-artefactid="{$file.id}" data-blockid="{$blockid}" title="{$file.title}">
{if $file.iconsrc}
<img src="{$file.iconsrc}" alt="" class="file-icon text-inline" />
{else}
<span class="icon icon-{$file.artefacttype} icon-lg left" role="presentation" aria-hidden="true"></span>
{/if}
</a>
{if $file.iconsrc}
<img src="{$file.iconsrc}" alt="" class="file-icon text-inline" />
{else}
<span class="icon icon-{$file.artefacttype} icon-lg left" role="presentation" aria-hidden="true"></span>
{/if}
<span class="icon icon-download icon-lg float-right text-watermark icon-action" role="presentation" aria-hidden="true"></span>
<h4 class="title list-group-item-heading">
{if !$editing}
<a class="modal_link inner-link"
data-toggle="modal-docked"
data-target="#configureblock"
href="#"
data-artefactid="{$file.id}"
data-blockid="{$blockid}"
title="{$file.title}">
{$file.title}
<span class="sr-only">
{str tag=Details section=artefact.file}
</span>
</a>
{if $file.iconsrc}
<img src="{$file.iconsrc}" alt="" class="file-icon text-inline" />
{else}
{$file.title}
<span class="sr-only">
{str tag=Details section=artefact.file}
</span>
<span class="icon icon-{$file.artefacttype} icon-lg left" role="presentation" aria-hidden="true"></span>
{/if}
{/if}
<h4 class="title list-group-item-heading">
{if !$editing}
<a class="modal_link inner-link" title="{$child->hovertitle}" data-toggle="modal-docked" data-target="#configureblock" href="#" data-blockid="{$blockid}" data-artefactid="{$file.id}">
{$file.title}
<span class="sr-only">{str tag=Details section=artefact.file}</span>
</a>
{else}
<span class="inner-link">{$file.title}</span>
{/if}
</h4>
<br />
<span class="text-small text-midtone">
{$file.ctime|format_date:'strftimedaydate'}
[{$file.size|display_size}]
</span>
<a href="{$file.downloadurl}">
<span class="icon icon-download icon-lg float-right text-watermark icon-action" role="presentation" aria-hidden="true" data-toggle="tooltip" title="{str tag=downloadfilesize section=artefact.file arg1=$file.title arg2=$file.size|display_size}"></span>
<span class="sr-only">{str tag=downloadfilesize section=artefact.file arg1=$file.title arg2=$file.size|display_size}}</span>
</a>
{if $file.description}
<div class="file-description">
<p class="text-small">
{$file.description|safe|clean_html}
</p>
<div class="file-description text-small">
{$file.description|clean_html|safe}
</div>
<script>
jQuery("div.file-description a").addClass('inner-link');
</script>
{/if}
</li>
{/foreach}
......
......@@ -9,7 +9,7 @@
{if $showdescription && $image.title}
<div class="carousel-caption" id="description_{$instanceid}_{$k}">
{$image.title|safe|clean_html}
{$image.title|clean_html|safe}
</div>
{/if}
</div>
......
......@@ -6,7 +6,7 @@
</a>
{if $showdescription && $image.title}
<p class="text-small title">
{$image.title|truncate:60|safe|clean_html}
{$image.title|truncate:60|clean_html|safe}
</p>
{/if}
</div>
......
......@@ -6,7 +6,7 @@
</a>
{if $showdescription && $image.title}
<p class="text-small title">
{$image.title|truncate:60|safe|clean_html}
{$image.title|truncate:60|clean_html|safe}
</p>
{/if}
</div>
......
......@@ -11,7 +11,7 @@
{if $showdescription}
<div class="detail" itemprop="description">
{$description|safe|clean_html}
{$description|clean_html|safe}
</div>
{/if}
</div>
......@@ -17,7 +17,7 @@
{if $description}
<tr>
<th>{str tag=Description section=artefact.file}:</th>
<td>{$description|safe|clean_html}</td>
<td>{$description|clean_html|safe}</td>
</tr>
{/if}
{if $tags}
......
......@@ -21,40 +21,26 @@
<ul class="list-group">
{foreach from=$children item=child}
<li class="filedownload-item list-group-item">
{if $child->artefacttype != 'folder'}
<a href="{$WWWROOT}artefact/file/download.php?file={$child->id}&amp;view={$viewid}" class="outer-link icon-on-hover">
<span class="sr-only">
{str tag=Details section=artefact.file}
{$child->title}
</span>
</a>
{/if}
<a class="modal_link" title="{$child->hovertitle}" data-toggle="modal-docked" data-target="#configureblock" href="#" data-blockid="{$blockid}" data-artefactid="{$child->id}">
{if $child->iconsrc}
<img src="{$child->iconsrc}" alt="{$child->artefacttype}" class="file-icon text-inline {if $modal}file-icon-render-in-modal{/if}">
{else}
<span class="icon icon-{$child->artefacttype} icon-lg left {if $modal}file-icon-render-in-modal{/if}" role="presentation" aria-hidden="true"></span>
{/if}
<span class="icon icon-download icon-lg float-right text-watermark icon-action" role="presentation" aria-hidden="true"></span>
<h4 class="title list-group-item-heading text-inline">
<a class="modal_link inner-link" title="{$child->hovertitle}" data-toggle="modal-docked" data-target="#configureblock" href="#" data-blockid="{$blockid}" data-artefactid="{$child->id}">
</a>
<h4 class="title list-group-item-heading">
<a class="modal_link" title="{$child->hovertitle}" data-toggle="modal-docked" data-target="#configureblock" href="#" data-blockid="{$blockid}" data-artefactid="{$child->id}">
{$child->title}
</a>
{if !$simpledisplay}
<span class="filedate metadata">
{$child->date}
</span>
{/if}
</h4>
{if $child->artefacttype != 'folder'}
{/if}
<a href="{$WWWROOT}artefact/file/download.php?file={$child->id}&amp;view={$viewid}">