diff --git a/composer.json b/composer.json index b1c12ae07fa..80cd7dafb04 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,9 @@ "www/lib/HTML/QuickForm/HTML_QuickFormCustom.php", "www/lib/HTML/QuickForm/HTML_QuickForm_radio_Custom.php", "www/lib/HTML/QuickForm/select2.php", - "www/lib/HTML/QuickForm/advmultiselect.php" + "www/lib/HTML/QuickForm/advmultiselect.php", + "www/lib/HTML/QuickForm/tags.php", + "www/lib/HTML/QuickForm/customcheckbox.php" ] } } diff --git a/www/lib/HTML/QuickForm/customcheckbox.php b/www/lib/HTML/QuickForm/customcheckbox.php new file mode 100644 index 00000000000..fb2794c5409 --- /dev/null +++ b/www/lib/HTML/QuickForm/customcheckbox.php @@ -0,0 +1,69 @@ + + * @author Bertrand Mansion + * @author Alexey Borzov + * @copyright 2001-2011 The PHP Group + * @license http://www.php.net/license/3_01.txt PHP License 3.01 + * @version CVS: $Id$ + * @link http://pear.php.net/package/HTML_QuickForm + */ + +/** + * HTML class for a checkbox type field + * + * @category HTML + * @package HTML_QuickForm + * @author Adam Daniel + * @author Bertrand Mansion + * @author Alexey Borzov + * @version Release: 3.2.14 + * @since 1.0 + */ +class HTML_QuickForm_customcheckbox extends HTML_QuickForm_checkbox +{ + + public $checkboxTemplate; + + + public function toHtml() + { + $oldHtml = parent::toHtml(); + $matches = array( + '{element}', + '{id}' + ); + $replacements = array( + $oldHtml, + $this->getAttribute('id') + ); + return str_replace($matches, $replacements, $this->checkboxTemplate); + } + + public function setCheckboxTemplate($checkboxTemplate) + { + $this->checkboxTemplate = $checkboxTemplate; + } +} + +if (class_exists('HTML_QuickForm')) { + (new HTML_QuickForm)->registerElementType( + 'customcheckbox', + 'HTML/QuickForm/customcheckbox.php', + 'HTML_QuickForm_customcheckbox' + ); +} diff --git a/www/lib/HTML/QuickForm/tags.php b/www/lib/HTML/QuickForm/tags.php new file mode 100644 index 00000000000..9bf94e0d1ad --- /dev/null +++ b/www/lib/HTML/QuickForm/tags.php @@ -0,0 +1,146 @@ +. + * + * Linking this program statically or dynamically with other modules is making a + * combined work based on this program. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this program give Centreon + * permission to link this program with independent modules to produce an executable, + * regardless of the license terms of these independent modules, and to copy and + * distribute the resulting executable under terms of Centreon choice, provided that + * Centreon also meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module which is not + * derived from this program. If you modify this program, you may extend this + * exception to your version of the program, but you are not obliged to do so. If you + * do not wish to do so, delete this exception statement from your version. + * + * For more information : contact@centreon.com + * + * + */ + +/** + * Description of tags + * + * @author Toufik MECHOUET + */ +class HTML_QuickForm_tags extends HTML_QuickForm_select2 +{ + + /** + * + * @param string $elementName + * @param string $elementLabel + * @param array $options + * @param array $attributes + * @param string $sort + */ + public function __construct( + $elementName = null, + $elementLabel = null, + $options = null, + $attributes = null, + $sort = null + ) { + global $centreon; + + $this->_ajaxSource = false; + $this->_defaultSelectedOptions = ''; + $this->_multipleHtml = ''; + $this->_allowClear = true; + $this->_elementHtmlName = $this->getName(); + $this->_defaultDataset = array(); + $this->_defaultDatasetOptions = array(); + $this->_jsCallback = ''; + $this->_allowClear = false; + $this->_pagination = $centreon->optGen['selectPaginationSize']; + $this->parseCustomAttributes($attributes); + + parent::__construct($elementName, $elementLabel, $options, $attributes); + } + + /** + * + * @return string + */ + public function getJsInit() + { + $allowClear = 'true'; + if (false === $this->_allowClear || $this->_flagFrozen) { + $allowClear = 'false'; + } + + $disabled = 'false'; + if ($this->_flagFrozen) { + $disabled = 'true'; + } + + $ajaxOption = ''; + $defaultData = ''; + if ($this->_ajaxSource) { + $ajaxOption = 'ajax: { + url: "' . $this->_availableDatasetRoute . '" + },'; + + if ($this->_defaultDatasetRoute && (count($this->_defaultDataset) == 0)) { + $additionnalJs = $this->setDefaultAjaxDatas(); + } else { + $this->setDefaultFixedDatas(); + } + } else { + $defaultData = $this->setFixedDatas() . ','; + } + + $additionnalJs = ' jQuery(".select2-selection").each(function(){' + . ' if(typeof this.isResiable == "undefined" || this.isResiable){' + . ' jQuery(this).resizable({ maxWidth: 500, ' + . ' minWidth : jQuery(this).width() != 0 ? jQuery(this).width() : 200, ' + . ' minHeight : jQuery(this).height() != 0 ? jQuery(this).height() : 45 });' + . ' this.isResiable = true; ' + . ' }' + . ' }); '; + + $javascriptString = ''; + + return $javascriptString; + } +} + +if (class_exists('HTML_QuickForm')) { + (new HTML_QuickForm)->registerElementType( + 'tags', + 'HTML/QuickForm/tags.php', + 'HTML_QuickForm_tags' + ); +}