mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-22 00:32:16 +02:00
N°3423 - Allow AttributeImage / AttributeDocument content to be cached by the browser (portal)
This commit is contained in:
@@ -691,15 +691,17 @@ class ManageBrickController extends BrickController
|
||||
}
|
||||
elseif ($oAttDef instanceof AttributeImage)
|
||||
{
|
||||
/** @var \ormDocument $oOrmDoc */
|
||||
$oOrmDoc = $oCurrentRow->Get($sItemAttr);
|
||||
if (is_object($oOrmDoc) && !$oOrmDoc->IsEmpty())
|
||||
{
|
||||
$sUrl = $oUrlGenerator->generate('p_object_document_display', array(
|
||||
$sUrl = $oUrlGenerator->generate('p_object_document_display', [
|
||||
'sObjectClass' => get_class($oCurrentRow),
|
||||
'sObjectId' => $oCurrentRow->GetKey(),
|
||||
'sObjectField' => $sItemAttr,
|
||||
'cache' => 86400,
|
||||
));
|
||||
's' => $oOrmDoc->GetSignature(),
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1322,15 +1322,17 @@ class ObjectController extends BrickController
|
||||
}
|
||||
elseif ($oAttDef instanceof AttributeImage)
|
||||
{
|
||||
/** @var \ormDocument $oOrmDoc */
|
||||
$oOrmDoc = $oObject->Get($oAttDef->GetCode());
|
||||
if (is_object($oOrmDoc) && !$oOrmDoc->IsEmpty())
|
||||
{
|
||||
$sUrl = $oUrlGenerator->generate('p_object_document_display', array(
|
||||
$sUrl = $oUrlGenerator->generate('p_object_document_display', [
|
||||
'sObjectClass' => get_class($oObject),
|
||||
'sObjectId' => $oObject->GetKey(),
|
||||
'sObjectField' => $oAttDef->GetCode(),
|
||||
'cache' => 86400,
|
||||
));
|
||||
's' => $oOrmDoc->GetSignature(),
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -373,8 +373,14 @@ class UserProfileBrickController extends BrickController
|
||||
$aFormData['error'] = $e->GetMessage();
|
||||
}
|
||||
|
||||
// TODO: This should be changed when refactoring the ormDocument GetDisplayUrl() and GetDownloadUrl() in iTop 3.0
|
||||
$aFormData['picture_url'] = $oUrlGenerator->generate('p_object_document_display', array('sObjectClass' => get_class($oCurContact), 'sObjectId' => $oCurContact->GetKey(), 'sObjectField' => $sPictureAttCode, 'cache' => 86400, 't' => time()));
|
||||
$oOrmDoc = $oCurContact->Get($sPictureAttCode);
|
||||
$aFormData['picture_url'] = $oUrlGenerator->generate('p_object_document_display', [
|
||||
'sObjectClass' => get_class($oCurContact),
|
||||
'sObjectId' => $oCurContact->GetKey(),
|
||||
'sObjectField' => $sPictureAttCode,
|
||||
'cache' => 86400,
|
||||
's' => $oOrmDoc->GetSignature(),
|
||||
]);
|
||||
$aFormData['validation'] = array(
|
||||
'valid' => true,
|
||||
'messages' => array(),
|
||||
|
||||
@@ -908,8 +908,21 @@ class ObjectFormManager extends FormManager
|
||||
if ($this->oContainer !== null)
|
||||
{
|
||||
// Override hardcoded URLs in ormDocument pointing to back office console
|
||||
$sDisplayUrl = $this->oContainer->get('url_generator')->generate('p_object_document_display', array('sObjectClass' => get_class($this->oObject), 'sObjectId' => $this->oObject->GetKey(), 'sObjectField' => $sAttCode, 'cache' => 86400));
|
||||
$sDownloadUrl = $this->oContainer->get('url_generator')->generate('p_object_document_download', array('sObjectClass' => get_class($this->oObject), 'sObjectId' => $this->oObject->GetKey(), 'sObjectField' => $sAttCode, 'cache' => 86400));
|
||||
$oOrmDoc = $this->oObject->Get($sAttCode);
|
||||
$sDisplayUrl = $this->oContainer->get('url_generator')->generate('p_object_document_display', [
|
||||
'sObjectClass' => get_class($this->oObject),
|
||||
'sObjectId' => $this->oObject->GetKey(),
|
||||
'sObjectField' => $sAttCode,
|
||||
'cache' => 86400,
|
||||
's' => $oOrmDoc->GetSignature(),
|
||||
]);
|
||||
$sDownloadUrl = $this->oContainer->get('url_generator')->generate('p_object_document_download', [
|
||||
'sObjectClass' => get_class($this->oObject),
|
||||
'sObjectId' => $this->oObject->GetKey(),
|
||||
'sObjectField' => $sAttCode,
|
||||
'cache' => 86400,
|
||||
's' => $oOrmDoc->GetSignature(),
|
||||
]);
|
||||
/** @var \Combodo\iTop\Form\Field\BlobField $oField */
|
||||
$oField->SetDisplayUrl($sDisplayUrl)
|
||||
->SetDownloadUrl($sDownloadUrl);
|
||||
|
||||
@@ -360,12 +360,14 @@ class BrowseBrickHelper
|
||||
{
|
||||
if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty())
|
||||
{
|
||||
$tmpAttValue = $this->oUrlGenerator->generate('p_object_document_display', array(
|
||||
$oOrmDoc = $tmpAttValue;
|
||||
$tmpAttValue = $this->oUrlGenerator->generate('p_object_document_display', [
|
||||
'sObjectClass' => $sCurrentObjectClass,
|
||||
'sObjectId' => $sCurrentObjectId,
|
||||
'sObjectField' => $aLevelsProperties[$key][$sOptionalAttribute],
|
||||
'cache' => 86400,
|
||||
));
|
||||
's' => $oOrmDoc->GetSignature(),
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -410,12 +412,13 @@ class BrowseBrickHelper
|
||||
$oOrmDoc = $value->Get($aField['code']);
|
||||
if (is_object($oOrmDoc) && !$oOrmDoc->IsEmpty())
|
||||
{
|
||||
$sUrl = $this->oUrlGenerator->generate('p_object_document_display', array(
|
||||
$sUrl = $this->oUrlGenerator->generate('p_object_document_display', [
|
||||
'sObjectClass' => $sCurrentObjectClass,
|
||||
'sObjectId' => $sCurrentObjectId,
|
||||
'sObjectField' => $aField['code'],
|
||||
'cache' => 86400,
|
||||
));
|
||||
's' => $oOrmDoc->GetSignature(),
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -530,12 +533,14 @@ class BrowseBrickHelper
|
||||
{
|
||||
if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty())
|
||||
{
|
||||
$tmpAttValue = $this->oUrlGenerator->generate('p_object_document_display', array(
|
||||
$oOrmDoc = $tmpAttValue;
|
||||
$tmpAttValue = $this->oUrlGenerator->generate('p_object_document_display', [
|
||||
'sObjectClass' => get_class($aCurrentRowValues[0]),
|
||||
'sObjectId' => $aCurrentRowValues[0]->GetKey(),
|
||||
'sObjectField' => $aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute],
|
||||
'cache' => 86400,
|
||||
));
|
||||
's' => $oOrmDoc->GetSignature(),
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -112,7 +112,13 @@ class CombodoCurrentContactPhotoUrl
|
||||
if (is_object($oImage) && !$oImage->IsEmpty())
|
||||
{
|
||||
// TODO: This should be changed when refactoring the ormDocument GetDisplayUrl() and GetDownloadUrl() in iTop 3.0
|
||||
$sContactPhotoUrl = $this->oContainer->get('url_generator')->generate('p_object_document_display', array('sObjectClass' => get_class($oContact), 'sObjectId' => $oContact->GetKey(), 'sObjectField' => $sPictureAttCode, 'cache' => 86400));
|
||||
$sContactPhotoUrl = $this->oContainer->get('url_generator')->generate('p_object_document_display', [
|
||||
'sObjectClass' => get_class($oContact),
|
||||
'sObjectId' => $oContact->GetKey(),
|
||||
'sObjectField' => $sPictureAttCode,
|
||||
'cache' => 86400,
|
||||
's' => $oImage->GetSignature(),
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user