Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobocoder <anthon.pang@gmail.com>2010-07-06 22:28:19 +0400
committerrobocoder <anthon.pang@gmail.com>2010-07-06 22:28:19 +0400
commit6c8f3b8d6c9a52e900567a92ebb6277188ed2174 (patch)
treed775d5bfe92944a799552a37d21b3539bfc8b00e /core/QuickForm2.php
parent6ed0125bd7fc55d452cbb3ee6e467786fb18c379 (diff)
fixes #1442 - all GPL license incompatibilities resolved
Live: Thanks to Remy Sharp, jquery.spy is now explicitly MIT licensed. Installation: converted to use HTML_QuickForm2 Login: converted to use HTML_QuickForm2 git-svn-id: http://dev.piwik.org/svn/trunk@2438 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'core/QuickForm2.php')
-rw-r--r--core/QuickForm2.php111
1 files changed, 111 insertions, 0 deletions
diff --git a/core/QuickForm2.php b/core/QuickForm2.php
new file mode 100644
index 0000000000..d39aa8a97b
--- /dev/null
+++ b/core/QuickForm2.php
@@ -0,0 +1,111 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
+ * @version $Id:$
+ *
+ * @category Piwik
+ * @package Piwik
+ */
+
+/**
+ * Parent class for forms to be included in Smarty
+ *
+ * For an example, @see Piwik_Login_FormLogin
+ *
+ * @package Piwik
+ * @see HTML_QuickForm2, libs/HTML/QuickForm2.php
+ * @link http://pear.php.net/package/HTML_QuickForm2/
+ */
+abstract class Piwik_QuickForm2 extends HTML_QuickForm2
+{
+ protected $a_formElements = array();
+
+ function __construct( $id, $method = 'post', $attributes = null, $trackSubmit = false)
+ {
+ if(!isset($attributes['action']))
+ {
+ $attributes['action'] = Piwik_Url::getCurrentQueryString();
+ }
+ if(!isset($attributes['name']))
+ {
+ $attributes['name'] = $id;
+ }
+ parent::__construct($id, $method, $attributes, $trackSubmit);
+
+ $this->init();
+ }
+
+ /**
+ * Class specific initialization
+ */
+ abstract function init();
+
+ /**
+ * The elements in this form
+ *
+ * @return array Element names
+ */
+ public function getElementList()
+ {
+ return $this->a_formElements;
+ }
+
+ /**
+ * Wrapper around HTML_QuickForm2_Container's addElement()
+ *
+ * @param string|HTML_QuickForm2_Node Either type name (treated
+ * case-insensitively) or an element instance
+ * @param mixed Element name
+ * @param mixed Element attributes
+ * @param array Element-specific data
+ * @return HTML_QuickForm2_Node Added element
+ * @throws HTML_QuickForm2_InvalidArgumentException
+ * @throws HTML_QuickForm2_NotFoundException
+ */
+ public function addElement($elementOrType, $name = null, $attributes = null,
+ array $data = array())
+ {
+ if($name != 'submit')
+ {
+ $this->a_formElements[] = $name;
+ }
+
+ return parent::addElement($elementOrType, $name, $attributes, $data);
+ }
+
+ function setChecked( $nameElement )
+ {
+ foreach( $this->_elements as $key => $value)
+ {
+ if($value->_attributes['name'] == $nameElement)
+ {
+ $this->_elements[$key]->_attributes['checked'] = 'checked';
+ }
+ }
+ }
+ function setSelected( $nameElement, $value )
+ {
+ foreach( $this->_elements as $key => $value)
+ {
+ if($value->_attributes['name'] == $nameElement)
+ {
+ $this->_elements[$key]->_attributes['selected'] = 'selected';
+ }
+ }
+ }
+
+ /**
+ * Ported from HTML_QuickForm to minimize changes to Controllers
+ *
+ * @param string $elementName
+ * @return mixed
+ */
+ function getSubmitValue($elementName)
+ {
+ $value = $this->getValue();
+ return isset($value[$elementName]) ? $value[$elementName] : null;
+ }
+}