Skip to content
Snippets Groups Projects
Commit 260ff57d authored by Prasad's avatar Prasad
Browse files

Added php7_trim, php7_htmlentities with null-check safety to use in templates.

parent bc7b736d
No related branches found
No related tags found
No related merge requests found
......@@ -1031,4 +1031,12 @@ function php7_sizeof($value) {
return php7_count($value);
}
?>
function php7_trim($str) {
// PHP 8.x marks as deprecated
return $str == null ? $str : trim($str);
}
function php7_htmlentities($str) {
// PHP 8.x marks as deprecated
return $str == null ? $str : htmlentities($str);
}
......@@ -87,7 +87,7 @@ class Vtiger_Viewer extends Smarty {
$modifiers = array('vtranslate', 'vtlib_isModuleActive', 'vimage_path', 'strstr', 'stripos', 'strpos', 'date', 'vtemplate_path', 'vresource_url',
'decode_html', 'vtlib_purify', 'php7_count', 'getUserFullName', 'array_flip', 'explode', 'trim', 'array_push',
'array_map', 'array_key_exists', 'get_class', 'vtlib_array', 'getDuplicatesPreventionMessage', 'htmlentities',
'getCurrencySymbolandCRate', 'mb_substr', 'isPermitted', 'getEntityName', 'function_exists',
'getCurrencySymbolandCRate', 'mb_substr', 'isPermitted', 'getEntityName', 'function_exists', 'php7_trim', 'php7_htmlentities',
'strtolower', 'strtoupper', 'str_replace', 'urlencode', 'getTranslatedCurrencyString', 'getTranslatedString', 'is_object', 'is_numeric');
foreach ($modifiers as $modifier) {
if (function_exists($modifier)) {
......
......@@ -21,7 +21,7 @@
{if $FIELD_MODEL->isEmptyPicklistOptionAllowed()}<option value="">{vtranslate('LBL_SELECT_OPTION','Vtiger')}</option>{/if}
{foreach item=PICKLIST_VALUE key=PICKLIST_NAME from=$PICKLIST_VALUES}
{assign var=CLASS_NAME value="picklistColor_{$FIELD_MODEL->getFieldName()}_{$PICKLIST_NAME|replace:' ':'_'}"}
<option value="{Vtiger_Util_Helper::toSafeHTML($PICKLIST_NAME)}" {if isset($PICKLIST_COLORS[$PICKLIST_NAME]) && $PICKLIST_COLORS[$PICKLIST_NAME]}class="{$CLASS_NAME}"{/if} {if trim(decode_html($FIELD_MODEL->get('fieldvalue'))) eq trim($PICKLIST_NAME)} selected {/if}>{$PICKLIST_VALUE}</option>
<option value="{Vtiger_Util_Helper::toSafeHTML($PICKLIST_NAME)}" {if isset($PICKLIST_COLORS[$PICKLIST_NAME]) && $PICKLIST_COLORS[$PICKLIST_NAME]}class="{$CLASS_NAME}"{/if} {if php7_trim(decode_html($FIELD_MODEL->get('fieldvalue'))) eq php7_trim($PICKLIST_NAME)} selected {/if}>{$PICKLIST_VALUE}</option>
{/foreach}
</select>
{if $PICKLIST_COLORS}
......
......@@ -16,7 +16,7 @@
{if (!$FIELD_NAME)}
{assign var="FIELD_NAME" value=$FIELD_MODEL->getFieldName()}
{/if}
<input id="{$MODULE}_editView_fieldName_{$FIELD_NAME}" type="text" data-fieldname="{$FIELD_NAME}" data-fieldtype="string" class="inputElement {if $FIELD_MODEL->isNameField()}nameField{/if}" name="{$FIELD_NAME}" value="{decode_html($FIELD_MODEL->get('fieldvalue'))|htmlentities}"
<input id="{$MODULE}_editView_fieldName_{$FIELD_NAME}" type="text" data-fieldname="{$FIELD_NAME}" data-fieldtype="string" class="inputElement {if $FIELD_MODEL->isNameField()}nameField{/if}" name="{$FIELD_NAME}" value="{decode_html($FIELD_MODEL->get('fieldvalue'))|php7_htmlentities}"
{if $FIELD_MODEL->get('uitype') eq '3' || $FIELD_MODEL->get('uitype') eq '4'|| $FIELD_MODEL->isReadOnly()}
{if $FIELD_MODEL->get('uitype') neq '106'}
readonly
......
......@@ -70,6 +70,7 @@ class Vtiger_Date_UIType extends Vtiger_Base_UIType {
* @return converted value
*/
public function getEditViewDisplayValue($value) {
if ($value == null) return $value;
if (empty($value) || $value === ' ') {
$value = trim($value);
$fieldInstance = $this->get('field')->getWebserviceFieldObject();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment