mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 17:48:43 +02:00
Inline images in formatted case log & descriptions: beta version fixperms js The inline images are now no longer stored stored as Attachments but using a specific object InlineImage...
SVN:trunk[3926]
This commit is contained in:
@@ -34,7 +34,6 @@ define('ITOP_CONFIG_FILE', 'config-itop.php');
|
||||
define('ITOP_DEFAULT_CONFIG_FILE', APPCONF.ITOP_DEFAULT_ENV.'/'.ITOP_CONFIG_FILE);
|
||||
|
||||
define('SERVER_NAME_PLACEHOLDER', '$SERVER_NAME$');
|
||||
define('ATTACHMENT_DOWNLOAD_URL', 'pages/ajax.render.php?operation=download_document&class=Attachment&field=contents&id=');
|
||||
|
||||
class FileUploadException extends Exception
|
||||
{
|
||||
@@ -1169,34 +1168,4 @@ class utils
|
||||
$sText = str_replace("\r", "\n", $sText);
|
||||
return str_replace("\n", '</br>', htmlentities($sText, ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the supplied HTML fragment to rebuild the attribute src="" for images
|
||||
* that refer to an attachment (detected via the attribute data-att-id="") so that
|
||||
* the URL is consistent with the current URL of the application.
|
||||
* @param string $sHtml The HTML fragment to process
|
||||
* @return string The modified HTML
|
||||
*/
|
||||
public static function FixInlineAttachments($sHtml)
|
||||
{
|
||||
$aNeedles = array();
|
||||
$aReplacements = array();
|
||||
// Find img tags with an attribute data-att-id
|
||||
if (preg_match_all('/<img ([^>]*)data-att-id="([0-9]+)"([^>]*)>/i', $sHtml, $aMatches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
|
||||
{
|
||||
$sUrl = utils::GetAbsoluteUrlAppRoot().ATTACHMENT_DOWNLOAD_URL;
|
||||
foreach($aMatches as $aImgInfo)
|
||||
{
|
||||
$sImgTag = $aImgInfo[0][0];
|
||||
$sAttId = $aImgInfo[2][0];
|
||||
|
||||
$sNewImgTag = preg_replace('/src="[^"]+"/', 'src="'.$sUrl.$sAttId.'"', $sImgTag); // preserve other attributes
|
||||
$aNeedles[] = $sImgTag;
|
||||
$aReplacements[] = $sNewImgTag;
|
||||
}
|
||||
$sHtml = str_replace($aNeedles, $aReplacements, $sHtml);
|
||||
}
|
||||
return $sHtml;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user