File tree 2 files changed +13
-4
lines changed
2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -50,11 +50,11 @@ public function getError($languageKey = NULL) {
50
50
return isset ($ this ->errors [$ languageKey ]) ? I18N ::_ ($ this ->errors [$ languageKey ]) : NULL ;
51
51
}
52
52
53
- public static function getPostValues ($ name , $ languages ) {
53
+ public static function getPostValues ($ name , $ languages, $ filter = NULL ) {
54
54
$ rc = array ();
55
55
$ request = \TgUtils \Request::getRequest ();
56
56
foreach ($ languages AS $ key => $ label ) {
57
- $ rc [$ key ] = $ request ->getPostParam ($ name .'- ' .$ key );
57
+ $ rc [$ key ] = $ request ->getPostParam ($ name .'- ' .$ key, NULL , $ filter );
58
58
if ($ rc [$ key ] != NULL ) $ rc [$ key ] = trim ($ rc [$ key ]);
59
59
}
60
60
return $ rc ;
Original file line number Diff line number Diff line change 5
5
use TgLog \Log ;
6
6
use TgLog \Error ;
7
7
use WebApp \Component \Alert ;
8
+ use TgUtils \StringFilters ;
8
9
9
10
class RestPage extends Page {
10
11
@@ -110,10 +111,18 @@ protected function getJsonBody() {
110
111
return $ this ->jsonBody ;
111
112
}
112
113
113
- protected function getJsonParam ($ key , $ default = NULL ) {
114
+ /**
115
+ * Returns the JSON parameter with the given key.
116
+ * @param string $key - the object attribute of root JSON object
117
+ * @param mixed $default - the default value if not available
118
+ * @param StringFilter $filter - the filter to apply for the param (NULL will mean NOHTML)
119
+ * @return the filtered value or default value.
120
+ */
121
+ protected function getJsonParam ($ key , $ default = NULL , $ filter = NULL ) {
114
122
$ obj = $ this ->getJsonBody ();
115
123
if (!isset ($ obj ->$ key )) return $ default ;
116
- return $ obj ->$ key ;
124
+ if ($ filter == NULL ) $ filter = StringFilters::$ NO_HTML ;
125
+ return $ filter ->filter ($ obj ->$ key );
117
126
}
118
127
}
119
128
You can’t perform that action at this time.
0 commit comments