diff --git a/datamodels/2.x/itop-portal-base/portal/web/css/portal.css b/datamodels/2.x/itop-portal-base/portal/web/css/portal.css index 1e73a76d8..b79c6c076 100644 --- a/datamodels/2.x/itop-portal-base/portal/web/css/portal.css +++ b/datamodels/2.x/itop-portal-base/portal/web/css/portal.css @@ -916,3 +916,7 @@ table .group-actions { width: 100%; text-align: center; } +/* Wiki text (hyperlinks) */ +.wiki_broken_link { + text-decoration: line-through; +} diff --git a/datamodels/2.x/itop-portal-base/portal/web/css/portal.scss b/datamodels/2.x/itop-portal-base/portal/web/css/portal.scss index fce7377d2..acfa8c458 100644 --- a/datamodels/2.x/itop-portal-base/portal/web/css/portal.scss +++ b/datamodels/2.x/itop-portal-base/portal/web/css/portal.scss @@ -960,4 +960,8 @@ table .group-actions .item-action-wrapper .panel-body > p:last-child{ display: inline-block; width: 100%; text-align: center; +} +/* Wiki text (hyperlinks) */ +.wiki_broken_link { + text-decoration: line-through; } \ No newline at end of file diff --git a/datamodels/2.x/itop-portal/index.php b/datamodels/2.x/itop-portal/index.php index 7cff3ec3f..aba5b6041 100644 --- a/datamodels/2.x/itop-portal/index.php +++ b/datamodels/2.x/itop-portal/index.php @@ -37,4 +37,5 @@ $sDir = basename(__DIR__); define('PORTAL_MODULE_ID', $sDir); define('PORTAL_ID', $sDir); +ApplicationContext::SetUrlMakerClass('iTopPortalViewUrlMaker'); require_once APPROOT . '/env-' . utils::GetCurrentEnvironment() . '/itop-portal-base/portal/web/index.php'; diff --git a/datamodels/2.x/itop-portal/main.itop-portal.php b/datamodels/2.x/itop-portal/main.itop-portal.php index 8a9280ac9..d27479ae8 100644 --- a/datamodels/2.x/itop-portal/main.itop-portal.php +++ b/datamodels/2.x/itop-portal/main.itop-portal.php @@ -22,20 +22,26 @@ * * @author Guillaume Lajarige */ -class iTopPortalUrlMaker implements iDBObjectURLMaker +class iTopPortalEditUrlMaker implements iDBObjectURLMaker { - - public static function MakeObjectURL($sClass, $iId) + /** + * Generate an (absolute) URL to an object, either in view or edit mode + * @param string $sClass The class of the object + * @param int $iId The identifier of the object + * @param string $sMode edit|view + * @return string + */ + public static function PrepareObjectURL($sClass, $iId, $sMode) { require_once APPROOT . '/lib/silex/vendor/autoload.php'; require_once APPROOT . '/env-' . utils::GetCurrentEnvironment() . '/itop-portal-base/portal/src/providers/urlgeneratorserviceprovider.class.inc.php'; require_once APPROOT . '/env-' . utils::GetCurrentEnvironment() . '/itop-portal-base/portal/src/helpers/urlgeneratorhelper.class.inc.php'; require_once APPROOT . '/env-' . utils::GetCurrentEnvironment() . '/itop-portal-base/portal/src/helpers/applicationhelper.class.inc.php'; - + // Using a static var allows to preserve the object through function calls static $oApp = null; static $sPortalId = null; - + // Initializing Silex app if ($oApp === null) { @@ -49,15 +55,51 @@ class iTopPortalUrlMaker implements iDBObjectURLMaker // Retrieving portal id $sPortalId = basename(__DIR__); } - - $sObjectQueryString = $oApp['url_generator']->generate('p_object_edit', array('sObjectClass' => $sClass, 'sObjectId' => $iId)); - $sPortalAbsoluteUrl = utils::GetAbsoluteUrlModulePage($sPortalId, 'index.php'); - $sUrl = str_replace('?', $sObjectQueryString . '?', $sPortalAbsoluteUrl); + // The object is reachable in the specified mode (edit/view) + switch($sMode) + { + case 'view': + $sObjectQueryString = $oApp['url_generator']->generate('p_object_view', array('sObjectClass' => $sClass, 'sObjectId' => $iId)); + break; + + case 'edit': + default: + $sObjectQueryString = $oApp['url_generator']->generate('p_object_edit', array('sObjectClass' => $sClass, 'sObjectId' => $iId)); + } + $sPortalAbsoluteUrl = utils::GetAbsoluteUrlModulePage($sPortalId, 'index.php'); + if (strpos($sPortalAbsoluteUrl, '?') !== false) + { + $sUrl = substr($sPortalAbsoluteUrl, 0, strpos($sPortalAbsoluteUrl, '?')).$sObjectQueryString; + } + else + { + $sUrl = $sPortalAbsoluteUrl.$sObjectQueryString; + } + return $sUrl; } - + + public static function MakeObjectURL($sClass, $iId) + { + return static::PrepareObjectURL($sClass, $iId, 'edit'); + } } -DBObject::RegisterURLMakerClass('portal', 'iTopPortalUrlMaker'); +/** + * Hyperlinks to the "view" of the object (vs edition) + * @author denis + * + */ +class iTopPortalViewUrlMaker extends iTopPortalEditUrlMaker +{ + public static function MakeObjectURL($sClass, $iId) + { + return static::PrepareObjectURL($sClass, $iId, 'view'); + } + +} + +// Default portal hyperlink (for notifications) is the edit hyperlink +DBObject::RegisterURLMakerClass('portal', 'iTopPortalEditUrlMaker'); diff --git a/sources/form/field/datetimefield.class.inc.php b/sources/form/field/datetimefield.class.inc.php index 935f36213..76ea5bb60 100644 --- a/sources/form/field/datetimefield.class.inc.php +++ b/sources/form/field/datetimefield.class.inc.php @@ -82,11 +82,6 @@ class DateTimeField extends StringField return $this; } - public function GetDisplayValue() - { - return $this->currentValue; - } - /** * Set the DateOnly flag * @return \Combodo\iTop\Form\Field\DateTimeField diff --git a/sources/form/field/field.class.inc.php b/sources/form/field/field.class.inc.php index 87672649f..eb9ce9d35 100644 --- a/sources/form/field/field.class.inc.php +++ b/sources/form/field/field.class.inc.php @@ -174,6 +174,12 @@ abstract class Field return $this->currentValue; } + + public function GetDisplayValue() + { + return $this->currentValue; + } + /** * Sets the field formpath * Usually Called by the form when adding the field diff --git a/sources/form/field/textareafield.class.inc.php b/sources/form/field/textareafield.class.inc.php index 84c2f41fc..9820d0e47 100644 --- a/sources/form/field/textareafield.class.inc.php +++ b/sources/form/field/textareafield.class.inc.php @@ -21,6 +21,8 @@ namespace Combodo\iTop\Form\Field; use \Closure; use \DBObject; +use \InlineImage; +use \AttributeText; use \Combodo\iTop\Form\Field\TextField; /** @@ -106,5 +108,20 @@ class TextAreaField extends TextField $this->sTransactionId = $sTransactionId; return $this; } + + public function GetDisplayValue() + { + if ($this->GetFormat() == TextAreaField::ENUM_FORMAT_TEXT) + { + $sValue = $this->GetCurrentValue(); + $sValue = AttributeText::RenderWikiHtml($sValue); + return "
".str_replace("\n", "
\n", $sValue).'
'; + } + else + { + $sValue = AttributeText::RenderWikiHtml($this->GetCurrentValue(), true /* wiki only */); + return "
".InlineImage::FixUrls($sValue).'
'; + } + } } diff --git a/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php b/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php index 8f9b42fc4..3317d1a09 100644 --- a/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php +++ b/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php @@ -23,6 +23,7 @@ use \utils; use \Dict; use \UserRights; use \AttributeDateTime; +use \AttributeText; use \InlineImage; use \Combodo\iTop\Renderer\FieldRenderer; use \Combodo\iTop\Renderer\RenderingOutput; @@ -223,14 +224,7 @@ EOF if($sFieldClass === 'Combodo\\iTop\\Form\\Field\\TextAreaField') { $bEncodeHtmlEntities = false; - if($this->oField->GetFormat() === TextAreaField::ENUM_FORMAT_HTML) - { - $sDisplayValue = $this->oField->GetCurrentValue(); - } - else - { - $sDisplayValue = utils::TextToHtml($this->oField->GetCurrentValue()); - } + $sDisplayValue = $this->oField->GetDisplayValue(); } else { @@ -452,6 +446,8 @@ EOF $sEntryHeaderButtonClass = ($i < 2) ? '' : 'collapsed'; $sEntryContentClass = ($i < 2) ? 'in' : ''; $sEntryContentId = 'caselog_field_entry_content-' . $this->oField->GetGlobalId() . '-' . $i; + $sEntryHtml = AttributeText::RenderWikiHtml($aEntries[$i]['message_html'], true /* wiki only */); + $sEntryHtml = InlineImage::FixUrls($sEntryHtml); // Note : We use CKEditor stylesheet to format this $oOutput->AddHtml( @@ -464,7 +460,7 @@ EOF
- {$aEntries[$i]['message_html']} + {$sEntryHtml}
EOF