public function form() { $text = new FormElement("textarea", "q_post"); $t = new Theme(); $text->addClasses("actualite_area_text"); return $t->process_form_elements($text); }
function coupleWith(FormElement $component, $url, $filter_column = null, $empty_value = '') { $this->setAttribute('rel', $component->getId()); $this->setAttribute('data-url', UrlHelper::get($url)); $this->filter_column = $filter_column; $this->related = $component; $this->empty_value = $empty_value; }
function submitEditFormElementDescData($moduleCompId, $elementId) { $myElement = new FormElement(); $myElement->fromHtmlForm(); $updateQuery = $myElement->toMysqlUpdateQuery($moduleCompId); if (mysql_query($updateQuery)) { return true; } else { return false; } }
/** * Return an array with the elements according to the parameters * * @param int $id * @param int $langId * @param string $type * * @return array */ protected function _selectElements($id, $all = false) { $oElem = new FormElement(); $oElemType = new FormElementType(); $select = $oElem->select()->setIntegrityCheck(false)->from($oElem->getName())->joinInner($oElemType->getName(), 'FET_ID = FE_TypeID', 'FET_Title'); if (!$all) { $select->where('FE_ID = ?', $id); } else { $select->where('FE_SectionID = ?', $id); } $select->order('FE_Seq ASC'); $elements = $oElem->fetchAll($select)->toArray(); return $elements; }
public function set($key, $value) { if ($key == 'options') { // The options need to be an array, (hence the plural use) if (!is_array($value)) return false; // if every key in this is an int, transpose the value over to the key instead. // This allows for having an option with a different title and value. // (and cheating, not actually checking every key) if (isset($value[0]) && isset($value[sizeof($value) - 1])) { foreach ($value as $k => $v) { unset($value[$k]); $value[$v] = $v; } } // Please note, this system CANNOT call the parent function, because its default behaviour is to // remap any int-based array to value/value pairs. Since that logic is already handled here, there // is no need to perform it again, (of which it performs incorrectly)... $this->_attributes[$key] = $value; return true; //return parent::set($key, $value); } else { parent::set($key, $value); } }
public function renderAttributes() { $this->_processAttributes(); if (!$this->path) { $action_path = $_SERVER['PHP_SELF']; if($node_id = Limb :: toolkit()->getRequest()->get('node_id')) $action_path .= '?node_id=' . $node_id; } else $action_path = $this->path; if (strpos($action_path, '?') === false) $action_path .= '?'; else $action_path .= '&'; if($this->action) $action_path .= 'action=' . $this->action; if ((bool)$this->reload_parent) { $action_path .= '&reload_parent=1'; } $this->attributes['onclick'] = $this->onclick; $this->attributes['onclick'] .= "submitForm(this.form, '{$action_path}')"; parent :: renderAttributes(); unset($this->attributes['onclick']); }
public function __construct($atts = null) { parent::__construct($atts); // Some defaults $this->_attributes['class'] = 'formelement formpasswordinput'; $this->_validattributes = array('accesskey', 'autocomplete', 'dir', 'disabled', 'id', 'lang', 'name', 'required', 'size', 'tabindex', 'width', 'height', 'value', 'style'); }
public function __construct($atts = null) { parent::__construct($atts); // Some defaults $this->_attributes['class'] = 'formelement formcheckboxinput'; $this->_validattributes = array('accesskey', 'checked', 'dir', 'disabled', 'id', 'lang', 'name', 'required', 'tabindex', 'style', 'value'); }
/** * Render and add a form element to both the PHP session and HTML output. * * @experimental * @param array $params Associative (and/or indexed) array of smarty parameters passed in from the template * @param Smarty $smarty Parent Smarty template object * * @return string * @throws SmartyException */ function smarty_function_add_form_element($params, $smarty){ if(!isset($params['form'])){ $form = null; } elseif($params['form'] instanceof Form){ $form = $params['form']; } elseif($params['form'] instanceof \Core\ListingTable\Table){ $form = $params['form']->getEditForm(); } else{ throw new SmartyException('Unsupported value provided for "form", please ensure it is either a valid Form object or omitted completely!'); } $type = isset($params['type']) ? $params['type'] : 'text'; $element = FormElement::Factory($type, $params); if($form){ $form->addElement($element); } // Assign or render? if(isset($params['assign'])){ $smarty->assign($params['assign'], $element->render()); } else{ echo $element->render(); } }
public function __construct($atts = null) { parent::__construct($atts); // Some defaults $this->_attributes['class'] = 'formelement formtextareainput'; $this->_validattributes = array('accesskey', 'dir', 'disabled', 'id', 'lang', 'name', 'placeholder', 'readonly', 'required', 'tabindex', 'rows', 'cols', 'style', 'class'); }
/** * Return html rendering for the element label * $arr_return['label'] - array or string of form element lable * $arr_return['html'] - array or string of form element * * @return Array $arr_return * */ function toHtml() { $arr_return = parent::toHtml(); $arr_return['html'] = ''; $arr_checkboxes = array(); $arr_checkboxes = $this->getAttribute('checkboxes'); $arr_checked = array(); $arr_checked = $this->getAttribute('checked'); $string = ''; $id = $this->getAttribute('id'); if (is_array($arr_checkboxes)) { foreach ($arr_checkboxes as $key => $value) { $encode_key = str_replace(' ', '_', $key); $string = '<input {attr_name=attr_value} {extra_attr} id="' . "{$id}_{$encode_key}" . '" value="' . $key . '" '; if (is_array($arr_checked)) { $string .= in_array($key, $arr_checked) ? 'checked ' : ''; } $string .= '%id|checked|checkboxes|separator% />'; $string .= $value != '' ? '<label for="{attr_id}_' . $encode_key . '">' . $value . '</label>' : ''; $string .= $this->arr_attr['separator'] . "\n"; if ($this->return_type == 'string') { $arr_return['html'] .= $string; } else { $arr_return['html'][] = $string; } } } return $arr_return; }
function __toString() { //Allows children to write this attribute first if ($this->getAttribute('value') === false) { $this->setAttribute("value", $this->getRawValue()); } return parent::__toString(); }
public function __construct($atts = null) { parent::__construct($atts); // Some defaults $this->_attributes['class'] = 'formelement formwysiwyginput tinymce'; $this->_attributes['rows'] = '25'; // Note, I'm taking the required flag out from here; tinymce doesn't support it. $this->_validattributes = array('accesskey', 'dir', 'disabled', 'id', 'lang', 'name', 'readonly', 'tabindex', 'rows', 'cols', 'style', 'class'); }
/** * @see FormElement::renderInput() * * @param array $params * @return string */ public function renderInput($params = null) { parent::renderInput($params); $output = '<div class="color_input"><input type="text" id="colorh_' . $this->getId() . '" name="' . $this->getName() . '" ' . ($this->getValue() !== null ? '" value="' . $this->getValue() . '"' : '') . ' />' . ' <input type="button" class="color_button" id="color_' . $this->getId() . '" style="background:' . ($this->getValue() !== null ? $this->getValue() : '') . '" /> <div style="display:none;"><div id="colorcont_' . $this->getId() . '"></div></div></div>'; $varName = rand(10, 100000); $js = "var callback" . $varName . " = function(color){\n \$('#colorh_" . $this->getId() . "').attr('value', color);\n \$('#color_" . $this->getId() . "').css({backgroundColor:color});\n window.colorPickers['" . $this->getId() . "'].close();\n };\n new ColorPicker(\$('#colorcont_" . $this->getId() . "'), callback" . $varName . ", '" . $this->getValue() . "');\n \$('#color_" . $this->getId() . "').click(\n function(){\n if( !window.colorPickers )\n {\n window.colorPickers = {};\n }\n window.colorPickers['" . $this->getId() . "'] = new OW_FloatBox({\$contents:\$('#colorcont_" . $this->getId() . "'), \$title:'Color Picker'});\n }\n );"; OW::getDocument()->addOnloadScript($js); return $output; }
function Display() { $html = $this->_loadTemplate(); $html = str_replace("#LABEL#", $this->label, $html); $html = str_replace("#NOMBRE#", $this->nombre, $html); $html = str_replace("#ID#", $this->id, $html); $html = str_replace("#SELECTED_VALUE#", $this->selected_value, $html); $html = str_replace("#OPTIONS#", parent::Display(), $html); return $html; }
function __toString() { $this->setAttribute('class', 'tinymce_textarea'); $this->innerHTML = HtmlHelper::escape($this->_value); $config = JsonHelper::encode($this->config); $script = HtmlHelper::inlineJavascript('tinyMCE.init(' . $config . ');'); $this->afterHTML = $script; self::$instances_included++; return parent::__toString(); }
/** * Overrides then calls with the parent render_attributes() method dealing * with the special case of the checked attribute */ public function renderAttributes() { $value = $this->getValue(); if ($value) $this->attributes['checked'] = 1; else unset($this->attributes['checked']); parent :: renderAttributes(); }
/** * Overrides then calls with the parent render_attributes() method. Makes * sure there is always a value attribute, even if it's empty. * Called from within a compiled template render function. */ public function renderAttributes() { $value = $this->getValue(); if (!is_null($value)) { $this->attributes['value'] = $value; } parent :: renderAttributes(); }
function __toString() { if (!$this->getAttribute('cols')) { $this->setAttribute('cols', 30); } if (!$this->getAttribute('rows')) { $this->setAttribute('rows', 5); } $this->innerHTML = HtmlHelper::escape($this->_value); return parent::__toString(); }
/** * @see FormElement::renderInput() * * @param array $params * @return string */ public function renderInput($params = null) { parent::renderInput($params); $deleteLabel = OW::getLanguage()->text('base', 'delete'); $markup = '<div class="ow_avatar_field">'; $markup .= UTIL_HtmlTag::generateTag('input', $this->attributes); $markup .= '<div class="ow_avatar_field_preview" style="display: none;"><img src="" alt="" /><span title="' . $deleteLabel . '"></span></div>'; $markup .= '<input type="hidden" name="" value="" class="ow_avatar_field_value" />'; $markup .= '</div>'; return $markup; }
public function setValue($value) { if (!$value) { $this->_error = $this->get('title') . ' is required.'; return false; } if ($value != \Core\Session::Get('captcha')) { $this->_error = $this->get('title') . ' does not match image.'; return false; } parent::setValue(''); }
/** * This function will validate the element's value against defined validation rules (e.g. not null, ...) * * The validation will also activate the error flag, if any * rule is broken, which will trigger the error message in * form mode output. * * @see setMaximumLength() * @see FormElement::validate() * @return boolean TRUE if no errors occurred */ public function validate() { parent::validate(); $value = trim($this->value()); // only use reg exp validation if value is not empty. // an empty value validation should be made with setNotNull() if (!$this->isEmpty() && $this->validRegExp() != '' && !preg_match($this->validRegExp(), $value)) { $this->setError('REGEXP MISMATCH'); } $this->_isValidated = true; return !$this->error(); }
public function getInputAttributes(){ if($this->get('autocomplete') && !($this->get('autocomplete') == 'off' || $this->get('autocomplete') == 'on')){ // These get handled by the smarty snippet. if(($k = array_search('name', $this->_validattributes))){ unset($this->_validattributes[$k]); } if(($k = array_search('value', $this->_validattributes))){ unset($this->_validattributes[$k]); } } return parent::getInputAttributes(); }
public function confirmDelete($label) { $group = new GroupObject(); if ($group->load_by_label($label)) { if (isset($_POST['delete'])) { $group = new GroupObject(); $group->load_by_label($label); $group->delete(); header("Location:" . Page::url("/admin/groups")); } $theme = new Theme(); $form = new Form("POST", Page::url("/admin/groups/confirm/{$label}")); $link = new FormElement("a", null, t("Retourner à la liste des groupes"), "", ""); $link->setAttribute("href", Page::url("/admin/groups/")); $form->addElement($link); $form->addElement(new InputElement("delete", "", t("supprimer le groupe"), "submit")); $theme->add_to_body($theme->forming($form)); $theme->set_title("Confirmer la suppression du groupe {$label}"); $theme->process_theme(Theme::STRUCT_ADMIN); } else { header("Location:" . Page::url("/admin/groups?err=notexists")); } }
/** * Overrides then calls with the parent render_attributes() method dealing * with the special case of the checked attribute */ public function renderAttributes() { $value = $this->getValue(); if (isset($this->attributes['value']) && $value == $this->attributes['value']) { $this->attributes['checked'] = 1; } else { unset($this->attributes['checked']); } parent::renderAttributes(); }
function smarty_function_input($params, $smarty) { $type = FormElement::getParameter($params, 'type', 'text'); $label = FormElement::getParameter($params, 'label'); if (! $label && !FormElement::getBoolParameter($params, 'nolabel')) { $type = 'hidden'; } $object = FormElement::getObject($type); if ($object instanceof FileInput) { $smarty->_coorg_form->file_upload = true; } if ($object instanceof LabeledFormElement) { $object->setLabel(t($label)); $object->setIDPrefix($smarty->_coorg_form->formID); if (FormElement::getBoolParameter($params, 'disabled')) $object->disable(); if ($tabindex = FormElement::getParameter($params, 'tabindex')) $object->tabindex($tabindex); } if ($object instanceof IUserInput) { if ($placeholder = FormElement::getParameter($params, 'placeholder')) $object->setPlaceholder($placeholder); if (FormElement::getBoolParameter($params, 'readonly')) $object->readonly(); if ($for = FormElement::getParameter($params, 'for')) { $object->setName($for); // This can be overriden by a name="" (see later) $instance = $smarty->_coorg_form->instance; $object->setObject($instance, $for); } else { $object->setValue(FormElement::getParameter($params, 'value')); } } if ($name = FormElement::getParameter($params, 'name')) { $object->setName($name); } $object->setSpecificParameters($params); return $object->render(); }
public function render() { if (!$this->get('basedir')) { throw new Exception('MultiFileInput cannot be rendered without a basedir attribute!'); } // Make sure it ends with a trailing slash. if (substr($this->get('basedir'), -1) != '/') { $this->_attributes['basedir'] .= '/'; } //var_dump($_SESSION['multifileinputobjects'], serialize($this->_attributes)); die(); // This is a slightly different element than the traditional form system, as it must be able to be called without // the rest of the form system on submit. // This is because this system will do an ajax submit to do the actual upload. if (!is_array(\Core\Session::Get('multifileinputobjects'))) { \Core\Session::Set('multifileinputobjects', []); } // I don't need this key to be cryptographically secure, just generally unique. $key = md5(serialize($this->_attributes)); foreach (\Core\Session::Get('multifileinputobjects') as $obj) { if (!isset($obj['key'])) { continue; } if ($obj['key'] == $key) { $this->set('id', $obj['id']); } } if (!isset($this->_attributes['id'])) { // This system requires a valid id. $this->set('id', 'multifileinput-' . Core::RandomHex('2')); } $this->set('key', $key); $this->set('uploadkey', $key); // Convert the string representation of a filesize to the raw bytes. $size = strtoupper(str_replace(' ', '', ini_get('upload_max_filesize'))); if (strpos($size, 'G') !== false) { $size = preg_replace('/[^0-9]/', '', $size); $size = $size * (1024 * 1024 * 1024); } elseif (strpos($size, 'M') !== false) { $size = preg_replace('/[^0-9]/', '', $size); $size = $size * (1024 * 1024); } elseif (strpos($size, 'K') !== false) { $size = preg_replace('/[^0-9]/', '', $size); $size = $size * 1024; } $this->set('maxsize', $size); // Now that the session variable has been initialized, the traditional session variable is reliable. $_SESSION['multifileinputobjects'][$key] = array('obj' => serialize($this), 'key' => $key, 'id' => $this->_attributes['id']); return parent::render(); }
/** * @see FormElement::renderInput() * * @param array $params * @return string */ public function renderInput($params = null) { parent::renderInput($params); $staticUrl = OW::getPluginManager()->getPlugin('mcompose')->getStaticUrl(); OW::getDocument()->addStyleSheet($staticUrl . 'select2.css'); OW::getDocument()->addScript($staticUrl . 'select2.js'); OW::getDocument()->addStyleSheet($staticUrl . 'style.css'); OW::getDocument()->addScript($staticUrl . 'script.js'); $this->addAttribute('type', 'hidden'); $this->addAttribute('style', 'width: 100%'); $imagesUrl = OW::getPluginManager()->getPlugin('base')->getStaticCssUrl(); $css = array('.mc-tag-bg { background-image: url(' . $imagesUrl . 'images/tag_bg.png); };'); OW::getDocument()->addStyleDeclaration(implode("\n", $css)); return UTIL_HtmlTag::generateTag('input', $this->attributes) . '<div class="us-field-fake"><input type="text" class="ow_text invitation" value="' . $this->invitation . '" /></div>'; }
public function __construct($atts = null) { parent::__construct($atts); // Some defaults $defaults = [ 'class' => 'formelement formbuttoninput', ]; foreach($defaults as $k => $v){ if(!isset($this->_attributes[$k])){ $this->_attributes[$k] = $v; } } $this->_validattributes = array('accesskey', 'dir', 'disabled', 'id', 'lang', 'name', 'size', 'tabindex', 'width', 'height', 'value', 'style'); }
/** * @param null $atts */ public function __construct($atts = null) { // Some defaults $this->_attributes = array( 'accept' => '*', 'class' => 'formelement formfileinput', 'previewdimensions' => '200x100', 'browsable' => false, 'basedir' => '', 'allowlink' => true, ); $this->_validattributes = array(); $this->requiresupload = true; parent::__construct($atts); }