@@ -26,19 +26,19 @@ discard block |
||
26 | 26 | public static function call(OkapiRequest $request) |
27 | 27 | { |
28 | 28 | $issue_id = $request->get_parameter('issue_id'); |
29 | - if (!$issue_id) |
|
30 | - throw new ParamMissing('issue_id'); |
|
31 | - if ((!preg_match("/^[0-9]+$/", $issue_id)) || (strlen($issue_id) > 6)) |
|
32 | - throw new InvalidParam('issue_id'); |
|
29 | + if (!$issue_id) { |
|
30 | + throw new ParamMissing('issue_id'); |
|
31 | + } |
|
32 | + if ((!preg_match("/^[0-9]+$/", $issue_id)) || (strlen($issue_id) > 6)) { |
|
33 | + throw new InvalidParam('issue_id'); |
|
34 | + } |
|
33 | 35 | |
34 | 36 | $cache_key = "apiref/issue#".$issue_id; |
35 | 37 | $result = Cache::get($cache_key); |
36 | - if ($result == null) |
|
37 | - { |
|
38 | + if ($result == null) { |
|
38 | 39 | # Download the number of comments from GitHub Issue Tracker. |
39 | 40 | |
40 | - try |
|
41 | - { |
|
41 | + try { |
|
42 | 42 | $extra_headers = array(); |
43 | 43 | $extra_headers[] = "Accept: application/vnd.github.v3.html+json"; |
44 | 44 | $extra_headers[] = "User-Agent: https://github.com/opencaching/okapi/"; |
@@ -55,9 +55,7 @@ discard block |
||
55 | 55 | $context = stream_context_create($opts); |
56 | 56 | $json = file_get_contents("https://api.github.com/repos/opencaching/okapi/issues/$issue_id", |
57 | 57 | false, $context); |
58 | - } |
|
59 | - catch (ErrorException $e) |
|
60 | - { |
|
58 | + } catch (ErrorException $e) { |
|
61 | 59 | throw new BadRequest("Sorry, we could not retrieve issue stats from the GitHub site. ". |
62 | 60 | "This is probably due to a temporary connection problem. Try again later or contact ". |
63 | 61 | "us if this seems permanent."); |
@@ -185,14 +185,14 @@ |
||
185 | 185 | if (($include_list === null) && (count($exclude_list) == 0)) |
186 | 186 | { |
187 | 187 | $arg['description'] = "<i>Inherited from <a href='".$referenced_method_info['ref_url']. |
188 | - "#arg_". $arg['name'] . "'>".$referenced_method_info['name']."</a> method.</i>"; |
|
188 | + "#arg_".$arg['name']."'>".$referenced_method_info['name']."</a> method.</i>"; |
|
189 | 189 | } |
190 | 190 | elseif ( |
191 | 191 | (($include_list === null) || in_array($arg['name'], $include_list)) |
192 | 192 | && (!in_array($arg['name'], $exclude_list)) |
193 | 193 | ) { |
194 | 194 | $arg['description'] = "<i>Same as in the <a href='".$referenced_method_info['ref_url']. |
195 | - "#arg_". $arg['name'] . "'>".$referenced_method_info['name']."</a> method.</i>"; |
|
195 | + "#arg_".$arg['name']."'>".$referenced_method_info['name']."</a> method.</i>"; |
|
196 | 196 | } else { |
197 | 197 | continue; |
198 | 198 | } |
@@ -102,12 +102,10 @@ discard block |
||
102 | 102 | case 'methodretref': |
103 | 103 | $elements = explode('#', $arr[1]); |
104 | 104 | $result = ''; |
105 | - if ($elements[0] != '') |
|
106 | - { |
|
105 | + if ($elements[0] != '') { |
|
107 | 106 | $result .= Settings::get('SITE_URL')."okapi/".$elements[0].'.html'; |
108 | 107 | } |
109 | - if (count($elements) > 1) |
|
110 | - { |
|
108 | + if (count($elements) > 1) { |
|
111 | 109 | $result .= '#'; |
112 | 110 | switch ($plugin_name) { |
113 | 111 | case 'methodargref': |
@@ -128,15 +126,19 @@ discard block |
||
128 | 126 | public static function call(OkapiRequest $request) |
129 | 127 | { |
130 | 128 | $methodname = $request->get_parameter('name'); |
131 | - if (!$methodname) |
|
132 | - throw new ParamMissing('name'); |
|
133 | - if (!preg_match("#^services/[0-9a-z_/]*$#", $methodname)) |
|
134 | - throw new InvalidParam('name'); |
|
135 | - if (!OkapiServiceRunner::exists($methodname)) |
|
136 | - throw new InvalidParam('name', "Method does not exist: '$methodname'."); |
|
129 | + if (!$methodname) { |
|
130 | + throw new ParamMissing('name'); |
|
131 | + } |
|
132 | + if (!preg_match("#^services/[0-9a-z_/]*$#", $methodname)) { |
|
133 | + throw new InvalidParam('name'); |
|
134 | + } |
|
135 | + if (!OkapiServiceRunner::exists($methodname)) { |
|
136 | + throw new InvalidParam('name', "Method does not exist: '$methodname'."); |
|
137 | + } |
|
137 | 138 | $options = OkapiServiceRunner::options($methodname); |
138 | - if (!isset($options['min_auth_level'])) |
|
139 | - throw new Exception("Method $methodname is missing a required 'min_auth_level' option!"); |
|
139 | + if (!isset($options['min_auth_level'])) { |
|
140 | + throw new Exception("Method $methodname is missing a required 'min_auth_level' option!"); |
|
141 | + } |
|
140 | 142 | $docs = simplexml_load_string(OkapiServiceRunner::docs($methodname)); |
141 | 143 | $exploded = explode("/", $methodname); |
142 | 144 | $result = array( |
@@ -149,45 +151,49 @@ discard block |
||
149 | 151 | 'oauth_token' => $options['min_auth_level'] >= 3, |
150 | 152 | ) |
151 | 153 | ); |
152 | - if (!$docs->brief) |
|
153 | - throw new Exception("Missing <brief> element in the $methodname.xml file."); |
|
154 | - if ($docs->brief != self::get_inner_xml($docs->brief)) |
|
155 | - throw new Exception("The <brief> element may not contain HTML markup ($methodname.xml)."); |
|
156 | - if (strlen($docs->brief) > 80) |
|
157 | - throw new Exception("The <brief> description may not be longer than 80 characters ($methodname.xml)."); |
|
158 | - if (strpos($docs->brief, "\n") !== false) |
|
159 | - throw new Exception("The <brief> element may not contain new-lines ($methodname.xml)."); |
|
160 | - if (substr(trim($docs->brief), -1) == '.') |
|
161 | - throw new Exception("The <brief> element should not end with a dot ($methodname.xml)."); |
|
154 | + if (!$docs->brief) { |
|
155 | + throw new Exception("Missing <brief> element in the $methodname.xml file."); |
|
156 | + } |
|
157 | + if ($docs->brief != self::get_inner_xml($docs->brief)) { |
|
158 | + throw new Exception("The <brief> element may not contain HTML markup ($methodname.xml)."); |
|
159 | + } |
|
160 | + if (strlen($docs->brief) > 80) { |
|
161 | + throw new Exception("The <brief> description may not be longer than 80 characters ($methodname.xml)."); |
|
162 | + } |
|
163 | + if (strpos($docs->brief, "\n") !== false) { |
|
164 | + throw new Exception("The <brief> element may not contain new-lines ($methodname.xml)."); |
|
165 | + } |
|
166 | + if (substr(trim($docs->brief), -1) == '.') { |
|
167 | + throw new Exception("The <brief> element should not end with a dot ($methodname.xml)."); |
|
168 | + } |
|
162 | 169 | $result['brief_description'] = self::get_inner_xml($docs->brief); |
163 | - if ($docs->{'issue-id'}) |
|
164 | - $result['issue_id'] = (string)$docs->{'issue-id'}; |
|
165 | - else |
|
166 | - $result['issue_id'] = null; |
|
167 | - if (!$docs->desc) |
|
168 | - throw new Exception("Missing <desc> element in the $methodname.xml file."); |
|
170 | + if ($docs->{'issue-id'}) { |
|
171 | + $result['issue_id'] = (string)$docs->{'issue-id'}; |
|
172 | + } else { |
|
173 | + $result['issue_id'] = null; |
|
174 | + } |
|
175 | + if (!$docs->desc) { |
|
176 | + throw new Exception("Missing <desc> element in the $methodname.xml file."); |
|
177 | + } |
|
169 | 178 | $result['description'] = self::get_inner_xml($docs->desc); |
170 | 179 | $result['arguments'] = array(); |
171 | 180 | foreach ($docs->req as $arg) { $result['arguments'][] = self::arg_desc($arg); } |
172 | 181 | foreach ($docs->opt as $arg) { $result['arguments'][] = self::arg_desc($arg); } |
173 | - foreach ($docs->{'import-params'} as $import_desc) |
|
174 | - { |
|
182 | + foreach ($docs->{'import-params'} as $import_desc) { |
|
175 | 183 | $attrs = $import_desc->attributes(); |
176 | 184 | $referenced_methodname = $attrs['method']; |
177 | 185 | $referenced_method_info = OkapiServiceRunner::call('services/apiref/method', |
178 | 186 | new OkapiInternalRequest(new OkapiInternalConsumer(), null, array('name' => $referenced_methodname))); |
179 | 187 | $include_list = isset($attrs['params']) ? explode("|", $attrs['params']) : null; |
180 | 188 | $exclude_list = isset($attrs['except']) ? explode("|", $attrs['except']) : array(); |
181 | - foreach ($referenced_method_info['arguments'] as $arg) |
|
182 | - { |
|
183 | - if ($arg['class'] == 'common-formatting') |
|
184 | - continue; |
|
185 | - if (($include_list === null) && (count($exclude_list) == 0)) |
|
186 | - { |
|
189 | + foreach ($referenced_method_info['arguments'] as $arg) { |
|
190 | + if ($arg['class'] == 'common-formatting') { |
|
191 | + continue; |
|
192 | + } |
|
193 | + if (($include_list === null) && (count($exclude_list) == 0)) { |
|
187 | 194 | $arg['description'] = "<i>Inherited from <a href='".$referenced_method_info['ref_url']. |
188 | 195 | "#arg_". $arg['name'] . "'>".$referenced_method_info['name']."</a> method.</i>"; |
189 | - } |
|
190 | - elseif ( |
|
196 | + } elseif ( |
|
191 | 197 | (($include_list === null) || in_array($arg['name'], $include_list)) |
192 | 198 | && (!in_array($arg['name'], $exclude_list)) |
193 | 199 | ) { |
@@ -200,8 +206,7 @@ discard block |
||
200 | 206 | $result['arguments'][] = $arg; |
201 | 207 | } |
202 | 208 | } |
203 | - if ($docs->{'common-format-params'}) |
|
204 | - { |
|
209 | + if ($docs->{'common-format-params'}) { |
|
205 | 210 | $result['arguments'][] = array( |
206 | 211 | 'name' => 'format', |
207 | 212 | 'is_required' => false, |
@@ -217,12 +222,14 @@ discard block |
||
217 | 222 | 'description' => "<i>Standard <a href='".Settings::get('SITE_URL')."okapi/introduction.html#common-formatting'>common formatting</a> argument.</i>" |
218 | 223 | ); |
219 | 224 | } |
220 | - foreach ($result['arguments'] as &$arg_ref) |
|
221 | - if ($arg_ref['is_deprecated']) |
|
225 | + foreach ($result['arguments'] as &$arg_ref) { |
|
226 | + if ($arg_ref['is_deprecated']) |
|
222 | 227 | $arg_ref['class'] .= " deprecated"; |
223 | - if (!$docs->returns) |
|
224 | - throw new Exception("Missing <returns> element in the $methodname.xml file. ". |
|
228 | + } |
|
229 | + if (!$docs->returns) { |
|
230 | + throw new Exception("Missing <returns> element in the $methodname.xml file. ". |
|
225 | 231 | "If your method does not return anything, you should document in nonetheless."); |
232 | + } |
|
226 | 233 | $result['returns'] = self::get_inner_xml($docs->returns); |
227 | 234 | return Okapi::formatted_response($request, $result); |
228 | 235 | } |
@@ -136,7 +136,7 @@ |
||
136 | 136 | throw new InvalidParam('name', "Method does not exist: '$methodname'."); |
137 | 137 | $options = OkapiServiceRunner::options($methodname); |
138 | 138 | if (!isset($options['min_auth_level'])) |
139 | - throw new Exception("Method $methodname is missing a required 'min_auth_level' option!"); |
|
139 | + throw new Exception("method $methodname is missing a required 'min_auth_level' option!"); |
|
140 | 140 | $docs = simplexml_load_string(OkapiServiceRunner::docs($methodname)); |
141 | 141 | $exploded = explode("/", $methodname); |
142 | 142 | $result = array( |
@@ -28,11 +28,9 @@ |
||
28 | 28 | sort($methodnames); |
29 | 29 | $cache_key = "api_ref/method_index#".md5(implode("#", $methodnames)); |
30 | 30 | $results = Cache::get($cache_key); |
31 | - if ($results == null) |
|
32 | - { |
|
31 | + if ($results == null) { |
|
33 | 32 | $results = array(); |
34 | - foreach ($methodnames as $methodname) |
|
35 | - { |
|
33 | + foreach ($methodnames as $methodname) { |
|
36 | 34 | $info = OkapiServiceRunner::call('services/apiref/method', new OkapiInternalRequest( |
37 | 35 | new OkapiInternalConsumer(), null, array('name' => $methodname))); |
38 | 36 | $results[] = array( |
@@ -26,8 +26,7 @@ |
||
26 | 26 | { |
27 | 27 | $cachekey = "apisrv/stats"; |
28 | 28 | $result = Cache::get($cachekey); |
29 | - if (!$result) |
|
30 | - { |
|
29 | + if (!$result) { |
|
31 | 30 | $result = array( |
32 | 31 | 'cache_count' => 0 + Db::select_value(" |
33 | 32 | select count(*) from caches where status in (1,2,3) |
@@ -113,7 +113,7 @@ |
||
113 | 113 | # Cache it for one day. Also, save a backup (valid for 30 days). |
114 | 114 | |
115 | 115 | Cache::set($cachekey, $results, 86400); |
116 | - Cache::set($backupkey, $results, 86400*30); |
|
116 | + Cache::set($backupkey, $results, 86400 * 30); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | return Okapi::formatted_response($request, $results); |
@@ -30,12 +30,10 @@ discard block |
||
30 | 30 | $cachekey = 'apisrv/installations'; |
31 | 31 | $backupkey = 'apisrv/installations-backup'; |
32 | 32 | $results = Cache::get($cachekey); |
33 | - if (!$results) |
|
34 | - { |
|
33 | + if (!$results) { |
|
35 | 34 | # Download the current list of OKAPI servers. |
36 | 35 | |
37 | - try |
|
38 | - { |
|
36 | + try { |
|
39 | 37 | $opts = array( |
40 | 38 | 'http' => array( |
41 | 39 | 'method' => "GET", |
@@ -49,14 +47,11 @@ discard block |
||
49 | 47 | if (!$doc) { |
50 | 48 | throw new ErrorException(); # just to get to the catch block |
51 | 49 | } |
52 | - } |
|
53 | - catch (ErrorException $e) |
|
54 | - { |
|
50 | + } catch (ErrorException $e) { |
|
55 | 51 | # GitHub failed on us. Try to respond with a backup list. |
56 | 52 | |
57 | 53 | $results = Cache::get($backupkey); |
58 | - if ($results) |
|
59 | - { |
|
54 | + if ($results) { |
|
60 | 55 | Cache::set($cachekey, $results, 12 * 3600); # so to retry no earlier than after 12 hours |
61 | 56 | return Okapi::formatted_response($request, $results); |
62 | 57 | } |
@@ -77,31 +72,32 @@ discard block |
||
77 | 72 | |
78 | 73 | $results = array(); |
79 | 74 | $i_was_included = false; |
80 | - foreach ($doc->installation as $inst) |
|
81 | - { |
|
75 | + foreach ($doc->installation as $inst) { |
|
82 | 76 | $site_url = (string)$inst[0]['site_url']; |
83 | - if ($inst[0]['okapi_base_url']) |
|
84 | - $okapi_base_url = (string)$inst[0]['okapi_base_url']; |
|
85 | - else |
|
86 | - $okapi_base_url = $site_url."okapi/"; |
|
87 | - if ($inst[0]['site_name']) |
|
88 | - $site_name = (string)$inst[0]['site_name']; |
|
89 | - else |
|
90 | - $site_name = Okapi::get_normalized_site_name($site_url); |
|
77 | + if ($inst[0]['okapi_base_url']) { |
|
78 | + $okapi_base_url = (string)$inst[0]['okapi_base_url']; |
|
79 | + } else { |
|
80 | + $okapi_base_url = $site_url."okapi/"; |
|
81 | + } |
|
82 | + if ($inst[0]['site_name']) { |
|
83 | + $site_name = (string)$inst[0]['site_name']; |
|
84 | + } else { |
|
85 | + $site_name = Okapi::get_normalized_site_name($site_url); |
|
86 | + } |
|
91 | 87 | $results[] = array( |
92 | 88 | 'site_url' => $site_url, |
93 | 89 | 'site_name' => $site_name, |
94 | 90 | 'okapi_base_url' => $okapi_base_url, |
95 | 91 | ); |
96 | - if ($site_url == Settings::get('SITE_URL')) |
|
97 | - $i_was_included = true; |
|
92 | + if ($site_url == Settings::get('SITE_URL')) { |
|
93 | + $i_was_included = true; |
|
94 | + } |
|
98 | 95 | } |
99 | 96 | |
100 | 97 | # If running on a local development installation, then include the local |
101 | 98 | # installation URL. |
102 | 99 | |
103 | - if (!$i_was_included) |
|
104 | - { |
|
100 | + if (!$i_was_included) { |
|
105 | 101 | $results[] = array( |
106 | 102 | 'site_url' => Settings::get('SITE_URL'), |
107 | 103 | 'site_name' => "DEVELSITE", |
@@ -49,24 +49,24 @@ |
||
49 | 49 | require_once('replicate_common.inc.php'); |
50 | 50 | |
51 | 51 | $data = Cache::get("last_fulldump"); |
52 | - if ($data == null) |
|
53 | - throw new BadRequest("No fulldump found. Try again later. If this doesn't help ". |
|
52 | + if ($data == null) { |
|
53 | + throw new BadRequest("No fulldump found. Try again later. If this doesn't help ". |
|
54 | 54 | "contact site administrator and/or OKAPI developers."); |
55 | + } |
|
55 | 56 | |
56 | 57 | # Check consumer's quota |
57 | 58 | |
58 | 59 | $please = $request->get_parameter('pleeaase'); |
59 | - if ($please != 'true') |
|
60 | - { |
|
60 | + if ($please != 'true') { |
|
61 | 61 | $not_good = 3 < self::count_calls($request->consumer->key, 30); |
62 | - if ($not_good) |
|
63 | - throw new BadRequest("Consumer's monthly quota exceeded. Try later or call with '&pleeaase=true'."); |
|
64 | - } |
|
65 | - else |
|
66 | - { |
|
62 | + if ($not_good) { |
|
63 | + throw new BadRequest("Consumer's monthly quota exceeded. Try later or call with '&pleeaase=true'."); |
|
64 | + } |
|
65 | + } else { |
|
67 | 66 | $not_good = 5 < self::count_calls($request->consumer->key, 1); |
68 | - if ($not_good) |
|
69 | - throw new BadRequest("No more please. Seriously, dude..."); |
|
67 | + if ($not_good) { |
|
68 | + throw new BadRequest("No more please. Seriously, dude..."); |
|
69 | + } |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $response = new OkapiHttpResponse(); |
@@ -35,8 +35,7 @@ |
||
35 | 35 | 'revision' => ReplicateCommon::get_revision(), |
36 | 36 | ); |
37 | 37 | $dump = Cache::get("last_fulldump"); |
38 | - if ($dump) |
|
39 | - { |
|
38 | + if ($dump) { |
|
40 | 39 | $result['latest_fulldump'] = array( |
41 | 40 | 'revision' => $dump['revision'], |
42 | 41 | 'generated_at' => $dump['meta']['generated_at'], |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | public static function get_required_locales() |
21 | 21 | { |
22 | 22 | $arr = array('POSIX'); |
23 | - foreach (self::$languages as $key => $value) |
|
24 | - $arr[] = $value['locale']; |
|
23 | + foreach (self::$languages as $key => $value) { |
|
24 | + $arr[] = $value['locale']; |
|
25 | + } |
|
25 | 26 | return $arr; |
26 | 27 | } |
27 | 28 | |
@@ -31,26 +32,28 @@ discard block |
||
31 | 32 | public static function get_installed_locales() |
32 | 33 | { |
33 | 34 | $arr = array(); |
34 | - foreach (explode("\n", shell_exec("locale -a")) as $item) |
|
35 | - if ($item) |
|
35 | + foreach (explode("\n", shell_exec("locale -a")) as $item) { |
|
36 | + if ($item) |
|
36 | 37 | $arr[] = $item; |
38 | + } |
|
37 | 39 | return $arr; |
38 | 40 | } |
39 | 41 | |
40 | 42 | private static function get_locale_for_language($lang) |
41 | 43 | { |
42 | - if (isset(self::$languages[$lang])) |
|
43 | - return self::$languages[$lang]['locale']; |
|
44 | + if (isset(self::$languages[$lang])) { |
|
45 | + return self::$languages[$lang]['locale']; |
|
46 | + } |
|
44 | 47 | return null; |
45 | 48 | } |
46 | 49 | |
47 | 50 | public static function get_best_locale($langprefs) |
48 | 51 | { |
49 | - foreach ($langprefs as $lang) |
|
50 | - { |
|
52 | + foreach ($langprefs as $lang) { |
|
51 | 53 | $locale = self::get_locale_for_language($lang); |
52 | - if ($locale != null) |
|
53 | - return $locale; |
|
54 | + if ($locale != null) { |
|
55 | + return $locale; |
|
56 | + } |
|
54 | 57 | } |
55 | 58 | return self::$languages['en']['locale']; |
56 | 59 | } |
@@ -21,8 +21,7 @@ discard block |
||
21 | 21 | OkapiErrorHandler::$treat_notices_as_errors = true; |
22 | 22 | require_once($GLOBALS['rootpath'].'okapi/urls.php'); |
23 | 23 | |
24 | -if (ob_list_handlers() == array('default output handler')) |
|
25 | -{ |
|
24 | +if (ob_list_handlers() == array('default output handler')) { |
|
26 | 25 | # We will assume that this one comes from "output_buffering" being turned on |
27 | 26 | # in PHP config. This is very common and probably is good for most other OC |
28 | 27 | # pages. But we don't need it in OKAPI. We will just turn this off. |
@@ -37,20 +36,23 @@ discard block |
||
37 | 36 | { |
38 | 37 | # Chop off the ?args=... part. |
39 | 38 | |
40 | - if (strpos($uri, '?') !== false) |
|
41 | - $uri = substr($uri, 0, strpos($uri, '?')); |
|
39 | + if (strpos($uri, '?') !== false) { |
|
40 | + $uri = substr($uri, 0, strpos($uri, '?')); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | # Chop off everything before "/okapi/". This should work for okay for most "weird" |
44 | 44 | # server configurations. It will also address a more subtle issue described here: |
45 | 45 | # http://stackoverflow.com/questions/8040461/request-uri-unexpectedly-contains-fqdn |
46 | 46 | |
47 | - if (strpos($uri, "/okapi/") !== false) |
|
48 | - $uri = substr($uri, strpos($uri, "/okapi/")); |
|
47 | + if (strpos($uri, "/okapi/") !== false) { |
|
48 | + $uri = substr($uri, strpos($uri, "/okapi/")); |
|
49 | + } |
|
49 | 50 | |
50 | 51 | # Make sure we're in the right directory (.htaccess should make sure of that). |
51 | 52 | |
52 | - if (strpos($uri, "/okapi/") !== 0) |
|
53 | - throw new Exception("'$uri' is outside of the /okapi/ path."); |
|
53 | + if (strpos($uri, "/okapi/") !== 0) { |
|
54 | + throw new Exception("'$uri' is outside of the /okapi/ path."); |
|
55 | + } |
|
54 | 56 | $uri = substr($uri, 7); |
55 | 57 | |
56 | 58 | # Initializing internals and running pre-request cronjobs (we don't want |
@@ -62,27 +64,23 @@ discard block |
||
62 | 64 | |
63 | 65 | # Checking for allowed patterns... |
64 | 66 | |
65 | - try |
|
66 | - { |
|
67 | - foreach (OkapiUrls::$mapping as $pattern => $namespace) |
|
68 | - { |
|
67 | + try { |
|
68 | + foreach (OkapiUrls::$mapping as $pattern => $namespace) { |
|
69 | 69 | $matches = null; |
70 | - if (preg_match("#$pattern#", $uri, $matches)) |
|
71 | - { |
|
70 | + if (preg_match("#$pattern#", $uri, $matches)) { |
|
72 | 71 | # Pattern matched! Moving on to the proper View... |
73 | 72 | |
74 | 73 | array_shift($matches); |
75 | 74 | require_once($GLOBALS['rootpath']."okapi/views/$namespace.php"); |
76 | 75 | $response = call_user_func_array(array('\\okapi\\views\\'. |
77 | 76 | str_replace('/', '\\', $namespace).'\\View', 'call'), $matches); |
78 | - if ($response) |
|
79 | - $response->display(); |
|
77 | + if ($response) { |
|
78 | + $response->display(); |
|
79 | + } |
|
80 | 80 | return; |
81 | 81 | } |
82 | 82 | } |
83 | - } |
|
84 | - catch (Http404 $e) |
|
85 | - { |
|
83 | + } catch (Http404 $e) { |
|
86 | 84 | /* pass */ |
87 | 85 | } |
88 | 86 |