diff --git a/datamodels/2.x/itop-portal-base/portal/src/controllers/browsebrickcontroller.class.inc.php b/datamodels/2.x/itop-portal-base/portal/src/controllers/browsebrickcontroller.class.inc.php index c58c2221c..765f39771 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/controllers/browsebrickcontroller.class.inc.php +++ b/datamodels/2.x/itop-portal-base/portal/src/controllers/browsebrickcontroller.class.inc.php @@ -19,21 +19,22 @@ namespace Combodo\iTop\Portal\Controller; -use BinaryExpression; -use Combodo\iTop\Portal\Brick\AbstractBrick; -use Combodo\iTop\Portal\Brick\BrowseBrick; -use Combodo\iTop\Portal\Helper\ApplicationHelper; -use Combodo\iTop\Portal\Helper\ContextManipulatorHelper; -use Combodo\iTop\Portal\Helper\SecurityHelper; -use DBObjectSet; -use DBSearch; -use Dict; -use FieldExpression; -use MetaModel; use Silex\Application; use Symfony\Component\HttpFoundation\Request; use UserRights; +use Dict; +use MetaModel; +use AttributeImage; +use DBSearch; +use DBObjectSet; +use BinaryExpression; +use FieldExpression; use VariableExpression; +use Combodo\iTop\Portal\Helper\ApplicationHelper; +use Combodo\iTop\Portal\Helper\SecurityHelper; +use Combodo\iTop\Portal\Helper\ContextManipulatorHelper; +use Combodo\iTop\Portal\Brick\AbstractBrick; +use Combodo\iTop\Portal\Brick\BrowseBrick; /** * Class BrowseBrickController @@ -653,34 +654,41 @@ class BrowseBrickController extends BrickController ); // Adding optional attributes if necessary - foreach (static::$aOptionalAttributes as $sOptionalAttribute) - { - if ($aLevelsProperties[$key][$sOptionalAttribute] !== null) - { - $sPropertyName = substr($sOptionalAttribute, 0, -4); - $oAttDef = MetaModel::GetAttributeDef(get_class($value), $aLevelsProperties[$key][$sOptionalAttribute]); + foreach(static::$aOptionalAttributes as $sOptionalAttribute) + { + if ($aLevelsProperties[$key][$sOptionalAttribute] !== null) + { + $sPropertyName = substr($sOptionalAttribute, 0, -4); + $oAttDef = MetaModel::GetAttributeDef(get_class($value), $aLevelsProperties[$key][$sOptionalAttribute]); - $tmpAttValue = $value->GetAsHTML($aLevelsProperties[$key][$sOptionalAttribute]); - if ($sOptionalAttribute === 'image_att') - { - if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty()) - { - $tmpAttValue = $oApp['url_generator']->generate('p_object_document_display', array( - 'sObjectClass' => get_class($value), - 'sObjectId' => $value->GetKey(), - 'sObjectField' => $aLevelsProperties[$key][$sOptionalAttribute], - 'cache' => 86400, - )); - } - else - { - $tmpAttValue = $oAttDef->Get('default_image'); - } - } + if($oAttDef instanceof AttributeImage) + { + $tmpAttValue = $value->Get($aLevelsProperties[$key][$sOptionalAttribute]); + if ($sOptionalAttribute === 'image_att') + { + if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty()) + { + $tmpAttValue = $oApp['url_generator']->generate('p_object_document_display', array( + 'sObjectClass' => get_class($value), + 'sObjectId' => $value->GetKey(), + 'sObjectField' => $aLevelsProperties[$key][$sOptionalAttribute], + 'cache' => 86400 + )); + } + else + { + $tmpAttValue = $oAttDef->Get('default_image'); + } + } + } + else + { + $tmpAttValue = $value->GetAsHTML($aLevelsProperties[$key][$sOptionalAttribute]); + } - $aRow[$key][$sPropertyName] = $tmpAttValue; - } - } + $aRow[$key][$sPropertyName] = $tmpAttValue; + } + } // Adding fields attributes if necessary if (!empty($aLevelsProperties[$key]['fields'])) { @@ -770,36 +778,37 @@ class BrowseBrickController extends BrickController 'action_rules_token' => static::PrepareActionRulesForItems($aCurrentRowObjects, $aCurrentRowKeys[0], $aLevelsProperties) ); - // Adding optional attributes if necessary - foreach (static::$aOptionalAttributes as $sOptionalAttribute) - { - if ($aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute] !== null) - { - $sPropertyName = substr($sOptionalAttribute, 0, -4); - $oAttDef = MetaModel::GetAttributeDef(get_class($aCurrentRowValues[0]), - $aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute]); + // Adding optional attributes if necessary + foreach(static::$aOptionalAttributes as $sOptionalAttribute) + { + if ($aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute] !== null) + { + $sPropertyName = substr($sOptionalAttribute, 0, -4); + $oAttDef = MetaModel::GetAttributeDef(get_class($aCurrentRowValues[0]), $aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute]); - $tmpAttValue = $aCurrentRowValues[0]->GetAsHTML($aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute]); - if ($sOptionalAttribute === 'image_att') - { - if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty()) - { - $tmpAttValue = $oApp['url_generator']->generate('p_object_document_display', array( - 'sObjectClass' => get_class($aCurrentRowValues[0]), - 'sObjectId' => $aCurrentRowValues[0]->GetKey(), - 'sObjectField' => $aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute], - 'cache' => 86400, - )); - } - else - { - $tmpAttValue = $oAttDef->Get('default_image'); - } - } + if($oAttDef instanceof AttributeImage) + { + $tmpAttValue = $aCurrentRowValues[0]->Get($aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute]); + if($sOptionalAttribute === 'image_att') + { + if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty()) + { + $tmpAttValue = $oApp['url_generator']->generate('p_object_document_display', array('sObjectClass' => get_class($aCurrentRowValues[0]), 'sObjectId' => $aCurrentRowValues[0]->GetKey(), 'sObjectField' => $aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute], 'cache' => 86400)); + } + else + { + $tmpAttValue = $oAttDef->Get('default_image'); + } + } + } + else + { + $tmpAttValue = $aCurrentRowValues[0]->GetAsHTML($aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute]); + } - $aItems[$sCurrentIndex][$sPropertyName] = $tmpAttValue; - } - } + $aItems[$sCurrentIndex][$sPropertyName] = $tmpAttValue; + } + } } $aCurrentRowSliced = array_slice($aCurrentRow, 1); diff --git a/js/jquery.autocomplete.js b/js/jquery.autocomplete.js index 7d33ddd82..860a2f647 100644 --- a/js/jquery.autocomplete.js +++ b/js/jquery.autocomplete.js @@ -473,13 +473,14 @@ function matchSubset(s, sub) { if (!options.matchCase) - s = s.toLowerCase(); + s = s.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, ""); + sub = sub.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, ""); var i = s.indexOf(sub); - if (options.matchContains == "word"){ + if (options.matchContains === "word"){ i = s.toLowerCase().search("\\b" + sub.toLowerCase()); } - if (i == -1) return false; - return i == 0 || options.matchContains; + if (i === -1) return false; + return i === 0 || options.matchContains; }; function add(q, value) { diff --git a/pages/ajax.render.php b/pages/ajax.render.php index ed74623b3..60cc6e422 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -25,16 +25,25 @@ */ require_once('../approot.inc.php'); -require_once(APPROOT.'/application/application.inc.php'); -require_once(APPROOT.'/application/webpage.class.inc.php'); -require_once(APPROOT.'/application/ajaxwebpage.class.inc.php'); -require_once(APPROOT.'/application/pdfpage.class.inc.php'); -require_once(APPROOT.'/application/wizardhelper.class.inc.php'); -require_once(APPROOT.'/application/ui.linkswidget.class.inc.php'); -require_once(APPROOT.'/application/ui.searchformforeignkeys.class.inc.php'); -require_once(APPROOT.'/application/ui.extkeywidget.class.inc.php'); -require_once(APPROOT.'/application/datatable.class.inc.php'); -require_once(APPROOT.'/application/excelexporter.class.inc.php'); +require_once(APPROOT.'application/application.inc.php'); +require_once(APPROOT.'application/webpage.class.inc.php'); +require_once(APPROOT.'application/ajaxwebpage.class.inc.php'); +require_once(APPROOT.'application/pdfpage.class.inc.php'); +require_once(APPROOT.'application/wizardhelper.class.inc.php'); +require_once(APPROOT.'application/ui.linkswidget.class.inc.php'); +require_once(APPROOT.'application/ui.searchformforeignkeys.class.inc.php'); +require_once(APPROOT.'application/ui.extkeywidget.class.inc.php'); +require_once(APPROOT.'application/datatable.class.inc.php'); +require_once(APPROOT.'application/excelexporter.class.inc.php'); + + +function LogErrorMessage($sMsgPrefix, $aContextInfo) { + $sCurrentUserLogin = UserRights::GetUser(); + $sContextInfo = urldecode(http_build_query($aContextInfo, '', ', ')); + $sErrorMessage = "$sMsgPrefix - User='$sCurrentUserLogin', $sContextInfo"; + IssueLog::Error($sErrorMessage); +} + try { @@ -2506,8 +2515,16 @@ EOF try { $oDoc = utils::ReadPostedDocument('upload'); - if (InlineImage::IsImage($oDoc->GetMimeType())) + $sDocMimeType = $oDoc->GetMimeType(); + if (!InlineImage::IsImage($sDocMimeType)) { + LogErrorMessage('CKE : error when uploading image in ajax.render.php, not an image', + array( + 'operation' => 'cke_upload_and_browse', + 'class' => $sObjClass, + 'ImgMimeType' => $sDocMimeType, + )); + } else { $aDimensions = null; $oDoc = InlineImage::ResizeImageToFit($oDoc, $aDimensions); $oAttachment = MetaModel::NewObject('InlineImage'); @@ -2518,13 +2535,16 @@ EOF $oAttachment->Set('contents', $oDoc); $oAttachment->Set('secret', sprintf('%06x', mt_rand(0, 0xFFFFFF))); // something not easy to guess $iAttId = $oAttachment->DBInsert(); - } + } catch (FileUploadException $e) { - $sCurrentUserLogin = UserRights::GetUser(); - $sErrorMessage = "CKE : error when uploading image in ajax.render.php - operation=cke_upload_and_browse,User='$sCurrentUserLogin', class='$sObjClass',exception=$e"; - IssueLog::Error($sErrorMessage); + LogErrorMessage('CKE : error when uploading image in ajax.render.php, exception occured', + array( + 'operation' => 'cke_upload_and_browse', + 'class' => $sObjClass, + 'exceptionMsg' => $e, + )); } // Fall though !! => browse