mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
N°8796 - Add PHP code style validation in iTop and extensions - format whole code base
This commit is contained in:
@@ -45,11 +45,11 @@ use utils;
|
||||
*/
|
||||
class BsSimpleFieldRenderer extends BsFieldRenderer
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function Render() {
|
||||
public function Render()
|
||||
{
|
||||
$oOutput = parent::Render();
|
||||
|
||||
$sFieldClass = get_class($this->oField);
|
||||
@@ -72,68 +72,70 @@ class BsSimpleFieldRenderer extends BsFieldRenderer
|
||||
case 'Combodo\\iTop\\Form\\Field\\SelectField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\MultipleSelectField':
|
||||
// Opening container
|
||||
$oOutput->AddHtml('<div class="form-group form_group_small '.$sFieldMandatoryClass.'">');
|
||||
$oOutput->AddHtml('<div class="form-group form_group_small '.$sFieldMandatoryClass.'">');
|
||||
|
||||
// Label
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '') {
|
||||
$oOutput->AddHtml('<label for="'.$this->oField->GetGlobalId().'" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
// Label
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '') {
|
||||
$oOutput->AddHtml('<label for="'.$this->oField->GetGlobalId().'" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
// Value
|
||||
$oOutput->AddHtml('<div class="form_field_control">');
|
||||
// - Help block
|
||||
$oOutput->AddHtml('<div class="help-block"></div>');
|
||||
// Value
|
||||
$oOutput->AddHtml('<div class="form_field_control">');
|
||||
// - Help block
|
||||
$oOutput->AddHtml('<div class="help-block"></div>');
|
||||
|
||||
// - Value regarding the field type
|
||||
switch ($sFieldClass) {
|
||||
case 'Combodo\\iTop\\Form\\Field\\DateTimeField':
|
||||
// - Value regarding the field type
|
||||
switch ($sFieldClass) {
|
||||
case 'Combodo\\iTop\\Form\\Field\\DateTimeField':
|
||||
|
||||
/* @see N°803 - Allow display & edition of attributes on n:n relations on Portal
|
||||
* LinkedSetFieldRenderer allow modification of link attributes, the default widget positioning truncates the popup.
|
||||
*/
|
||||
$sParent = '';
|
||||
if ($this->oField->GetDateTimePickerWidgetParent() != null) {
|
||||
$sParent = ", widgetParent: '{$this->oField->GetDateTimePickerWidgetParent()}'";
|
||||
}
|
||||
/* @see N°803 - Allow display & edition of attributes on n:n relations on Portal
|
||||
* LinkedSetFieldRenderer allow modification of link attributes, the default widget positioning truncates the popup.
|
||||
*/
|
||||
$sParent = '';
|
||||
if ($this->oField->GetDateTimePickerWidgetParent() != null) {
|
||||
$sParent = ", widgetParent: '{$this->oField->GetDateTimePickerWidgetParent()}'";
|
||||
}
|
||||
|
||||
$oOutput->AddHtml('<div class="input-group date" id="datepicker_'.$this->oField->GetGlobalId().'">');
|
||||
$oOutput->AddHtml('<input type="text" id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" value="')->AddHtml($this->oField->GetDisplayValue(), true)->AddHtml('" class="form-control" maxlength="255" '.$sInputTags.'/>');
|
||||
$oOutput->AddHtml('<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>');
|
||||
$oOutput->AddHtml('</div>');
|
||||
$sJSFormat = json_encode($this->oField->GetJSDateTimeFormat());
|
||||
$sLocale = Dict::S('Portal:Calendar-FirstDayOfWeek');
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
$oOutput->AddHtml('<div class="input-group date" id="datepicker_'.$this->oField->GetGlobalId().'">');
|
||||
$oOutput->AddHtml('<input type="text" id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" value="')->AddHtml($this->oField->GetDisplayValue(), true)->AddHtml('" class="form-control" maxlength="255" '.$sInputTags.'/>');
|
||||
$oOutput->AddHtml('<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>');
|
||||
$oOutput->AddHtml('</div>');
|
||||
$sJSFormat = json_encode($this->oField->GetJSDateTimeFormat());
|
||||
$sLocale = Dict::S('Portal:Calendar-FirstDayOfWeek');
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
$('#datepicker_{$this->oField->GetGlobalId()}').datetimepicker({format: $sJSFormat, locale: '$sLocale' $sParent});
|
||||
EOF
|
||||
);
|
||||
break;
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Combodo\\iTop\\Form\\Field\\PasswordField':
|
||||
$oOutput->AddHtml('<input type="password" id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" maxlength="255" autocomplete="off" '.$sInputTags.'/>');
|
||||
break;
|
||||
case 'Combodo\\iTop\\Form\\Field\\PasswordField':
|
||||
$oOutput->AddHtml('<input type="password" id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" maxlength="255" autocomplete="off" '.$sInputTags.'/>');
|
||||
break;
|
||||
|
||||
case 'Combodo\\iTop\\Form\\Field\\StringField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\UrlField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\EmailField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\PhoneField':
|
||||
$oOutput->AddHtml('<input type="text" id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" value="')->AddHtml($this->oField->GetCurrentValue(),
|
||||
true)->AddHtml('" class="form-control" maxlength="255" '.$sInputTags.'/>');
|
||||
break;
|
||||
case 'Combodo\\iTop\\Form\\Field\\StringField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\UrlField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\EmailField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\PhoneField':
|
||||
$oOutput->AddHtml('<input type="text" id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" value="')->AddHtml(
|
||||
$this->oField->GetCurrentValue(),
|
||||
true
|
||||
)->AddHtml('" class="form-control" maxlength="255" '.$sInputTags.'/>');
|
||||
break;
|
||||
|
||||
case 'Combodo\\iTop\\Form\\Field\\SelectField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\MultipleSelectField':
|
||||
$oOutput->AddHtml('<select id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" '.(($this->oField->GetMultipleValuesEnabled()) ? 'multiple' : '').' class="form-control" '.$sInputTags.'>');
|
||||
foreach ($this->oField->GetChoices() as $sChoice => $sLabel) {
|
||||
// Note : The test is a double equal on purpose as the type of the value received from the XHR is not always the same as the type of the allowed values. (eg : string vs int)
|
||||
$sSelectedAtt = ($this->oField->GetCurrentValue() == $sChoice) ? 'selected' : '';
|
||||
$oOutput->AddHtml('<option value="'.$sChoice.'" '.$sSelectedAtt.' >')->AddHtml($sLabel)->AddHtml('</option>');
|
||||
}
|
||||
$oOutput->AddHtml('</select>');
|
||||
break;
|
||||
}
|
||||
case 'Combodo\\iTop\\Form\\Field\\SelectField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\MultipleSelectField':
|
||||
$oOutput->AddHtml('<select id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" '.(($this->oField->GetMultipleValuesEnabled()) ? 'multiple' : '').' class="form-control" '.$sInputTags.'>');
|
||||
foreach ($this->oField->GetChoices() as $sChoice => $sLabel) {
|
||||
// Note : The test is a double equal on purpose as the type of the value received from the XHR is not always the same as the type of the allowed values. (eg : string vs int)
|
||||
$sSelectedAtt = ($this->oField->GetCurrentValue() == $sChoice) ? 'selected' : '';
|
||||
$oOutput->AddHtml('<option value="'.$sChoice.'" '.$sSelectedAtt.' >')->AddHtml($sLabel)->AddHtml('</option>');
|
||||
}
|
||||
$oOutput->AddHtml('</select>');
|
||||
break;
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
// Closing container
|
||||
@@ -145,34 +147,34 @@ EOF
|
||||
$bRichEditor = ($this->oField->GetFormat() === TextAreaField::ENUM_FORMAT_HTML);
|
||||
|
||||
// Opening container
|
||||
$oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
|
||||
$oOutput->AddHtml('<div class="form-group '.$sFieldMandatoryClass.'">');
|
||||
|
||||
// Label
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '') {
|
||||
$oOutput->AddHtml('<label for="'.$this->oField->GetGlobalId().'" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
if ($this->oField->GetLabel() !== '') {
|
||||
$oOutput->AddHtml('<label for="'.$this->oField->GetGlobalId().'" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
// Value
|
||||
$oOutput->AddHtml('<div class="form_field_control">');
|
||||
// - Help block
|
||||
$oOutput->AddHtml('<div class="help-block"></div>');
|
||||
// First the edition area
|
||||
$oOutput->AddHtml('<div>');
|
||||
$sEditorClasses = $bRichEditor ? 'htmlEditor' : '';
|
||||
$oOutput->AddHtml('<textarea id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" class="' . $sEditorClasses . ' form-control" rows="8" '.$sInputTags.'>'. CKEditorHelper::PrepareCKEditorValueTextEncodingForTextarea($this->oField->GetCurrentValue()) .'</textarea>');
|
||||
$oOutput->AddHtml('</div>');
|
||||
// Then the previous entries if necessary
|
||||
if ($sFieldClass === 'Combodo\\iTop\\Form\\Field\\CaseLogField') {
|
||||
$this->PreparingCaseLogEntries($oOutput);
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
// Value
|
||||
$oOutput->AddHtml('<div class="form_field_control">');
|
||||
// - Help block
|
||||
$oOutput->AddHtml('<div class="help-block"></div>');
|
||||
// First the edition area
|
||||
$oOutput->AddHtml('<div>');
|
||||
$sEditorClasses = $bRichEditor ? 'htmlEditor' : '';
|
||||
$oOutput->AddHtml('<textarea id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" class="'.$sEditorClasses.' form-control" rows="8" '.$sInputTags.'>'.CKEditorHelper::PrepareCKEditorValueTextEncodingForTextarea($this->oField->GetCurrentValue()).'</textarea>');
|
||||
$oOutput->AddHtml('</div>');
|
||||
// Then the previous entries if necessary
|
||||
if ($sFieldClass === 'Combodo\\iTop\\Form\\Field\\CaseLogField') {
|
||||
$this->PreparingCaseLogEntries($oOutput);
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
// Closing container
|
||||
$oOutput->AddHtml('</div>');
|
||||
// Closing container
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
// Some additional stuff if we are displaying it with a rich editor
|
||||
// Some additional stuff if we are displaying it with a rich editor
|
||||
if ($bRichEditor) {
|
||||
|
||||
// Enable CKEditor
|
||||
@@ -189,7 +191,7 @@ EOF
|
||||
$sFieldType = ($sFieldClass === 'Combodo\\iTop\\Form\\Field\\RadioField') ? 'radio' : 'checkbox';
|
||||
|
||||
// Opening container
|
||||
$oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '" id="' . $this->oField->GetGlobalId() . '">');
|
||||
$oOutput->AddHtml('<div class="form-group '.$sFieldMandatoryClass.'" id="'.$this->oField->GetGlobalId().'">');
|
||||
|
||||
// Label
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
@@ -208,7 +210,7 @@ EOF
|
||||
// Note : The test is a double equal on purpose as the type of the value received from the XHR is not always the same as the type of the allowed values. (eg : string vs int)
|
||||
$sCheckedAtt = ($this->oField->IsAmongValues($sChoice)) ? 'checked' : '';
|
||||
$sCheckedClass = ($this->oField->IsAmongValues($sChoice)) ? 'active' : '';
|
||||
$oOutput->AddHtml('<label class="btn btn-default ' . $sCheckedClass . '"><input type="' . $sFieldType . '" name="' . $this->oField->GetId() . '" id="' . $this->oField->GetId() . $i . '" value="' . $sChoice . '" ' . $sCheckedAtt . ' />' . $sLabel . '</label>');
|
||||
$oOutput->AddHtml('<label class="btn btn-default '.$sCheckedClass.'"><input type="'.$sFieldType.'" name="'.$this->oField->GetId().'" id="'.$this->oField->GetId().$i.'" value="'.$sChoice.'" '.$sCheckedAtt.' />'.$sLabel.'</label>');
|
||||
$i++;
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
@@ -219,7 +221,7 @@ EOF
|
||||
break;
|
||||
|
||||
case 'Combodo\\iTop\\Form\\Field\\HiddenField':
|
||||
$oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('"/>');
|
||||
$oOutput->AddHtml('<input type="hidden" id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('"/>');
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -233,7 +235,8 @@ EOF
|
||||
case 'Combodo\\iTop\\Form\\Field\\SelectField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\MultipleSelectField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\HiddenField':
|
||||
$oOutput->AddJs(<<<JS
|
||||
$oOutput->AddJs(
|
||||
<<<JS
|
||||
$("#{$this->oField->GetGlobalId()}").off("change keyup").on("change keyup", function(){
|
||||
var me = this;
|
||||
|
||||
@@ -250,7 +253,8 @@ JS
|
||||
case 'Combodo\\iTop\\Form\\Field\\TextAreaField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\CaseLogField':
|
||||
if ($this->oField->GetFormat() === TextAreaField::ENUM_FORMAT_HTML) {
|
||||
$oOutput->AddJs(<<<JS
|
||||
$oOutput->AddJs(
|
||||
<<<JS
|
||||
CombodoCKEditorHandler.GetInstance("#{$this->oField->GetGlobalId()}")
|
||||
.then((oCKEditor) => {
|
||||
oCKEditor.model.document.on("change:data", () => {
|
||||
@@ -266,7 +270,8 @@ JS
|
||||
JS
|
||||
);
|
||||
} else {
|
||||
$oOutput->AddJs(<<<JS
|
||||
$oOutput->AddJs(
|
||||
<<<JS
|
||||
$("#{$this->oField->GetGlobalId()}").off("change keyup").on("change keyup", function(){
|
||||
var me = this;
|
||||
|
||||
@@ -340,21 +345,21 @@ EOF
|
||||
// Label
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '') {
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="'.$this->oField->GetGlobalId().'" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
// Value
|
||||
$bEncodeHtmlEntities = ( in_array($sFieldClass, array('Combodo\\iTop\\Form\\Field\\UrlField', 'Combodo\\iTop\\Form\\Field\\EmailField', 'Combodo\\iTop\\Form\\Field\\PhoneField')) ) ? false : true;
|
||||
$bEncodeHtmlEntities = (in_array($sFieldClass, ['Combodo\\iTop\\Form\\Field\\UrlField', 'Combodo\\iTop\\Form\\Field\\EmailField', 'Combodo\\iTop\\Form\\Field\\PhoneField'])) ? false : true;
|
||||
$oOutput->AddHtml('<div class="form_field_control">');
|
||||
$oOutput->AddHtml('<div class="form-control-static">')->AddHtml($this->oField->GetDisplayValue(), $bEncodeHtmlEntities)->AddHtml('</div>');
|
||||
$oOutput->AddHtml('</div>');
|
||||
}
|
||||
|
||||
// Adding hidden input if not a label
|
||||
if($sFieldClass !== 'Combodo\\iTop\\Form\\Field\\LabelField') {
|
||||
if ($sFieldClass !== 'Combodo\\iTop\\Form\\Field\\LabelField') {
|
||||
$sValueForInput = ($sFieldClass === 'Combodo\\iTop\\Form\\Field\\DateTimeField') ? $this->oField->GetDisplayValue() : $this->oField->GetCurrentValue();
|
||||
$oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($sValueForInput, true)->AddHtml('" class="form-control" />');
|
||||
$oOutput->AddHtml('<input type="hidden" id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" value="')->AddHtml($sValueForInput, true)->AddHtml('" class="form-control" />');
|
||||
}
|
||||
|
||||
// Closing container
|
||||
@@ -370,7 +375,7 @@ EOF
|
||||
// Label
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '') {
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="'.$this->oField->GetGlobalId().'" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
@@ -381,7 +386,7 @@ EOF
|
||||
}
|
||||
|
||||
// Adding hidden input
|
||||
$oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" />');
|
||||
$oOutput->AddHtml('<input type="hidden" id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" />');
|
||||
|
||||
// Closing container
|
||||
$oOutput->AddHtml('</div>');
|
||||
@@ -389,12 +394,12 @@ EOF
|
||||
|
||||
case 'Combodo\\iTop\\Form\\Field\\CaseLogField':
|
||||
// Opening container
|
||||
$oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
|
||||
$oOutput->AddHtml('<div class="form-group '.$sFieldMandatoryClass.'">');
|
||||
|
||||
// Label
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '') {
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="'.$this->oField->GetGlobalId().'" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
@@ -418,23 +423,22 @@ EOF
|
||||
// Label
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '') {
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="'.$this->oField->GetGlobalId().'" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
// Value
|
||||
$oOutput->AddHtml('<div class="form_field_control">');
|
||||
$oOutput->AddHtml('<div class="form-control-static">');
|
||||
if($sFieldClass === 'Combodo\\iTop\\Form\\Field\\ImageField') {
|
||||
$oOutput->AddHtml('<img src="' . $this->oField->GetDisplayUrl() . '" />', false);
|
||||
}
|
||||
else {
|
||||
if ($sFieldClass === 'Combodo\\iTop\\Form\\Field\\ImageField') {
|
||||
$oOutput->AddHtml('<img src="'.$this->oField->GetDisplayUrl().'" />', false);
|
||||
} else {
|
||||
$oOutput->AddHtml($this->oField->GetDisplayValue(), false);
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
$oOutput->AddHtml('</div>');
|
||||
}
|
||||
$oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" />');
|
||||
$oOutput->AddHtml('<input type="hidden" id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" />');
|
||||
|
||||
// Closing container
|
||||
$oOutput->AddHtml('</div>');
|
||||
@@ -454,50 +458,50 @@ EOF
|
||||
// Label
|
||||
$oOutput->AddHtml('<div class="form_field_label">');
|
||||
if ($this->oField->GetLabel() !== '') {
|
||||
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
$oOutput->AddHtml('<label for="'.$this->oField->GetGlobalId().'" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
|
||||
}
|
||||
$oOutput->AddHtml('</div>');
|
||||
|
||||
// Value
|
||||
$oOutput->AddHtml('<div class="form_field_control">');
|
||||
$oOutput->AddHtml('<div class="form-control-static">' . $sFieldValue . '</div>');
|
||||
$oOutput->AddHtml('<div class="form-control-static">'.$sFieldValue.'</div>');
|
||||
$oOutput->AddHtml('</div>');
|
||||
}
|
||||
|
||||
// Adding hidden value
|
||||
$oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="' . $this->oField->GetCurrentValue() . '" class="form-control" />');
|
||||
$oOutput->AddHtml('<input type="hidden" id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" value="'.$this->oField->GetCurrentValue().'" class="form-control" />');
|
||||
|
||||
// Closing container
|
||||
$oOutput->AddHtml('</div>');
|
||||
break;
|
||||
|
||||
case 'Combodo\\iTop\\Form\\Field\\HiddenField':
|
||||
$oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('"/>');
|
||||
$oOutput->AddHtml('<input type="hidden" id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('"/>');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attaching JS widget only if field is hidden or NOT read only
|
||||
if($this->oField->GetHidden() || !$this->oField->GetReadOnly()) {
|
||||
if ($this->oField->GetHidden() || !$this->oField->GetReadOnly()) {
|
||||
|
||||
// JS Form field widget construct
|
||||
$aValidators = array();
|
||||
$aValidators = [];
|
||||
foreach ($this->oField->GetValidators() as $oValidator) {
|
||||
if (false === ($oValidator instanceof AbstractRegexpValidator)) {
|
||||
// no JS counterpart, so skipping !
|
||||
continue;
|
||||
}
|
||||
|
||||
$aValidators[$oValidator::GetName()] = array(
|
||||
$aValidators[$oValidator::GetName()] = [
|
||||
'reg_exp' => $oValidator->GetRegExp(),
|
||||
'message' => Dict::S($oValidator->GetErrorMessage()),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$sFormFieldOptions = json_encode(array(
|
||||
'validators' => $aValidators
|
||||
));
|
||||
$sFormFieldOptions = json_encode([
|
||||
'validators' => $aValidators,
|
||||
]);
|
||||
|
||||
switch ($sFieldClass) {
|
||||
case 'Combodo\\iTop\\Form\\Field\\PasswordField':
|
||||
@@ -520,7 +524,7 @@ EOF
|
||||
case 'Combodo\\iTop\\Form\\Field\\TextAreaField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\CaseLogField':
|
||||
$bRichEditor = ($this->oField->GetFormat() === TextAreaField::ENUM_FORMAT_HTML);
|
||||
if($bRichEditor) {
|
||||
if ($bRichEditor) {
|
||||
// Overloading $sFormFieldOptions to include the set_current_value_callback. It would have been nicer to refactor the variable for all field types, but as this is a fix for a maintenance release, we rather be safe.
|
||||
$sValidators = json_encode($aValidators);
|
||||
$oOutput->AddJs(
|
||||
@@ -531,8 +535,7 @@ EOF
|
||||
});
|
||||
EOF
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$oOutput->AddJs(
|
||||
<<<EOF
|
||||
$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field($sFormFieldOptions);
|
||||
@@ -548,11 +551,12 @@ EOF
|
||||
case 'Combodo\\iTop\\Form\\Field\\TextAreaField':
|
||||
case 'Combodo\\iTop\\Form\\Field\\CaseLogField':
|
||||
$bRichEditor = ($this->oField->GetFormat() === TextAreaField::ENUM_FORMAT_HTML);
|
||||
if($bRichEditor) {
|
||||
if ($bRichEditor) {
|
||||
// MagnificPopup on images
|
||||
$oOutput->AddJs(InlineImage::FixImagesWidth());
|
||||
// Trigger highlighter for all code blocks in this caselog
|
||||
$oOutput->AddJs(<<<JS
|
||||
$oOutput->AddJs(
|
||||
<<<JS
|
||||
$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}'] pre").each(function(i, block) {
|
||||
hljs.highlightBlock(block);
|
||||
});
|
||||
@@ -572,7 +576,8 @@ JS
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function PreparingCaseLogEntries(RenderingOutput &$oOutput) {
|
||||
protected function PreparingCaseLogEntries(RenderingOutput &$oOutput)
|
||||
{
|
||||
$aEntries = $this->oField->GetEntries();
|
||||
$iNbEntries = count($aEntries);
|
||||
|
||||
@@ -585,7 +590,7 @@ JS
|
||||
$sCloseEntryTooltip = utils::HtmlEntities(Dict::S('Portal:Form:Caselog:Entry:Close:Tooltip'));
|
||||
|
||||
// First pass to retrieve number of users
|
||||
$aUserIds = array();
|
||||
$aUserIds = [];
|
||||
for ($i = 0; $i < $iNbEntries; $i++) {
|
||||
$iEntryUserId = $aEntries[$i]['user_id'];
|
||||
if (!in_array($iEntryUserId, $aUserIds)) {
|
||||
@@ -595,12 +600,14 @@ JS
|
||||
$iNbUsers = count($aUserIds);
|
||||
|
||||
// Opening thread
|
||||
$oOutput->AddHtml(<<<HTML
|
||||
$oOutput->AddHtml(
|
||||
<<<HTML
|
||||
<div class="ipb-caselog-thread ipb-is-html-content">
|
||||
HTML
|
||||
);
|
||||
// - Header
|
||||
$oOutput->AddHtml(<<<HTML
|
||||
$oOutput->AddHtml(
|
||||
<<<HTML
|
||||
<div class="ipb-caselog-thread--header">
|
||||
<span class="ipb-caselog-thread--header-togglers">
|
||||
<a href="#" class="ipb-caselog-thread--header-toggler ipb-caselog-thread--open-all-toggler" data-tooltip-content="{$sOpenAllEntriesTooltip}"><span class="fas fa-book-open"></span></a>
|
||||
@@ -614,7 +621,8 @@ HTML
|
||||
HTML
|
||||
);
|
||||
// - Content
|
||||
$oOutput->AddHtml(<<<HTML
|
||||
$oOutput->AddHtml(
|
||||
<<<HTML
|
||||
<div class="ipb-caselog-thread--content">
|
||||
HTML
|
||||
);
|
||||
@@ -625,13 +633,12 @@ HTML
|
||||
$iLastLoopIndex = $iNbEntries - 1;
|
||||
|
||||
// Caching profile picture url as it is resource consuming
|
||||
$aContactPicturesCache = array();
|
||||
$aPeerColorClassCache = array();
|
||||
$aContactPicturesCache = [];
|
||||
$aPeerColorClassCache = [];
|
||||
// Note: Yes, the config. param. is named after the backoffice element but we hope that we will "soon" have some kind of "light" activity panel in the portal too, so we keep this name.
|
||||
$bHideContactPicture = false;
|
||||
if (defined('PORTAL_ID'))
|
||||
{
|
||||
$bHideContactPicture= in_array(PORTAL_ID, utils::GetConfig()->Get('activity_panel.hide_avatars'));
|
||||
if (defined('PORTAL_ID')) {
|
||||
$bHideContactPicture = in_array(PORTAL_ID, utils::GetConfig()->Get('activity_panel.hide_avatars'));
|
||||
}
|
||||
// Current user
|
||||
$iCurrentUserId = UserRights::GetUserId();
|
||||
@@ -645,7 +652,7 @@ HTML
|
||||
// - Friendlyname
|
||||
if (false === empty($iEntryUserId)) {
|
||||
$oEntryUser = MetaModel::GetObject('User', $iEntryUserId, false /* Necessary in case user has been deleted */, true);
|
||||
if(!is_null($oEntryUser)) {
|
||||
if (!is_null($oEntryUser)) {
|
||||
$sEntryUserLogin = UserRights::GetUserFriendlyName($oEntryUser->Get('login'));
|
||||
}
|
||||
|
||||
@@ -658,10 +665,9 @@ HTML
|
||||
}
|
||||
// Otherwise try to retrieve one for the current contact
|
||||
else {
|
||||
if(is_null($oEntryUser)) {
|
||||
if (is_null($oEntryUser)) {
|
||||
$sEntryContactPictureAbsoluteUrl = null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sEntryContactPictureAbsoluteUrl = UserRights::GetUserPictureAbsUrl($oEntryUser->Get('login'), false);
|
||||
}
|
||||
}
|
||||
@@ -673,7 +679,8 @@ HTML
|
||||
// Open user block if previous user was different or if previous date was different
|
||||
if (($iEntryUserId !== $sLastUserId) || ($sEntryDate !== $sLastDate)) {
|
||||
if ($sEntryDate !== $sLastDate) {
|
||||
$oOutput->AddHtml(<<<HTML
|
||||
$oOutput->AddHtml(
|
||||
<<<HTML
|
||||
<div class="ipb-caselog-thread--date">{$sEntryDate}</div>
|
||||
HTML
|
||||
);
|
||||
@@ -682,15 +689,15 @@ HTML
|
||||
// Open block
|
||||
if ($iEntryUserId === $iCurrentUserId) {
|
||||
$sEntryBlockClass = 'ipb-caselog-thread--block-me';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!array_key_exists($iEntryUserId, $aPeerColorClassCache)) {
|
||||
$iPeerClassNumber = (count($aPeerColorClassCache) % 5) + 1;
|
||||
$aPeerColorClassCache[$iEntryUserId] = 'ipb-caselog-thread--block-color-'.$iPeerClassNumber;
|
||||
}
|
||||
$sEntryBlockClass = $aPeerColorClassCache[$iEntryUserId];
|
||||
}
|
||||
$oOutput->AddHtml(<<<HTML
|
||||
$oOutput->AddHtml(
|
||||
<<<HTML
|
||||
<div class="ipb-caselog-thread--block {$sEntryBlockClass}">
|
||||
HTML
|
||||
);
|
||||
@@ -702,7 +709,8 @@ HTML
|
||||
// - Entry tooltip
|
||||
$sEntryMedallionTooltip = utils::HtmlEntities($sEntryUserLogin);
|
||||
$sEntryMedallionTooltipPlacement = ($iEntryUserId === $iCurrentUserId) ? 'left' : 'right';
|
||||
$oOutput->AddHtml(<<<HTML
|
||||
$oOutput->AddHtml(
|
||||
<<<HTML
|
||||
<div class="ipb-caselog-thread--block-medallion" style="{$sEntryMedallionStyle}" data-tooltip-content="{$sEntryMedallionTooltip}" data-placement="{$sEntryMedallionTooltipPlacement}">
|
||||
$sEntryMedallionContent
|
||||
</div>
|
||||
@@ -711,7 +719,8 @@ HTML
|
||||
);
|
||||
|
||||
// Open entries
|
||||
$oOutput->AddHtml(<<<HTML
|
||||
$oOutput->AddHtml(
|
||||
<<<HTML
|
||||
<div class="ipb-caselog-thread--block-entries">
|
||||
HTML
|
||||
);
|
||||
@@ -723,7 +732,8 @@ HTML
|
||||
$sEntryHtml = InlineImage::FixUrls($sEntryHtml);
|
||||
|
||||
// Add entry
|
||||
$oOutput->AddHtml(<<<HTML
|
||||
$oOutput->AddHtml(
|
||||
<<<HTML
|
||||
<div class="ipb-caselog-thread--block-entry" id="{$sEntryId}">
|
||||
<div class="ipb-caselog-thread--block-entry-content">{$sEntryHtml}</div>
|
||||
<div class="ipb-caselog-thread--block-entry-date">{$sEntryDatetime}</div>
|
||||
@@ -737,7 +747,8 @@ HTML
|
||||
|| ($i < $iLastLoopIndex && $iEntryUserId !== $aEntries[$i + 1]['user_id'])
|
||||
|| ($i < $iLastLoopIndex && $sEntryDate !== AttributeDate::GetFormat()->Format($aEntries[$i + 1]['date']))) {
|
||||
// Close entries and block
|
||||
$oOutput->AddHtml(<<<HTML
|
||||
$oOutput->AddHtml(
|
||||
<<<HTML
|
||||
</div>
|
||||
</div>
|
||||
HTML
|
||||
@@ -750,14 +761,16 @@ HTML
|
||||
}
|
||||
|
||||
// Close thread content and thread
|
||||
$oOutput->AddHtml(<<<HTML
|
||||
$oOutput->AddHtml(
|
||||
<<<HTML
|
||||
</div>
|
||||
</div>
|
||||
HTML
|
||||
);
|
||||
|
||||
// Add JS handlers
|
||||
$oOutput->AddJs(<<<JS
|
||||
$oOutput->AddJs(
|
||||
<<<JS
|
||||
$('[data-field-id="{$this->oField->GetId()}"][data-form-path="{$this->oField->GetFormPath()}"]')
|
||||
.on('click', '.ipb-caselog-thread--block-entry-toggler, .ipb-caselog-thread--block-entry.closed', function(){
|
||||
$(this).closest('.ipb-caselog-thread--block-entry').toggleClass('closed');
|
||||
|
||||
Reference in New Issue
Block a user