');
+ utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php?operation=history&class='.$sClass.'&id='.$iKey);
+ $oPage->add(<<
+HTML
+ );
}
}
@@ -2399,15 +2427,31 @@ EOF
$oPage->add_dict_entry('UI:ValueMustBeChanged');
$oPage->add_dict_entry('UI:ValueInvalidFormat');
+ // Note: In 2.8, remove the data-attcode attribute (either because it's has been moved to .field_container in 2.7 or even better because the admin. console has been reworked)
return "
{$sHTMLValue}
";
}
+ /**
+ * @param \WebPage $oPage
+ * @param array $aExtraParams
+ *
+ * @throws \ArchivedObjectException
+ * @throws \CoreException
+ * @throws \CoreUnexpectedValue
+ * @throws \DictExceptionMissingString
+ * @throws \MissingQueryArgument
+ * @throws \MySQLException
+ * @throws \MySQLHasGoneAwayException
+ * @throws \OQLException
+ */
public function DisplayModifyForm(WebPage $oPage, $aExtraParams = array())
{
$sOwnershipToken = null;
$iKey = $this->GetKey();
$sClass = get_class($this);
- if ($iKey > 0)
+ $sMode = ($iKey > 0) ? static::ENUM_OBJECT_MODE_EDIT : static::ENUM_OBJECT_MODE_CREATE;
+
+ if ($sMode === static::ENUM_OBJECT_MODE_EDIT)
{
// The concurrent access lock makes sense only for already existing objects
$LockEnabled = MetaModel::GetConfig()->Get('concurrent_lock_enabled');
@@ -2442,13 +2486,22 @@ EOF
if (isset($aExtraParams['wizard_container']) && $aExtraParams['wizard_container'])
{
$sClassLabel = MetaModel::GetName($sClass);
+ $sHeaderTitle = Dict::Format('UI:ModificationTitle_Class_Object', $sClassLabel,
+ $this->GetName());
+
$oPage->set_title(Dict::Format('UI:ModificationPageTitle_Object_Class', $this->GetRawName(),
$sClassLabel)); // Set title will take care of the encoding
- $oPage->add("
\n");
+
+ // Get info on current state
+ $sCurrentState = $this->GetState();
$sTargetState = $aTransitions[$sStimulus]['target_state'];
+
+ $oPage->set_title($sActionLabel);
+ $oPage->add(<<
+
+HTML
+ );
if ($sButtonsPosition != 'top')
{
// bottom or both: Displays the ticket details AFTER the actions
@@ -3081,20 +3170,7 @@ EOF
'label' => ''.MetaModel::GetLabel($sClass, $sAttCode).'',
'value' => $sDisplayValue,
- 'attcode' => $sAttCode,
);
-
- // Checking how the field should be rendered
- // Note: For edit mode, this is done in self::GetBareProperties()
- // Note 2: Shouldn't this be a AttDef property instead of an array to maintain?
- if (in_array($oAttDef->GetEditClass(), array('Text', 'HTML', 'CaseLog', 'CustomFields', 'OQLExpression')))
- {
- $retVal['layout'] = 'large';
- }
- else
- {
- $retVal['layout'] = 'small';
- }
}
return $retVal;
@@ -4994,4 +5070,40 @@ EOF
EOF
);
}
+
+ /**
+ * Return an array of AttributeDefinition EditClass that should be rendered as large field in the UI
+ *
+ * @return array
+ * @since 2.7.0
+ */
+ protected static function GetAttEditClassesToRenderAsLargeField(){
+ return array(
+ 'CaseLog',
+ 'CustomFields',
+ 'HTML',
+ 'OQLExpression',
+ 'Text',
+ );
+ }
+
+ /**
+ * Return an array of AttributeDefinition classes that should be excluded from the markup metadata when priting raw value (typically large values)
+ * This markup is mostly aimed at CSS/JS hooks for extensions and Behat tests
+ *
+ * @return array
+ * @since 2.7.0
+ */
+ protected static function GetAttDefClassesToExcludeFromMarkupMetadataRawValue(){
+ return array(
+ 'AttributeBlob',
+ 'AttributeCustomFields',
+ 'AttributeDashboard',
+ 'AttributeLinkedSet',
+ 'AttributeStopWatch',
+ 'AttributeSubItem',
+ 'AttributeTable',
+ 'AttributeText'
+ );
+ }
}
diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php
index 628291d147..c4a39a4a84 100644
--- a/application/itopwebpage.class.inc.php
+++ b/application/itopwebpage.class.inc.php
@@ -1130,7 +1130,7 @@ EOF
{
$sBodyClass = 'printable-version';
}
- $sHtml .= "\n";
+ $sHtml .= "\n";
if ($this->IsPrintableVersion())
{
$sHtml .= "
";
diff --git a/application/menunode.class.inc.php b/application/menunode.class.inc.php
index 0c13142211..efeacf87fe 100644
--- a/application/menunode.class.inc.php
+++ b/application/menunode.class.inc.php
@@ -1,27 +1,20 @@
-
-
/**
- * Construction and display of the application's main menu
+ * Copyright (C) 2013-2019 Combodo SARL
*
- * @copyright Copyright (C) 2010-2016 Combodo SARL
- * @license http://opensource.org/licenses/AGPL-3.0
+ * This file is part of iTop.
+ *
+ * iTop is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * iTop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
*/
require_once(APPROOT.'/application/utils.inc.php');
@@ -217,7 +210,7 @@ class ApplicationMenu
{
if (!self::CanDisplayMenu($aMenu)) { continue; }
$oMenuNode = self::GetMenuNode($aMenu['index']);
- $oPage->AddToMenu('
";
}
}
diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php
index 9e6017e77b..c1460feaa8 100644
--- a/core/attributedef.class.inc.php
+++ b/core/attributedef.class.inc.php
@@ -1022,6 +1022,14 @@ abstract class AttributeDefinition
$oFormField->AddValidator(new \Combodo\iTop\Form\Validator\Validator($this->GetValidationPattern()));
}
+ // Metadata
+ $oFormField->AddMetadata('attribute-code', $this->GetCode());
+ $oFormField->AddMetadata('attribute-type', get_class($this));
+ if($this::IsScalar())
+ {
+ $oFormField->AddMetadata('value-raw', $oObject->Get($this->GetCode()));
+ }
+
return $oFormField;
}
diff --git a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig
index d6d768a1ab..ee92e23756 100644
--- a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig
+++ b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig
@@ -158,7 +158,7 @@
{% endblock %}
-
+
{% block pPageBodyWrapper %}
{% block pEnvBannerWrapper %}
{% if app['combodo.current_environment'] != 'production' %}
diff --git a/js/field_set.js b/js/field_set.js
index cbc436aa69..dcad9a573b 100644
--- a/js/field_set.js
+++ b/js/field_set.js
@@ -276,6 +276,14 @@ $(function()
{
oFieldContainer.html(oField.html);
}
+ // HTML metadata
+ if( (oField.html_metadata !== undefined) && (Object.keys(oField.html_metadata).length > 0) )
+ {
+ for(var i in oField.html_metadata)
+ {
+ oFieldContainer.attr('data-' + i, oField.html_metadata[i]);
+ }
+ }
// JS files
if( (oField.js_files !== undefined) && (oField.js_files.length > 0) )
{
diff --git a/sources/autoload.php b/sources/autoload.php
index 612f727c53..518eb985ca 100644
--- a/sources/autoload.php
+++ b/sources/autoload.php
@@ -1,21 +1,22 @@
+/**
+ * Copyright (C) 2013-2019 Combodo SARL
+ *
+ * This file is part of iTop.
+ *
+ * iTop is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * iTop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ */
/**
* This is a "manual autoloader" for now that is meant to evolve into a real autoloader.
@@ -56,6 +57,7 @@ require_once APPROOT . 'sources/renderer/formrenderer.class.inc.php';
require_once APPROOT . 'sources/renderer/fieldrenderer.class.inc.php';
require_once APPROOT . 'sources/renderer/renderingoutput.class.inc.php';
require_once APPROOT . 'sources/renderer/bootstrap/bsformrenderer.class.inc.php';
+require_once APPROOT . 'sources/renderer/bootstrap/fieldrenderer/bsfieldrenderer.class.inc.php';
require_once APPROOT . 'sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php';
require_once APPROOT . 'sources/renderer/bootstrap/fieldrenderer/bsselectobjectfieldrenderer.class.inc.php';
require_once APPROOT . 'sources/renderer/bootstrap/fieldrenderer/bssetfieldrenderer.class.inc.php';
diff --git a/sources/form/field/field.class.inc.php b/sources/form/field/field.class.inc.php
index 5eea0240cd..9bae98e1f8 100644
--- a/sources/form/field/field.class.inc.php
+++ b/sources/form/field/field.class.inc.php
@@ -1,21 +1,22 @@
+/**
+ * Copyright (C) 2013-2019 Combodo SARL
+ *
+ * This file is part of iTop.
+ *
+ * iTop is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * iTop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ */
namespace Combodo\iTop\Form\Field;
@@ -36,6 +37,7 @@ abstract class Field
const ENUM_DISPLAY_MODE_DENSE = 'dense'; // Label and value side by side, closely
const DEFAULT_LABEL = '';
+ const DEFAULT_METADATA = array();
const DEFAULT_HIDDEN = false;
const DEFAULT_READ_ONLY = false;
const DEFAULT_MANDATORY = false;
@@ -46,6 +48,7 @@ abstract class Field
protected $sGlobalId;
protected $sFormPath;
protected $sLabel;
+ protected $aMetadata;
protected $bHidden;
protected $bReadOnly;
protected $bMandatory;
@@ -68,6 +71,7 @@ abstract class Field
// No space in such an id, that could be used as a DOM node id
$this->sGlobalId = 'field_' . str_replace(' ', '_', $sId) . '_' . uniqid();
$this->sLabel = static::DEFAULT_LABEL;
+ $this->aMetadata = static::DEFAULT_METADATA;
$this->bHidden = static::DEFAULT_HIDDEN;
$this->bReadOnly = static::DEFAULT_READ_ONLY;
$this->bMandatory = static::DEFAULT_MANDATORY;
@@ -117,6 +121,17 @@ abstract class Field
return $this->sLabel;
}
+ /**
+ * Return an array of $sName => $sValue metadata.
+ *
+ * @return array
+ * @since 2.7.0
+ */
+ public function GetMetadata()
+ {
+ return $this->aMetadata;
+ }
+
/**
*
* @return boolean
@@ -233,6 +248,20 @@ abstract class Field
return $this;
}
+ /**
+ * Must be an array of $sName => $sValue metadata.
+ *
+ * @param array $aMetadata
+ *
+ * @return $this
+ * @since 2.7.0
+ */
+ public function SetMetadata($aMetadata)
+ {
+ $this->aMetadata = $aMetadata;
+ return $this;
+ }
+
/**
*
* @param boolean $bHidden
@@ -367,6 +396,21 @@ abstract class Field
return $this;
}
+ /**
+ * Add a metadata to the field. If the metadata $sName already exists, it will be overwritten.
+ *
+ * @param string $sName
+ * @param string $sValue
+ *
+ * @return $this;
+ * @since 2.7.0
+ */
+ public function AddMetadata($sName, $sValue)
+ {
+ $this->aMetadata[$sName] = $sValue;
+ return $this;
+ }
+
/**
*
* @param \Combodo\iTop\Form\Validator\Validator $oValidator
diff --git a/sources/renderer/bootstrap/fieldrenderer/bsfieldrenderer.class.inc.php b/sources/renderer/bootstrap/fieldrenderer/bsfieldrenderer.class.inc.php
new file mode 100644
index 0000000000..71c2fa574c
--- /dev/null
+++ b/sources/renderer/bootstrap/fieldrenderer/bsfieldrenderer.class.inc.php
@@ -0,0 +1,46 @@
+
+ * @since 2.7.0
+ */
+class BsFieldRenderer extends FieldRenderer
+{
+
+ /**
+ * @inheritDoc
+ */
+ public function Render()
+ {
+ $oOutput = parent::Render();
+ $oOutput->AddCssClass('form_field_'.$this->oField->GetDisplayMode());
+
+ return $oOutput;
+ }
+}
diff --git a/sources/renderer/bootstrap/fieldrenderer/bsfileuploadfieldrenderer.class.inc.php b/sources/renderer/bootstrap/fieldrenderer/bsfileuploadfieldrenderer.class.inc.php
index 423f5b94ac..5bc617d5c5 100644
--- a/sources/renderer/bootstrap/fieldrenderer/bsfileuploadfieldrenderer.class.inc.php
+++ b/sources/renderer/bootstrap/fieldrenderer/bsfileuploadfieldrenderer.class.inc.php
@@ -1,52 +1,46 @@
+/**
+ * Copyright (C) 2013-2019 Combodo SARL
+ *
+ * This file is part of iTop.
+ *
+ * iTop is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * iTop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ */
namespace Combodo\iTop\Renderer\Bootstrap\FieldRenderer;
-use utils;
+use AttachmentPlugIn;
+use Combodo\iTop\Renderer\RenderingOutput;
+use DBObjectSearch;
+use DBObjectSet;
use Dict;
use InlineImage;
-use DBObjectSet;
-use DBObjectSearch;
-use AttachmentPlugIn;
-use Combodo\iTop\Renderer\FieldRenderer;
-use Combodo\iTop\Renderer\RenderingOutput;
+use utils;
/**
* Description of BsFileUploadFieldRenderer
*
* @author Guillaume Lajarige
*/
-class BsFileUploadFieldRenderer extends FieldRenderer
+class BsFileUploadFieldRenderer extends BsFieldRenderer
{
/**
- * Returns a RenderingOutput for the FieldRenderer's Field
- *
- * @return \Combodo\iTop\Renderer\RenderingOutput
- *
- * @throws \CoreException
- * @throws \OQLException
+ * @inheritDoc
*/
public function Render()
{
- $oOutput = new RenderingOutput();
- $oOutput->AddCssClass('form_field_' . $this->oField->GetDisplayMode());
+ $oOutput = parent::Render();
$sObjectClass = get_class($this->oField->GetObject());
$sIsDeleteAllowed = ($this->oField->GetAllowDelete() && !$this->oField->GetReadOnly()) ? 'true' : 'false';
diff --git a/sources/renderer/bootstrap/fieldrenderer/bslinkedsetfieldrenderer.class.inc.php b/sources/renderer/bootstrap/fieldrenderer/bslinkedsetfieldrenderer.class.inc.php
index e701cd1938..54b469c9f7 100644
--- a/sources/renderer/bootstrap/fieldrenderer/bslinkedsetfieldrenderer.class.inc.php
+++ b/sources/renderer/bootstrap/fieldrenderer/bslinkedsetfieldrenderer.class.inc.php
@@ -22,8 +22,6 @@ namespace Combodo\iTop\Renderer\Bootstrap\FieldRenderer;
use ApplicationContext;
use AttributeFriendlyName;
-use Combodo\iTop\Renderer\FieldRenderer;
-use Combodo\iTop\Renderer\RenderingOutput;
use Dict;
use Exception;
use IssueLog;
@@ -37,19 +35,14 @@ use MetaModel;
* @property \Combodo\iTop\Form\Field\LinkedSetField $oField
*
*/
-class BsLinkedSetFieldRenderer extends FieldRenderer
+class BsLinkedSetFieldRenderer extends BsFieldRenderer
{
/**
- * Returns a RenderingOutput for the FieldRenderer's Field
- *
- * @return \Combodo\iTop\Renderer\RenderingOutput
- *
- * @throws \CoreException
+ * @inheritDoc
*/
public function Render()
{
- $oOutput = new RenderingOutput();
- $oOutput->AddCssClass('form_field_' . $this->oField->GetDisplayMode());
+ $oOutput = parent::Render();
$sFieldMandatoryClass = ($this->oField->GetMandatory()) ? 'form_mandatory' : '';
// Vars to build the table
diff --git a/sources/renderer/bootstrap/fieldrenderer/bsselectobjectfieldrenderer.class.inc.php b/sources/renderer/bootstrap/fieldrenderer/bsselectobjectfieldrenderer.class.inc.php
index 2cb692500a..2263e1340e 100644
--- a/sources/renderer/bootstrap/fieldrenderer/bsselectobjectfieldrenderer.class.inc.php
+++ b/sources/renderer/bootstrap/fieldrenderer/bsselectobjectfieldrenderer.class.inc.php
@@ -21,7 +21,6 @@
namespace Combodo\iTop\Renderer\Bootstrap\FieldRenderer;
use ApplicationContext;
-use Combodo\iTop\Renderer\FieldRenderer;
use Combodo\iTop\Renderer\RenderingOutput;
use ContextTag;
use CoreException;
@@ -38,22 +37,15 @@ use MetaModel;
*
* @property \Combodo\iTop\Form\Field\SelectObjectField $oField
*/
-class BsSelectObjectFieldRenderer extends FieldRenderer
+class BsSelectObjectFieldRenderer extends BsFieldRenderer
{
/**
- * Returns a RenderingOutput for the FieldRenderer's Field
- *
- * @return \Combodo\iTop\Renderer\RenderingOutput
- *
- * @throws \Exception
- * @throws \CoreException
- * @throws \ArchivedObjectException
+ * @inheritDoc
*/
public function Render()
{
- $oOutput = new RenderingOutput();
- $oOutput->AddCssClass('form_field_' . $this->oField->GetDisplayMode());
+ $oOutput = parent::Render();
$sFieldValueClass = $this->oField->GetSearch()->GetClass();
$sFieldMandatoryClass = ($this->oField->GetMandatory()) ? 'form_mandatory' : '';
diff --git a/sources/renderer/bootstrap/fieldrenderer/bssetfieldrenderer.class.inc.php b/sources/renderer/bootstrap/fieldrenderer/bssetfieldrenderer.class.inc.php
index 2a68a5a101..59d6269dbe 100644
--- a/sources/renderer/bootstrap/fieldrenderer/bssetfieldrenderer.class.inc.php
+++ b/sources/renderer/bootstrap/fieldrenderer/bssetfieldrenderer.class.inc.php
@@ -1,42 +1,40 @@
+/**
+ * Copyright (C) 2013-2019 Combodo SARL
+ *
+ * This file is part of iTop.
+ *
+ * iTop is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * iTop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ */
namespace Combodo\iTop\Renderer\Bootstrap\FieldRenderer;
use MetaModel;
-use Combodo\iTop\Renderer\FieldRenderer;
-use Combodo\iTop\Renderer\RenderingOutput;
/**
* Description of BsSetFieldRenderer
*
* @author Guillaume Lajarige
*/
-class BsSetFieldRenderer extends FieldRenderer
+class BsSetFieldRenderer extends BsFieldRenderer
{
/**
* @inheritdoc
*/
public function Render()
{
- $oOutput = new RenderingOutput();
- $oOutput->AddCssClass('form_field_' . $this->oField->GetDisplayMode());
+ $oOutput = parent::Render();
$sFieldMandatoryClass = ($this->oField->GetMandatory()) ? 'form_mandatory' : '';
// Vars to build the table
diff --git a/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php b/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php
index d9b4657493..cda101550b 100644
--- a/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php
+++ b/sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php
@@ -1,21 +1,22 @@
+/**
+ * Copyright (C) 2013-2019 Combodo SARL
+ *
+ * This file is part of iTop.
+ *
+ * iTop is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * iTop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ */
namespace Combodo\iTop\Renderer\Bootstrap\FieldRenderer;
@@ -25,7 +26,6 @@ use UserRights;
use AttributeDateTime;
use AttributeText;
use InlineImage;
-use Combodo\iTop\Renderer\FieldRenderer;
use Combodo\iTop\Renderer\RenderingOutput;
use Combodo\iTop\Form\Field\TextAreaField;
use Combodo\iTop\Form\Field\MultipleChoicesField;
@@ -35,20 +35,15 @@ use Combodo\iTop\Form\Field\MultipleChoicesField;
*
* @author Guillaume Lajarige
*/
-class BsSimpleFieldRenderer extends FieldRenderer
+class BsSimpleFieldRenderer extends BsFieldRenderer
{
/**
- * Returns a RenderingOutput for the FieldRenderer's Field
- *
- * @return \Combodo\iTop\Renderer\RenderingOutput
- *
- * @throws \Exception
+ * @inheritDoc
*/
public function Render()
{
- $oOutput = new RenderingOutput();
- $oOutput->AddCssClass('form_field_' . $this->oField->GetDisplayMode());
+ $oOutput = parent::Render();
$sFieldClass = get_class($this->oField);
$sFieldMandatoryClass = ($this->oField->GetMandatory()) ? 'form_mandatory' : '';
diff --git a/sources/renderer/bootstrap/fieldrenderer/bssubformfieldrenderer.class.inc.php b/sources/renderer/bootstrap/fieldrenderer/bssubformfieldrenderer.class.inc.php
index 7dcdf5b318..556d3970df 100644
--- a/sources/renderer/bootstrap/fieldrenderer/bssubformfieldrenderer.class.inc.php
+++ b/sources/renderer/bootstrap/fieldrenderer/bssubformfieldrenderer.class.inc.php
@@ -1,33 +1,36 @@
+/**
+ * Copyright (C) 2013-2019 Combodo SARL
+ *
+ * This file is part of iTop.
+ *
+ * iTop is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * iTop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ */
namespace Combodo\iTop\Renderer\Bootstrap\FieldRenderer;
use Combodo\iTop\Renderer\Bootstrap\BsFormRenderer;
-use Combodo\iTop\Renderer\FieldRenderer;
use Combodo\iTop\Renderer\RenderingOutput;
-class BsSubFormFieldRenderer extends FieldRenderer
+/**
+ * Class BsSubFormFieldRenderer
+ *
+ * @author Guillaume Lajarige
+ */
+class BsSubFormFieldRenderer extends BsFieldRenderer
{
/**
- * @return \Combodo\iTop\Renderer\RenderingOutput
- *
- * @throws \Exception
+ * @inheritDoc
*/
public function Render()
{
diff --git a/sources/renderer/console/fieldrenderer/consoleselectobjectfieldrenderer.class.inc.php b/sources/renderer/console/fieldrenderer/consoleselectobjectfieldrenderer.class.inc.php
index e1ca29ca3d..3012832e69 100644
--- a/sources/renderer/console/fieldrenderer/consoleselectobjectfieldrenderer.class.inc.php
+++ b/sources/renderer/console/fieldrenderer/consoleselectobjectfieldrenderer.class.inc.php
@@ -1,20 +1,21 @@
+/**
+ * Copyright (C) 2013-2019 Combodo SARL
+ *
+ * This file is part of iTop.
+ *
+ * iTop is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * iTop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ */
namespace Combodo\iTop\Renderer\Console\FieldRenderer;
@@ -22,25 +23,21 @@ use Combodo\iTop\Form\Validator\MandatoryValidator;
use \Dict;
use \DBObjectSet;
use Combodo\iTop\Renderer\FieldRenderer;
-use Combodo\iTop\Renderer\RenderingOutput;
use Combodo\iTop\Form\Field\SelectObjectField;
-
+/**
+ * Class ConsoleSelectObjectFieldRenderer
+ *
+ * @author Romain Quetiez
+ */
class ConsoleSelectObjectFieldRenderer extends FieldRenderer
{
/**
- * @return RenderingOutput
- *
- * @throws \Exception
- * @throws \CoreException
- * @throws \CoreUnexpectedValue
- * @throws \MissingQueryArgument
- * @throws \MySQLException
- * @throws \MySQLHasGoneAwayException
+ * @inheritDoc
*/
public function Render()
{
- $oOutput = new RenderingOutput();
+ $oOutput = parent::Render();
$oOutput->AddHtml('
');
$oOutput->AddHtml('
');
diff --git a/sources/renderer/console/fieldrenderer/consolesimplefieldrenderer.class.inc.php b/sources/renderer/console/fieldrenderer/consolesimplefieldrenderer.class.inc.php
index 52a4d9ce7e..3478fd4399 100644
--- a/sources/renderer/console/fieldrenderer/consolesimplefieldrenderer.class.inc.php
+++ b/sources/renderer/console/fieldrenderer/consolesimplefieldrenderer.class.inc.php
@@ -1,20 +1,21 @@
+/**
+ * Copyright (C) 2013-2019 Combodo SARL
+ *
+ * This file is part of iTop.
+ *
+ * iTop is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * iTop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ */
namespace Combodo\iTop\Renderer\Console\FieldRenderer;
@@ -28,13 +29,17 @@ use UserRights;
use utils;
use Combodo\iTop\Form\Field\TextAreaField;
use Combodo\iTop\Renderer\FieldRenderer;
-use Combodo\iTop\Renderer\RenderingOutput;
+/**
+ * Class ConsoleSimpleFieldRenderer
+ *
+ * @author Romain Quetiez
+ */
class ConsoleSimpleFieldRenderer extends FieldRenderer
{
public function Render()
{
- $oOutput = new RenderingOutput();
+ $oOutput = parent::Render();
$sFieldClass = get_class($this->oField);
if ($sFieldClass == 'Combodo\\iTop\\Form\\Field\\HiddenField')
diff --git a/sources/renderer/console/fieldrenderer/consolesubformfieldrenderer.class.inc.php b/sources/renderer/console/fieldrenderer/consolesubformfieldrenderer.class.inc.php
index 53753d3715..76abe4b594 100644
--- a/sources/renderer/console/fieldrenderer/consolesubformfieldrenderer.class.inc.php
+++ b/sources/renderer/console/fieldrenderer/consolesubformfieldrenderer.class.inc.php
@@ -1,37 +1,41 @@
+/**
+ * Copyright (C) 2013-2019 Combodo SARL
+ *
+ * This file is part of iTop.
+ *
+ * iTop is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * iTop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ */
namespace Combodo\iTop\Renderer\Console\FieldRenderer;
use Combodo\iTop\Renderer\Console\ConsoleFormRenderer;
use Combodo\iTop\Renderer\FieldRenderer;
-use Combodo\iTop\Renderer\RenderingOutput;
+/**
+ * Class ConsoleSubFormFieldRenderer
+ *
+ * @author Romain Quetiez
+ */
class ConsoleSubFormFieldRenderer extends FieldRenderer
{
- /**
- * @return RenderingOutput
- *
- * @throws \Exception
- */
+ /**
+ * @inheritDoc
+ * @throws \Exception
+ */
public function Render()
{
- $oOutput = new RenderingOutput();
+ $oOutput = parent::Render();
$oOutput->AddHtml('
');
$oOutput->AddHtml('
');
diff --git a/sources/renderer/fieldrenderer.class.inc.php b/sources/renderer/fieldrenderer.class.inc.php
index 6655004fb5..159aae4e00 100644
--- a/sources/renderer/fieldrenderer.class.inc.php
+++ b/sources/renderer/fieldrenderer.class.inc.php
@@ -1,26 +1,28 @@
+/**
+ * Copyright (C) 2013-2019 Combodo SARL
+ *
+ * This file is part of iTop.
+ *
+ * iTop is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * iTop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ */
namespace Combodo\iTop\Renderer;
use Combodo\iTop\Form\Field\Field;
use Dict;
+use utils;
/**
* Description of FieldRenderer
@@ -96,5 +98,16 @@ abstract class FieldRenderer
*
* @return \Combodo\iTop\Renderer\RenderingOutput
*/
- abstract public function Render();
+ public function Render()
+ {
+ $oOutput = new RenderingOutput();
+
+ // Field metadata
+ foreach ($this->oField->GetMetadata() as $sMetadataName => $sMetadataValue)
+ {
+ $oOutput->AddMetadata($sMetadataName, utils::HtmlEntities($sMetadataValue));
+ }
+
+ return $oOutput;
+ }
}
diff --git a/sources/renderer/formrenderer.class.inc.php b/sources/renderer/formrenderer.class.inc.php
index e63345bf87..d4ecde37c9 100644
--- a/sources/renderer/formrenderer.class.inc.php
+++ b/sources/renderer/formrenderer.class.inc.php
@@ -1,21 +1,22 @@
+/**
+ * Copyright (C) 2013-2019 Combodo SARL
+ *
+ * This file is part of iTop.
+ *
+ * iTop is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * iTop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ */
namespace Combodo\iTop\Renderer;
@@ -233,6 +234,7 @@ abstract class FormRenderer
$output = array(
'id' => $oField->GetId(),
'html' => '',
+ 'html_metadata' => array(),
'js_inline' => '',
'css_inline' => '',
'js_files' => array(),
@@ -260,6 +262,18 @@ abstract class FormRenderer
$output['html'] .= $oRenderingOutput->GetHtml();
}
}
+ // HTML metadata
+ foreach ($oRenderingOutput->GetMetadata() as $sMetadataName => $sMetadataValue)
+ {
+ // Warning: Do not work with ENUM_RENDER_MODE_JOINED mode
+ if ($sMode === static::ENUM_RENDER_MODE_EXPLODED)
+ {
+ if (!in_array($sMetadataName, $output['html_metadata']))
+ {
+ $output['html_metadata'][$sMetadataName] = $sMetadataValue;
+ }
+ }
+ }
// JS files
foreach ($oRenderingOutput->GetJsFiles() as $sJsFile)
diff --git a/sources/renderer/renderingoutput.class.inc.php b/sources/renderer/renderingoutput.class.inc.php
index d777686d50..44ffa13d41 100644
--- a/sources/renderer/renderingoutput.class.inc.php
+++ b/sources/renderer/renderingoutput.class.inc.php
@@ -1,21 +1,22 @@
+/**
+ * Copyright (C) 2013-2019 Combodo SARL
+ *
+ * This file is part of iTop.
+ *
+ * iTop is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * iTop is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ */
namespace Combodo\iTop\Renderer;
@@ -27,6 +28,7 @@ namespace Combodo\iTop\Renderer;
class RenderingOutput
{
protected $sHtml;
+ protected $aMetadata;
protected $sJsInline;
protected $aJsFiles;
protected $sCssInline;
@@ -36,6 +38,7 @@ class RenderingOutput
public function __construct()
{
$this->sHtml = '';
+ $this->aMetadata = array();
$this->sJsInline = '';
$this->aJsFiles = array();
$this->sCssInline = '';
@@ -52,6 +55,15 @@ class RenderingOutput
return $this->sHtml;
}
+ /**
+ * @return array
+ * @since 2.7.0
+ */
+ public function GetMetadata()
+ {
+ return $this->aMetadata;
+ }
+
/**
*
* @return string
@@ -110,6 +122,38 @@ class RenderingOutput
return $this;
}
+ /**
+ * Add a metadata identified by $sName.
+ *
+ * @param string $sName
+ * @param string $sValue
+ *
+ * @return $this
+ * @since 2.7.0
+ */
+ public function AddMetadata($sName, $sValue)
+ {
+ $this->aMetadata[$sName] = $sValue;
+ return $this;
+ }
+
+ /**
+ * Remove the metadata identified by $sName
+ *
+ * @param string $sName
+ *
+ * @return $this
+ * @since 2.7.0
+ */
+ public function RemoveMetadata($sName)
+ {
+ if (in_array($sName, $this->aMetadata))
+ {
+ unset($this->aJsFiles[$sName]);
+ }
+ return $this;
+ }
+
/**
*
* @param string $sJs