N°2313 - Markup extensibility: Add metadata on attachments

This commit is contained in:
Molkobain
2020-01-24 16:08:42 +01:00
parent 3ae2058f6f
commit c48bbfd32a
6 changed files with 66 additions and 70 deletions

View File

@@ -3830,14 +3830,20 @@ input:checked + .slider:before {
.pull-left { float: left; }
table.attachmentsList {
&>tbody{
&>tr>td:first-child {
text-align: center;
}
&>tr>td:nth-child(3) {
text-align: right;
padding-right: 0.5em;
.attachmentsList {
>tbody{
>tr>td{
&[role="icon"] {
text-align: center;
padding: 0.25em;
}
&[role="formatted-size"] {
text-align: right;
padding-right: 0.5em;
}
&[role="delete"] {
text-align: center;
}
}
}
}

View File

@@ -1,9 +1,6 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2018 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
* Copyright (C) 2013-2020 Combodo SARL
*
* This file is part of iTop.
*
@@ -18,7 +15,6 @@
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with iTop. If not, see <http://www.gnu.org/licenses/>
*/
Dict::Add('EN US', 'English', 'English', array(
@@ -66,7 +62,7 @@ Dict::Add('EN US', 'English', 'English', array(
'Attachments:File:Thumbnail' => 'Icon',
'Attachments:File:Name' => 'File name',
'Attachments:File:Date' => 'Upload date',
'Attachments:File:Creator' => 'Uploaded by',
'Attachments:File:Uploader' => 'Uploaded by',
'Attachments:File:Size' => 'Size',
'Attachments:File:MimeType' => 'Type',
));

View File

@@ -1,26 +1,22 @@
<?php
// Copyright (C) 2010-2012 Combodo SARL
//
// This file is part of iTop.
//
// iTop is free software; you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// iTop is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
/**
* Localized data
* Copyright (C) 2013-2020 Combodo SARL
*
* @copyright Copyright (C) 2010-2012 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
Dict::Add('FR FR', 'French', 'Français', array(
'Attachments:TabTitle_Count' => 'Pièces jointes (%1$d)',
'Attachments:EmptyTabTitle' => 'Pièces jointes',
@@ -66,7 +62,7 @@ Dict::Add('FR FR', 'French', 'Français', array(
'Attachments:File:Thumbnail' => 'Icône',
'Attachments:File:Name' => 'Nom du fichier',
'Attachments:File:Date' => 'Date de chargement',
'Attachments:File:Creator' => 'Chargé par',
'Attachments:File:Uploader' => 'Chargé par',
'Attachments:File:Size' => 'Taille',
'Attachments:File:MimeType' => 'Type',
));

View File

@@ -348,22 +348,22 @@ class TableDetailsAttachmentsRenderer extends AbstractAttachmentsRenderer
$sFileName = Dict::S('Attachments:File:Name');
$sFileSize = Dict::S('Attachments:File:Size');
$sFileDate = Dict::S('Attachments:File:Date');
$sFileCreator = Dict::S('Attachments:File:Creator');
$sFileUploader = Dict::S('Attachments:File:Uploader');
$sFileType = Dict::S('Attachments:File:MimeType');
$sDeleteColumn = '';
if ($bWithDeleteButton)
{
$sDeleteColumn = '<th></th>';
$sDeleteColumn = '<th role="delete"></th>';
}
$this->oPage->add(<<<HTML
<table class="listResults attachmentsList">
<thead>
<th>$sThumbnail</th>
<th>$sFileName</th>
<th>$sFileSize</th>
<th>$sFileDate</th>
<th>$sFileCreator</th>
<th>$sFileType</th>
<th role="icon">$sThumbnail</th>
<th role="filename">$sFileName</th>
<th role="formatted-size">$sFileSize</th>
<th role="upload-date">$sFileDate</th>
<th role="uploader">$sFileUploader</th>
<th role="type">$sFileType</th>
$sDeleteColumn
</thead>
<tbody>
@@ -452,7 +452,8 @@ JS
$sFileName = utils::HtmlEntities($oDoc->GetFileName());
$sTrId = $this->GetAttachmentContainerId($iAttachmentId);
$sAttachmentMeta = $this->GetAttachmentHiddenInput($iAttachmentId, $bIsDeletedAttachment);
$sFileSize = $oDoc->GetFormattedSize();
$sFileSize = $oDoc->GetSize();
$sFileFormattedSize = $oDoc->GetFormattedSize();
$bIsTempAttachment = ($oAttachment->Get('item_id') === 0);
$sAttachmentDate = '';
if (!$bIsTempAttachment)
@@ -464,7 +465,8 @@ JS
}
}
$sAttachmentCreator = $oAttachment->Get('contact_id_friendlyname');
$sAttachmentUploader = $oAttachment->Get('contact_id_friendlyname');
$sAttachmentUploaderForHtml = utils::HtmlEntities($sAttachmentUploader);
$sFileType = $oDoc->GetMimeType();
@@ -483,17 +485,17 @@ JS
if ($bWithDeleteButton)
{
$sDeleteButton = $this->GetDeleteAttachmentButton($iAttachmentId);
$sDeleteColumn = "<td>$sDeleteButton</td>";
$sDeleteColumn = "<td role=\"delete\">$sDeleteButton</td>";
}
$this->oPage->add(<<<HTML
<tr id="$sTrId" $sLineClass $sLineStyle>
<td><a href="$sDocDownloadUrl" target="_blank" class="trigger-preview $sIconClass"><img $sIconClass style="max-height: 48px;" src="$sAttachmentThumbUrl"></a></td>
<td><a href="$sDocDownloadUrl" target="_blank" class="$sIconClass">$sFileName</a>$sAttachmentMeta</td>
<td>$sFileSize</td>
<td>$sAttachmentDate</td>
<td>$sAttachmentCreator</td>
<td>$sFileType</td>
<tr id="$sTrId" $sLineClass $sLineStyle data-file-type="$sFileType" data-file-size-raw="$sFileSize" data-file-size-formatted="$sFileFormattedSize" data-file-uploader="$sAttachmentUploaderForHtml">
<td role="icon"><a href="$sDocDownloadUrl" target="_blank" class="trigger-preview $sIconClass"><img $sIconClass style="max-height: 48px;" src="$sAttachmentThumbUrl"></a></td>
<td role="filename"><a href="$sDocDownloadUrl" target="_blank" class="$sIconClass">$sFileName</a>$sAttachmentMeta</td>
<td role="formatted-size">$sFileFormattedSize</td>
<td role="upload-date">$sAttachmentDate</td>
<td role="uploader">$sAttachmentUploader</td>
<td role="type">$sFileType</td>
$sDeleteColumn
</tr>
HTML

View File

@@ -1,9 +1,6 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2018 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
* Copyright (C) 2013-2020 Combodo SARL
*
* This file is part of iTop.
*
@@ -18,7 +15,6 @@
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with iTop. If not, see <http://www.gnu.org/licenses/>
*/
Dict::Add('ZH CN', 'Chinese', '简体中文', array(
@@ -66,7 +62,7 @@ Dict::Add('ZH CN', 'Chinese', '简体中文', array(
'Attachments:File:Thumbnail' => '图标',
'Attachments:File:Name' => '文件名',
'Attachments:File:Date' => '上传日期',
'Attachments:File:Creator' => '上传者',
'Attachments:File:Uploader' => '上传者',
'Attachments:File:Size' => '大小',
'Attachments:File:MimeType' => '类型',
));

View File

@@ -472,11 +472,11 @@ HTML
return <<<HTML
<thead>
<th>$sTitleThumbnail</th>
<th data-priority="1">$sTitleFileName</th>
<th>$sTitleFileSize</th>
<th>$sTitleFileDate</th>
<th data-priority="1"></th>
<th role="icon">$sTitleThumbnail</th>
<th role="filename" data-priority="1">$sTitleFileName</th>
<th role="formatted-size">$sTitleFileSize</th>
<th role="upload-date">$sTitleFileDate</th>
$sDeleteHeaderAsHtml
</thead>
HTML;
}
@@ -500,20 +500,20 @@ HTML;
$iAttId, $sLineStyle, $sDocDownloadUrl, $sIconClass, $sAttachmentThumbUrl, $sFileName, $sAttachmentMeta, $sFileSize,
$sAttachmentDate, $bIsDeleteAllowed
) {
$sDeleteButton = '';
$sDeleteCell = '';
if ($bIsDeleteAllowed)
{
$sDeleteBtnLabel = Dict::S('Portal:Button:Delete');
$sDeleteButton = '<input id="btn_remove_'.$iAttId.'" type="button" class="btn btn-xs btn-primary" value="'.$sDeleteBtnLabel.'">';
$sDeleteCell = '<td role="delete"><input id="btn_remove_'.$iAttId.'" type="button" class="btn btn-xs btn-primary" value="'.$sDeleteBtnLabel.'"></td>';
}
return <<<HTML
<tr id="display_attachment_{$iAttId}" class="attachment" $sLineStyle>
<td><a href="$sDocDownloadUrl" target="_blank" class="$sIconClass"><img $sIconClass style="max-height: 48px;" src="$sAttachmentThumbUrl"></a></td>
<td><a href="$sDocDownloadUrl" target="_blank">$sFileName</a>$sAttachmentMeta</td>
<td>$sFileSize</td>
<td>$sAttachmentDate</td>
<td>$sDeleteButton</td>
<td role="icon"><a href="$sDocDownloadUrl" target="_blank" class="$sIconClass"><img $sIconClass src="$sAttachmentThumbUrl"></a></td>
<td role="filename"><a href="$sDocDownloadUrl" target="_blank">$sFileName</a>$sAttachmentMeta</td>
<td role="formatted-size">$sFileSize</td>
<td role="upload-date">$sAttachmentDate</td>
$sDeleteCell
</tr>
HTML;
}