Index: branches/RL2/extensions/Gadgets/Gadgets.i18n.php |
— | — | @@ -78,6 +78,11 @@ |
79 | 79 | 'gadgetmanager-modifylink-tooltip' => 'Modify this gadget', |
80 | 80 | 'gadgetmanager-deletelink' => 'delete', |
81 | 81 | 'gadgetmanager-deletelink-tooltip' => 'Delete ths gadget', |
| 82 | + |
| 83 | + # Validation error messages |
| 84 | + 'gadget-validate-invalidjson' => 'The gadget definition page contents are not a valid JSON object.', |
| 85 | + 'gadget-validate-notset' => 'The property $1 is not set.', |
| 86 | + 'gadget-validate-wrongtype' => 'The property $1 must be of type $2 instead of $3.', |
82 | 87 | |
83 | 88 | # Permissions |
84 | 89 | 'gadgets-cant-create' => 'You do not have the right to create new Gadgets.', |
— | — | @@ -127,7 +132,11 @@ |
128 | 133 | * $2 is a link to a user page with a user name as link text, followed by a series of related links |
129 | 134 | * $3 is the date |
130 | 135 | * $4 is the time |
131 | | -* $5 is the user name which can be used with GENDER' |
| 136 | +* $5 is the user name which can be used with GENDER', |
| 137 | + 'gadget-validate-notset' => '$1 is the name of the property, e.g. settings.rights .', |
| 138 | + 'gadget-validate-wrongtype' => '* $1 is the name of the property, e.g. settings.rights or module.messages[3]. |
| 139 | +* $2 is the type that this property is expected to have |
| 140 | +* $3 is the type it actually had', |
132 | 141 | ); |
133 | 142 | |
134 | 143 | /** Afrikaans (Afrikaans) |
Index: branches/RL2/extensions/Gadgets/backend/Gadget.php |
— | — | @@ -69,13 +69,9 @@ |
70 | 70 | * @return Status object with error message if applicable |
71 | 71 | */ |
72 | 72 | public static function validatePropertiesArray( $properties ) { |
73 | | - if ( $properties === null ) { |
| 73 | + if ( $properties === null || !is_array( $properties ) ) { |
74 | 74 | return Status::newFatal( 'gadgets-validate-invalidjson' ); |
75 | 75 | } |
76 | | - if ( !is_array( $properties ) ) { |
77 | | - return Status::newFatal( 'gadgets-validate-notanobject', gettype( $properties ) ); // Use JSON terminology |
78 | | - } |
79 | | - |
80 | 76 | foreach ( self::$propertyValidation as $property => $validation ) { |
81 | 77 | $path = explode( '.', $property ); |
82 | 78 | $val = $properties; |