public function __toString() { $element = Form_Element::__toString(); $title = htmlspecialchars(gettext($this->_title)); $html = implode('', $this->_groups); $footer = implode('', $this->_global); $modalClass = $this->_isLarge ? 'modal-lg' : 'modal-sm'; return <<<EOT \t{$element} \t\t<div class="modal-dialog {$modalClass}"> \t\t\t<div class="modal-content"> \t\t\t\t<div class="modal-header"> \t\t\t\t\t<button type="button" class="close" data-dismiss="modal" aria-label="Close"> \t\t\t\t\t\t<span aria-hidden="true">×</span> \t\t\t\t\t</button> \t\t\t\t\t<h3 class="modal-title">{$title}</h3> \t\t\t\t</div> <!--\t\t\t\t<form class="form-horizontal" action="" method="post"> --> \t\t\t\t\t<div class="modal-body"> \t\t\t\t\t\t{$html} \t\t\t\t\t</div> \t\t\t\t\t<div class="modal-footer"> \t\t\t\t\t\t{$footer} \t\t\t\t\t</div> <!--\t\t\t\t</form> --> \t\t\t</div> \t\t</div> \t</div> EOT; }
public function __toString() { $element = parent::__toString(); $title = htmlspecialchars(gettext($this->_title)); $body = implode('', $this->_groups); $hdricon = ""; $bodyclass = '<div class="panel-body">'; if ($this->_collapsible & COLLAPSIBLE) { $hdricon = '<span class="widget-heading-icon">' . '<a data-toggle="collapse" href="#' . $this->_attributes['id'] . '_panel-body">' . '<i class="fa fa-plus-circle"></i>' . '</a>' . '</span>'; $bodyclass = '<div id="' . $this->_attributes['id'] . '_panel-body" class="panel-body collapse '; if ($this->_collapsible & SEC_CLOSED) { $bodyclass .= 'out">'; } else { $bodyclass .= 'in">'; } } return <<<EOT \t{$element} \t\t<div class="panel-heading"> \t\t\t<h2 class="panel-title">{$title}{$hdricon}</h2> \t\t</div> \t\t{$bodyclass} \t\t\t{$body} \t\t</div> \t</div> EOT; }
public function setValue($value) { $db_id_idx = $this->getName() . '_db_id'; $this->_db_id = __paramInit('int', $db_id_idx, $db_id_idx, 0); $columns_id_idx = 'el-' . $this->getName() . '_columns'; $this->_columns = __paramInit('array_int', $columns_id_idx, $columns_id_idx, $this->_columns); return parent::setValue($value); }
/** * Constructor * @since 1.0.0 * @param string $name Name of field. * @param string $label Label of field. * @param string $description Description of field which is shown under element * @param array/string $args List of Arguments. */ function __construct($name, $label = FALSE, $args = array()) { $defaults = array('description' => '', 'default' => '', 'disabled' => FALSE); $args = wp_parse_args($args, $defaults); $args['label'] = $label; parent::__construct('input', $name, $args); $this->add_param('type', 'text'); // This is a text field! }
/** * Constructor * @since 1.0 * @param string $name Name of field. * @param array/string $args List of Arguments. */ function __construct($name, $args = array()) { $args = wp_parse_args($args); $args['close_tag'] = FALSE; // No Close tag for Input type Text parent::__construct('input', $name, $args); $this->add_param('type', 'text'); // This is a text field! }
/** * Constructor * @since 1.0 * @param string $name The name of field. * @param array/string $args List of Arguments. */ function __construct($name, $args = array()) { global $post, $skip_form_option_group; $args = wp_parse_args($args); extract($args, EXTR_SKIP); $args['close_tag'] = FALSE; // No Close tag for Input type Text parent::__construct('input', $name, $args); $this->add_param('type', 'hidden'); // This is a text field! }
public function __toString() { $element = parent::__toString(); $html = implode('', $this->_sections); $buttons = ''; foreach ($this->_global as $global) { if ($global instanceof Form_Button) { $buttons .= $global; } else { $html .= $global; } } if (!empty($buttons)) { $group = new Form_Element(); $group->addClass('col-sm-' . Form::MAX_INPUT_WIDTH, 'col-sm-offset-' . Form::LABEL_WIDTH); $html .= $group . $buttons . '</div>'; } return <<<EOT \t{$element} \t\t{$html} \t</form> EOT; }
public function __toString() { $element = Form_Element::__toString(); $column = new Form_Element(); $column->addClass('checkbox', 'multi', 'col-sm-10'); $inputs = implode('', $this->_inputs); $help = $this->_getHelp(); $label = new Form_Element('label'); $label->addClass('col-sm-' . Form::LABEL_WIDTH, 'control-label'); $title = htmlspecialchars(gettext($this->_title)); return <<<EOT \t{$element} \t\t{$label} \t\t\t{$title} \t\t</label> \t\t{$column} \t\t\t{$inputs} \t\t</div> \t\t{$help} \t</div> EOT; }
/** * Rendering Editor field * @package Skip * @since 1.0 * @return string $html Returns The HTML Code. */ public function render() { global $skip_used_dialog; $skip_used_dialog = TRUE; if (array_key_exists('class', $this->params)) { $class = $this->params['class'] . ' skip_editor'; } else { $class = 'skip_editor'; } $settings = array('textarea_name' => $this->field_name, 'editor_class' => $class); ob_start(array($this, 'buffer')); wp_editor(stripslashes($this->value), $this->params['id'], $settings); ob_end_flush(); $this->content = $this->buffer; return parent::render(); }
/** * Constructor * @since 1.0 * @param string $name The name of the checkbox field. * @param string $value The value of the checkbox element which will be saved if box is checked. * @param array/string $args List of Arguments. */ function __construct($name, $value, $label = FALSE, $args = array()) { global $skip_hidden_elements; $defaults = array('checked' => FALSE); $args = wp_parse_args($args, $defaults); $args['label'] = $label; $args['close_tag'] = FALSE; // No Close tag for Input type Button parent::__construct('input', $name, $args); $this->add_param('type', 'checkbox'); $this->add_param('value', $value); // Overwriting value from DB if ('' != $this->value || $this->value == 'checked' || $args['checked']) { $this->add_param('checked', 'checked'); } }
/** * Rendering Select field * @package Skip * @since 1.0 * @return string $html Returns The HTML Code. */ public function render() { $this->content = ''; foreach ($this->elements as $element) { $params = $element['params']; unset($element['params']); $label = $element['label']; unset($element['label']); $params = array_merge($element, $params); if ($params['value'] == $this->value) { $params['selected'] = 'selected'; } $this->content .= '<option' . $this->params($params) . '>' . $label . '</option>'; } return parent::render(); }
public function __toString() { $element = parent::__toString(); $title = htmlspecialchars(gettext($this->_title)); $body = implode('', $this->_groups); return <<<EOT \t{$element} \t\t<div class="panel-heading"> \t\t\t<h2 class="panel-title">{$title}</h2> \t\t</div> \t\t<div class="panel-body"> \t\t\t{$body} \t\t</div> \t</div> EOT; }
/** * Constructor * @since 1.0 * @param string $name Name of field. * @param array/string $args List of Arguments. */ function __construct($name, $label = FALSE, $args = array()) { $defaults = array('rows' => '', 'cols' => '', 'description' => '', 'default' => '', 'disabled' => FALSE); $args = wp_parse_args($args, $defaults); $args['label'] = $label; $args['close_tag'] = TRUE; // No Close tag for Input type Text parent::__construct('textarea', $name, $args); if ('' != $args['rows']) { $this->add_param('rows', $args['rows']); } if ('' != $args['cols']) { $this->add_param('cols', $args['cols']); } if ('' != $this->value) { $this->add_element($this->value); }
$this->delete = $args['delete']; $args['close_tag'] = FALSE; // No Close tag for Input type Text $args['label'] = $label; parent::__construct('input', $name, $args); $this->del_param('value'); // Not needed here $this->add_param('type', 'file'); // This is a text field! } /** * Rendering Editor field * @package Skip * @since 1.0 * @return string $html Returns The HTML Code. */ public function render() { global $skip_javascripts; $file_url = $this->value['url']; $file_path = $this->value['file'];
/** * Constructor * @since 1.0 * @param string $name Name of field. * @param string $value The value of the checkbox element which will be saved if Radiobutton is checked. * @param array/string $args List of Arguments. */ function __construct($name, $value, $label = FALSE, $args = array()) { /* * Additional parent args: * 'id' * 'classes' * 'before_element' * 'after_element' * 'params' */ $defaults = array('checked' => FALSE); $args = wp_parse_args($args, $defaults); $args['label'] = $label; $args['close_tag'] = FALSE; // No Close tag for Input type Button parent::__construct('input', $name, $args); $this->add_param('type', 'radio'); // This is a radio button $this->add_param('value', $value); // Overwriting value from DB if ($value == $this->value || $this->value == 'checked' || $args['checked']) {
protected function _getInput() { return parent::__toString(); }
/** * Form::element() * get or create an element * * @param string $key * @param mixed $mixedTypeIndex FALSE/ int : get element, string: create element * @param array $settings * @return Form_Element */ public function element($key, $mixedTypeIndex = FALSE, $settings = array()) { if ($mixedTypeIndex === FALSE) { /** * get element */ if (isset($this->_fields[$key])) { if ($this->_fields[$key]['group'] === TRUE) { // return array(group) return $this->_fields[$key]['elements']; } else { // return first element (not group) return $this->_fields[$key]['elements'][0]; } } else { return FALSE; } } elseif (is_int($mixedTypeIndex)) { /** * get n'th element */ if (isset($this->_fields[$key]) && isset($this->_fields[$key]['elements'][$mixedTypeIndex])) { return $this->_fields[$key]['elements'][$mixedTypeIndex]; } else { return FALSE; } } else { /** * add element */ // raise event Event::raise($this, Event::BEFORE_FORM_ELEMENT, array('form' => $this, 'key' => $key, 'type' => $mixedTypeIndex, 'settings' => $settings)); // create the element $element = new Form_Element($key, $mixedTypeIndex, $settings); // get field if (isset($this->_fields[$key])) { // get existing field $field = $this->_fields[$key]; // check if existing elementnames should be updated if ($field['group'] === FALSE) { $updateName = TRUE; } else { $updateName = FALSE; } // set group property to true $field['group'] = TRUE; } else { // create new field $field = array('group' => FALSE, 'multiple' => FALSE, 'elements' => array(), 'rules' => array(), 'processors' => array(), 'default' => NULL, 'compound' => FALSE, 'keys' => array()); $updateName = FALSE; } // check & set compound if (isset($settings['compound']) && $settings['compound'] == TRUE) { $field['compound'] = TRUE; } // check $ set compound keys if (isset($settings['keys'])) { $field['keys'] = $settings['keys']; } // check if a default was given & set default if (isset($settings['default'])) { $field['default'] = $settings['default']; } // check if the group property is explicitly set if (isset($settings['group']) && $settings['group'] == TRUE) { $field['group'] = TRUE; } // check if it is multiple $field['multiple'] = $element->multiple(); // create name $name = $key; if ($field['group'] === TRUE) { $name .= '[]'; } if ($field['multiple'] === TRUE) { $name .= '[]'; } // set name of this element $element->name($name); // update existing elements if necesary if ($updateName === TRUE) { $this->_fields[$key]['elements'][0]->name($name); } // store element $field['elements'][] = $element; // store field $this->_fields[$key] = $field; // store element in list $this->_elements[] = $element; // raise hook Event::raise($this, Event::AFTER_FORM_ELEMENT, array('form' => $this, 'element' => $element)); // return element return $element; } }
$args['close_tag'] = FALSE; // No Close tag for Input type Text $args['save'] = FALSE; $args['value'] = $value; parent::__construct('input', $name, $args); $this->add_param('type', 'submit'); // This is a text field!
public function __toString() { global $config, $user_settings; $element = parent::__toString(); // Automatically determine width for inputs without explicit set $spaceLeft = Form::MAX_INPUT_WIDTH; $missingWidth = array(); foreach ($this->_inputs as $input) { if (count($this->_inputs) > 1 && !$input->hasAttribute('placeholder')) { $input->setPlaceholder($input->getTitle()); } $width = $input->getWidth(); if (isset($width)) { $spaceLeft -= $width; } else { array_push($missingWidth, $input); } } foreach ($missingWidth as $input) { $input->setWidth($spaceLeft / count($missingWidth)); } if (strtolower($this->_labelTarget->getType()) == 'hidden') { $hidden = true; } $form_controls = array('input', 'select', 'button', 'textarea', 'option', 'optgroup', 'fieldset', 'label'); if (in_array(strtolower($this->_labelTarget->getTagName()), $form_controls) && !$hidden) { $target = $this->_labelTarget->getId(); } $inputs = implode('', $this->_inputs); $help = $this->_getHelp(); if (!$user_settings['webgui']['webguileftcolumnhyper']) { $target = null; } $label = new Form_Element('label', false, ['for' => $target]); $label->addClass('col-sm-' . Form::LABEL_WIDTH, 'control-label'); if (!empty(trim($this->_title)) || is_numeric($this->_title)) { $title = htmlspecialchars(gettext($this->_title)); } return <<<EOT \t{$element} \t\t{$label} \t\t\t{$title} \t\t</label> \t\t{$inputs} \t\t{$help} \t</div> EOT; }
public function setValue($value) { $value = isset($value[self::GROUP_DBID]) && $value[self::GROUP_DBID] > 0 ? $value : null; return parent::setValue($value); }
public function __toString() { $element = parent::__toString(); // Automatically determine width for inputs without explicit set $spaceLeft = Form::MAX_INPUT_WIDTH; $missingWidth = array(); foreach ($this->_inputs as $input) { if (count($this->_inputs) > 1 && !$input->hasAttribute('placeholder')) { $input->setPlaceholder($input->getTitle()); } $width = $input->getWidth(); if (isset($width)) { $spaceLeft -= $width; } else { array_push($missingWidth, $input); } } foreach ($missingWidth as $input) { $input->setWidth($spaceLeft / count($missingWidth)); } $target = $this->_labelTarget->getId(); $inputs = implode('', $this->_inputs); $help = $this->_getHelp(); $label = new Form_Element('label', false, ['for' => $target]); $label->addClass('col-sm-' . Form::LABEL_WIDTH, 'control-label'); $title = htmlspecialchars(gettext($this->_title)); return <<<EOT \t{$element} \t\t{$label} \t\t\t{$title} \t\t</label> \t\t{$inputs} \t\t{$help} \t</div> EOT; }