Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix(quickform): add previously deleted elements #6311

Merged
merged 1 commit into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
69 changes: 69 additions & 0 deletions www/lib/HTML/QuickForm/customcheckbox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
* HTML class for a checkbox type field
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Alexey Borzov <avb@php.net>
* @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 <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Alexey Borzov <avb@php.net>
* @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'
);
}
146 changes: 146 additions & 0 deletions www/lib/HTML/QuickForm/tags.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?php
/*
* Copyright 2005-2015 Centreon
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation ; either version 2 of the License.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses>.
*
* 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 = '<script>
jQuery(function () {
var $currentSelect2Object'. $this->getName() . ' = jQuery("#' . $this->getName() . '").centreonSelect2({
allowClear: ' . $allowClear .',
pageLimit: ' . $this->_pagination . ',
select2: {
tags: true,
' . $ajaxOption . '
' . $defaultData . '
placeholder: "' . $this->getLabel() . '",
disabled: ' . $disabled . '
}
});

' . $additionnalJs . '
});
</script>';

return $javascriptString;
}
}

if (class_exists('HTML_QuickForm')) {
(new HTML_QuickForm)->registerElementType(
'tags',
'HTML/QuickForm/tags.php',
'HTML_QuickForm_tags'
);
}