/** * Class constructor * * @param string $elementName (optional)Input field name attribute * @param string $value (optional)Input field value * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @since 1.0 * @access public * @return void */ function __construct($elementName = null, $value = null, $attributes = null) { parent::__construct($elementName, null, $attributes); $this->_persistantFreeze = false; $this->setValue($value); $this->setType('button'); }
/** * Class constructor * * @param string $elementName (optional)Input field name attribute * @param string $value (optional)Input field value * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @since 1.0 * @access public * @return void */ function HTML_QuickForm_button($elementName = null, $value = null, $attributes = null) { HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); $this->_persistantFreeze = false; $this->setValue($value); $this->setType('button'); }
function exportValue(&$submitValues, $assoc = false) { $val = parent::exportValue($submitValues, $assoc); $currency_field_name = '__'.str_replace(array('[',']'),'',$this->getName()).'__currency'; if(isset($submitValues[$currency_field_name])) $currency = $submitValues[$currency_field_name]; else return null; if ($assoc) { if (!isset($val[$this->getName()])) { $key = explode('[', $this->getName()); $key[1] = str_replace(']','',$key[1]); $val = $val[$key[0]][$key[1]]; } else $val = $val[$this->getName()]; } $cur = explode(Utils_CurrencyFieldCommon::get_decimal_point(), $val); if (!isset($cur[1])) $ret = $cur[0]; else { $this->dec_digits = DB::GetOne('SELECT decimals FROM utils_currency WHERE id=%d', array($currency)); $cur[1] = str_pad($cur[1], $this->dec_digits, '0'); $cur[1] = substr($cur[1], 0, $this->dec_digits); $ret = $cur[0] + (($cur[0]<0?-1:1)*$cur[1]/pow(10,$this->dec_digits)); } $ret .= '__'.$currency; if($assoc) { $val = array(); if (isset($key)) { $val[$key[0]][$key[1]] = $ret; } else $val[$this->getName()] = $ret; return $val; } else { return $ret; } }
/** * <code> * $form->addElement('textarea_counter', 'message', 'Message', * array('cols'=>60, 'rows'=>10), 160); * </code> */ function MoodleQuickForm_recaptcha($elementName = null, $elementLabel = null, $attributes = null) { parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes); $this->_type = 'recaptcha'; if (!empty($attributes['https'])) { $this->_https = $attributes['https']; } }
/** * Class constructor * * @param string Name * @param mixed Label for the CAPTCHA * @param array Options for the Text_CAPTCHA package * <ul> * <li>'sessionVar' (string) name of session variable containing * the Text_CAPTCHA instance (defaults to * _HTML_QuickForm_CAPTCHA.)</li> * <li>Other options depend on the driver used</li> * </ul> * @param mixed HTML Attributes for the <a> tag surrounding the * image. Can be a string or array. * @access public */ function HTML_QuickForm_CAPTCHA($elementName = null, $elementLabel = null, $options = null, $attributes = null) { HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); $this->setType('CAPTCHA_' . $this->_CAPTCHA_driver); if (is_array($options)) { $this->_options = array_merge($this->_options, $options); } }
/** * constructor * * @param string $elementName (optional) name of the recaptcha element * @param string $elementLabel (optional) label for recaptcha element * @param mixed $attributes (optional) Either a typical HTML attribute string * or an associative array */ function MoodleQuickForm_recaptcha($elementName = null, $elementLabel = null, $attributes = null) { global $CFG; parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes); $this->_type = 'recaptcha'; if (is_https()) { $this->_https = true; } else { $this->_https = false; } }
/** * <code> * $form->addElement('textarea_counter', 'message', 'Message', * array('cols'=>60, 'rows'=>10), 160); * </code> */ function MoodleQuickForm_recaptcha($elementName = null, $elementLabel = null, $attributes = null) { global $CFG; parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes); $this->_type = 'recaptcha'; if (!empty($attributes['https']) or strpos($CFG->httpswwwroot, 'https:') === 0) { $this->_https = true; } else { $this->_https = false; } }
/** * constructor * * @param string $elementName (optional) name of the recaptcha element * @param string $elementLabel (optional) label for recaptcha element * @param mixed $attributes (optional) Either a typical HTML attribute string * or an associative array */ public function __construct($elementName = null, $elementLabel = null, $attributes = null) { global $CFG; parent::__construct($elementName, $elementLabel, $attributes); $this->_type = 'recaptcha'; if (is_https()) { $this->_https = true; } else { $this->_https = false; } }
/** * Class constructor * * @param string $elementName (optional)Input field name attribute * @param string $elementLabel (optional)Input field label * @param mixed $callback (optional)Method callback that will be used to populate table * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @return void */ function HTML_QuickForm_autocomplete($elementName = null, $elementLabel = null, $callback = null, $args = null, $attributes = null) { HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); $this->callback = $callback; if (!$args || !is_array($args)) { $args = array(); } $this->args = $args; $this->_persistantFreeze = true; $this->setType('text'); }
/** * Returns the checkbox element in HTML * * @since 1.0 * @access public * @return string */ function toHtml() { if (0 == strlen($this->_text)) { $label = ''; } elseif ($this->_flagFrozen) { // チェックの時のみラベルを表示 $label = $this->getChecked() ? $this->_text : ''; } else { $label = '<label for="' . $this->getAttribute('id') . '">' . $this->_text . '</label>'; } return HTML_QuickForm_input::toHtml() . $label; }
/** * @param string $name input name example 'submit' * @param string $text button text to show * @param string $icon icons based in font-awesome * @param string $style i.e default|primary|success|info|warning|danger|link * @param string $size large|default|small|extra-small * @param string $class * @param array $attributes */ public function __construct($name, $text, $icon = 'check', $style = 'default', $size = 'default', $class = null, $attributes = array()) { $this->setIcon($icon); $this->setStyle($style); $this->setSize($size); $this->setClass($class); $columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null; $this->setColumnsSize($columnsSize); parent::__construct($name, null, $attributes); $this->_persistantFreeze = false; $this->setValue($text); $this->setType('submit'); }
/** * Class constructor * * @param string $elementName (optional)Input field name attribute * @param string $elementLabel (optional)Input field label * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @since 1.0 * @access public * @return void */ function HTML_QuickForm_text($elementName = null, $elementLabel = null, $attributes = null) { if (isset($attributes) && is_array($attributes) && !empty($attributes['class'])) { $attributes['class'] .= $attributes['class'] . ' form-control'; } else { if (empty($attributes['class'])) { $attributes = array('class' => 'form-control'); } } HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->setType('text'); }
function MoodleQuickForm_filepicker($elementName=null, $elementLabel=null, $attributes=null, $options=null) { global $CFG; $options = (array)$options; foreach ($options as $name=>$value) { if (array_key_exists($name, $this->_options)) { $this->_options[$name] = $value; } } if (!empty($options['maxbytes'])) { $this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']); } parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes); }
/** * Constructor. * * @param string $elementName (optional) name of the listing. * @param string $elementLabel (optional) listing label. * @param array $attributes (optional) Either a typical HTML attribute string or an associative array. * @param array $options set of options to initalize listing. */ public function __construct($elementName = null, $elementLabel = null, $attributes = null, $options = array()) { $this->_type = 'listing'; if (!empty($options['items'])) { $this->items = $options['items']; } if (!empty($options['showall'])) { $this->showall = $options['showall']; } else { $this->showall = get_string('showall'); } if (!empty($options['hideall'])) { $this->hideall = $options['hideall']; } else { $this->hideall = get_string('hide'); } parent::__construct($elementName, $elementLabel, $attributes); }
/** * Constructor. * * @param string $elementName (optional) name of the listing. * @param string $elementLabel (optional) listing label. * @param array $attributes (optional) Either a typical HTML attribute string or an associative array. * @param array $options set of options to initalize listing. */ function MoodleQuickForm_listing($elementName = null, $elementLabel = null, $attributes = null, $options = array()) { $this->_type = 'listing'; if (!empty($options['items'])) { $this->items = $options['items']; } if (!empty($options['showall'])) { $this->showall = $options['showall']; } else { $this->showall = get_string('showall'); } if (!empty($options['hideall'])) { $this->hideall = $options['hideall']; } else { $this->hideall = get_string('hide'); } parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes); }
/** * Class constructor * * @param string $elementName (optional)Input field name attribute * @param string $elementLabel (optional)Input field label * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @since 1.0 * @access public * @return void */ public function __construct($elementName = null, $elementLabel = null, $attributes = array()) { if (is_array($attributes) || empty($attributes)) { $attributes['class'] = 'form-control'; } $inputSize = isset($attributes['input-size']) ? $attributes['input-size'] : null; $this->setInputSize($inputSize); $columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null; $this->setColumnsSize($columnsSize); $icon = isset($attributes['icon']) ? $attributes['icon'] : null; $this->setIcon($icon); if (!empty($inputSize)) { unset($attributes['input-size']); } if (!empty($icon)) { unset($attributes['icon']); } parent::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->setType('text'); }
/** * Constructor * * @param string $elementName (optional) name of the filepicker * @param string $elementLabel (optional) filepicker label * @param array $attributes (optional) Either a typical HTML attribute string * or an associative array * @param array $options set of options to initalize filepicker */ function MoodleQuickForm_filepicker($elementName = null, $elementLabel = null, $attributes = null, $options = null) { global $CFG, $PAGE; $options = (array) $options; foreach ($options as $name => $value) { if (array_key_exists($name, $this->_options)) { $this->_options[$name] = $value; } } if (empty($options['return_types'])) { $this->_options['return_types'] = FILE_INTERNAL; } $fpmaxbytes = 0; if (!empty($options['maxbytes'])) { $fpmaxbytes = $options['maxbytes']; } $coursemaxbytes = 0; if (!empty($PAGE->course->maxbytes)) { $coursemaxbytes = $PAGE->course->maxbytes; } $this->_options['maxbytes'] = get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $coursemaxbytes, $fpmaxbytes); $this->_type = 'filepicker'; parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes); }
/** * Class constructor * * @param string $elementName (optional)Input field name attribute * @param string $elementLabel (optional)Input field label * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @since 1.0 * @access public * @return void */ public function HTML_QuickForm_text($elementName = null, $elementLabel = null, $attributes = null) { HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->setType('text'); }
/** * Class constructor * * @param string $elementName (optional)Input field name attribute * @param string $value (optional)Input field value * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @since 1.0 * @access public * @return void */ public function HTML_QuickForm_hidden($elementName = null, $value = '', $attributes = null) { HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); $this->setType('hidden'); $this->setValue($value); }
/** * Called by HTML_QuickForm whenever form event is made on this element * * @param string $event Name of event * @param mixed $arg event arguments * @param object &$caller calling object * @since 1.0 * @access public * @return void */ function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'updateValue': // constant values override both default and submitted ones // default values are overriden by submitted $value = $this->_findValue($caller->_constantValues); if (null === $value) { // if no boxes were checked, then there is no value in the array // yet we don't want to display default value in this case if ($caller->isSubmitted()) { $value = $this->_findValue($caller->_submitValues); } else { $value = $this->_findValue($caller->_defaultValues); } } if (null !== $value || $caller->isSubmitted()) { $this->setChecked($value); } break; case 'setGroupValue': $this->setChecked($arg); break; default: parent::onQuickFormEvent($event, $arg, $caller); } return true; }
/** * Constructor * * @param string $elementname * @param string $elementlabel * @param array $attributes */ public function moodlequickform_guideeditor($elementname = null, $elementlabel = null, $attributes = null) { parent::HTML_QuickForm_input($elementname, $elementlabel, $attributes); }
/** * Class constructor * * @param string $elementName (optional)Input field name attribute * @param string $elementLabel (optional)Input field label * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @since 1.0 * @access public * @return void * @throws */ function HTML_QuickForm_password($elementName = null, $elementLabel = null, $attributes = null) { HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); $this->setType('password'); }
/** * Class constructor * * @param string $elementName (optional)Element name attribute * @param string $src (optional)Image source * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @since 1.0 * @access public * @return void */ public function __construct($elementName = null, $src = '', $attributes = null) { parent::__construct($elementName, null, $attributes); $this->setType('image'); $this->setSource($src); }
/** * Class constructor * * @param string $elementName (optional)Element name attribute * @param string $src (optional)Image source * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @since 1.0 * @access public * @return void */ function HTML_QuickForm_image($elementName = null, $src = '', $attributes = null) { HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); $this->setType('image'); $this->setSource($src); }
/** * Constructor for rubric editor * * @param string $elementName * @param string $elementLabel * @param array $attributes */ public function __construct($elementName = null, $elementLabel = null, $attributes = null) { parent::__construct($elementName, $elementLabel, $attributes); }
function toHtml() { if ($this->isFrozen()) { return $this->getFrozenHtml(); } else { return parent::toHtml(); } }
/** * Class constructor * * @param string $elementName (optional)Input field name attribute * @param string $value (optional)Input field value * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @since 1.0 * @access public * @return void */ function HTML_QuickForm_reset($elementName = null, $value = null, $attributes = null) { HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); $this->setValue($value); $this->setType('reset'); }
/** * Class constructor * * @param string Input field name attribute * @param string Input field value * @param mixed Either a typical HTML attribute string or an associative array * @since 1.0 * @access public * @return void */ public function __construct($elementName = null, $value = null, $attributes = null) { parent::__construct($elementName, null, $attributes); $this->setValue($value); $this->setType('submit'); }
/** * Called by HTML_QuickForm whenever form event is made on this element * * @param string $event Name of event * @param mixed $arg event arguments * @param object $caller calling object * @since 1.0 * @access public * @return void */ function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'updateValue': // constant values override both default and submitted ones // default values are overriden by submitted $value = $this->_findValue($caller->_constantValues); if (null === $value) { $value = $this->_findValue($caller->_submitValues); if (null === $value) { $value = $this->_findValue($caller->_defaultValues); } } if (!is_null($value) && $value == $this->getValue()) { $this->setChecked(true); } else { $this->setChecked(false); } break; case 'setGroupValue': if ($arg == $this->getValue()) { $this->setChecked(true); } else { $this->setChecked(false); } break; default: parent::onQuickFormEvent($event, $arg, $caller); } return true; }
/** * Called by HTML_QuickForm whenever form event is made on this element * * @param string $event Name of event * @param mixed $arg event arguments * @param object &$caller calling object * @since 1.0 * @access public * @return void */ function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'updateValue': // constant values override both default and submitted ones $value = $this->_findValue($caller->_constantValues); if (null === $value) { // we should retrieve value from submitted values when form is submitted, // else set value from defaults values if ($caller->isSubmitted()) { $value = $this->_findValue($caller->_submitValues); } else { $value = $this->_findValue($caller->_defaultValues); } } if (!is_null($value) && $value == $this->getValue()) { $this->setChecked(true); } else { $this->setChecked(false); } break; case 'setGroupValue': if ($arg == $this->getValue()) { $this->setChecked(true); } else { $this->setChecked(false); } break; default: parent::onQuickFormEvent($event, $arg, $caller); } return true; }