| 1 | <?php |
||
| 24 | class AdminPageFramework_Message { |
||
|
1 ignored issue
–
show
|
|||
| 25 | |||
| 26 | /** |
||
| 27 | * Stores the framework's messages. |
||
| 28 | * |
||
| 29 | * @since 2.0.0 |
||
| 30 | * @since 3.1.3 No item is defined by default but done on the fly per request. The below array structure is kept for backward compatibility. |
||
| 31 | * @remark The user may modify this property directly. |
||
| 32 | */ |
||
| 33 | public $aMessages = array(); |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Stores default translated items. |
||
| 37 | * |
||
| 38 | * @remark These items should be accessed only when its label needs to be displayed. |
||
| 39 | * So the translation method `__()` only gets executed for one file. |
||
| 40 | * |
||
| 41 | * Consider the difference between the two. |
||
| 42 | * <code> |
||
| 43 | * $_aTranslations = array( |
||
| 44 | * 'foo' => __( 'Foo', 'admin-page-framework' ), |
||
| 45 | * 'bar' => __( 'Bar', 'admin-page-framework' ), |
||
| 46 | * ... more 100 items |
||
| 47 | * ) |
||
| 48 | * return isset( $_aTranslations[ $sKey ] ) ? $_aTranslations[ $sKey ] : ''; |
||
| 49 | * </code> |
||
| 50 | * |
||
| 51 | * <code> |
||
| 52 | * $_aTranslations = array( |
||
| 53 | * 'foo' => 'Foo', |
||
| 54 | * 'bar' => 'Bar', |
||
| 55 | * ... more 100 items |
||
| 56 | * ) |
||
| 57 | * return isset( $_aTranslations[ $sKey ] ) |
||
| 58 | * ? __( $_aTranslations[ $sKey ], $sUserSetTextdomain ) |
||
| 59 | * : ''; |
||
| 60 | * </code> |
||
| 61 | * @since 3.5.3 |
||
| 62 | */ |
||
| 63 | public $aDefaults = array( |
||
| 64 | |||
| 65 | // AdminPageFramework |
||
| 66 | 'option_updated' => 'The options have been updated.', |
||
| 67 | 'option_cleared' => 'The options have been cleared.', |
||
| 68 | 'export' => 'Export', |
||
| 69 | 'export_options' => 'Export Options', |
||
| 70 | 'import_options' => 'Import', |
||
| 71 | 'import_options' => 'Import Options', |
||
| 72 | 'submit' => 'Submit', |
||
| 73 | 'import_error' => 'An error occurred while uploading the import file.', |
||
| 74 | 'uploaded_file_type_not_supported' => 'The uploaded file type is not supported: %1$s', |
||
| 75 | 'could_not_load_importing_data' => 'Could not load the importing data.', |
||
| 76 | 'imported_data' => 'The uploaded file has been imported.', |
||
| 77 | 'not_imported_data' => 'No data could be imported.', |
||
| 78 | 'upload_image' => 'Upload Image', |
||
| 79 | 'use_this_image' => 'Use This Image', |
||
| 80 | 'insert_from_url' => 'Insert from URL', |
||
| 81 | 'reset_options' => 'Are you sure you want to reset the options?', |
||
| 82 | 'confirm_perform_task' => 'Please confirm your action.', |
||
| 83 | 'specified_option_been_deleted' => 'The specified options have been deleted.', |
||
| 84 | 'nonce_verification_failed' => 'A problem occurred while processing the form data. Please try again.', |
||
| 85 | 'check_max_input_vars' => 'Not all form fields could not be sent. Please check your server settings of PHP <code>max_input_vars</code> and consult the server administrator to increase the value. <code>max input vars</code>: %1$s. <code>$_POST</code> count: %2$s', // 3.5.11+ |
||
| 86 | 'send_email' => 'Is it okay to send the email?', // 3.3.0+ |
||
| 87 | 'email_sent' => 'The email has been sent.', // 3.3.0+, 3.3.5+ deprecated |
||
| 88 | 'email_scheduled' => 'The email has been scheduled.', // 3.3.5+ |
||
| 89 | 'email_could_not_send' => 'There was a problem sending the email', // 3.3.0+ |
||
| 90 | |||
| 91 | // AdminPageFramework_PostType |
||
| 92 | 'title' => 'Title', |
||
| 93 | 'author' => 'Author', |
||
| 94 | 'categories' => 'Categories', |
||
| 95 | 'tags' => 'Tags', |
||
| 96 | 'comments' => 'Comments', |
||
| 97 | 'date' => 'Date', |
||
| 98 | 'show_all' => 'Show All', |
||
| 99 | 'show_all_authors' => 'Show all Authors', // 3.5.10+ |
||
| 100 | |||
| 101 | // AdminPageFramework_Link_Base |
||
| 102 | 'powered_by' => 'Powered by', |
||
| 103 | |||
| 104 | // AdminPageFramework_Link_Page |
||
| 105 | 'settings' => 'Settings', |
||
| 106 | |||
| 107 | // AdminPageFramework_Link_PostType |
||
| 108 | 'manage' => 'Manage', |
||
| 109 | |||
| 110 | // AdminPageFramework_FieldType_{...} |
||
| 111 | 'select_image' => 'Select Image', |
||
| 112 | 'upload_file' => 'Upload File', |
||
| 113 | 'use_this_file' => 'Use This File', |
||
| 114 | 'select_file' => 'Select File', |
||
| 115 | 'remove_value' => 'Remove Value', // 3.2.0+ |
||
| 116 | 'select_all' => 'Select All', // 3.3.0+ |
||
| 117 | 'select_none' => 'Select None', // 3.3.0+ |
||
| 118 | 'no_term_found' => 'No term found.', // 3.3.2+ |
||
| 119 | |||
| 120 | // AdminPageFramework_Form_View___Script_{...} |
||
| 121 | 'select' => 'Select', // 3.4.2+ |
||
| 122 | 'insert' => 'Insert', // 3.4.2+ |
||
| 123 | 'use_this' => 'Use This', // 3.4.2+ |
||
| 124 | 'return_to_library' => 'Return to Library', // 3.4.2+ |
||
| 125 | |||
| 126 | // AdminPageFramework_PageLoadInfo_Base |
||
| 127 | 'queries_in_seconds' => '%1$s queries in %2$s seconds.', |
||
| 128 | 'out_of_x_memory_used' => '%1$s out of %2$s MB (%3$s) memory used.', |
||
| 129 | 'peak_memory_usage' => 'Peak memory usage %1$s MB.', |
||
| 130 | 'initial_memory_usage' => 'Initial memory usage %1$s MB.', |
||
| 131 | |||
| 132 | // AdminPageFramework_FormField |
||
| 133 | 'allowed_maximum_number_of_fields' => 'The allowed maximum number of fields is {0}.', |
||
| 134 | 'allowed_minimum_number_of_fields' => 'The allowed minimum number of fields is {0}.', |
||
| 135 | 'add' => 'Add', |
||
| 136 | 'remove' => 'Remove', |
||
| 137 | |||
| 138 | // AdminPageFramework_FormPart_Table |
||
| 139 | 'allowed_maximum_number_of_sections' => 'The allowed maximum number of sections is {0}', |
||
| 140 | 'allowed_minimum_number_of_sections' => 'The allowed minimum number of sections is {0}', |
||
| 141 | 'add_section' => 'Add Section', |
||
| 142 | 'remove_section' => 'Remove Section', |
||
| 143 | 'toggle_all' => 'Toggle All', |
||
| 144 | 'toggle_all_collapsible_sections' => 'Toggle all collapsible sections', |
||
| 145 | |||
| 146 | // AdminPageFramework_FieldType_reset 3.3.0+ |
||
| 147 | 'reset' => 'Reset', |
||
| 148 | |||
| 149 | // AdminPageFramework_FieldType_system 3.5.3+ |
||
| 150 | 'yes' => 'Yes', |
||
| 151 | 'no' => 'No', |
||
| 152 | 'on' => 'On', |
||
| 153 | 'off' => 'Off', |
||
| 154 | 'enabled' => 'Enabled', |
||
| 155 | 'disabled' => 'Disabled', |
||
| 156 | 'supported' => 'Supported', |
||
| 157 | 'not_supported' => 'Not Supported', |
||
| 158 | 'functional' => 'Functional', |
||
| 159 | 'not_functional' => 'Not Functional', |
||
| 160 | 'too_long' => 'Too Long', |
||
| 161 | 'acceptable' => 'Acceptable', |
||
| 162 | 'no_log_found' => 'No log found.', |
||
| 163 | |||
| 164 | // DEVVER+ - accessed from `AdminPageFramework_Form` |
||
| 165 | 'method_called_too_early' => 'The method is called too early.', |
||
| 166 | |||
| 167 | // DEVVER+ - accessed from `AdminPageFramework_Form_View___DebugInfo` |
||
| 168 | 'debug_info' => 'Debug Info', |
||
| 169 | |||
| 170 | 'click_to_expand' => 'Click here to expand to view the contents.', |
||
| 171 | 'click_to_collapse' => 'Click here to collapse the contents.', |
||
| 172 | |||
| 173 | // DEVVER+ - displayed while the page laods |
||
| 174 | 'loading' => 'Loading...', |
||
| 175 | 'please_enable_javascript' => 'Please enable JavaScript for better experience.' |
||
| 176 | ); |
||
| 177 | |||
| 178 | /** |
||
| 179 | * Stores the text domain. |
||
| 180 | * @since 3.x |
||
| 181 | * @since 3.5.0 Declared as a default property. |
||
| 182 | */ |
||
| 183 | protected $_sTextDomain = 'admin-page-framework'; |
||
| 184 | |||
| 185 | /** |
||
| 186 | * Stores the self instance by text domain. |
||
| 187 | * @internal |
||
| 188 | * @since 3.2.0 |
||
| 189 | */ |
||
| 190 | static private $_aInstancesByTextDomain = array(); |
||
| 191 | |||
| 192 | /** |
||
| 193 | * Ensures that only one instance of this class object exists. ( no multiple instances of this object ) |
||
| 194 | * |
||
| 195 | * @since 2.1.6 |
||
| 196 | * @since 3.2.0 Changed it to create an instance per text domain basis. |
||
| 197 | * @remark This class should be instantiated via this method. |
||
| 198 | */ |
||
| 199 | public static function getInstance( $sTextDomain='admin-page-framework' ) { |
||
| 208 | /** |
||
| 209 | * Ensures that only one instance of this class object exists. ( no multiple instances of this object ) |
||
| 210 | * @deprecated 3.2.0 |
||
| 211 | */ |
||
| 212 | public static function instantiate( $sTextDomain='admin-page-framework' ) { |
||
| 215 | |||
| 216 | /** |
||
| 217 | * Sets up properties. |
||
| 218 | */ |
||
| 219 | public function __construct( $sTextDomain='admin-page-framework' ) { |
||
| 232 | |||
| 233 | /** |
||
| 234 | * Returns the set text domain string. |
||
| 235 | * |
||
| 236 | * This is used from field type and input classes to display deprecated admin errors/ |
||
| 237 | * |
||
| 238 | * @since 3.3.3 |
||
| 239 | */ |
||
| 240 | public function getTextDomain() { |
||
| 243 | |||
| 244 | /** |
||
| 245 | * Sets a message for the given key. |
||
| 246 | * @since DEVVER |
||
| 247 | */ |
||
| 248 | public function set( $sKey, $sValue ) { |
||
| 251 | |||
| 252 | /** |
||
| 253 | * Returns the framework system message by key. |
||
| 254 | * |
||
| 255 | * @remark An alias of the __() method. |
||
| 256 | * @since 3.2.0 |
||
| 257 | * @since DEVVER If no key is specified, return the entire mesage array. |
||
| 258 | * @return string|array |
||
| 259 | */ |
||
| 260 | public function get( $sKey='' ) { |
||
| 268 | /** |
||
| 269 | * Returns the all registered messag items. |
||
| 270 | * By default, no item is set for a performance reason; the message is retuned on the fly. |
||
| 271 | * So all the keys must be iterated to get all the values. |
||
| 272 | * @since DEVVER |
||
| 273 | * @return array |
||
| 274 | */ |
||
| 275 | private function _getAllMessages() { |
||
| 282 | |||
| 283 | /** |
||
| 284 | * Echoes the framework system message by key. |
||
| 285 | * @remark An alias of the _e() method. |
||
| 286 | * @since 3.2.0 |
||
| 287 | */ |
||
| 288 | public function output( $sKey ) { |
||
| 291 | |||
| 292 | /** |
||
| 293 | * Returns the framework system message by key. |
||
| 294 | * @since 2.x |
||
| 295 | * @deprecated 3.2.0 |
||
| 296 | */ |
||
| 297 | public function __( $sKey ) { |
||
| 300 | /** |
||
| 301 | * Echoes the framework system message by key. |
||
| 302 | * @since 2.x |
||
| 303 | * @deprecated 3.2.0 |
||
| 304 | */ |
||
| 305 | public function _e( $sKey ) { |
||
| 308 | |||
| 309 | /** |
||
| 310 | * Responds to a request to an undefined property. |
||
| 311 | * |
||
| 312 | * @since 3.1.3 |
||
| 313 | * @return string |
||
| 314 | */ |
||
| 315 | public function __get( $sPropertyName ) { |
||
| 318 | |||
| 319 | |||
| 320 | /** |
||
| 321 | * A dummy method just lists translation items to be parsed by translation programs such as POEdit. |
||
| 322 | * |
||
| 323 | * @since 3.5.3 |
||
| 324 | */ |
||
| 325 | private function __doDummy() { |
||
| 413 | |||
| 414 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.