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: abstract class Quform_Validator_Abstract implements Quform_Validator_Interface
  7: {
  8:     /**
  9:      * Last failure error message
 10:      *
 11:      * @var string
 12:      */
 13:     protected $message = '';
 14: 
 15:     /**
 16:      * The validator settings
 17:      *
 18:      * @var array
 19:      */
 20:     protected $config = array();
 21: 
 22:     /**
 23:      * @param array $options
 24:      */
 25:     public function __construct(array $options = array())
 26:     {
 27:         $this->setConfig($options);
 28:     }
 29: 
 30:     /**
 31:      * Set the error message
 32:      *
 33:      * @param string $message
 34:      */
 35:     protected function setMessage($message)
 36:     {
 37:         $this->message = $message;
 38:     }
 39: 
 40:     /**
 41:      * Get the last failure error message
 42:      *
 43:      * @return string
 44:      */
 45:     public function getMessage()
 46:     {
 47:         return $this->message;
 48:     }
 49: 
 50:     /**
 51:      * Clears the error message
 52:      *
 53:      * @return $this
 54:      */
 55:     public function reset()
 56:     {
 57:         $this->message = '';
 58: 
 59:         return $this;
 60:     }
 61: 
 62:     /**
 63:      * Create and set the error message from a template
 64:      *
 65:      * @param  string  $key         The key of the message template
 66:      * @param  array   $variables   Variables that can be replaced in the error message
 67:      */
 68:     protected function error($key, array $variables = array())
 69:     {
 70:         $this->message = $this->createMessage($key, $variables);
 71:     }
 72: 
 73:     /**
 74:      * Constructs and returns a validation failure message with the given message key
 75:      *
 76:      * If a translation exists for $key, the translation will be used
 77:      *
 78:      * @param   string  $key        The message template key
 79:      * @param   array   $variables  An array of variable keys and values for replacement
 80:      * @return  string
 81:      */
 82:     public function createMessage($key, array $variables = array())
 83:     {
 84:         $message = call_user_func(array(get_class($this), 'getMessageTemplates'), $key);
 85: 
 86:         if ($message === null) {
 87:             return '';
 88:         }
 89: 
 90:         $message = $this->getTranslation('messages.' . $key, $message);
 91: 
 92:         foreach ($variables as $variable => $value) {
 93:             $message = str_replace("%$variable%", $value, $message);
 94:         }
 95: 
 96:         return $message;
 97:     }
 98: 
 99:     /**
100:      * Returns the config value for the given $key
101:      *
102:      * @param   string|null  $key
103:      * @param   null|mixed   $default
104:      * @return  mixed        The config value or $default if not set
105:      */
106:     public function config($key = null, $default = null)
107:     {
108:         $value = Quform::get($this->config, $key, $default);
109: 
110:         if ($value === null) {
111:             $value = Quform::get(call_user_func(array(get_class($this), 'getDefaultConfig')), $key, $default);
112:         }
113: 
114:         return $value;
115:     }
116: 
117:     /**
118:      * Set the config value for the given $key or multiple values using an array
119:      *
120:      * @param   string|array  $key    Key or array of key/values
121:      * @param   mixed         $value  Value or null if $key is array
122:      * @return  $this
123:      */
124:     public function setConfig($key, $value = null)
125:     {
126:         if (is_array($key)) {
127:             foreach ($key as $k => $v) {
128:                 $this->config[$k] = $v;
129:             }
130:         } else {
131:             $this->config[$key] = $value;
132:         }
133: 
134:         return $this;
135:     }
136: 
137:     /**
138:      * @param   string  $key
139:      * @param   string  $default
140:      * @return  string
141:      */
142:     public function getTranslation($key, $default = '')
143:     {
144:         $string = $this->config($key);
145: 
146:         if (Quform::isNonEmptyString($string)) {
147:             return $string;
148:         }
149: 
150:         return $default;
151:     }
152: }
153: 
API documentation generated by ApiGen