diff --git a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php
index 075949a85..9c5e605b8 100644
--- a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php
+++ b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php
@@ -16,10 +16,20 @@
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see
| '.Dict::S('Attachments:File:Thumbnail').' | '.PHP_EOL); - $this->oPage->add(''.Dict::S('Attachments:File:Name').' | '.PHP_EOL); - $this->oPage->add(''.Dict::S('Attachments:File:Size').' | '.PHP_EOL); - $this->oPage->add(''.Dict::S('Attachments:File:Date').' | '.PHP_EOL); - $this->oPage->add(''.Dict::S('Attachments:File:Creator').' | '.PHP_EOL); - $this->oPage->add(''.Dict::S('Attachments:File:MimeType').' | '.PHP_EOL); + + $sThumbnail = Dict::S('Attachments:File:Thumbnail'); + $sFileName = Dict::S('Attachments:File:Name'); + $sFileSize = Dict::S('Attachments:File:Size'); + $sFileDate = Dict::S('Attachments:File:Date'); + $sFileCreator = Dict::S('Attachments:File:Creator'); + $sFileType = Dict::S('Attachments:File:MimeType'); + $sDeleteColumn = ''; if ($bWithDeleteButton) { - $this->oPage->add(''.PHP_EOL); + $sDeleteColumn = ' | '; } - $this->oPage->add(''.PHP_EOL); - $this->oPage->add(''.PHP_EOL); - + $this->oPage->add(<< + + | $sThumbnail | +$sFileName | +$sFileSize | +$sFileDate | +$sFileCreator | +$sFileType | + $sDeleteColumn + + +HTML + ); $iMaxWidth = MetaModel::GetModuleSetting('itop-attachments', 'preview_max_width', 290); $sPreviewNotAvailable = addslashes(Dict::S('Attachments:PreviewNotAvailable')); diff --git a/datamodels/2.x/itop-portal-base/portal/public/css/portal.css b/datamodels/2.x/itop-portal-base/portal/public/css/portal.css index 4075fd873..e53e325ae 100644 --- a/datamodels/2.x/itop-portal-base/portal/public/css/portal.css +++ b/datamodels/2.x/itop-portal-base/portal/public/css/portal.css @@ -1111,13 +1111,15 @@ table .group-actions { .fileupload_field_content > div { margin-bottom: 15px; } +.attachments_container .attachmentsList thead > tr > th { + text-align: center; +} +.attachments_container .attachmentsList tbody > tr > td { + text-align: center; +} .attachments_container .attachment { height: 95px; overflow-x: hidden; - text-align: center; -} -.attachments_container .attachment:hover { - background-color: #e0e0e0; } .attachments_container .attachment .attachment_name { overflow-x: hidden; @@ -1127,6 +1129,9 @@ table .group-actions { .attachments_container .attachment .btn { margin-top: 3px; } +.attachments_container .attachmenthover { + background-color: #e0e0e0; +} .upload_container input { display: inline; } diff --git a/datamodels/2.x/itop-portal-base/portal/public/css/portal.scss b/datamodels/2.x/itop-portal-base/portal/public/css/portal.scss index cacb0b20c..2df2907ec 100644 --- a/datamodels/2.x/itop-portal-base/portal/public/css/portal.scss +++ b/datamodels/2.x/itop-portal-base/portal/public/css/portal.scss @@ -1194,21 +1194,35 @@ table .group-actions .item-action-wrapper .panel-body > p:last-child{ .fileupload_field_content > div{ margin-bottom: 15px; } -.attachments_container .attachment { - height: 95px; - overflow-x: hidden; - text-align: center; -} -.attachments_container .attachment:hover { - background-color: #e0e0e0; -} -.attachments_container .attachment .attachment_name{ - overflow-x: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} -.attachments_container .attachment .btn{ - margin-top: 3px; +.attachments_container { + .attachmentsList { + & thead > tr > th { + text-align: center; + } + + & tbody > tr > td { + text-align: center; + } + } + + .attachment { + height: 95px; + overflow-x: hidden; + + .attachment_name { + overflow-x: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .btn { + margin-top: 3px; + } + + &hover { + background-color: #e0e0e0; + } + } } .upload_container input{ display: inline; diff --git a/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php b/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php index 7b7b288e4..24af64e02 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php +++ b/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php @@ -1152,6 +1152,8 @@ class ObjectController extends BrickController $oAttachment->Set('expire', time() + MetaModel::GetConfig()->Get('draft_attachments_lifetime')); // one hour... $oAttachment->Set('temp_id', $sTempId); $oAttachment->Set('item_class', $sObjectClass); + $oAttachment->Set('creation_date', time()); + $oAttachment->Set('user_id', UserRights::GetUserObject()); $oAttachment->SetDefaultOrgId(); $oAttachment->Set('contents', $oDocument); $iAttId = $oAttachment->DBInsert(); @@ -1162,6 +1164,10 @@ class ObjectController extends BrickController $aData['icon'] = utils::GetAbsoluteUrlAppRoot().'env-'.utils::GetCurrentEnvironment().'/itop-attachments/icons/image.png'; $aData['att_id'] = $iAttId; $aData['preview'] = $oDocument->IsPreviewAvailable() ? 'true' : 'false'; + $aData['file_size'] = $oDocument->GetFormatedSize(); + $aData['creation_date'] = $oAttachment->Get('creation_date'); + $aData['user_id_friendlyname'] = $oAttachment->Get('user_id_friendlyname'); + $aData['file_type'] = $oDocument->GetMimeType(); } catch (FileUploadException $e) { diff --git a/sources/renderer/bootstrap/fieldrenderer/bsfileuploadfieldrenderer.class.inc.php b/sources/renderer/bootstrap/fieldrenderer/bsfileuploadfieldrenderer.class.inc.php index 3801d2e29..a5153dde7 100644 --- a/sources/renderer/bootstrap/fieldrenderer/bsfileuploadfieldrenderer.class.inc.php +++ b/sources/renderer/bootstrap/fieldrenderer/bsfileuploadfieldrenderer.class.inc.php @@ -20,6 +20,7 @@ namespace Combodo\iTop\Renderer\Bootstrap\FieldRenderer; +use AbstractAttachmentsRenderer; use AttachmentPlugIn; use Combodo\iTop\Renderer\RenderingOutput; use DBObjectSearch; @@ -29,7 +30,11 @@ use InlineImage; use utils; /** - * Description of BsFileUploadFieldRenderer + * This is the class used to render attachments in the user portal. + * + * In the iTop console this is handled in the itop-attachments module. Most of the code here is a duplicate of this module. + * + * @see \AbstractAttachmentsRenderer and its implementations for the iTop console * * @author Guillaume Lajarige$sTitleThumbnail | +$sTitleFileName | +$sTitleFileSize | +$sTitleFileDate | +$sTitleFileCreator | +$sTitleFileType | ++ + +HTML + ); + while ($oAttachment = $oSet->Fetch()) { $iAttId = $oAttachment->GetKey(); + + $sLineStyle = ''; + + $sAttachmentMeta = ''; + $oDoc = $oAttachment->Get('contents'); $sFileName = htmlentities($oDoc->GetFileName(), ENT_QUOTES, 'UTF-8'); - $sIcon = utils::GetAbsoluteUrlAppRoot().'env-'.utils::GetCurrentEnvironment().'/itop-attachments/icons/image.png'; - $sPreview = $oDoc->IsPreviewAvailable() ? 'true' : 'false'; - $sDownloadLink = str_replace('-sAttachmentId-', $iAttId, $this->oField->GetDownloadEndpoint()); - $oOutput->Addhtml( - << |
|---|