Overview

Namespaces

  • None
  • Quform
    • Traduttore_Registry

Classes

  • Quform
  • Quform_Admin_InsertForm
  • Quform_Admin_Page
  • Quform_Admin_Page_Controller
  • Quform_Admin_Page_Dashboard
  • Quform_Admin_Page_Entries
  • Quform_Admin_Page_Entries_Edit
  • Quform_Admin_Page_Entries_List
  • Quform_Admin_Page_Entries_View
  • Quform_Admin_Page_Factory
  • Quform_Admin_Page_Forms_Add
  • Quform_Admin_Page_Forms_Edit
  • Quform_Admin_Page_Forms_List
  • Quform_Admin_Page_Help
  • Quform_Admin_Page_Preview
  • Quform_Admin_Page_Settings
  • Quform_Admin_Page_Tools
  • Quform_Admin_Page_Tools_ExportEntries
  • Quform_Admin_Page_Tools_ExportForm
  • Quform_Admin_Page_Tools_Home
  • Quform_Admin_Page_Tools_ImportForm
  • Quform_Admin_Page_Tools_Migrate
  • Quform_Admin_Page_Tools_Uninstall
  • Quform_Api
  • Quform_Block
  • Quform_Builder
  • Quform_Captcha
  • Quform_ClassLoader
  • Quform_Confirmation
  • Quform_Container
  • Quform_Dashboard_Widget
  • Quform_Dispatcher
  • Quform_Element
  • Quform_Element_Captcha
  • Quform_Element_Checkbox
  • Quform_Element_Column
  • Quform_Element_Container
  • Quform_Element_Container_Iterator
  • Quform_Element_Date
  • Quform_Element_Email
  • Quform_Element_Factory
  • Quform_Element_Field
  • Quform_Element_File
  • Quform_Element_Group
  • Quform_Element_Hidden
  • Quform_Element_Honeypot
  • Quform_Element_Html
  • Quform_Element_Multi
  • Quform_Element_Multiselect
  • Quform_Element_Name
  • Quform_Element_Page
  • Quform_Element_Password
  • Quform_Element_Radio
  • Quform_Element_Recaptcha
  • Quform_Element_Row
  • Quform_Element_Select
  • Quform_Element_Submit
  • Quform_Element_Text
  • Quform_Element_Textarea
  • Quform_Element_Time
  • Quform_Entry_Controller
  • Quform_Entry_Exporter
  • Quform_Entry_List_Settings
  • Quform_Entry_List_Table
  • Quform_Entry_Processor
  • Quform_Entry_UserSearcher
  • Quform_Filter_Abstract
  • Quform_Filter_Alpha
  • Quform_Filter_AlphaNumeric
  • Quform_Filter_Digits
  • Quform_Filter_Regex
  • Quform_Filter_Static
  • Quform_Filter_StripTags
  • Quform_Filter_Trim
  • Quform_Form
  • Quform_Form_Controller
  • Quform_Form_Exporter
  • Quform_Form_Factory
  • Quform_Form_Importer
  • Quform_Form_Iterator
  • Quform_Form_List_Settings
  • Quform_Form_List_Table
  • Quform_Form_Processor
  • Quform_License
  • Quform_Migrator
  • Quform_NonceRefresher
  • Quform_Notification
  • Quform_Notification_Resender
  • Quform_Options
  • Quform_Permissions
  • Quform_Repository
  • Quform_ScriptLoader
  • Quform_Session
  • Quform_Settings
  • Quform_Shortcode
  • Quform_Themes
  • Quform_TokenReplacer
  • Quform_Toolbar
  • Quform_Translations
  • Quform_Updater
  • Quform_Upgrader
  • Quform_Uploader
  • Quform_Validator_Abstract
  • Quform_Validator_Alpha
  • Quform_Validator_AlphaNumeric
  • Quform_Validator_Array
  • Quform_Validator_Captcha
  • Quform_Validator_Date
  • Quform_Validator_Digits
  • Quform_Validator_Duplicate
  • Quform_Validator_Email
  • Quform_Validator_FileUpload
  • Quform_Validator_GreaterThan
  • Quform_Validator_Honeypot
  • Quform_Validator_Identical
  • Quform_Validator_InArray
  • Quform_Validator_Length
  • Quform_Validator_LessThan
  • Quform_Validator_Recaptcha
  • Quform_Validator_Regex
  • Quform_Validator_Required
  • Quform_Validator_Static
  • Quform_Validator_Time
  • Quform_View
  • Quform_ViewFactory
  • Quform_Widget_Form
  • Quform_Widget_Popup

Interfaces

  • Quform_Attachable
  • Quform_Element_Editable
  • Quform_Filter_Interface
  • Quform_Validator_Interface

Constants

  • Quform\Traduttore_Registry\TRANSIENT_KEY_PLUGIN
  • Quform\Traduttore_Registry\TRANSIENT_KEY_THEME

Functions

  • Quform\Traduttore_Registry\add_project
  • Quform\Traduttore_Registry\clean_translations_cache
  • Quform\Traduttore_Registry\get_available_locales
  • Quform\Traduttore_Registry\get_installed_translations
  • Quform\Traduttore_Registry\get_translations
  • Quform\Traduttore_Registry\register_clean_translations_cache
  • Quform\Traduttore_Registry\sanitize_date
  • Overview
  • Namespace
  • Class
  1: <?php
  2: 
  3: /**
  4:  * @copyright Copyright (c) 2009-2022 ThemeCatcher (https://www.themecatcher.net)
  5:  */
  6: class Quform_Element_Textarea extends Quform_Element_Field implements Quform_Element_Editable
  7: {
  8:     /**
  9:      * Set the default value
 10:      *
 11:      * @param  string   $value
 12:      * @param  boolean  $replacePlaceholders  Whether or not to replace variables
 13:      */
 14:     public function setDefaultValue($value, $replacePlaceholders = true)
 15:     {
 16:         $this->defaultValue = $replacePlaceholders ? $this->getForm()->replaceVariablesPreProcess($value) : $value;
 17:     }
 18: 
 19:     /**
 20:      * Get the value formatted in HTML
 21:      *
 22:      * @return string
 23:      */
 24:     public function getValueHtml()
 25:     {
 26:         $value = nl2br(Quform::escape($this->getValue()));
 27: 
 28:         $value = apply_filters('quform_get_value_html_' . $this->getIdentifier(), $value, $this, $this->getForm());
 29: 
 30:         return $value;
 31:     }
 32: 
 33:     /**
 34:      * Get the HTML attributes for the field
 35:      *
 36:      * @param   array   $context
 37:      * @return  array
 38:      */
 39:     protected function getFieldAttributes(array $context = array())
 40:     {
 41:         $attributes = array(
 42:             'id' => $this->getUniqueId(),
 43:             'name' => $this->getFullyQualifiedName(),
 44:             'class' => Quform::sanitizeClass($this->getFieldClasses($context))
 45:         );
 46: 
 47:         $placeholder = $this->form->replaceVariablesPreProcess($this->config('placeholder'));
 48:         if (Quform::isNonEmptyString($placeholder)) {
 49:             $attributes['placeholder'] = $placeholder;
 50:         }
 51: 
 52:         if (Quform::isNonEmptyString($this->config('autocomplete'))) {
 53:             $attributes['autocomplete'] = $this->config('autocomplete');
 54:         }
 55: 
 56:         if (Quform::isNonEmptyString($this->config('maxLength'))) {
 57:             $attributes['maxlength'] = $this->config('maxLength');
 58:         }
 59: 
 60:         if ($this->config('readOnly')) {
 61:             $attributes['readonly'] = true;
 62:         }
 63: 
 64:         $attributes = apply_filters('quform_field_attributes', $attributes, $this, $this->form, $context);
 65:         $attributes = apply_filters('quform_field_attributes_' . $this->getIdentifier(), $attributes, $this, $this->form, $context);
 66: 
 67:         return $attributes;
 68:     }
 69: 
 70:     /**
 71:      * Get the classes for the field
 72:      *
 73:      * @param   array  $context
 74:      * @return  array
 75:      */
 76:     protected function getFieldClasses(array $context = array())
 77:     {
 78:         $classes = array(
 79:             'quform-field',
 80:             'quform-field-textarea',
 81:             sprintf('quform-field-%s', $this->getIdentifier())
 82:         );
 83: 
 84:         if ($this->form->config('tooltipsEnabled') && Quform::isNonEmptyString($this->config('tooltip')) && Quform::get($context, 'tooltipType') == 'field') {
 85:             $classes[] = sprintf('quform-tooltip-%s', Quform::get($context, 'tooltipEvent'));
 86:         }
 87: 
 88:         if (Quform::isNonEmptyString($this->config('customClass'))) {
 89:             $classes[] = $this->config('customClass');
 90:         }
 91: 
 92:         $classes = apply_filters('quform_field_classes', $classes, $this, $this->form, $context);
 93:         $classes = apply_filters('quform_field_classes_' . $this->getIdentifier(), $classes, $this, $this->form, $context);
 94: 
 95:         return $classes;
 96:     }
 97: 
 98:     /**
 99:      * Get the HTML for the field
100:      *
101:      * @param   array   $context
102:      * @return  string
103:      */
104:     protected function getFieldHtml(array $context = array())
105:     {
106:         if ($this->config('enableEditor')) {
107:             ob_start();
108: 
109:             $settings = apply_filters('quform_textarea_editor_settings', array());
110:             $settings = apply_filters('quform_textarea_editor_settings_' . $this->getIdentifier(), $settings);
111:             $settings['textarea_name'] = $this->getFullyQualifiedName();
112: 
113:             wp_editor($this->getValue(), $this->getUniqueId(), $settings);
114: 
115:             return ob_get_clean();
116:         }
117: 
118:         return Quform::getHtmlTag('textarea', $this->getFieldAttributes($context), Quform::escape($this->getValue()));
119:     }
120: 
121:     /**
122:      * Get the field HTML when editing
123:      *
124:      * @return string
125:      */
126:     public function getEditFieldHtml()
127:     {
128:         return $this->getFieldHtml();
129:     }
130: 
131:     /**
132:      * Render the CSS for this element
133:      *
134:      * @param   array   $context
135:      * @return  string
136:      */
137:     protected function renderCss(array $context = array())
138:     {
139:         $css = parent::renderCss($context);
140: 
141:         if ($context['fieldWidth'] == 'custom' && Quform::isNonEmptyString($context['fieldWidthCustom'])) {
142:             $css .= sprintf('.quform-input-textarea.quform-input-%s { width: %s; }', $this->getIdentifier(), Quform::addCssUnit($context['fieldWidthCustom']));
143:             $css .= sprintf('.quform-inner-%s > .quform-error > .quform-error-inner { float: left; min-width: %s; }', $this->getIdentifier(), Quform::addCssUnit($context['fieldWidthCustom']));
144:         }
145: 
146:         return $css;
147:     }
148: 
149:     /**
150:      * Get the default element configuration
151:      *
152:      * @param   string|null  $key  Get the config by key, if omitted the full config is returned
153:      * @return  array
154:      */
155:     public static function getDefaultConfig($key = null)
156:     {
157:         $config = apply_filters('quform_default_config_textarea', array(
158:             // Basic
159:             'label' => __('Untitled', 'quform'),
160:             'description' => '',
161:             'descriptionAbove' => '',
162:             'required' => false,
163: 
164:             // Styles
165:             'labelIcon' => '',
166:             'fieldIconLeft' => '',
167:             'fieldIconRight' => '',
168:             'fieldSize' => 'inherit',
169:             'fieldWidth' => 'inherit',
170:             'fieldWidthCustom' => '',
171:             'enableEditor' => false,
172:             'customClass' => '',
173:             'customElementClass' => '',
174:             'styles' => array(),
175: 
176:             // Labels
177:             'placeholder' => '',
178:             'subLabel' => '',
179:             'subLabelAbove' => '',
180:             'adminLabel' => '',
181:             'tooltip' => '',
182:             'tooltipType' => 'inherit',
183:             'tooltipEvent' => 'inherit',
184:             'labelPosition' => 'inherit',
185:             'labelWidth' => '',
186: 
187:             // Logic
188:             'logicEnabled' => false,
189:             'logicAction' => true,
190:             'logicMatch' => 'all',
191:             'logicRules' => array(),
192: 
193:             // Data
194:             'defaultValue' => '',
195:             'dynamicDefaultValue' => false,
196:             'dynamicKey' => '',
197:             'autocomplete' => '',
198:             'maxLength' => '',
199:             'readOnly' => false,
200:             'showInEmail' => true,
201:             'saveToDatabase' => true,
202: 
203:             // Advanced
204:             'visibility' => '',
205:             'filters' => array(array('type' => 'trim')),
206:             'validators' => array(),
207: 
208:             // Translations
209:             'messageRequired' => '',
210:             'messageLengthTooLong' => ''
211:         ));
212: 
213:         $config['type'] = 'textarea';
214: 
215:         if (Quform::isNonEmptyString($key)) {
216:             return Quform::get($config, $key);
217:         }
218: 
219:         return $config;
220:     }
221: }
222: 
API documentation generated by ApiGen