1
0
قرینه از https://github.com/matomo-org/matomo.git synced 2025-08-22 15:07:44 +00:00
Files
matomo/libs/HTML/QuickForm2/Element/InputCheckable.php
diosmosis d0aaab95f1 Switch from bower to npm and update JS libraries (#14082)
* Starting to replace bower with npm: use updated jquery-ui from npm.

* Use jquery from npm./

* Use angular from npm.

* Add more angular libraries.

* Use chroma-js from npm.

* Remove html5shiv, does not appear to be used.

* Use iframe resizer library from npm.

* Add jquery-mousewheel

* Add jquery.dotdotdot from npm.

* Get jquery.scrollto from npm.

* Get jscrollpane from npm.

* Get materialize-css from npm.

* Get mousetrap from npm.

* Remove ngDialog, as it is no longer used.

* Install qrcode.js from npm.

* Get sprintf-js from npm.

* Get visibillityjs from npm.

* Remove bower.json.

* Getting parts of matomo to work w/ new versions of libraries installed by npm.

* Ignore node_modules subfolders in node_modules since we only use npm for frontend dependencies + fix a test.

* Fix button padding.

* Fix series picker checkboxes.

* Fix karma conf.

* Fix CSS in right place.

* Fixing more css/less issues.

* More test fixes.

* Limit selection style fix.

* Fix more tests + materializecss issues.

* Fix a couple more tests.

* Fix annotation styling.

* remove error

* add ng-dialog files

* try to fix some tests

* Fix several UI tests.

* fixing more build issues

* Fix several more tests and issues.

* fixing more tests

* split ui tests into 3 groups

* fix several more issues and tests

* Fix some console warnings on chrome.

* Updating more test files.

* fix some tests

* yet more fixes

* couple more fixes

* another form fix

* Fix some tests.

* update screenshot

* update more expected files

* Fix two more form issues.

* test commit (travis is not fetching submodules for some reason...)

* remove scripts removed in merge

* three travis builds

* split UIIntegrationTest into multiple suites

* lets try this again

* updae several expected screenshots

* fix some more tests

* fix plugin details material select and tabs initiaialization

* update screenshots + css fix

* re-initialize materialize tabs since we load jquery-ui afterwards for datepicker which unsets materialize tabs

* update more screenshots and fix couple more issues

* update more screenshots + tweak to test

* more fixes and screenshot updates

* fix some issues and update more screenshots

* update submodules

* more fixes + more updated screenshots

* more css fixes and test fixes

* couple fixes & updated screenshots

* update screenshots

* fix random failure

* Map old bower_component files to new ones in AssetManager.

* Remove node_modules from PR and ignore node_modules in .gitignore and remove libs/jquery (adding new required libs).

* Update .travis.yml.

* update screenshots

* fixing some more issues

* fix copy pasta

* update screenshots

* fix more modal issues

* Update css & screenshots.

* correct close modal calls

* fixing more issues

* data-target instead of data-activates

* fix more tests

* trigger build that works?

* fix more tests

* update submodule

* debugging travis

* more debugging

* try to fix test

* fix modal no button click in test

* update more screenshots

* couple more test fixes

* some more fixes and updated screenshots

* update screenshots

* apply some review feedback

* Fix modal centering and initial top position.

* apply some more pr feedback

* another pr fix

* update submodule

* remove style

* fix color of checkbox mark

* Fix centering the popover

Note: centering the popover relative to body doesn't work poperly anymore, maybe because of the fixed position of the widget overlay. Using the ui-widget-overlay to position the dialog centered seems to work

* ignore line endings check for node modules

* updates expected UI files

* submodule updates

* use minified file of jquery.browser.js

* updates expected test files

* ensure to hide parent tooltips when row action tooltips are shown

* tweak less for datatable navigation

* style is only useful for dashboard

* update some screenshots

* update submodules

Co-authored-by: sgiehl <stefan@matomo.org>
2020-06-07 16:46:56 -07:00

171 خطوط
5.4 KiB
PHP
Vendored

<?php
/**
* Base class for checkboxes and radios
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: InputCheckable.php 300722 2010-06-24 10:15:52Z mansion $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for <input> elements
*/
// require_once 'HTML/QuickForm2/Element/Input.php';
/**
* Base class for <input> elements having 'checked' attribute (checkboxes and radios)
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_InputCheckable extends HTML_QuickForm2_Element_Input
{
protected $persistent = true;
/**
* HTML to represent the element in "frozen" state
*
* Array index "checked" contains HTML for element's "checked" state,
* "unchecked" for not checked
* @var array
*/
protected $frozenHtml = array(
'checked' => 'On',
'unchecked' => 'Off'
);
/**
* Contains options and data used for the element creation
* - content: Label "glued" to a checkbox or radio
* @var array
*/
protected $data = array('content' => '');
public function __construct($name = null, $attributes = null, $data = null)
{
parent::__construct($name, $attributes, $data);
// "checked" attribute should be updated on changes to "value" attribute
// see bug #15708
$this->watchedAttributes[] = 'value';
}
protected function onAttributeChange($name, $value = null)
{
if ('value' != $name) {
return parent::onAttributeChange($name, $value);
}
if (null === $value) {
unset($this->attributes['value'], $this->attributes['checked']);
} else {
$this->attributes['value'] = $value;
$this->updateValue();
}
}
/**
* Sets the label to be rendered glued to the element
*
* This label is returned by {@link __toString()} method with the element's
* HTML. It is automatically wrapped into the <label> tag.
*
* @param string
* @return HTML_QuickForm2_Element_InputCheckable
*/
public function setContent($content)
{
$this->data['content'] = $content;
return $this;
}
/**
* Returns the label that will be "glued" to element's HTML
*
* @return string
*/
public function getContent()
{
return $this->data['content'];
}
public function setValue($value)
{
if ((string)$value == $this->getAttribute('value')) {
return $this->setAttribute('checked');
} else {
return $this->removeAttribute('checked');
}
}
public function getValue()
{
if (!empty($this->attributes['checked']) && empty($this->attributes['disabled'])) {
return $this->applyFilters($this->getAttribute('value'));
} else {
return null;
}
}
public function __toString()
{
if (0 == strlen($this->data['content'])) {
$label = '';
} elseif ($this->frozen) {
$label = $this->data['content'];
} else {
return '<label>' . parent::__toString() . '<span>' . $this->data['content'] . '</span></label>';
}
return parent::__toString() . $label;
}
public function getFrozenHtml()
{
if ($this->getAttribute('checked')) {
return $this->frozenHtml['checked'] . $this->getPersistentContent();
} else {
return $this->frozenHtml['unchecked'];
}
}
}
?>