@@ -6,24 +6,24 @@ |
||
6 | 6 | */ |
7 | 7 | class HTML_QuickForm_Compare_Fields extends HTML_QuickForm_Rule_Compare |
8 | 8 | { |
9 | - /** |
|
10 | - * Function to check an array of fields |
|
11 | - * @param array of field names |
|
9 | + /** |
|
10 | + * Function to check an array of fields |
|
11 | + * @param array of field names |
|
12 | 12 | * @param string operator ==, >=, etc |
13 | 13 | * @param string the value to compare |
14 | - * @return boolean True if date is valid |
|
15 | - */ |
|
16 | - function validate($values, $operator_and_max_value) { |
|
14 | + * @return boolean True if date is valid |
|
15 | + */ |
|
16 | + function validate($values, $operator_and_max_value) { |
|
17 | 17 | if (is_array($values) && !empty($values) && !empty($operator_and_max_value)) { |
18 | - $final_value = 0; |
|
19 | - foreach ($values as $value) { |
|
20 | - $final_value += $value; |
|
21 | - } |
|
22 | - $params = explode('@', $operator_and_max_value); |
|
23 | - $operator = $params[0]; |
|
24 | - $max_value = $params[1]; |
|
25 | - return parent::validate(array($final_value, $max_value), $operator); |
|
18 | + $final_value = 0; |
|
19 | + foreach ($values as $value) { |
|
20 | + $final_value += $value; |
|
21 | + } |
|
22 | + $params = explode('@', $operator_and_max_value); |
|
23 | + $operator = $params[0]; |
|
24 | + $max_value = $params[1]; |
|
25 | + return parent::validate(array($final_value, $max_value), $operator); |
|
26 | 26 | } |
27 | 27 | return false; |
28 | - } |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -109,7 +109,7 @@ |
||
109 | 109 | }*/ |
110 | 110 | // If the session time has expired, refresh the starttime value, |
111 | 111 | // so we're starting to count down from a later time |
112 | - if ( $session->has('starttime') && $session->is_expired()) { |
|
112 | + if ($session->has('starttime') && $session->is_expired()) { |
|
113 | 113 | $session->destroy(); |
114 | 114 | } else { |
115 | 115 | //error_log('Time not expired, extend session for a bit more'); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | echo '<tr>'; |
54 | 54 | self::display_dashboard_plugin_checkboxes($testplugin); |
55 | - for ($i = 0 ; $i < count($table_cols); $i++) { |
|
55 | + for ($i = 0; $i < count($table_cols); $i++) { |
|
56 | 56 | if (isset($plugin_info[strtolower($table_cols[$i])])) { |
57 | 57 | echo '<td>'; |
58 | 58 | echo $plugin_info[$table_cols[$i]]; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | echo Display::tag( |
68 | 68 | 'tr', |
69 | 69 | Display::tag('td', |
70 | - get_lang('CheckFilePermissions') . ' ' . Security::remove_XSS($plugin_info_file), |
|
70 | + get_lang('CheckFilePermissions').' '.Security::remove_XSS($plugin_info_file), |
|
71 | 71 | array('colspan' => '3')) |
72 | 72 | ); |
73 | 73 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | foreach ($disabled_blocks_data as $disabled_block) { |
80 | 80 | echo '<tr style="background-color:#eee">'; |
81 | 81 | echo '<td><center><input type="checkbox" name="disabled_block" value="true" checked disabled /></center>'; |
82 | - for ($j = 0 ; $j < count($table_cols); $j++) { |
|
82 | + for ($j = 0; $j < count($table_cols); $j++) { |
|
83 | 83 | if (isset($disabled_block[strtolower($table_cols[$j])])) { |
84 | 84 | if ($j == 2) { |
85 | 85 | echo '<td>'; |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | } |
190 | 190 | // clean from block data |
191 | 191 | if (!empty($not_selected_blocks_id)) { |
192 | - $sql_check = "SELECT id FROM $tbl_block WHERE id IN(".implode(',',$not_selected_blocks_id).")"; |
|
192 | + $sql_check = "SELECT id FROM $tbl_block WHERE id IN(".implode(',', $not_selected_blocks_id).")"; |
|
193 | 193 | $rs_check = Database::query($sql_check); |
194 | 194 | if (Database::num_rows($rs_check) > 0) { |
195 | - $del = "DELETE FROM $tbl_block WHERE id IN(".implode(',',$not_selected_blocks_id).")"; |
|
195 | + $del = "DELETE FROM $tbl_block WHERE id IN(".implode(',', $not_selected_blocks_id).")"; |
|
196 | 196 | Database::query($del); |
197 | 197 | } |
198 | 198 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $affected_rows = Database::affected_rows($result); |
213 | 213 | } else { |
214 | 214 | // insert |
215 | - $plugin_info_file = $dashboard_pluginpath . $testplugin . "/$testplugin.info"; |
|
215 | + $plugin_info_file = $dashboard_pluginpath.$testplugin."/$testplugin.info"; |
|
216 | 216 | $plugin_info = array(); |
217 | 217 | if (file_exists($plugin_info_file)) { |
218 | 218 | $plugin_info = parse_info_file($plugin_info_file); |
@@ -282,10 +282,10 @@ discard block |
||
282 | 282 | // We check if plugin exists inside directory for updating active field |
283 | 283 | $sql = "SELECT * FROM $tbl_block"; |
284 | 284 | $rs = Database::query($sql); |
285 | - if (Database::num_rows($rs) > 0){ |
|
285 | + if (Database::num_rows($rs) > 0) { |
|
286 | 286 | while ($row = Database::fetch_array($rs)) { |
287 | 287 | $path = $row['path']; |
288 | - if (!in_array($row['path'],$possibleplugins)) { |
|
288 | + if (!in_array($row['path'], $possibleplugins)) { |
|
289 | 289 | $active = 0; |
290 | 290 | } else { |
291 | 291 | $active = 1; |
@@ -390,13 +390,13 @@ discard block |
||
390 | 390 | echo '<td>'.$block['description'].'</td>'; |
391 | 391 | echo '<td> |
392 | 392 | <select class="selectpicker show-tick form-control" name="columns['.$block['id'].']"> |
393 | - <option value="1" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==1?'selected':'').' >1</option> |
|
394 | - <option value="2" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==2?'selected':'').' >2</option> |
|
393 | + <option value="1" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column'] == 1 ? 'selected' : '').' >1</option> |
|
394 | + <option value="2" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column'] == 2 ? 'selected' : '').' >2</option> |
|
395 | 395 | </select> |
396 | 396 | </td>'; |
397 | 397 | echo '</tr>'; |
398 | 398 | } else { |
399 | - echo Display::tag('tr', Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3'))); |
|
399 | + echo Display::tag('tr', Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3'))); |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
@@ -475,10 +475,10 @@ discard block |
||
475 | 475 | $user_id = intval($user_id); |
476 | 476 | $field_variable = 'dashboard'; |
477 | 477 | $extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable); |
478 | - $extra_user_data = explode(';',$extra_user_data[$field_variable]); |
|
478 | + $extra_user_data = explode(';', $extra_user_data[$field_variable]); |
|
479 | 479 | $data = array(); |
480 | 480 | foreach ($extra_user_data as $extra) { |
481 | - $split_extra = explode(':',$extra); |
|
481 | + $split_extra = explode(':', $extra); |
|
482 | 482 | if (!empty($split_extra)) { |
483 | 483 | $block_id = $split_extra[0]; |
484 | 484 | $column = isset($split_extra[1]) ? $split_extra[1] : null; |
@@ -380,7 +380,9 @@ |
||
380 | 380 | // check if user is allowed to see the block |
381 | 381 | if (method_exists($obj_block, 'is_block_visible_for_user')) { |
382 | 382 | $is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id); |
383 | - if (!$is_block_visible_for_user) continue; |
|
383 | + if (!$is_block_visible_for_user) { |
|
384 | + continue; |
|
385 | + } |
|
384 | 386 | } |
385 | 387 | |
386 | 388 | echo '<tr>'; |
@@ -249,283 +249,283 @@ |
||
249 | 249 | return $affected_rows; |
250 | 250 | } |
251 | 251 | |
252 | - /** |
|
253 | - * Get all plugins path inside dashboard directory |
|
254 | - * @return array name plugins directories |
|
255 | - */ |
|
256 | - public static function getPossibleDashboardPluginsPath() |
|
252 | + /** |
|
253 | + * Get all plugins path inside dashboard directory |
|
254 | + * @return array name plugins directories |
|
255 | + */ |
|
256 | + public static function getPossibleDashboardPluginsPath() |
|
257 | 257 | { |
258 | - // get all plugins path inside plugin directory |
|
259 | - /* We scan the plugin directory. Each folder is a potential plugin. */ |
|
260 | - $possiblePlugins = array(); |
|
261 | - $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/'; |
|
262 | - $handle = @opendir($dashboard_pluginpath); |
|
263 | - while (false !== ($file = readdir($handle))) { |
|
264 | - if ($file <> '.' AND $file <> '..' AND is_dir($dashboard_pluginpath.$file)) { |
|
265 | - $possiblePlugins[] = $file; |
|
266 | - } |
|
267 | - } |
|
268 | - @closedir($handle); |
|
269 | - |
|
270 | - return $possiblePlugins; |
|
271 | - } |
|
272 | - |
|
273 | - /** |
|
274 | - * Get all blocks data without plugin directory |
|
275 | - * @return array Block data |
|
276 | - */ |
|
277 | - public static function get_block_data_without_plugin() |
|
258 | + // get all plugins path inside plugin directory |
|
259 | + /* We scan the plugin directory. Each folder is a potential plugin. */ |
|
260 | + $possiblePlugins = array(); |
|
261 | + $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/'; |
|
262 | + $handle = @opendir($dashboard_pluginpath); |
|
263 | + while (false !== ($file = readdir($handle))) { |
|
264 | + if ($file <> '.' AND $file <> '..' AND is_dir($dashboard_pluginpath.$file)) { |
|
265 | + $possiblePlugins[] = $file; |
|
266 | + } |
|
267 | + } |
|
268 | + @closedir($handle); |
|
269 | + |
|
270 | + return $possiblePlugins; |
|
271 | + } |
|
272 | + |
|
273 | + /** |
|
274 | + * Get all blocks data without plugin directory |
|
275 | + * @return array Block data |
|
276 | + */ |
|
277 | + public static function get_block_data_without_plugin() |
|
278 | 278 | { |
279 | - $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); |
|
280 | - $possibleplugins = self::getPossibleDashboardPluginsPath(); |
|
281 | - |
|
282 | - // We check if plugin exists inside directory for updating active field |
|
283 | - $sql = "SELECT * FROM $tbl_block"; |
|
284 | - $rs = Database::query($sql); |
|
285 | - if (Database::num_rows($rs) > 0){ |
|
286 | - while ($row = Database::fetch_array($rs)) { |
|
287 | - $path = $row['path']; |
|
288 | - if (!in_array($row['path'],$possibleplugins)) { |
|
289 | - $active = 0; |
|
290 | - } else { |
|
291 | - $active = 1; |
|
292 | - } |
|
293 | - // update active |
|
294 | - $upd = "UPDATE $tbl_block SET active = '$active' |
|
279 | + $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); |
|
280 | + $possibleplugins = self::getPossibleDashboardPluginsPath(); |
|
281 | + |
|
282 | + // We check if plugin exists inside directory for updating active field |
|
283 | + $sql = "SELECT * FROM $tbl_block"; |
|
284 | + $rs = Database::query($sql); |
|
285 | + if (Database::num_rows($rs) > 0){ |
|
286 | + while ($row = Database::fetch_array($rs)) { |
|
287 | + $path = $row['path']; |
|
288 | + if (!in_array($row['path'],$possibleplugins)) { |
|
289 | + $active = 0; |
|
290 | + } else { |
|
291 | + $active = 1; |
|
292 | + } |
|
293 | + // update active |
|
294 | + $upd = "UPDATE $tbl_block SET active = '$active' |
|
295 | 295 | WHERE path = '".$row['path']."'"; |
296 | - Database::query($upd); |
|
297 | - } |
|
298 | - } |
|
299 | - |
|
300 | - // get disabled block data |
|
301 | - $block_data = array(); |
|
302 | - $sql = "SELECT * FROM $tbl_block WHERE active = 0"; |
|
303 | - $rs_block = Database::query($sql); |
|
304 | - if (Database::num_rows($rs_block) > 0) { |
|
305 | - while ($row_block = Database::fetch_array($rs_block)) { |
|
306 | - $block_data[] = $row_block; |
|
307 | - } |
|
308 | - } |
|
309 | - |
|
310 | - return $block_data; |
|
311 | - |
|
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * get data about enabled dashboard block (stored insise block table) |
|
316 | - * @param string plugin path |
|
317 | - * @return array data |
|
318 | - */ |
|
319 | - public static function get_enabled_dashboard_blocks($path = '') |
|
296 | + Database::query($upd); |
|
297 | + } |
|
298 | + } |
|
299 | + |
|
300 | + // get disabled block data |
|
301 | + $block_data = array(); |
|
302 | + $sql = "SELECT * FROM $tbl_block WHERE active = 0"; |
|
303 | + $rs_block = Database::query($sql); |
|
304 | + if (Database::num_rows($rs_block) > 0) { |
|
305 | + while ($row_block = Database::fetch_array($rs_block)) { |
|
306 | + $block_data[] = $row_block; |
|
307 | + } |
|
308 | + } |
|
309 | + |
|
310 | + return $block_data; |
|
311 | + |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * get data about enabled dashboard block (stored insise block table) |
|
316 | + * @param string plugin path |
|
317 | + * @return array data |
|
318 | + */ |
|
319 | + public static function get_enabled_dashboard_blocks($path = '') |
|
320 | 320 | { |
321 | - $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); |
|
322 | - $condition_path = ''; |
|
323 | - if (!empty($path)) { |
|
324 | - $path = Database::escape_string($path); |
|
325 | - $condition_path = ' AND path = "'.$path.'" '; |
|
326 | - } |
|
327 | - |
|
328 | - $sql = "SELECT * FROM $tbl_block WHERE active = 1 $condition_path "; |
|
329 | - $rs = Database::query($sql); |
|
330 | - $block_data = array(); |
|
331 | - if (Database::num_rows($rs) > 0) { |
|
332 | - while ($row = Database::fetch_array($rs)) { |
|
333 | - $block_data[$row['path']] = $row; |
|
334 | - } |
|
335 | - } |
|
336 | - return $block_data; |
|
337 | - } |
|
338 | - |
|
339 | - /** |
|
340 | - * display user dashboard list |
|
341 | - * @param int User id |
|
342 | - * @return void |
|
343 | - */ |
|
344 | - public static function display_user_dashboard_list($user_id) |
|
321 | + $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); |
|
322 | + $condition_path = ''; |
|
323 | + if (!empty($path)) { |
|
324 | + $path = Database::escape_string($path); |
|
325 | + $condition_path = ' AND path = "'.$path.'" '; |
|
326 | + } |
|
327 | + |
|
328 | + $sql = "SELECT * FROM $tbl_block WHERE active = 1 $condition_path "; |
|
329 | + $rs = Database::query($sql); |
|
330 | + $block_data = array(); |
|
331 | + if (Database::num_rows($rs) > 0) { |
|
332 | + while ($row = Database::fetch_array($rs)) { |
|
333 | + $block_data[$row['path']] = $row; |
|
334 | + } |
|
335 | + } |
|
336 | + return $block_data; |
|
337 | + } |
|
338 | + |
|
339 | + /** |
|
340 | + * display user dashboard list |
|
341 | + * @param int User id |
|
342 | + * @return void |
|
343 | + */ |
|
344 | + public static function display_user_dashboard_list($user_id) |
|
345 | 345 | { |
346 | - $enabled_dashboard_plugins = self::get_enabled_dashboard_blocks(); |
|
347 | - $user_block_data = self::get_user_block_data($user_id); |
|
348 | - |
|
349 | - if (count($enabled_dashboard_plugins) > 0) { |
|
350 | - echo '<div style="margin-top:20px">'; |
|
351 | - echo '<div><strong>'.get_lang('SelectBlockForDisplayingInsideBlocksDashboardView').'</strong></div><br />'; |
|
352 | - echo '<form name="dashboard_list" method="post" action="index.php?action=store_user_block">'; |
|
353 | - echo '<table class="data_table">'; |
|
354 | - echo '<tr>'; |
|
355 | - echo '<th width="5%">'; |
|
356 | - echo get_lang('Enabled'); |
|
357 | - echo '</th>'; |
|
358 | - echo '<th width="30%">'; |
|
359 | - echo get_lang('Name'); |
|
360 | - echo '</th>'; |
|
361 | - echo '<th width="40%">'; |
|
362 | - echo get_lang('Description'); |
|
363 | - echo '</th>'; |
|
364 | - echo '<th>'; |
|
365 | - echo get_lang('ColumnPosition'); |
|
366 | - echo '</th>'; |
|
367 | - echo '</tr>'; |
|
368 | - |
|
369 | - // We display all enabled plugins and the checkboxes |
|
370 | - foreach ($enabled_dashboard_plugins as $block) { |
|
371 | - |
|
372 | - $path = $block['path']; |
|
373 | - $controller_class = $block['controller']; |
|
374 | - $filename_controller = $path.'.class.php'; |
|
375 | - $dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/'; |
|
376 | - require_once $dashboard_plugin_path.$filename_controller; |
|
377 | - if (class_exists($controller_class)) { |
|
378 | - $obj_block = new $controller_class($user_id); |
|
379 | - |
|
380 | - // check if user is allowed to see the block |
|
381 | - if (method_exists($obj_block, 'is_block_visible_for_user')) { |
|
382 | - $is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id); |
|
383 | - if (!$is_block_visible_for_user) continue; |
|
384 | - } |
|
385 | - |
|
386 | - echo '<tr>'; |
|
387 | - // checkboxes |
|
388 | - self::display_user_dashboard_list_checkboxes($user_id, $block['id']); |
|
389 | - echo '<td>'.$block['name'].'</td>'; |
|
390 | - echo '<td>'.$block['description'].'</td>'; |
|
391 | - echo '<td> |
|
346 | + $enabled_dashboard_plugins = self::get_enabled_dashboard_blocks(); |
|
347 | + $user_block_data = self::get_user_block_data($user_id); |
|
348 | + |
|
349 | + if (count($enabled_dashboard_plugins) > 0) { |
|
350 | + echo '<div style="margin-top:20px">'; |
|
351 | + echo '<div><strong>'.get_lang('SelectBlockForDisplayingInsideBlocksDashboardView').'</strong></div><br />'; |
|
352 | + echo '<form name="dashboard_list" method="post" action="index.php?action=store_user_block">'; |
|
353 | + echo '<table class="data_table">'; |
|
354 | + echo '<tr>'; |
|
355 | + echo '<th width="5%">'; |
|
356 | + echo get_lang('Enabled'); |
|
357 | + echo '</th>'; |
|
358 | + echo '<th width="30%">'; |
|
359 | + echo get_lang('Name'); |
|
360 | + echo '</th>'; |
|
361 | + echo '<th width="40%">'; |
|
362 | + echo get_lang('Description'); |
|
363 | + echo '</th>'; |
|
364 | + echo '<th>'; |
|
365 | + echo get_lang('ColumnPosition'); |
|
366 | + echo '</th>'; |
|
367 | + echo '</tr>'; |
|
368 | + |
|
369 | + // We display all enabled plugins and the checkboxes |
|
370 | + foreach ($enabled_dashboard_plugins as $block) { |
|
371 | + |
|
372 | + $path = $block['path']; |
|
373 | + $controller_class = $block['controller']; |
|
374 | + $filename_controller = $path.'.class.php'; |
|
375 | + $dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/'; |
|
376 | + require_once $dashboard_plugin_path.$filename_controller; |
|
377 | + if (class_exists($controller_class)) { |
|
378 | + $obj_block = new $controller_class($user_id); |
|
379 | + |
|
380 | + // check if user is allowed to see the block |
|
381 | + if (method_exists($obj_block, 'is_block_visible_for_user')) { |
|
382 | + $is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id); |
|
383 | + if (!$is_block_visible_for_user) continue; |
|
384 | + } |
|
385 | + |
|
386 | + echo '<tr>'; |
|
387 | + // checkboxes |
|
388 | + self::display_user_dashboard_list_checkboxes($user_id, $block['id']); |
|
389 | + echo '<td>'.$block['name'].'</td>'; |
|
390 | + echo '<td>'.$block['description'].'</td>'; |
|
391 | + echo '<td> |
|
392 | 392 | <select class="selectpicker show-tick form-control" name="columns['.$block['id'].']"> |
393 | 393 | <option value="1" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==1?'selected':'').' >1</option> |
394 | 394 | <option value="2" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==2?'selected':'').' >2</option> |
395 | 395 | </select> |
396 | 396 | </td>'; |
397 | - echo '</tr>'; |
|
398 | - } else { |
|
399 | - echo Display::tag('tr', Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3'))); |
|
400 | - } |
|
401 | - } |
|
402 | - |
|
403 | - echo '</table>'; |
|
404 | - echo '<div class="row"><div class="col-md-12">'; |
|
405 | - echo '<button class="btn btn-default" type="submit" name="submit_dashboard_list" value="'.get_lang('EnableDashboardBlock').'"><em class="fa fa-check-square"></em> '. |
|
397 | + echo '</tr>'; |
|
398 | + } else { |
|
399 | + echo Display::tag('tr', Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3'))); |
|
400 | + } |
|
401 | + } |
|
402 | + |
|
403 | + echo '</table>'; |
|
404 | + echo '<div class="row"><div class="col-md-12">'; |
|
405 | + echo '<button class="btn btn-default" type="submit" name="submit_dashboard_list" value="'.get_lang('EnableDashboardBlock').'"><em class="fa fa-check-square"></em> '. |
|
406 | 406 | get_lang('EnableDashboardBlock').'</button></form>'; |
407 | - echo '</div></div>'; |
|
408 | - } else { |
|
409 | - echo '<div style="margin-top:20px">'.get_lang('ThereAreNoEnabledDashboardPlugins').'</div>'; |
|
410 | - if (api_is_platform_admin()) { |
|
411 | - echo '<a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">'. |
|
407 | + echo '</div></div>'; |
|
408 | + } else { |
|
409 | + echo '<div style="margin-top:20px">'.get_lang('ThereAreNoEnabledDashboardPlugins').'</div>'; |
|
410 | + if (api_is_platform_admin()) { |
|
411 | + echo '<a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">'. |
|
412 | 412 | get_lang('ConfigureDashboardPlugin').'</a>'; |
413 | - } |
|
414 | - } |
|
415 | - } |
|
416 | - |
|
417 | - /** |
|
418 | - * display checkboxes for user dashboard list |
|
419 | - * @param int User id |
|
420 | - * @param int Block id |
|
421 | - * @return void |
|
422 | - */ |
|
423 | - public static function display_user_dashboard_list_checkboxes($user_id, $block_id) { |
|
424 | - |
|
425 | - $user_id = intval($user_id); |
|
426 | - $user_block_data = self::get_user_block_data($user_id); |
|
427 | - $enabled_blocks_id = array_keys($user_block_data); |
|
428 | - |
|
429 | - $checked = ''; |
|
430 | - if (in_array($block_id, $enabled_blocks_id)) { |
|
431 | - $checked = "checked"; |
|
432 | - } |
|
433 | - |
|
434 | - echo "<td align=\"center\">"; |
|
435 | - echo '<input type="checkbox" name="enabled_blocks['.$block_id.']" value="true" '.$checked.'/>'; |
|
436 | - echo "</td>"; |
|
437 | - } |
|
438 | - |
|
439 | - /** |
|
440 | - * This function store enabled blocks id with its column position (block_id1:colum;block_id2:colum; ...) inside extra user fields |
|
441 | - * @param int User id |
|
442 | - * @param array selected blocks |
|
443 | - * @param array columns position |
|
444 | - * @return bool |
|
445 | - */ |
|
446 | - public static function store_user_blocks($user_id, $enabled_blocks, $columns) { |
|
447 | - $selected_blocks_id = array(); |
|
448 | - if (is_array($enabled_blocks) && count($enabled_blocks) > 0) { |
|
449 | - $selected_blocks_id = array_keys($enabled_blocks); |
|
450 | - } |
|
451 | - |
|
452 | - // build data for storing inside extra user field |
|
453 | - $fname = 'dashboard'; |
|
454 | - $fvalue = array(); |
|
455 | - foreach ($selected_blocks_id as $block_id) { |
|
456 | - $fvalue[] = $block_id.':'.$columns[$block_id]; |
|
457 | - } |
|
413 | + } |
|
414 | + } |
|
415 | + } |
|
416 | + |
|
417 | + /** |
|
418 | + * display checkboxes for user dashboard list |
|
419 | + * @param int User id |
|
420 | + * @param int Block id |
|
421 | + * @return void |
|
422 | + */ |
|
423 | + public static function display_user_dashboard_list_checkboxes($user_id, $block_id) { |
|
424 | + |
|
425 | + $user_id = intval($user_id); |
|
426 | + $user_block_data = self::get_user_block_data($user_id); |
|
427 | + $enabled_blocks_id = array_keys($user_block_data); |
|
428 | + |
|
429 | + $checked = ''; |
|
430 | + if (in_array($block_id, $enabled_blocks_id)) { |
|
431 | + $checked = "checked"; |
|
432 | + } |
|
433 | + |
|
434 | + echo "<td align=\"center\">"; |
|
435 | + echo '<input type="checkbox" name="enabled_blocks['.$block_id.']" value="true" '.$checked.'/>'; |
|
436 | + echo "</td>"; |
|
437 | + } |
|
438 | + |
|
439 | + /** |
|
440 | + * This function store enabled blocks id with its column position (block_id1:colum;block_id2:colum; ...) inside extra user fields |
|
441 | + * @param int User id |
|
442 | + * @param array selected blocks |
|
443 | + * @param array columns position |
|
444 | + * @return bool |
|
445 | + */ |
|
446 | + public static function store_user_blocks($user_id, $enabled_blocks, $columns) { |
|
447 | + $selected_blocks_id = array(); |
|
448 | + if (is_array($enabled_blocks) && count($enabled_blocks) > 0) { |
|
449 | + $selected_blocks_id = array_keys($enabled_blocks); |
|
450 | + } |
|
451 | + |
|
452 | + // build data for storing inside extra user field |
|
453 | + $fname = 'dashboard'; |
|
454 | + $fvalue = array(); |
|
455 | + foreach ($selected_blocks_id as $block_id) { |
|
456 | + $fvalue[] = $block_id.':'.$columns[$block_id]; |
|
457 | + } |
|
458 | 458 | $upd_extra_field = UserManager::update_extra_field_value( |
459 | 459 | $user_id, |
460 | 460 | $fname, |
461 | 461 | $fvalue |
462 | 462 | ); |
463 | 463 | |
464 | - return $upd_extra_field; |
|
464 | + return $upd_extra_field; |
|
465 | 465 | |
466 | - } |
|
466 | + } |
|
467 | 467 | |
468 | - /** |
|
469 | - * This function get user block data (block id with its number of column) from extra user data |
|
470 | - * @param int User id |
|
471 | - * @return array data (block_id,column) |
|
472 | - */ |
|
473 | - public static function get_user_block_data($user_id) |
|
468 | + /** |
|
469 | + * This function get user block data (block id with its number of column) from extra user data |
|
470 | + * @param int User id |
|
471 | + * @return array data (block_id,column) |
|
472 | + */ |
|
473 | + public static function get_user_block_data($user_id) |
|
474 | 474 | { |
475 | - $user_id = intval($user_id); |
|
476 | - $field_variable = 'dashboard'; |
|
477 | - $extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable); |
|
478 | - $extra_user_data = explode(';',$extra_user_data[$field_variable]); |
|
479 | - $data = array(); |
|
480 | - foreach ($extra_user_data as $extra) { |
|
481 | - $split_extra = explode(':',$extra); |
|
482 | - if (!empty($split_extra)) { |
|
483 | - $block_id = $split_extra[0]; |
|
484 | - $column = isset($split_extra[1]) ? $split_extra[1] : null; |
|
485 | - $data[$block_id] = array('block_id' => $block_id, 'column' => $column); |
|
486 | - } |
|
487 | - } |
|
488 | - |
|
489 | - return $data; |
|
490 | - } |
|
491 | - |
|
492 | - /** |
|
493 | - * This function update extra user blocks data after closing a dashboard block |
|
494 | - * @param int User id |
|
495 | - * @param string plugin path |
|
496 | - * @param integer $user_id |
|
497 | - * @return bool |
|
498 | - */ |
|
499 | - public static function close_user_block($user_id, $path) |
|
475 | + $user_id = intval($user_id); |
|
476 | + $field_variable = 'dashboard'; |
|
477 | + $extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable); |
|
478 | + $extra_user_data = explode(';',$extra_user_data[$field_variable]); |
|
479 | + $data = array(); |
|
480 | + foreach ($extra_user_data as $extra) { |
|
481 | + $split_extra = explode(':',$extra); |
|
482 | + if (!empty($split_extra)) { |
|
483 | + $block_id = $split_extra[0]; |
|
484 | + $column = isset($split_extra[1]) ? $split_extra[1] : null; |
|
485 | + $data[$block_id] = array('block_id' => $block_id, 'column' => $column); |
|
486 | + } |
|
487 | + } |
|
488 | + |
|
489 | + return $data; |
|
490 | + } |
|
491 | + |
|
492 | + /** |
|
493 | + * This function update extra user blocks data after closing a dashboard block |
|
494 | + * @param int User id |
|
495 | + * @param string plugin path |
|
496 | + * @param integer $user_id |
|
497 | + * @return bool |
|
498 | + */ |
|
499 | + public static function close_user_block($user_id, $path) |
|
500 | 500 | { |
501 | - $enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path); |
|
502 | - $user_block_data = self::get_user_block_data($user_id); |
|
503 | - |
|
504 | - foreach ($enabled_dashboard_blocks as $enabled_block) { |
|
505 | - unset($user_block_data[$enabled_block['id']]); |
|
506 | - } |
|
507 | - |
|
508 | - // get columns and blocks id for updating extra user data |
|
509 | - $columns = array(); |
|
510 | - $user_blocks_id = array(); |
|
511 | - foreach ($user_block_data as $data) { |
|
512 | - $user_blocks_id[$data['block_id']] = true; |
|
513 | - $columns[$data['block_id']] = $data['column']; |
|
514 | - } |
|
515 | - |
|
516 | - // update extra user blocks data |
|
517 | - $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns); |
|
518 | - |
|
519 | - return $upd_extra_field; |
|
520 | - } |
|
521 | - |
|
522 | - /** |
|
523 | - * get links for styles from dashboard plugins |
|
524 | - * @return string links |
|
525 | - */ |
|
526 | - public static function get_links_for_styles_from_dashboard_plugins() { |
|
527 | - |
|
528 | - return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL; |
|
529 | - } |
|
501 | + $enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path); |
|
502 | + $user_block_data = self::get_user_block_data($user_id); |
|
503 | + |
|
504 | + foreach ($enabled_dashboard_blocks as $enabled_block) { |
|
505 | + unset($user_block_data[$enabled_block['id']]); |
|
506 | + } |
|
507 | + |
|
508 | + // get columns and blocks id for updating extra user data |
|
509 | + $columns = array(); |
|
510 | + $user_blocks_id = array(); |
|
511 | + foreach ($user_block_data as $data) { |
|
512 | + $user_blocks_id[$data['block_id']] = true; |
|
513 | + $columns[$data['block_id']] = $data['column']; |
|
514 | + } |
|
515 | + |
|
516 | + // update extra user blocks data |
|
517 | + $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns); |
|
518 | + |
|
519 | + return $upd_extra_field; |
|
520 | + } |
|
521 | + |
|
522 | + /** |
|
523 | + * get links for styles from dashboard plugins |
|
524 | + * @return string links |
|
525 | + */ |
|
526 | + public static function get_links_for_styles_from_dashboard_plugins() { |
|
527 | + |
|
528 | + return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL; |
|
529 | + } |
|
530 | 530 | |
531 | 531 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | // If the mail only need to be send once (we know that thanks to the events.conf), we log it in the table |
126 | 126 | if ($event_config[$event_name]["sending_mail_once"]) { |
127 | - $sql = 'INSERT INTO ' . Database::get_main_table(TABLE_EVENT_SENT) . ' (user_from, user_to, event_type_name) |
|
127 | + $sql = 'INSERT INTO '.Database::get_main_table(TABLE_EVENT_SENT).' (user_from, user_to, event_type_name) |
|
128 | 128 | VALUES ('.$event_data["user_id"].', '.$id.' ,"'.Database::escape_string($event_name).'") |
129 | 129 | '; |
130 | 130 | Database::query($sql); |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | // Second, we send to people linked to the event |
136 | 136 | // So, we get everyone |
137 | 137 | $sql = 'SELECT u.user_id, u.language, u.email, u.firstname, u.lastname |
138 | - FROM ' . Database::get_main_table(TABLE_EVENT_TYPE_REL_USER) . ' ue |
|
138 | + FROM ' . Database::get_main_table(TABLE_EVENT_TYPE_REL_USER).' ue |
|
139 | 139 | INNER JOIN '.Database::get_main_table(TABLE_MAIN_USER).' u ON u.user_id = ue.user_id |
140 | - WHERE event_type_name = "' . $event_name . '"'; |
|
140 | + WHERE event_type_name = "' . $event_name.'"'; |
|
141 | 141 | $result = Database::store_result(Database::query($sql), 'ASSOC'); |
142 | 142 | // for each of the linked users |
143 | 143 | foreach ($result as $key => $value) { |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | // If the mail only need to be send once (we know that thanks to the events.conf, we log it in the table |
179 | 179 | if ($event_config[$event_name]["sending_mail_once"]) { |
180 | - $sql = 'INSERT INTO ' . Database::get_main_table(TABLE_EVENT_SENT) . ' |
|
180 | + $sql = 'INSERT INTO '.Database::get_main_table(TABLE_EVENT_SENT).' |
|
181 | 181 | (user_from, user_to, event_type_name) |
182 | 182 | VALUES ('.$event_data["user_id"].', '.$value["user_id"].' , "'.Database::escape_string($event_name).'"); |
183 | 183 | '; |
@@ -202,16 +202,16 @@ discard block |
||
202 | 202 | $current_language = api_get_interface_language(); |
203 | 203 | |
204 | 204 | $sql = 'SELECT COUNT(*) as total |
205 | - FROM ' . Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE) . ' em |
|
206 | - INNER JOIN ' . Database::get_main_table(TABLE_MAIN_LANGUAGE) . ' l |
|
205 | + FROM ' . Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE).' em |
|
206 | + INNER JOIN ' . Database::get_main_table(TABLE_MAIN_LANGUAGE).' l |
|
207 | 207 | ON em.language_id = l.id |
208 | 208 | WHERE |
209 | - em.event_type_name = "' . $event_name . '" and |
|
209 | + em.event_type_name = "' . $event_name.'" and |
|
210 | 210 | l.dokeos_folder = "'.$current_language.'" and |
211 | 211 | em.activated = 1'; |
212 | 212 | |
213 | 213 | $exists = Database::store_result(Database::query($sql), 'ASSOC'); |
214 | - if ($exists[0]["total"]) { |
|
214 | + if ($exists[0]["total"]) { |
|
215 | 215 | return true; |
216 | 216 | } else { |
217 | 217 | return false; |
@@ -228,12 +228,12 @@ discard block |
||
228 | 228 | private static function getMessage($event_name, $language) |
229 | 229 | { |
230 | 230 | $sql = 'SELECT message, subject, l.dokeos_folder |
231 | - FROM ' . Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE) . ' em |
|
232 | - INNER JOIN ' . Database::get_main_table(TABLE_MAIN_LANGUAGE) . ' l |
|
231 | + FROM ' . Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE).' em |
|
232 | + INNER JOIN ' . Database::get_main_table(TABLE_MAIN_LANGUAGE).' l |
|
233 | 233 | ON em.language_id = l.id |
234 | 234 | WHERE |
235 | - em.event_type_name = "' . $event_name . '" AND |
|
236 | - (l.dokeos_folder = "' . $language . '" OR l.dokeos_folder = "english") AND |
|
235 | + em.event_type_name = "' . $event_name.'" AND |
|
236 | + (l.dokeos_folder = "' . $language.'" OR l.dokeos_folder = "english") AND |
|
237 | 237 | em.message <> "" |
238 | 238 | '; |
239 | 239 | return Database::store_result(Database::query($sql), 'ASSOC'); |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | private static function formatMessage(&$message, &$subject, $event_config, $event_name, &$event_data) |
275 | 275 | { |
276 | 276 | foreach ($event_config[$event_name]["available_keyvars"] as $key => $word) { |
277 | - $message = str_replace('((' . $key . '))', $event_data[$word], $message); |
|
278 | - $subject = str_replace('((' . $key . '))', $event_data[$word], $subject); |
|
277 | + $message = str_replace('(('.$key.'))', $event_data[$word], $message); |
|
278 | + $subject = str_replace('(('.$key.'))', $event_data[$word], $subject); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 | } |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * Constructor |
14 | 14 | */ |
15 | - public function __construct() |
|
15 | + public function __construct() |
|
16 | 16 | { |
17 | 17 | $this->table = Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE); |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | 20 | public function get_all($where_conditions = array()) |
21 | 21 | { |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * Displays the title + grid |
31 | 31 | */ |
32 | - public function display() |
|
32 | + public function display() |
|
33 | 33 | { |
34 | - // action links |
|
35 | - $content = Display::actions(array( |
|
34 | + // action links |
|
35 | + $content = Display::actions(array( |
|
36 | 36 | array( |
37 | 37 | 'url' => 'event_type.php' , |
38 | 38 | 'content' => Display::return_icon('new_document.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM) |
39 | - ) |
|
39 | + ) |
|
40 | 40 | ) |
41 | 41 | ); |
42 | 42 | $content .= Display::grid_html('event_email_template'); |
43 | 43 | return $content; |
44 | - } |
|
44 | + } |
|
45 | 45 | |
46 | 46 | public function get_status_list() |
47 | 47 | { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'Height' => '250', |
83 | 83 | ) |
84 | 84 | ); |
85 | - $status_list = $this->get_status_list(); |
|
85 | + $status_list = $this->get_status_list(); |
|
86 | 86 | $form->addElement('select', 'status', get_lang('Status'), $status_list); |
87 | 87 | if ($action == 'edit') { |
88 | 88 | $form->addElement('text', 'created_at', get_lang('CreatedAt')); |
@@ -99,17 +99,17 @@ discard block |
||
99 | 99 | $defaults = $this->get($id); |
100 | 100 | |
101 | 101 | if (!empty($defaults['created_at'])) { |
102 | - $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']); |
|
102 | + $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']); |
|
103 | 103 | } |
104 | 104 | if (!empty($defaults['updated_at'])) { |
105 | - $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']); |
|
105 | + $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']); |
|
106 | 106 | } |
107 | 107 | $form->setDefaults($defaults); |
108 | 108 | |
109 | 109 | // Setting the rules |
110 | 110 | $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); |
111 | 111 | |
112 | - return $form; |
|
112 | + return $form; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | public function get_count() |
@@ -84,7 +84,7 @@ |
||
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Available driver list. |
87 | - * @return array |
|
87 | + * @return string[] |
|
88 | 88 | */ |
89 | 89 | private function getDefaultDriverList() |
90 | 90 | { |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public function __construct() |
16 | 16 | { |
17 | - $this->table = Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE); |
|
17 | + $this->table = Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | // action links |
39 | 39 | $content = Display::actions(array( |
40 | 40 | array( |
41 | - 'url' => 'event_type.php' , |
|
41 | + 'url' => 'event_type.php', |
|
42 | 42 | 'content' => Display::return_icon('new_document.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM) |
43 | 43 | ) |
44 | 44 | ) |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | public function get_count() |
123 | 123 | { |
124 | - $row = Database::select('count(*) as count', $this->table, array(),'first'); |
|
124 | + $row = Database::select('count(*) as count', $this->table, array(), 'first'); |
|
125 | 125 | |
126 | 126 | return $row['count']; |
127 | 127 | } |
@@ -43,22 +43,22 @@ |
||
43 | 43 | ' WHERE (username LIKE "'.$needle.'%" '. |
44 | 44 | ' OR firstname LIKE "'.$needle.'%" '. |
45 | 45 | ' OR lastname LIKE "'.$needle.'%") '. |
46 | - $order_clause . |
|
46 | + $order_clause. |
|
47 | 47 | ' LIMIT 11'; |
48 | 48 | |
49 | 49 | $rs = Database::query($sql); |
50 | - $i=0; |
|
50 | + $i = 0; |
|
51 | 51 | |
52 | 52 | while ($user = Database :: fetch_array($rs)) { |
53 | 53 | $i++; |
54 | - if ($i<=10) { |
|
54 | + if ($i <= 10) { |
|
55 | 55 | $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($user['user_id']).'\',\''.api_get_person_name(addslashes($user['firstname']), addslashes($user['lastname'])).' ('.addslashes($user['username']).')'.'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />'; |
56 | 56 | } else { |
57 | 57 | $return .= '...<br />'; |
58 | 58 | } |
59 | 59 | } |
60 | 60 | } |
61 | - $xajax_response -> addAssign('ajax_list_users','innerHTML',api_utf8_encode($return)); |
|
61 | + $xajax_response -> addAssign('ajax_list_users', 'innerHTML', api_utf8_encode($return)); |
|
62 | 62 | return $xajax_response; |
63 | 63 | } |
64 | 64 | } |
@@ -40,11 +40,11 @@ |
||
40 | 40 | // search users where username or firstname or lastname begins likes $needle |
41 | 41 | $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; |
42 | 42 | $sql = 'SELECT u.user_id, username, lastname, firstname FROM '.$tbl_user.' u '. |
43 | - ' WHERE (username LIKE "'.$needle.'%" '. |
|
44 | - ' OR firstname LIKE "'.$needle.'%" '. |
|
45 | - ' OR lastname LIKE "'.$needle.'%") '. |
|
43 | + ' WHERE (username LIKE "'.$needle.'%" '. |
|
44 | + ' OR firstname LIKE "'.$needle.'%" '. |
|
45 | + ' OR lastname LIKE "'.$needle.'%") '. |
|
46 | 46 | $order_clause . |
47 | - ' LIMIT 11'; |
|
47 | + ' LIMIT 11'; |
|
48 | 48 | |
49 | 49 | $rs = Database::query($sql); |
50 | 50 | $i=0; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | var $root_struct_name = ''; |
19 | 19 | var $root_struct_namespace = ''; |
20 | 20 | var $root_header = ''; |
21 | - var $document = ''; // incoming SOAP body (text) |
|
21 | + var $document = ''; // incoming SOAP body (text) |
|
22 | 22 | // determines where in the message we are (envelope,header,body,method) |
23 | 23 | var $status = ''; |
24 | 24 | var $position = 0; |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | var $fault_detail = ''; |
34 | 34 | var $depth_array = array(); |
35 | 35 | var $debug_flag = true; |
36 | - var $soapresponse = NULL; // parsed SOAP Body |
|
37 | - var $soapheader = NULL; // parsed SOAP Header |
|
38 | - var $responseHeaders = ''; // incoming SOAP headers (text) |
|
36 | + var $soapresponse = NULL; // parsed SOAP Body |
|
37 | + var $soapheader = NULL; // parsed SOAP Header |
|
38 | + var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | 39 | var $body_position = 0; |
40 | 40 | // for multiref parsing: |
41 | 41 | // array of id => pos |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param string $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
55 | 55 | * @access public |
56 | 56 | */ |
57 | - function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
|
57 | + function nusoap_parser($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = true) { |
|
58 | 58 | parent::nusoap_base(); |
59 | 59 | $this->xml = $xml; |
60 | 60 | $this->xml_encoding = $encoding; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $this->decode_utf8 = $decode_utf8; |
63 | 63 | |
64 | 64 | // Check whether content has been read. |
65 | - if(!empty($this->xml)){ |
|
65 | + if (!empty($this->xml)) { |
|
66 | 66 | // Check XML encoding |
67 | 67 | $pos_xml = strpos($xml, '<?xml'); |
68 | 68 | if ($pos_xml !== FALSE) { |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
71 | 71 | $xml_encoding = $res[1]; |
72 | 72 | if (strtoupper($xml_encoding) != $encoding) { |
73 | - $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
73 | + $err = "Charset from HTTP Content-Type '".$encoding."' does not match encoding from XML declaration '".$xml_encoding."'"; |
|
74 | 74 | $this->debug($err); |
75 | 75 | if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
76 | 76 | $this->setError($err); |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | // Set the object for the parser. |
97 | 97 | xml_set_object($this->parser, $this); |
98 | 98 | // Set the element handlers for the parser. |
99 | - xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
100 | - xml_set_character_data_handler($this->parser,'character_data'); |
|
99 | + xml_set_element_handler($this->parser, 'start_element', 'end_element'); |
|
100 | + xml_set_character_data_handler($this->parser, 'character_data'); |
|
101 | 101 | |
102 | 102 | xml_parse($this->parser, $this->xml); |
103 | 103 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | xml_get_current_line_number($this->parser), |
110 | 110 | xml_error_string(xml_get_error_code($this->parser))); |
111 | 111 | $this->debug($err); |
112 | - $this->debug("XML payload:\n" . $xml); |
|
112 | + $this->debug("XML payload:\n".$xml); |
|
113 | 113 | $this->setError($err); |
114 | 114 | } else { |
115 | 115 | $this->debug('in nusoap_parser ctor, message:'); |
@@ -118,18 +118,18 @@ discard block |
||
118 | 118 | // get final value |
119 | 119 | $this->soapresponse = $this->message[$this->root_struct]['result']; |
120 | 120 | // get header value |
121 | - if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
121 | + if ($this->root_header != '' && isset($this->message[$this->root_header]['result'])) { |
|
122 | 122 | $this->soapheader = $this->message[$this->root_header]['result']; |
123 | 123 | } |
124 | 124 | // resolve hrefs/ids |
125 | - if(sizeof($this->multirefs) > 0){ |
|
126 | - foreach($this->multirefs as $id => $hrefs){ |
|
125 | + if (sizeof($this->multirefs) > 0) { |
|
126 | + foreach ($this->multirefs as $id => $hrefs) { |
|
127 | 127 | $this->debug('resolving multirefs for id: '.$id); |
128 | 128 | $idVal = $this->buildVal($this->ids[$id]); |
129 | 129 | if (is_array($idVal) && isset($idVal['!id'])) { |
130 | 130 | unset($idVal['!id']); |
131 | 131 | } |
132 | - foreach($hrefs as $refPos => $ref){ |
|
132 | + foreach ($hrefs as $refPos => $ref) { |
|
133 | 133 | $this->debug('resolving href at pos '.$refPos); |
134 | 134 | $this->multirefs[$id][$refPos] = $idVal; |
135 | 135 | } |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | // update class level pos |
158 | 158 | $pos = $this->position++; |
159 | 159 | // and set mine |
160 | - $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
160 | + $this->message[$pos] = array('pos' => $pos, 'children'=>'', 'cdata'=>''); |
|
161 | 161 | // depth = how many levels removed from root? |
162 | 162 | // set mine as current global depth and increment global depth value |
163 | 163 | $this->message[$pos]['depth'] = $this->depth++; |
164 | 164 | |
165 | 165 | // else add self as child to whoever the current parent is |
166 | - if($pos != 0){ |
|
166 | + if ($pos != 0) { |
|
167 | 167 | $this->message[$this->parent]['children'] .= '|'.$pos; |
168 | 168 | } |
169 | 169 | // set my parent |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | // set self as current value for this depth |
174 | 174 | $this->depth_array[$this->depth] = $pos; |
175 | 175 | // get element prefix |
176 | - if(strpos($name,':')){ |
|
176 | + if (strpos($name, ':')) { |
|
177 | 177 | // get ns prefix |
178 | - $prefix = substr($name,0,strpos($name,':')); |
|
178 | + $prefix = substr($name, 0, strpos($name, ':')); |
|
179 | 179 | // get unqualified name |
180 | - $name = substr(strstr($name,':'),1); |
|
180 | + $name = substr(strstr($name, ':'), 1); |
|
181 | 181 | } |
182 | 182 | // set status |
183 | 183 | if ($name == 'Envelope' && $this->status == '') { |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | } elseif ($name == 'Header' && $this->status == 'envelope') { |
186 | 186 | $this->root_header = $pos; |
187 | 187 | $this->status = 'header'; |
188 | - } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
188 | + } elseif ($name == 'Body' && $this->status == 'envelope') { |
|
189 | 189 | $this->status = 'body'; |
190 | 190 | $this->body_position = $pos; |
191 | 191 | // set method |
192 | - } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
192 | + } elseif ($this->status == 'body' && $pos == ($this->body_position + 1)) { |
|
193 | 193 | $this->status = 'method'; |
194 | 194 | $this->root_struct_name = $name; |
195 | 195 | $this->root_struct = $pos; |
@@ -205,23 +205,23 @@ discard block |
||
205 | 205 | |
206 | 206 | // loop through atts, logging ns and type declarations |
207 | 207 | $attstr = ''; |
208 | - foreach($attrs as $key => $value){ |
|
208 | + foreach ($attrs as $key => $value) { |
|
209 | 209 | $key_prefix = $this->getPrefix($key); |
210 | 210 | $key_localpart = $this->getLocalPart($key); |
211 | 211 | // if ns declarations, add to class level array of valid namespaces |
212 | - if($key_prefix == 'xmlns'){ |
|
213 | - if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
212 | + if ($key_prefix == 'xmlns') { |
|
213 | + if (preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/', $value)) { |
|
214 | 214 | $this->XMLSchemaVersion = $value; |
215 | 215 | $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
216 | 216 | $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
217 | 217 | } |
218 | 218 | $this->namespaces[$key_localpart] = $value; |
219 | 219 | // set method namespace |
220 | - if($name == $this->root_struct_name){ |
|
220 | + if ($name == $this->root_struct_name) { |
|
221 | 221 | $this->methodNamespace = $value; |
222 | 222 | } |
223 | 223 | // if it's a type declaration, set type |
224 | - } elseif($key_localpart == 'type'){ |
|
224 | + } elseif ($key_localpart == 'type') { |
|
225 | 225 | if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
226 | 226 | // do nothing: already processed arrayType |
227 | 227 | } else { |
@@ -229,14 +229,14 @@ discard block |
||
229 | 229 | $value_localpart = $this->getLocalPart($value); |
230 | 230 | $this->message[$pos]['type'] = $value_localpart; |
231 | 231 | $this->message[$pos]['typePrefix'] = $value_prefix; |
232 | - if(isset($this->namespaces[$value_prefix])){ |
|
232 | + if (isset($this->namespaces[$value_prefix])) { |
|
233 | 233 | $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
234 | - } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
234 | + } else if (isset($attrs['xmlns:'.$value_prefix])) { |
|
235 | 235 | $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
236 | 236 | } |
237 | 237 | // should do something here with the namespace of specified type? |
238 | 238 | } |
239 | - } elseif($key_localpart == 'arrayType'){ |
|
239 | + } elseif ($key_localpart == 'arrayType') { |
|
240 | 240 | $this->message[$pos]['type'] = 'array'; |
241 | 241 | /* do arrayType ereg here |
242 | 242 | [1] arrayTypeValue ::= atype asize |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | [6] nextDimension ::= Digit+ ',' |
248 | 248 | */ |
249 | 249 | $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
250 | - if(preg_match($expr,$value,$regs)){ |
|
250 | + if (preg_match($expr, $value, $regs)) { |
|
251 | 251 | $this->message[$pos]['typePrefix'] = $regs[1]; |
252 | 252 | $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
253 | 253 | if (isset($this->namespaces[$regs[1]])) { |
@@ -260,22 +260,22 @@ discard block |
||
260 | 260 | $this->message[$pos]['arrayCols'] = $regs[4]; |
261 | 261 | } |
262 | 262 | // specifies nil value (or not) |
263 | - } elseif ($key_localpart == 'nil'){ |
|
263 | + } elseif ($key_localpart == 'nil') { |
|
264 | 264 | $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
265 | 265 | // some other attribute |
266 | 266 | } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
267 | - $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
267 | + $this->message[$pos]['xattrs']['!'.$key] = $value; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | if ($key == 'xmlns') { |
271 | 271 | $this->default_namespace = $value; |
272 | 272 | } |
273 | 273 | // log id |
274 | - if($key == 'id'){ |
|
274 | + if ($key == 'id') { |
|
275 | 275 | $this->ids[$value] = $pos; |
276 | 276 | } |
277 | 277 | // root |
278 | - if($key_localpart == 'root' && $value == 1){ |
|
278 | + if ($key_localpart == 'root' && $value == 1) { |
|
279 | 279 | $this->status = 'method'; |
280 | 280 | $this->root_struct_name = $name; |
281 | 281 | $this->root_struct = $pos; |
@@ -285,18 +285,18 @@ discard block |
||
285 | 285 | $attstr .= " $key=\"$value\""; |
286 | 286 | } |
287 | 287 | // get namespace - must be done after namespace atts are processed |
288 | - if(isset($prefix)){ |
|
288 | + if (isset($prefix)) { |
|
289 | 289 | $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
290 | 290 | $this->default_namespace = $this->namespaces[$prefix]; |
291 | 291 | } else { |
292 | 292 | $this->message[$pos]['namespace'] = $this->default_namespace; |
293 | 293 | } |
294 | - if($this->status == 'header'){ |
|
294 | + if ($this->status == 'header') { |
|
295 | 295 | if ($this->root_header != $pos) { |
296 | - $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
296 | + $this->responseHeaders .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>"; |
|
297 | 297 | } |
298 | - } elseif($this->root_struct_name != ''){ |
|
299 | - $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
298 | + } elseif ($this->root_struct_name != '') { |
|
299 | + $this->document .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>"; |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
@@ -312,27 +312,27 @@ discard block |
||
312 | 312 | $pos = $this->depth_array[$this->depth--]; |
313 | 313 | |
314 | 314 | // get element prefix |
315 | - if(strpos($name,':')){ |
|
315 | + if (strpos($name, ':')) { |
|
316 | 316 | // get ns prefix |
317 | - $prefix = substr($name,0,strpos($name,':')); |
|
317 | + $prefix = substr($name, 0, strpos($name, ':')); |
|
318 | 318 | // get unqualified name |
319 | - $name = substr(strstr($name,':'),1); |
|
319 | + $name = substr(strstr($name, ':'), 1); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | // build to native type |
323 | - if(isset($this->body_position) && $pos > $this->body_position){ |
|
323 | + if (isset($this->body_position) && $pos > $this->body_position) { |
|
324 | 324 | // deal w/ multirefs |
325 | - if(isset($this->message[$pos]['attrs']['href'])){ |
|
325 | + if (isset($this->message[$pos]['attrs']['href'])) { |
|
326 | 326 | // get id |
327 | - $id = substr($this->message[$pos]['attrs']['href'],1); |
|
327 | + $id = substr($this->message[$pos]['attrs']['href'], 1); |
|
328 | 328 | // add placeholder to href array |
329 | 329 | $this->multirefs[$id][$pos] = 'placeholder'; |
330 | 330 | // add set a reference to it as the result value |
331 | - $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
331 | + $this->message[$pos]['result'] = & $this->multirefs[$id][$pos]; |
|
332 | 332 | // build complexType values |
333 | - } elseif($this->message[$pos]['children'] != ''){ |
|
333 | + } elseif ($this->message[$pos]['children'] != '') { |
|
334 | 334 | // if result has already been generated (struct/array) |
335 | - if(!isset($this->message[$pos]['result'])){ |
|
335 | + if (!isset($this->message[$pos]['result'])) { |
|
336 | 336 | $this->message[$pos]['result'] = $this->buildVal($pos); |
337 | 337 | } |
338 | 338 | // build complexType values of attributes and possibly simpleContent |
@@ -382,15 +382,15 @@ discard block |
||
382 | 382 | } |
383 | 383 | |
384 | 384 | // for doclit |
385 | - if($this->status == 'header'){ |
|
385 | + if ($this->status == 'header') { |
|
386 | 386 | if ($this->root_header != $pos) { |
387 | - $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
387 | + $this->responseHeaders .= "</".(isset($prefix) ? $prefix.':' : '')."$name>"; |
|
388 | 388 | } |
389 | - } elseif($pos >= $this->root_struct){ |
|
390 | - $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
389 | + } elseif ($pos >= $this->root_struct) { |
|
390 | + $this->document .= "</".(isset($prefix) ? $prefix.':' : '')."$name>"; |
|
391 | 391 | } |
392 | 392 | // switch status |
393 | - if ($pos == $this->root_struct){ |
|
393 | + if ($pos == $this->root_struct) { |
|
394 | 394 | $this->status = 'body'; |
395 | 395 | $this->root_struct_namespace = $this->message[$pos]['namespace']; |
396 | 396 | } elseif ($pos == $this->root_header) { |
@@ -416,17 +416,17 @@ discard block |
||
416 | 416 | function character_data($parser, $data) |
417 | 417 | { |
418 | 418 | $pos = $this->depth_array[$this->depth]; |
419 | - if ($this->xml_encoding == 'UTF-8'){ |
|
419 | + if ($this->xml_encoding == 'UTF-8') { |
|
420 | 420 | // TODO: add an option to disable this for folks who want |
421 | 421 | // raw UTF-8 that, e.g., might not map to iso-8859-1 |
422 | 422 | // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
423 | - if($this->decode_utf8){ |
|
423 | + if ($this->decode_utf8) { |
|
424 | 424 | $data = utf8_decode($data); |
425 | 425 | } |
426 | 426 | } |
427 | 427 | $this->message[$pos]['cdata'] .= $data; |
428 | 428 | // for doclit |
429 | - if($this->status == 'header'){ |
|
429 | + if ($this->status == 'header') { |
|
430 | 430 | $this->responseHeaders .= $data; |
431 | 431 | } else { |
432 | 432 | $this->document .= $data; |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @access public |
441 | 441 | * @deprecated use get_soapbody instead |
442 | 442 | */ |
443 | - function get_response(){ |
|
443 | + function get_response() { |
|
444 | 444 | return $this->soapresponse; |
445 | 445 | } |
446 | 446 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * @return mixed |
451 | 451 | * @access public |
452 | 452 | */ |
453 | - function get_soapbody(){ |
|
453 | + function get_soapbody() { |
|
454 | 454 | return $this->soapresponse; |
455 | 455 | } |
456 | 456 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @return mixed |
461 | 461 | * @access public |
462 | 462 | */ |
463 | - function get_soapheader(){ |
|
463 | + function get_soapheader() { |
|
464 | 464 | return $this->soapheader; |
465 | 465 | } |
466 | 466 | |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @return string XML or empty if no Header |
471 | 471 | * @access public |
472 | 472 | */ |
473 | - function getHeaders(){ |
|
473 | + function getHeaders() { |
|
474 | 474 | return $this->responseHeaders; |
475 | 475 | } |
476 | 476 | |
@@ -527,40 +527,40 @@ discard block |
||
527 | 527 | * @return mixed PHP value |
528 | 528 | * @access private |
529 | 529 | */ |
530 | - function buildVal($pos){ |
|
531 | - if(!isset($this->message[$pos]['type'])){ |
|
530 | + function buildVal($pos) { |
|
531 | + if (!isset($this->message[$pos]['type'])) { |
|
532 | 532 | $this->message[$pos]['type'] = ''; |
533 | 533 | } |
534 | 534 | $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
535 | 535 | // if there are children... |
536 | - if($this->message[$pos]['children'] != ''){ |
|
536 | + if ($this->message[$pos]['children'] != '') { |
|
537 | 537 | $this->debug('in buildVal, there are children'); |
538 | - $children = explode('|',$this->message[$pos]['children']); |
|
538 | + $children = explode('|', $this->message[$pos]['children']); |
|
539 | 539 | array_shift($children); // knock off empty |
540 | 540 | // md array |
541 | - if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
542 | - $r=0; // rowcount |
|
543 | - $c=0; // colcount |
|
544 | - foreach($children as $child_pos){ |
|
541 | + if (isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != '') { |
|
542 | + $r = 0; // rowcount |
|
543 | + $c = 0; // colcount |
|
544 | + foreach ($children as $child_pos) { |
|
545 | 545 | $this->debug("in buildVal, got an MD array element: $r, $c"); |
546 | 546 | $params[$r][] = $this->message[$child_pos]['result']; |
547 | 547 | $c++; |
548 | - if($c == $this->message[$pos]['arrayCols']){ |
|
548 | + if ($c == $this->message[$pos]['arrayCols']) { |
|
549 | 549 | $c = 0; |
550 | 550 | $r++; |
551 | 551 | } |
552 | 552 | } |
553 | 553 | // array |
554 | - } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
554 | + } elseif ($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array') { |
|
555 | 555 | $this->debug('in buildVal, adding array '.$this->message[$pos]['name']); |
556 | - foreach($children as $child_pos){ |
|
556 | + foreach ($children as $child_pos) { |
|
557 | 557 | $params[] = &$this->message[$child_pos]['result']; |
558 | 558 | } |
559 | 559 | // apache Map type: java hashtable |
560 | - } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){ |
|
560 | + } elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
561 | 561 | $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']); |
562 | - foreach($children as $child_pos){ |
|
563 | - $kv = explode("|",$this->message[$child_pos]['children']); |
|
562 | + foreach ($children as $child_pos) { |
|
563 | + $kv = explode("|", $this->message[$child_pos]['children']); |
|
564 | 564 | $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
565 | 565 | } |
566 | 566 | // generic compound type |
@@ -574,8 +574,8 @@ discard block |
||
574 | 574 | $notstruct = 0; |
575 | 575 | } |
576 | 576 | // |
577 | - foreach($children as $child_pos){ |
|
578 | - if($notstruct){ |
|
577 | + foreach ($children as $child_pos) { |
|
578 | + if ($notstruct) { |
|
579 | 579 | $params[] = &$this->message[$child_pos]['result']; |
580 | 580 | } else { |
581 | 581 | if (isset($params[$this->message[$child_pos]['name']])) { |
@@ -52,7 +52,7 @@ |
||
52 | 52 | * @param string $encoding character encoding scheme of message |
53 | 53 | * @param string $method method for which XML is parsed (unused?) |
54 | 54 | * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
55 | - * @return void|bool |
|
55 | + * @return false|null |
|
56 | 56 | * @access public |
57 | 57 | */ |
58 | 58 | function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
@@ -11,235 +11,235 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class nusoap_parser extends nusoap_base |
13 | 13 | { |
14 | - var $xml = ''; |
|
15 | - var $xml_encoding = ''; |
|
16 | - var $method = ''; |
|
17 | - var $root_struct = ''; |
|
18 | - var $root_struct_name = ''; |
|
19 | - var $root_struct_namespace = ''; |
|
20 | - var $root_header = ''; |
|
14 | + var $xml = ''; |
|
15 | + var $xml_encoding = ''; |
|
16 | + var $method = ''; |
|
17 | + var $root_struct = ''; |
|
18 | + var $root_struct_name = ''; |
|
19 | + var $root_struct_namespace = ''; |
|
20 | + var $root_header = ''; |
|
21 | 21 | var $document = ''; // incoming SOAP body (text) |
22 | - // determines where in the message we are (envelope,header,body,method) |
|
23 | - var $status = ''; |
|
24 | - var $position = 0; |
|
25 | - var $depth = 0; |
|
26 | - var $default_namespace = ''; |
|
27 | - var $namespaces = array(); |
|
28 | - var $message = array(); |
|
22 | + // determines where in the message we are (envelope,header,body,method) |
|
23 | + var $status = ''; |
|
24 | + var $position = 0; |
|
25 | + var $depth = 0; |
|
26 | + var $default_namespace = ''; |
|
27 | + var $namespaces = array(); |
|
28 | + var $message = array(); |
|
29 | 29 | var $parent; |
30 | - var $fault = false; |
|
31 | - var $fault_code = ''; |
|
32 | - var $fault_str = ''; |
|
33 | - var $fault_detail = ''; |
|
34 | - var $depth_array = array(); |
|
35 | - var $debug_flag = true; |
|
36 | - var $soapresponse = NULL; // parsed SOAP Body |
|
37 | - var $soapheader = NULL; // parsed SOAP Header |
|
38 | - var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | - var $body_position = 0; |
|
40 | - // for multiref parsing: |
|
41 | - // array of id => pos |
|
42 | - var $ids = array(); |
|
43 | - // array of id => hrefs => pos |
|
44 | - var $multirefs = array(); |
|
45 | - // toggle for auto-decoding element content |
|
46 | - var $decode_utf8 = true; |
|
30 | + var $fault = false; |
|
31 | + var $fault_code = ''; |
|
32 | + var $fault_str = ''; |
|
33 | + var $fault_detail = ''; |
|
34 | + var $depth_array = array(); |
|
35 | + var $debug_flag = true; |
|
36 | + var $soapresponse = NULL; // parsed SOAP Body |
|
37 | + var $soapheader = NULL; // parsed SOAP Header |
|
38 | + var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | + var $body_position = 0; |
|
40 | + // for multiref parsing: |
|
41 | + // array of id => pos |
|
42 | + var $ids = array(); |
|
43 | + // array of id => hrefs => pos |
|
44 | + var $multirefs = array(); |
|
45 | + // toggle for auto-decoding element content |
|
46 | + var $decode_utf8 = true; |
|
47 | 47 | |
48 | - /** |
|
49 | - * constructor that actually does the parsing |
|
50 | - * |
|
51 | - * @param string $xml SOAP message |
|
52 | - * @param string $encoding character encoding scheme of message |
|
53 | - * @param string $method method for which XML is parsed (unused?) |
|
54 | - * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
|
55 | - * @return void|bool |
|
56 | - * @access public |
|
57 | - */ |
|
58 | - function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
|
59 | - parent::nusoap_base(); |
|
60 | - $this->xml = $xml; |
|
61 | - $this->xml_encoding = $encoding; |
|
62 | - $this->method = $method; |
|
63 | - $this->decode_utf8 = $decode_utf8; |
|
48 | + /** |
|
49 | + * constructor that actually does the parsing |
|
50 | + * |
|
51 | + * @param string $xml SOAP message |
|
52 | + * @param string $encoding character encoding scheme of message |
|
53 | + * @param string $method method for which XML is parsed (unused?) |
|
54 | + * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
|
55 | + * @return void|bool |
|
56 | + * @access public |
|
57 | + */ |
|
58 | + function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
|
59 | + parent::nusoap_base(); |
|
60 | + $this->xml = $xml; |
|
61 | + $this->xml_encoding = $encoding; |
|
62 | + $this->method = $method; |
|
63 | + $this->decode_utf8 = $decode_utf8; |
|
64 | 64 | |
65 | - // Check whether content has been read. |
|
66 | - if(!empty($this->xml)){ |
|
67 | - // Check XML encoding |
|
68 | - $pos_xml = strpos($xml, '<?xml'); |
|
69 | - if ($pos_xml !== FALSE) { |
|
70 | - $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1); |
|
71 | - if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
|
72 | - $xml_encoding = $res[1]; |
|
73 | - if (strtoupper($xml_encoding) != $encoding) { |
|
74 | - $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
75 | - $this->debug($err); |
|
76 | - if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
|
77 | - $this->setError($err); |
|
78 | - return false; |
|
79 | - } |
|
80 | - // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed |
|
81 | - } else { |
|
82 | - $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration'); |
|
83 | - } |
|
84 | - } else { |
|
85 | - $this->debug('No encoding specified in XML declaration'); |
|
86 | - } |
|
87 | - } else { |
|
88 | - $this->debug('No XML declaration'); |
|
89 | - } |
|
90 | - $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding); |
|
91 | - // Create an XML parser - why not xml_parser_create_ns? |
|
92 | - $this->parser = xml_parser_create($this->xml_encoding); |
|
93 | - // Set the options for parsing the XML data. |
|
94 | - //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
95 | - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
96 | - xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); |
|
97 | - // Set the object for the parser. |
|
98 | - xml_set_object($this->parser, $this); |
|
99 | - // Set the element handlers for the parser. |
|
100 | - xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
101 | - xml_set_character_data_handler($this->parser,'character_data'); |
|
65 | + // Check whether content has been read. |
|
66 | + if(!empty($this->xml)){ |
|
67 | + // Check XML encoding |
|
68 | + $pos_xml = strpos($xml, '<?xml'); |
|
69 | + if ($pos_xml !== FALSE) { |
|
70 | + $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1); |
|
71 | + if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
|
72 | + $xml_encoding = $res[1]; |
|
73 | + if (strtoupper($xml_encoding) != $encoding) { |
|
74 | + $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
75 | + $this->debug($err); |
|
76 | + if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
|
77 | + $this->setError($err); |
|
78 | + return false; |
|
79 | + } |
|
80 | + // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed |
|
81 | + } else { |
|
82 | + $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration'); |
|
83 | + } |
|
84 | + } else { |
|
85 | + $this->debug('No encoding specified in XML declaration'); |
|
86 | + } |
|
87 | + } else { |
|
88 | + $this->debug('No XML declaration'); |
|
89 | + } |
|
90 | + $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding); |
|
91 | + // Create an XML parser - why not xml_parser_create_ns? |
|
92 | + $this->parser = xml_parser_create($this->xml_encoding); |
|
93 | + // Set the options for parsing the XML data. |
|
94 | + //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
95 | + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
96 | + xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); |
|
97 | + // Set the object for the parser. |
|
98 | + xml_set_object($this->parser, $this); |
|
99 | + // Set the element handlers for the parser. |
|
100 | + xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
101 | + xml_set_character_data_handler($this->parser,'character_data'); |
|
102 | 102 | |
103 | - xml_parse($this->parser, $this->xml); |
|
103 | + xml_parse($this->parser, $this->xml); |
|
104 | 104 | |
105 | - // Parse the XML file. |
|
106 | - //if (!xml_parse($this->parser,$xml,true)){ |
|
107 | - if (false) { |
|
108 | - // Display an error message. |
|
109 | - $err = sprintf('XML error parsing SOAP payload on line %d: %s', |
|
110 | - xml_get_current_line_number($this->parser), |
|
111 | - xml_error_string(xml_get_error_code($this->parser))); |
|
112 | - $this->debug($err); |
|
113 | - $this->debug("XML payload:\n" . $xml); |
|
114 | - $this->setError($err); |
|
115 | - } else { |
|
116 | - $this->debug('in nusoap_parser ctor, message:'); |
|
117 | - $this->appendDebug($this->varDump($this->message)); |
|
118 | - $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name); |
|
119 | - // get final value |
|
120 | - $this->soapresponse = $this->message[$this->root_struct]['result']; |
|
121 | - // get header value |
|
122 | - if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
123 | - $this->soapheader = $this->message[$this->root_header]['result']; |
|
124 | - } |
|
125 | - // resolve hrefs/ids |
|
126 | - if(sizeof($this->multirefs) > 0){ |
|
127 | - foreach($this->multirefs as $id => $hrefs){ |
|
128 | - $this->debug('resolving multirefs for id: '.$id); |
|
129 | - $idVal = $this->buildVal($this->ids[$id]); |
|
130 | - if (is_array($idVal) && isset($idVal['!id'])) { |
|
131 | - unset($idVal['!id']); |
|
132 | - } |
|
133 | - foreach($hrefs as $refPos => $ref){ |
|
134 | - $this->debug('resolving href at pos '.$refPos); |
|
135 | - $this->multirefs[$id][$refPos] = $idVal; |
|
136 | - } |
|
137 | - } |
|
138 | - } |
|
139 | - } |
|
140 | - xml_parser_free($this->parser); |
|
141 | - } else { |
|
142 | - $this->debug('xml was empty, didn\'t parse!'); |
|
143 | - $this->setError('xml was empty, didn\'t parse!'); |
|
144 | - } |
|
145 | - } |
|
105 | + // Parse the XML file. |
|
106 | + //if (!xml_parse($this->parser,$xml,true)){ |
|
107 | + if (false) { |
|
108 | + // Display an error message. |
|
109 | + $err = sprintf('XML error parsing SOAP payload on line %d: %s', |
|
110 | + xml_get_current_line_number($this->parser), |
|
111 | + xml_error_string(xml_get_error_code($this->parser))); |
|
112 | + $this->debug($err); |
|
113 | + $this->debug("XML payload:\n" . $xml); |
|
114 | + $this->setError($err); |
|
115 | + } else { |
|
116 | + $this->debug('in nusoap_parser ctor, message:'); |
|
117 | + $this->appendDebug($this->varDump($this->message)); |
|
118 | + $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name); |
|
119 | + // get final value |
|
120 | + $this->soapresponse = $this->message[$this->root_struct]['result']; |
|
121 | + // get header value |
|
122 | + if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
123 | + $this->soapheader = $this->message[$this->root_header]['result']; |
|
124 | + } |
|
125 | + // resolve hrefs/ids |
|
126 | + if(sizeof($this->multirefs) > 0){ |
|
127 | + foreach($this->multirefs as $id => $hrefs){ |
|
128 | + $this->debug('resolving multirefs for id: '.$id); |
|
129 | + $idVal = $this->buildVal($this->ids[$id]); |
|
130 | + if (is_array($idVal) && isset($idVal['!id'])) { |
|
131 | + unset($idVal['!id']); |
|
132 | + } |
|
133 | + foreach($hrefs as $refPos => $ref){ |
|
134 | + $this->debug('resolving href at pos '.$refPos); |
|
135 | + $this->multirefs[$id][$refPos] = $idVal; |
|
136 | + } |
|
137 | + } |
|
138 | + } |
|
139 | + } |
|
140 | + xml_parser_free($this->parser); |
|
141 | + } else { |
|
142 | + $this->debug('xml was empty, didn\'t parse!'); |
|
143 | + $this->setError('xml was empty, didn\'t parse!'); |
|
144 | + } |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * start-element handler |
|
149 | - * |
|
150 | - * @param resource $parser XML parser object |
|
151 | - * @param string $name element name |
|
152 | - * @param array $attrs associative array of attributes |
|
153 | - * @access private |
|
154 | - */ |
|
155 | - function start_element($parser, $name, $attrs) { |
|
147 | + /** |
|
148 | + * start-element handler |
|
149 | + * |
|
150 | + * @param resource $parser XML parser object |
|
151 | + * @param string $name element name |
|
152 | + * @param array $attrs associative array of attributes |
|
153 | + * @access private |
|
154 | + */ |
|
155 | + function start_element($parser, $name, $attrs) { |
|
156 | 156 | |
157 | - // position in a total number of elements, starting from 0 |
|
158 | - // update class level pos |
|
159 | - $pos = $this->position++; |
|
160 | - // and set mine |
|
161 | - $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
162 | - // depth = how many levels removed from root? |
|
163 | - // set mine as current global depth and increment global depth value |
|
164 | - $this->message[$pos]['depth'] = $this->depth++; |
|
157 | + // position in a total number of elements, starting from 0 |
|
158 | + // update class level pos |
|
159 | + $pos = $this->position++; |
|
160 | + // and set mine |
|
161 | + $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
162 | + // depth = how many levels removed from root? |
|
163 | + // set mine as current global depth and increment global depth value |
|
164 | + $this->message[$pos]['depth'] = $this->depth++; |
|
165 | 165 | |
166 | - // else add self as child to whoever the current parent is |
|
167 | - if($pos != 0){ |
|
168 | - $this->message[$this->parent]['children'] .= '|'.$pos; |
|
169 | - } |
|
170 | - // set my parent |
|
171 | - $this->message[$pos]['parent'] = $this->parent; |
|
172 | - // set self as current parent |
|
173 | - $this->parent = $pos; |
|
174 | - // set self as current value for this depth |
|
175 | - $this->depth_array[$this->depth] = $pos; |
|
176 | - // get element prefix |
|
177 | - if(strpos($name,':')){ |
|
178 | - // get ns prefix |
|
179 | - $prefix = substr($name,0,strpos($name,':')); |
|
180 | - // get unqualified name |
|
181 | - $name = substr(strstr($name,':'),1); |
|
182 | - } |
|
183 | - // set status |
|
184 | - if ($name == 'Envelope' && $this->status == '') { |
|
185 | - $this->status = 'envelope'; |
|
186 | - } elseif ($name == 'Header' && $this->status == 'envelope') { |
|
187 | - $this->root_header = $pos; |
|
188 | - $this->status = 'header'; |
|
189 | - } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
190 | - $this->status = 'body'; |
|
191 | - $this->body_position = $pos; |
|
192 | - // set method |
|
193 | - } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
194 | - $this->status = 'method'; |
|
195 | - $this->root_struct_name = $name; |
|
196 | - $this->root_struct = $pos; |
|
197 | - $this->message[$pos]['type'] = 'struct'; |
|
198 | - $this->debug("found root struct $this->root_struct_name, pos $this->root_struct"); |
|
199 | - } |
|
200 | - // set my status |
|
201 | - $this->message[$pos]['status'] = $this->status; |
|
202 | - // set name |
|
203 | - $this->message[$pos]['name'] = htmlspecialchars($name); |
|
204 | - // set attrs |
|
205 | - $this->message[$pos]['attrs'] = $attrs; |
|
166 | + // else add self as child to whoever the current parent is |
|
167 | + if($pos != 0){ |
|
168 | + $this->message[$this->parent]['children'] .= '|'.$pos; |
|
169 | + } |
|
170 | + // set my parent |
|
171 | + $this->message[$pos]['parent'] = $this->parent; |
|
172 | + // set self as current parent |
|
173 | + $this->parent = $pos; |
|
174 | + // set self as current value for this depth |
|
175 | + $this->depth_array[$this->depth] = $pos; |
|
176 | + // get element prefix |
|
177 | + if(strpos($name,':')){ |
|
178 | + // get ns prefix |
|
179 | + $prefix = substr($name,0,strpos($name,':')); |
|
180 | + // get unqualified name |
|
181 | + $name = substr(strstr($name,':'),1); |
|
182 | + } |
|
183 | + // set status |
|
184 | + if ($name == 'Envelope' && $this->status == '') { |
|
185 | + $this->status = 'envelope'; |
|
186 | + } elseif ($name == 'Header' && $this->status == 'envelope') { |
|
187 | + $this->root_header = $pos; |
|
188 | + $this->status = 'header'; |
|
189 | + } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
190 | + $this->status = 'body'; |
|
191 | + $this->body_position = $pos; |
|
192 | + // set method |
|
193 | + } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
194 | + $this->status = 'method'; |
|
195 | + $this->root_struct_name = $name; |
|
196 | + $this->root_struct = $pos; |
|
197 | + $this->message[$pos]['type'] = 'struct'; |
|
198 | + $this->debug("found root struct $this->root_struct_name, pos $this->root_struct"); |
|
199 | + } |
|
200 | + // set my status |
|
201 | + $this->message[$pos]['status'] = $this->status; |
|
202 | + // set name |
|
203 | + $this->message[$pos]['name'] = htmlspecialchars($name); |
|
204 | + // set attrs |
|
205 | + $this->message[$pos]['attrs'] = $attrs; |
|
206 | 206 | |
207 | - // loop through atts, logging ns and type declarations |
|
207 | + // loop through atts, logging ns and type declarations |
|
208 | 208 | $attstr = ''; |
209 | - foreach($attrs as $key => $value){ |
|
210 | - $key_prefix = $this->getPrefix($key); |
|
211 | - $key_localpart = $this->getLocalPart($key); |
|
212 | - // if ns declarations, add to class level array of valid namespaces |
|
209 | + foreach($attrs as $key => $value){ |
|
210 | + $key_prefix = $this->getPrefix($key); |
|
211 | + $key_localpart = $this->getLocalPart($key); |
|
212 | + // if ns declarations, add to class level array of valid namespaces |
|
213 | 213 | if($key_prefix == 'xmlns'){ |
214 | - if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
215 | - $this->XMLSchemaVersion = $value; |
|
216 | - $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
|
217 | - $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
|
218 | - } |
|
214 | + if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
215 | + $this->XMLSchemaVersion = $value; |
|
216 | + $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
|
217 | + $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
|
218 | + } |
|
219 | 219 | $this->namespaces[$key_localpart] = $value; |
220 | - // set method namespace |
|
221 | - if($name == $this->root_struct_name){ |
|
222 | - $this->methodNamespace = $value; |
|
223 | - } |
|
224 | - // if it's a type declaration, set type |
|
220 | + // set method namespace |
|
221 | + if($name == $this->root_struct_name){ |
|
222 | + $this->methodNamespace = $value; |
|
223 | + } |
|
224 | + // if it's a type declaration, set type |
|
225 | 225 | } elseif($key_localpart == 'type'){ |
226 | - if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
|
227 | - // do nothing: already processed arrayType |
|
228 | - } else { |
|
229 | - $value_prefix = $this->getPrefix($value); |
|
230 | - $value_localpart = $this->getLocalPart($value); |
|
231 | - $this->message[$pos]['type'] = $value_localpart; |
|
232 | - $this->message[$pos]['typePrefix'] = $value_prefix; |
|
233 | - if(isset($this->namespaces[$value_prefix])){ |
|
234 | - $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
|
235 | - } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
236 | - $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
|
237 | - } |
|
238 | - // should do something here with the namespace of specified type? |
|
239 | - } |
|
240 | - } elseif($key_localpart == 'arrayType'){ |
|
241 | - $this->message[$pos]['type'] = 'array'; |
|
242 | - /* do arrayType ereg here |
|
226 | + if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
|
227 | + // do nothing: already processed arrayType |
|
228 | + } else { |
|
229 | + $value_prefix = $this->getPrefix($value); |
|
230 | + $value_localpart = $this->getLocalPart($value); |
|
231 | + $this->message[$pos]['type'] = $value_localpart; |
|
232 | + $this->message[$pos]['typePrefix'] = $value_prefix; |
|
233 | + if(isset($this->namespaces[$value_prefix])){ |
|
234 | + $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
|
235 | + } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
236 | + $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
|
237 | + } |
|
238 | + // should do something here with the namespace of specified type? |
|
239 | + } |
|
240 | + } elseif($key_localpart == 'arrayType'){ |
|
241 | + $this->message[$pos]['type'] = 'array'; |
|
242 | + /* do arrayType ereg here |
|
243 | 243 | [1] arrayTypeValue ::= atype asize |
244 | 244 | [2] atype ::= QName rank* |
245 | 245 | [3] rank ::= '[' (',')* ']' |
@@ -247,129 +247,129 @@ discard block |
||
247 | 247 | [5] length ::= nextDimension* Digit+ |
248 | 248 | [6] nextDimension ::= Digit+ ',' |
249 | 249 | */ |
250 | - $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
|
251 | - if(preg_match($expr,$value,$regs)){ |
|
252 | - $this->message[$pos]['typePrefix'] = $regs[1]; |
|
253 | - $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
|
254 | - if (isset($this->namespaces[$regs[1]])) { |
|
255 | - $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]]; |
|
256 | - } else if (isset($attrs['xmlns:'.$regs[1]])) { |
|
257 | - $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]]; |
|
258 | - } |
|
259 | - $this->message[$pos]['arrayType'] = $regs[2]; |
|
260 | - $this->message[$pos]['arraySize'] = $regs[3]; |
|
261 | - $this->message[$pos]['arrayCols'] = $regs[4]; |
|
262 | - } |
|
263 | - // specifies nil value (or not) |
|
264 | - } elseif ($key_localpart == 'nil'){ |
|
265 | - $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
|
266 | - // some other attribute |
|
267 | - } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
|
268 | - $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
269 | - } |
|
250 | + $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
|
251 | + if(preg_match($expr,$value,$regs)){ |
|
252 | + $this->message[$pos]['typePrefix'] = $regs[1]; |
|
253 | + $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
|
254 | + if (isset($this->namespaces[$regs[1]])) { |
|
255 | + $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]]; |
|
256 | + } else if (isset($attrs['xmlns:'.$regs[1]])) { |
|
257 | + $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]]; |
|
258 | + } |
|
259 | + $this->message[$pos]['arrayType'] = $regs[2]; |
|
260 | + $this->message[$pos]['arraySize'] = $regs[3]; |
|
261 | + $this->message[$pos]['arrayCols'] = $regs[4]; |
|
262 | + } |
|
263 | + // specifies nil value (or not) |
|
264 | + } elseif ($key_localpart == 'nil'){ |
|
265 | + $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
|
266 | + // some other attribute |
|
267 | + } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
|
268 | + $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
269 | + } |
|
270 | 270 | |
271 | - if ($key == 'xmlns') { |
|
272 | - $this->default_namespace = $value; |
|
273 | - } |
|
274 | - // log id |
|
275 | - if($key == 'id'){ |
|
276 | - $this->ids[$value] = $pos; |
|
277 | - } |
|
278 | - // root |
|
279 | - if($key_localpart == 'root' && $value == 1){ |
|
280 | - $this->status = 'method'; |
|
281 | - $this->root_struct_name = $name; |
|
282 | - $this->root_struct = $pos; |
|
283 | - $this->debug("found root struct $this->root_struct_name, pos $pos"); |
|
284 | - } |
|
271 | + if ($key == 'xmlns') { |
|
272 | + $this->default_namespace = $value; |
|
273 | + } |
|
274 | + // log id |
|
275 | + if($key == 'id'){ |
|
276 | + $this->ids[$value] = $pos; |
|
277 | + } |
|
278 | + // root |
|
279 | + if($key_localpart == 'root' && $value == 1){ |
|
280 | + $this->status = 'method'; |
|
281 | + $this->root_struct_name = $name; |
|
282 | + $this->root_struct = $pos; |
|
283 | + $this->debug("found root struct $this->root_struct_name, pos $pos"); |
|
284 | + } |
|
285 | 285 | // for doclit |
286 | 286 | $attstr .= " $key=\"$value\""; |
287 | - } |
|
287 | + } |
|
288 | 288 | // get namespace - must be done after namespace atts are processed |
289 | - if(isset($prefix)){ |
|
290 | - $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
|
291 | - $this->default_namespace = $this->namespaces[$prefix]; |
|
292 | - } else { |
|
293 | - $this->message[$pos]['namespace'] = $this->default_namespace; |
|
294 | - } |
|
289 | + if(isset($prefix)){ |
|
290 | + $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
|
291 | + $this->default_namespace = $this->namespaces[$prefix]; |
|
292 | + } else { |
|
293 | + $this->message[$pos]['namespace'] = $this->default_namespace; |
|
294 | + } |
|
295 | 295 | if($this->status == 'header'){ |
296 | - if ($this->root_header != $pos) { |
|
297 | - $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
298 | - } |
|
296 | + if ($this->root_header != $pos) { |
|
297 | + $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
298 | + } |
|
299 | 299 | } elseif($this->root_struct_name != ''){ |
300 | - $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
300 | + $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
301 | 301 | } |
302 | - } |
|
302 | + } |
|
303 | 303 | |
304 | - /** |
|
305 | - * end-element handler |
|
306 | - * |
|
307 | - * @param resource $parser XML parser object |
|
308 | - * @param string $name element name |
|
309 | - * @access private |
|
310 | - */ |
|
311 | - function end_element($parser, $name) { |
|
312 | - // position of current element is equal to the last value left in depth_array for my depth |
|
313 | - $pos = $this->depth_array[$this->depth--]; |
|
304 | + /** |
|
305 | + * end-element handler |
|
306 | + * |
|
307 | + * @param resource $parser XML parser object |
|
308 | + * @param string $name element name |
|
309 | + * @access private |
|
310 | + */ |
|
311 | + function end_element($parser, $name) { |
|
312 | + // position of current element is equal to the last value left in depth_array for my depth |
|
313 | + $pos = $this->depth_array[$this->depth--]; |
|
314 | 314 | |
315 | 315 | // get element prefix |
316 | - if(strpos($name,':')){ |
|
317 | - // get ns prefix |
|
318 | - $prefix = substr($name,0,strpos($name,':')); |
|
319 | - // get unqualified name |
|
320 | - $name = substr(strstr($name,':'),1); |
|
321 | - } |
|
316 | + if(strpos($name,':')){ |
|
317 | + // get ns prefix |
|
318 | + $prefix = substr($name,0,strpos($name,':')); |
|
319 | + // get unqualified name |
|
320 | + $name = substr(strstr($name,':'),1); |
|
321 | + } |
|
322 | 322 | |
323 | - // build to native type |
|
324 | - if(isset($this->body_position) && $pos > $this->body_position){ |
|
325 | - // deal w/ multirefs |
|
326 | - if(isset($this->message[$pos]['attrs']['href'])){ |
|
327 | - // get id |
|
328 | - $id = substr($this->message[$pos]['attrs']['href'],1); |
|
329 | - // add placeholder to href array |
|
330 | - $this->multirefs[$id][$pos] = 'placeholder'; |
|
331 | - // add set a reference to it as the result value |
|
332 | - $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
323 | + // build to native type |
|
324 | + if(isset($this->body_position) && $pos > $this->body_position){ |
|
325 | + // deal w/ multirefs |
|
326 | + if(isset($this->message[$pos]['attrs']['href'])){ |
|
327 | + // get id |
|
328 | + $id = substr($this->message[$pos]['attrs']['href'],1); |
|
329 | + // add placeholder to href array |
|
330 | + $this->multirefs[$id][$pos] = 'placeholder'; |
|
331 | + // add set a reference to it as the result value |
|
332 | + $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
333 | 333 | // build complexType values |
334 | - } elseif($this->message[$pos]['children'] != ''){ |
|
335 | - // if result has already been generated (struct/array) |
|
336 | - if(!isset($this->message[$pos]['result'])){ |
|
337 | - $this->message[$pos]['result'] = $this->buildVal($pos); |
|
338 | - } |
|
339 | - // build complexType values of attributes and possibly simpleContent |
|
340 | - } elseif (isset($this->message[$pos]['xattrs'])) { |
|
341 | - if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
342 | - $this->message[$pos]['xattrs']['!'] = null; |
|
343 | - } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
344 | - if (isset($this->message[$pos]['type'])) { |
|
345 | - $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
346 | - } else { |
|
347 | - $parent = $this->message[$pos]['parent']; |
|
348 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
349 | - $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
350 | - } else { |
|
351 | - $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata']; |
|
352 | - } |
|
353 | - } |
|
354 | - } |
|
355 | - $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; |
|
356 | - // set value of simpleType (or nil complexType) |
|
357 | - } else { |
|
358 | - //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); |
|
359 | - if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
360 | - $this->message[$pos]['xattrs']['!'] = null; |
|
361 | - } elseif (isset($this->message[$pos]['type'])) { |
|
362 | - $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
363 | - } else { |
|
364 | - $parent = $this->message[$pos]['parent']; |
|
365 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
366 | - $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
367 | - } else { |
|
368 | - $this->message[$pos]['result'] = $this->message[$pos]['cdata']; |
|
369 | - } |
|
370 | - } |
|
334 | + } elseif($this->message[$pos]['children'] != ''){ |
|
335 | + // if result has already been generated (struct/array) |
|
336 | + if(!isset($this->message[$pos]['result'])){ |
|
337 | + $this->message[$pos]['result'] = $this->buildVal($pos); |
|
338 | + } |
|
339 | + // build complexType values of attributes and possibly simpleContent |
|
340 | + } elseif (isset($this->message[$pos]['xattrs'])) { |
|
341 | + if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
342 | + $this->message[$pos]['xattrs']['!'] = null; |
|
343 | + } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
344 | + if (isset($this->message[$pos]['type'])) { |
|
345 | + $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
346 | + } else { |
|
347 | + $parent = $this->message[$pos]['parent']; |
|
348 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
349 | + $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
350 | + } else { |
|
351 | + $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata']; |
|
352 | + } |
|
353 | + } |
|
354 | + } |
|
355 | + $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; |
|
356 | + // set value of simpleType (or nil complexType) |
|
357 | + } else { |
|
358 | + //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); |
|
359 | + if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
360 | + $this->message[$pos]['xattrs']['!'] = null; |
|
361 | + } elseif (isset($this->message[$pos]['type'])) { |
|
362 | + $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
363 | + } else { |
|
364 | + $parent = $this->message[$pos]['parent']; |
|
365 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
366 | + $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
367 | + } else { |
|
368 | + $this->message[$pos]['result'] = $this->message[$pos]['cdata']; |
|
369 | + } |
|
370 | + } |
|
371 | 371 | |
372 | - /* add value to parent's result, if parent is struct/array |
|
372 | + /* add value to parent's result, if parent is struct/array |
|
373 | 373 | $parent = $this->message[$pos]['parent']; |
374 | 374 | if($this->message[$parent]['type'] != 'map'){ |
375 | 375 | if(strtolower($this->message[$parent]['type']) == 'array'){ |
@@ -379,261 +379,261 @@ discard block |
||
379 | 379 | } |
380 | 380 | } |
381 | 381 | */ |
382 | - } |
|
383 | - } |
|
382 | + } |
|
383 | + } |
|
384 | 384 | |
385 | 385 | // for doclit |
386 | 386 | if($this->status == 'header'){ |
387 | - if ($this->root_header != $pos) { |
|
388 | - $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
389 | - } |
|
387 | + if ($this->root_header != $pos) { |
|
388 | + $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
389 | + } |
|
390 | 390 | } elseif($pos >= $this->root_struct){ |
391 | - $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
391 | + $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
392 | 392 | } |
393 | - // switch status |
|
394 | - if ($pos == $this->root_struct){ |
|
395 | - $this->status = 'body'; |
|
396 | - $this->root_struct_namespace = $this->message[$pos]['namespace']; |
|
397 | - } elseif ($pos == $this->root_header) { |
|
398 | - $this->status = 'envelope'; |
|
399 | - } elseif ($name == 'Body' && $this->status == 'body') { |
|
400 | - $this->status = 'envelope'; |
|
401 | - } elseif ($name == 'Header' && $this->status == 'header') { // will never happen |
|
402 | - $this->status = 'envelope'; |
|
403 | - } elseif ($name == 'Envelope' && $this->status == 'envelope') { |
|
404 | - $this->status = ''; |
|
405 | - } |
|
406 | - // set parent back to my parent |
|
407 | - $this->parent = $this->message[$pos]['parent']; |
|
408 | - } |
|
393 | + // switch status |
|
394 | + if ($pos == $this->root_struct){ |
|
395 | + $this->status = 'body'; |
|
396 | + $this->root_struct_namespace = $this->message[$pos]['namespace']; |
|
397 | + } elseif ($pos == $this->root_header) { |
|
398 | + $this->status = 'envelope'; |
|
399 | + } elseif ($name == 'Body' && $this->status == 'body') { |
|
400 | + $this->status = 'envelope'; |
|
401 | + } elseif ($name == 'Header' && $this->status == 'header') { // will never happen |
|
402 | + $this->status = 'envelope'; |
|
403 | + } elseif ($name == 'Envelope' && $this->status == 'envelope') { |
|
404 | + $this->status = ''; |
|
405 | + } |
|
406 | + // set parent back to my parent |
|
407 | + $this->parent = $this->message[$pos]['parent']; |
|
408 | + } |
|
409 | 409 | |
410 | - /** |
|
411 | - * element content handler |
|
412 | - * |
|
413 | - * @param resource $parser XML parser object |
|
414 | - * @param string $data element content |
|
415 | - * @access private |
|
416 | - */ |
|
417 | - function character_data($parser, $data) |
|
410 | + /** |
|
411 | + * element content handler |
|
412 | + * |
|
413 | + * @param resource $parser XML parser object |
|
414 | + * @param string $data element content |
|
415 | + * @access private |
|
416 | + */ |
|
417 | + function character_data($parser, $data) |
|
418 | 418 | { |
419 | - $pos = $this->depth_array[$this->depth]; |
|
420 | - if ($this->xml_encoding == 'UTF-8'){ |
|
421 | - // TODO: add an option to disable this for folks who want |
|
422 | - // raw UTF-8 that, e.g., might not map to iso-8859-1 |
|
423 | - // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
|
424 | - if($this->decode_utf8){ |
|
425 | - $data = utf8_decode($data); |
|
426 | - } |
|
427 | - } |
|
419 | + $pos = $this->depth_array[$this->depth]; |
|
420 | + if ($this->xml_encoding == 'UTF-8'){ |
|
421 | + // TODO: add an option to disable this for folks who want |
|
422 | + // raw UTF-8 that, e.g., might not map to iso-8859-1 |
|
423 | + // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
|
424 | + if($this->decode_utf8){ |
|
425 | + $data = utf8_decode($data); |
|
426 | + } |
|
427 | + } |
|
428 | 428 | $this->message[$pos]['cdata'] .= $data; |
429 | 429 | // for doclit |
430 | 430 | if($this->status == 'header'){ |
431 | - $this->responseHeaders .= $data; |
|
431 | + $this->responseHeaders .= $data; |
|
432 | 432 | } else { |
433 | - $this->document .= $data; |
|
433 | + $this->document .= $data; |
|
434 | 434 | } |
435 | - } |
|
435 | + } |
|
436 | 436 | |
437 | - /** |
|
438 | - * get the parsed message (SOAP Body) |
|
439 | - * |
|
440 | - * @return mixed |
|
441 | - * @access public |
|
442 | - * @deprecated use get_soapbody instead |
|
443 | - */ |
|
444 | - function get_response(){ |
|
445 | - return $this->soapresponse; |
|
446 | - } |
|
437 | + /** |
|
438 | + * get the parsed message (SOAP Body) |
|
439 | + * |
|
440 | + * @return mixed |
|
441 | + * @access public |
|
442 | + * @deprecated use get_soapbody instead |
|
443 | + */ |
|
444 | + function get_response(){ |
|
445 | + return $this->soapresponse; |
|
446 | + } |
|
447 | 447 | |
448 | - /** |
|
449 | - * get the parsed SOAP Body (NULL if there was none) |
|
450 | - * |
|
451 | - * @return mixed |
|
452 | - * @access public |
|
453 | - */ |
|
454 | - function get_soapbody(){ |
|
455 | - return $this->soapresponse; |
|
456 | - } |
|
448 | + /** |
|
449 | + * get the parsed SOAP Body (NULL if there was none) |
|
450 | + * |
|
451 | + * @return mixed |
|
452 | + * @access public |
|
453 | + */ |
|
454 | + function get_soapbody(){ |
|
455 | + return $this->soapresponse; |
|
456 | + } |
|
457 | 457 | |
458 | - /** |
|
459 | - * get the parsed SOAP Header (NULL if there was none) |
|
460 | - * |
|
461 | - * @return mixed |
|
462 | - * @access public |
|
463 | - */ |
|
464 | - function get_soapheader(){ |
|
465 | - return $this->soapheader; |
|
466 | - } |
|
458 | + /** |
|
459 | + * get the parsed SOAP Header (NULL if there was none) |
|
460 | + * |
|
461 | + * @return mixed |
|
462 | + * @access public |
|
463 | + */ |
|
464 | + function get_soapheader(){ |
|
465 | + return $this->soapheader; |
|
466 | + } |
|
467 | 467 | |
468 | - /** |
|
469 | - * get the unparsed SOAP Header |
|
470 | - * |
|
471 | - * @return string XML or empty if no Header |
|
472 | - * @access public |
|
473 | - */ |
|
474 | - function getHeaders(){ |
|
475 | - return $this->responseHeaders; |
|
476 | - } |
|
468 | + /** |
|
469 | + * get the unparsed SOAP Header |
|
470 | + * |
|
471 | + * @return string XML or empty if no Header |
|
472 | + * @access public |
|
473 | + */ |
|
474 | + function getHeaders(){ |
|
475 | + return $this->responseHeaders; |
|
476 | + } |
|
477 | 477 | |
478 | - /** |
|
479 | - * decodes simple types into PHP variables |
|
480 | - * |
|
481 | - * @param string $value value to decode |
|
482 | - * @param string $type XML type to decode |
|
483 | - * @param string $typens XML type namespace to decode |
|
484 | - * @return mixed PHP value |
|
485 | - * @access private |
|
486 | - */ |
|
487 | - function decodeSimple($value, $type, $typens) { |
|
488 | - // TODO: use the namespace! |
|
489 | - if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { |
|
490 | - return (string) $value; |
|
491 | - } |
|
492 | - if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { |
|
493 | - return (int) $value; |
|
494 | - } |
|
495 | - if ($type == 'float' || $type == 'double' || $type == 'decimal') { |
|
496 | - return (double) $value; |
|
497 | - } |
|
498 | - if ($type == 'boolean') { |
|
499 | - if (strtolower($value) == 'false' || strtolower($value) == 'f') { |
|
500 | - return false; |
|
501 | - } |
|
502 | - return (boolean) $value; |
|
503 | - } |
|
504 | - if ($type == 'base64' || $type == 'base64Binary') { |
|
505 | - $this->debug('Decode base64 value'); |
|
506 | - return base64_decode($value); |
|
507 | - } |
|
508 | - // obscure numeric types |
|
509 | - if ($type == 'nonPositiveInteger' || $type == 'negativeInteger' |
|
510 | - || $type == 'nonNegativeInteger' || $type == 'positiveInteger' |
|
511 | - || $type == 'unsignedInt' |
|
512 | - || $type == 'unsignedShort' || $type == 'unsignedByte') { |
|
513 | - return (int) $value; |
|
514 | - } |
|
515 | - // bogus: parser treats array with no elements as a simple type |
|
516 | - if ($type == 'array') { |
|
517 | - return array(); |
|
518 | - } |
|
519 | - // everything else |
|
520 | - return (string) $value; |
|
521 | - } |
|
478 | + /** |
|
479 | + * decodes simple types into PHP variables |
|
480 | + * |
|
481 | + * @param string $value value to decode |
|
482 | + * @param string $type XML type to decode |
|
483 | + * @param string $typens XML type namespace to decode |
|
484 | + * @return mixed PHP value |
|
485 | + * @access private |
|
486 | + */ |
|
487 | + function decodeSimple($value, $type, $typens) { |
|
488 | + // TODO: use the namespace! |
|
489 | + if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { |
|
490 | + return (string) $value; |
|
491 | + } |
|
492 | + if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { |
|
493 | + return (int) $value; |
|
494 | + } |
|
495 | + if ($type == 'float' || $type == 'double' || $type == 'decimal') { |
|
496 | + return (double) $value; |
|
497 | + } |
|
498 | + if ($type == 'boolean') { |
|
499 | + if (strtolower($value) == 'false' || strtolower($value) == 'f') { |
|
500 | + return false; |
|
501 | + } |
|
502 | + return (boolean) $value; |
|
503 | + } |
|
504 | + if ($type == 'base64' || $type == 'base64Binary') { |
|
505 | + $this->debug('Decode base64 value'); |
|
506 | + return base64_decode($value); |
|
507 | + } |
|
508 | + // obscure numeric types |
|
509 | + if ($type == 'nonPositiveInteger' || $type == 'negativeInteger' |
|
510 | + || $type == 'nonNegativeInteger' || $type == 'positiveInteger' |
|
511 | + || $type == 'unsignedInt' |
|
512 | + || $type == 'unsignedShort' || $type == 'unsignedByte') { |
|
513 | + return (int) $value; |
|
514 | + } |
|
515 | + // bogus: parser treats array with no elements as a simple type |
|
516 | + if ($type == 'array') { |
|
517 | + return array(); |
|
518 | + } |
|
519 | + // everything else |
|
520 | + return (string) $value; |
|
521 | + } |
|
522 | 522 | |
523 | - /** |
|
524 | - * builds response structures for compound values (arrays/structs) |
|
525 | - * and scalars |
|
526 | - * |
|
527 | - * @param integer $pos position in node tree |
|
528 | - * @return mixed PHP value |
|
529 | - * @access private |
|
530 | - */ |
|
531 | - function buildVal($pos){ |
|
532 | - if(!isset($this->message[$pos]['type'])){ |
|
533 | - $this->message[$pos]['type'] = ''; |
|
534 | - } |
|
535 | - $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
|
536 | - // if there are children... |
|
537 | - if($this->message[$pos]['children'] != ''){ |
|
538 | - $this->debug('in buildVal, there are children'); |
|
539 | - $children = explode('|',$this->message[$pos]['children']); |
|
540 | - array_shift($children); // knock off empty |
|
541 | - // md array |
|
542 | - if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
543 | - $r=0; // rowcount |
|
544 | - $c=0; // colcount |
|
545 | - foreach($children as $child_pos){ |
|
546 | - $this->debug("in buildVal, got an MD array element: $r, $c"); |
|
547 | - $params[$r][] = $this->message[$child_pos]['result']; |
|
548 | - $c++; |
|
549 | - if($c == $this->message[$pos]['arrayCols']){ |
|
550 | - $c = 0; |
|
551 | - $r++; |
|
552 | - } |
|
523 | + /** |
|
524 | + * builds response structures for compound values (arrays/structs) |
|
525 | + * and scalars |
|
526 | + * |
|
527 | + * @param integer $pos position in node tree |
|
528 | + * @return mixed PHP value |
|
529 | + * @access private |
|
530 | + */ |
|
531 | + function buildVal($pos){ |
|
532 | + if(!isset($this->message[$pos]['type'])){ |
|
533 | + $this->message[$pos]['type'] = ''; |
|
534 | + } |
|
535 | + $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
|
536 | + // if there are children... |
|
537 | + if($this->message[$pos]['children'] != ''){ |
|
538 | + $this->debug('in buildVal, there are children'); |
|
539 | + $children = explode('|',$this->message[$pos]['children']); |
|
540 | + array_shift($children); // knock off empty |
|
541 | + // md array |
|
542 | + if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
543 | + $r=0; // rowcount |
|
544 | + $c=0; // colcount |
|
545 | + foreach($children as $child_pos){ |
|
546 | + $this->debug("in buildVal, got an MD array element: $r, $c"); |
|
547 | + $params[$r][] = $this->message[$child_pos]['result']; |
|
548 | + $c++; |
|
549 | + if($c == $this->message[$pos]['arrayCols']){ |
|
550 | + $c = 0; |
|
551 | + $r++; |
|
552 | + } |
|
553 | 553 | } |
554 | 554 | // array |
555 | - } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
555 | + } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
556 | 556 | $this->debug('in buildVal, adding array '.$this->message[$pos]['name']); |
557 | 557 | foreach($children as $child_pos){ |
558 | - $params[] = &$this->message[$child_pos]['result']; |
|
558 | + $params[] = &$this->message[$child_pos]['result']; |
|
559 | 559 | } |
560 | 560 | // apache Map type: java hashtable |
561 | 561 | } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){ |
562 | 562 | $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']); |
563 | 563 | foreach($children as $child_pos){ |
564 | - $kv = explode("|",$this->message[$child_pos]['children']); |
|
565 | - $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
|
564 | + $kv = explode("|",$this->message[$child_pos]['children']); |
|
565 | + $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
|
566 | 566 | } |
567 | 567 | // generic compound type |
568 | 568 | //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') { |
569 | - } else { |
|
570 | - // Apache Vector type: treat as an array |
|
569 | + } else { |
|
570 | + // Apache Vector type: treat as an array |
|
571 | 571 | $this->debug('in buildVal, adding Java Vector or generic compound type '.$this->message[$pos]['name']); |
572 | - if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
573 | - $notstruct = 1; |
|
574 | - } else { |
|
575 | - $notstruct = 0; |
|
576 | - } |
|
577 | - // |
|
578 | - foreach($children as $child_pos){ |
|
579 | - if($notstruct){ |
|
580 | - $params[] = &$this->message[$child_pos]['result']; |
|
581 | - } else { |
|
582 | - if (isset($params[$this->message[$child_pos]['name']])) { |
|
583 | - // de-serialize repeated element name into an array |
|
584 | - if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { |
|
585 | - $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); |
|
586 | - } |
|
587 | - $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; |
|
588 | - } else { |
|
589 | - $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result']; |
|
590 | - } |
|
591 | - } |
|
572 | + if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
573 | + $notstruct = 1; |
|
574 | + } else { |
|
575 | + $notstruct = 0; |
|
592 | 576 | } |
593 | - } |
|
594 | - if (isset($this->message[$pos]['xattrs'])) { |
|
577 | + // |
|
578 | + foreach($children as $child_pos){ |
|
579 | + if($notstruct){ |
|
580 | + $params[] = &$this->message[$child_pos]['result']; |
|
581 | + } else { |
|
582 | + if (isset($params[$this->message[$child_pos]['name']])) { |
|
583 | + // de-serialize repeated element name into an array |
|
584 | + if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { |
|
585 | + $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); |
|
586 | + } |
|
587 | + $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; |
|
588 | + } else { |
|
589 | + $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result']; |
|
590 | + } |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | + if (isset($this->message[$pos]['xattrs'])) { |
|
595 | 595 | $this->debug('in buildVal, handling attributes'); |
596 | - foreach ($this->message[$pos]['xattrs'] as $n => $v) { |
|
597 | - $params[$n] = $v; |
|
598 | - } |
|
599 | - } |
|
600 | - // handle simpleContent |
|
601 | - if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
596 | + foreach ($this->message[$pos]['xattrs'] as $n => $v) { |
|
597 | + $params[$n] = $v; |
|
598 | + } |
|
599 | + } |
|
600 | + // handle simpleContent |
|
601 | + if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
602 | 602 | $this->debug('in buildVal, handling simpleContent'); |
603 | - if (isset($this->message[$pos]['type'])) { |
|
604 | - $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
605 | - } else { |
|
606 | - $parent = $this->message[$pos]['parent']; |
|
607 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
608 | - $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
609 | - } else { |
|
610 | - $params['!'] = $this->message[$pos]['cdata']; |
|
611 | - } |
|
612 | - } |
|
613 | - } |
|
614 | - $ret = is_array($params) ? $params : array(); |
|
615 | - $this->debug('in buildVal, return:'); |
|
616 | - //$this->appendDebug($this->varDump($ret)); |
|
617 | - return $ret; |
|
618 | - } else { |
|
619 | - $this->debug('in buildVal, no children, building scalar'); |
|
620 | - $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; |
|
621 | - if (isset($this->message[$pos]['type'])) { |
|
622 | - $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
623 | - $this->debug("in buildVal, return: $ret"); |
|
624 | - return $ret; |
|
625 | - } |
|
626 | - $parent = $this->message[$pos]['parent']; |
|
627 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
628 | - $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
629 | - $this->debug("in buildVal, return: $ret"); |
|
630 | - return $ret; |
|
631 | - } |
|
632 | - $ret = $this->message[$pos]['cdata']; |
|
633 | - $this->debug("in buildVal, return: $ret"); |
|
634 | - return $ret; |
|
635 | - } |
|
636 | - } |
|
603 | + if (isset($this->message[$pos]['type'])) { |
|
604 | + $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
605 | + } else { |
|
606 | + $parent = $this->message[$pos]['parent']; |
|
607 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
608 | + $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
609 | + } else { |
|
610 | + $params['!'] = $this->message[$pos]['cdata']; |
|
611 | + } |
|
612 | + } |
|
613 | + } |
|
614 | + $ret = is_array($params) ? $params : array(); |
|
615 | + $this->debug('in buildVal, return:'); |
|
616 | + //$this->appendDebug($this->varDump($ret)); |
|
617 | + return $ret; |
|
618 | + } else { |
|
619 | + $this->debug('in buildVal, no children, building scalar'); |
|
620 | + $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; |
|
621 | + if (isset($this->message[$pos]['type'])) { |
|
622 | + $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
623 | + $this->debug("in buildVal, return: $ret"); |
|
624 | + return $ret; |
|
625 | + } |
|
626 | + $parent = $this->message[$pos]['parent']; |
|
627 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
628 | + $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
629 | + $this->debug("in buildVal, return: $ret"); |
|
630 | + return $ret; |
|
631 | + } |
|
632 | + $ret = $this->message[$pos]['cdata']; |
|
633 | + $this->debug("in buildVal, return: $ret"); |
|
634 | + return $ret; |
|
635 | + } |
|
636 | + } |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | /** |
@@ -16,189 +16,189 @@ |
||
16 | 16 | * @access public |
17 | 17 | */ |
18 | 18 | class nusoap_wsdlcache { |
19 | - /** |
|
20 | - * @var resource |
|
21 | - * @access private |
|
22 | - */ |
|
23 | - var $fplock; |
|
24 | - /** |
|
25 | - * @var integer |
|
26 | - * @access private |
|
27 | - */ |
|
28 | - var $cache_lifetime; |
|
29 | - /** |
|
30 | - * @var string |
|
31 | - * @access private |
|
32 | - */ |
|
33 | - var $cache_dir; |
|
34 | - /** |
|
35 | - * @var string |
|
36 | - * @access public |
|
37 | - */ |
|
38 | - var $debug_str = ''; |
|
19 | + /** |
|
20 | + * @var resource |
|
21 | + * @access private |
|
22 | + */ |
|
23 | + var $fplock; |
|
24 | + /** |
|
25 | + * @var integer |
|
26 | + * @access private |
|
27 | + */ |
|
28 | + var $cache_lifetime; |
|
29 | + /** |
|
30 | + * @var string |
|
31 | + * @access private |
|
32 | + */ |
|
33 | + var $cache_dir; |
|
34 | + /** |
|
35 | + * @var string |
|
36 | + * @access public |
|
37 | + */ |
|
38 | + var $debug_str = ''; |
|
39 | 39 | |
40 | - /** |
|
41 | - * constructor |
|
42 | - * |
|
43 | - * @param string $cache_dir directory for cache-files |
|
44 | - * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited |
|
45 | - * @access public |
|
46 | - */ |
|
47 | - function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) { |
|
48 | - $this->fplock = array(); |
|
49 | - $this->cache_dir = $cache_dir != '' ? $cache_dir : '.'; |
|
50 | - $this->cache_lifetime = $cache_lifetime; |
|
51 | - } |
|
40 | + /** |
|
41 | + * constructor |
|
42 | + * |
|
43 | + * @param string $cache_dir directory for cache-files |
|
44 | + * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited |
|
45 | + * @access public |
|
46 | + */ |
|
47 | + function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) { |
|
48 | + $this->fplock = array(); |
|
49 | + $this->cache_dir = $cache_dir != '' ? $cache_dir : '.'; |
|
50 | + $this->cache_lifetime = $cache_lifetime; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * creates the filename used to cache a wsdl instance |
|
55 | - * |
|
56 | - * @param string $wsdl The URL of the wsdl instance |
|
57 | - * @return string The filename used to cache the instance |
|
58 | - * @access private |
|
59 | - */ |
|
60 | - function createFilename($wsdl) { |
|
61 | - return $this->cache_dir.'/wsdlcache-' . md5($wsdl); |
|
62 | - } |
|
53 | + /** |
|
54 | + * creates the filename used to cache a wsdl instance |
|
55 | + * |
|
56 | + * @param string $wsdl The URL of the wsdl instance |
|
57 | + * @return string The filename used to cache the instance |
|
58 | + * @access private |
|
59 | + */ |
|
60 | + function createFilename($wsdl) { |
|
61 | + return $this->cache_dir.'/wsdlcache-' . md5($wsdl); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * adds debug data to the class level debug string |
|
66 | - * |
|
67 | - * @param string $string debug data |
|
68 | - * @access private |
|
69 | - */ |
|
70 | - function debug($string){ |
|
71 | - $this->debug_str .= get_class($this).": $string\n"; |
|
72 | - } |
|
64 | + /** |
|
65 | + * adds debug data to the class level debug string |
|
66 | + * |
|
67 | + * @param string $string debug data |
|
68 | + * @access private |
|
69 | + */ |
|
70 | + function debug($string){ |
|
71 | + $this->debug_str .= get_class($this).": $string\n"; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * gets a wsdl instance from the cache |
|
76 | - * |
|
77 | - * @param string $wsdl The URL of the wsdl instance |
|
78 | - * @return object wsdl The cached wsdl instance, null if the instance is not in the cache |
|
79 | - * @access public |
|
80 | - */ |
|
81 | - function get($wsdl) { |
|
82 | - $filename = $this->createFilename($wsdl); |
|
83 | - if ($this->obtainMutex($filename, "r")) { |
|
84 | - // check for expired WSDL that must be removed from the cache |
|
85 | - if ($this->cache_lifetime > 0) { |
|
86 | - if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) { |
|
87 | - unlink($filename); |
|
88 | - $this->debug("Expired $wsdl ($filename) from cache"); |
|
89 | - $this->releaseMutex($filename); |
|
90 | - return null; |
|
91 | - } |
|
92 | - } |
|
93 | - // see what there is to return |
|
94 | - if (!file_exists($filename)) { |
|
95 | - $this->debug("$wsdl ($filename) not in cache (1)"); |
|
96 | - $this->releaseMutex($filename); |
|
97 | - return null; |
|
98 | - } |
|
99 | - $fp = @fopen($filename, "r"); |
|
100 | - if ($fp) { |
|
101 | - $s = implode("", @file($filename)); |
|
102 | - fclose($fp); |
|
103 | - $this->debug("Got $wsdl ($filename) from cache"); |
|
104 | - } else { |
|
105 | - $s = null; |
|
106 | - $this->debug("$wsdl ($filename) not in cache (2)"); |
|
107 | - } |
|
108 | - $this->releaseMutex($filename); |
|
109 | - return (!is_null($s)) ? unserialize($s) : null; |
|
110 | - } else { |
|
111 | - $this->debug("Unable to obtain mutex for $filename in get"); |
|
112 | - } |
|
113 | - return null; |
|
114 | - } |
|
74 | + /** |
|
75 | + * gets a wsdl instance from the cache |
|
76 | + * |
|
77 | + * @param string $wsdl The URL of the wsdl instance |
|
78 | + * @return object wsdl The cached wsdl instance, null if the instance is not in the cache |
|
79 | + * @access public |
|
80 | + */ |
|
81 | + function get($wsdl) { |
|
82 | + $filename = $this->createFilename($wsdl); |
|
83 | + if ($this->obtainMutex($filename, "r")) { |
|
84 | + // check for expired WSDL that must be removed from the cache |
|
85 | + if ($this->cache_lifetime > 0) { |
|
86 | + if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) { |
|
87 | + unlink($filename); |
|
88 | + $this->debug("Expired $wsdl ($filename) from cache"); |
|
89 | + $this->releaseMutex($filename); |
|
90 | + return null; |
|
91 | + } |
|
92 | + } |
|
93 | + // see what there is to return |
|
94 | + if (!file_exists($filename)) { |
|
95 | + $this->debug("$wsdl ($filename) not in cache (1)"); |
|
96 | + $this->releaseMutex($filename); |
|
97 | + return null; |
|
98 | + } |
|
99 | + $fp = @fopen($filename, "r"); |
|
100 | + if ($fp) { |
|
101 | + $s = implode("", @file($filename)); |
|
102 | + fclose($fp); |
|
103 | + $this->debug("Got $wsdl ($filename) from cache"); |
|
104 | + } else { |
|
105 | + $s = null; |
|
106 | + $this->debug("$wsdl ($filename) not in cache (2)"); |
|
107 | + } |
|
108 | + $this->releaseMutex($filename); |
|
109 | + return (!is_null($s)) ? unserialize($s) : null; |
|
110 | + } else { |
|
111 | + $this->debug("Unable to obtain mutex for $filename in get"); |
|
112 | + } |
|
113 | + return null; |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * obtains the local mutex |
|
118 | - * |
|
119 | - * @param string $filename The Filename of the Cache to lock |
|
120 | - * @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode |
|
121 | - * @return boolean Lock successfully obtained ?! |
|
122 | - * @access private |
|
123 | - */ |
|
124 | - function obtainMutex($filename, $mode) { |
|
125 | - if (isset($this->fplock[md5($filename)])) { |
|
126 | - $this->debug("Lock for $filename already exists"); |
|
127 | - return false; |
|
128 | - } |
|
129 | - $this->fplock[md5($filename)] = fopen($filename.".lock", "w"); |
|
130 | - if ($mode == "r") { |
|
131 | - return flock($this->fplock[md5($filename)], LOCK_SH); |
|
132 | - } else { |
|
133 | - return flock($this->fplock[md5($filename)], LOCK_EX); |
|
134 | - } |
|
135 | - } |
|
116 | + /** |
|
117 | + * obtains the local mutex |
|
118 | + * |
|
119 | + * @param string $filename The Filename of the Cache to lock |
|
120 | + * @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode |
|
121 | + * @return boolean Lock successfully obtained ?! |
|
122 | + * @access private |
|
123 | + */ |
|
124 | + function obtainMutex($filename, $mode) { |
|
125 | + if (isset($this->fplock[md5($filename)])) { |
|
126 | + $this->debug("Lock for $filename already exists"); |
|
127 | + return false; |
|
128 | + } |
|
129 | + $this->fplock[md5($filename)] = fopen($filename.".lock", "w"); |
|
130 | + if ($mode == "r") { |
|
131 | + return flock($this->fplock[md5($filename)], LOCK_SH); |
|
132 | + } else { |
|
133 | + return flock($this->fplock[md5($filename)], LOCK_EX); |
|
134 | + } |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * adds a wsdl instance to the cache |
|
139 | - * |
|
140 | - * @param object wsdl $wsdl_instance The wsdl instance to add |
|
141 | - * @return boolean WSDL successfully cached |
|
142 | - * @access public |
|
143 | - */ |
|
144 | - function put($wsdl_instance) { |
|
145 | - $filename = $this->createFilename($wsdl_instance->wsdl); |
|
146 | - $s = serialize($wsdl_instance); |
|
147 | - if ($this->obtainMutex($filename, "w")) { |
|
148 | - $fp = fopen($filename, "w"); |
|
149 | - if (! $fp) { |
|
150 | - $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache"); |
|
151 | - $this->releaseMutex($filename); |
|
152 | - return false; |
|
153 | - } |
|
154 | - fputs($fp, $s); |
|
155 | - fclose($fp); |
|
156 | - $this->debug("Put $wsdl_instance->wsdl ($filename) in cache"); |
|
157 | - $this->releaseMutex($filename); |
|
158 | - return true; |
|
159 | - } else { |
|
160 | - $this->debug("Unable to obtain mutex for $filename in put"); |
|
161 | - } |
|
162 | - return false; |
|
163 | - } |
|
137 | + /** |
|
138 | + * adds a wsdl instance to the cache |
|
139 | + * |
|
140 | + * @param object wsdl $wsdl_instance The wsdl instance to add |
|
141 | + * @return boolean WSDL successfully cached |
|
142 | + * @access public |
|
143 | + */ |
|
144 | + function put($wsdl_instance) { |
|
145 | + $filename = $this->createFilename($wsdl_instance->wsdl); |
|
146 | + $s = serialize($wsdl_instance); |
|
147 | + if ($this->obtainMutex($filename, "w")) { |
|
148 | + $fp = fopen($filename, "w"); |
|
149 | + if (! $fp) { |
|
150 | + $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache"); |
|
151 | + $this->releaseMutex($filename); |
|
152 | + return false; |
|
153 | + } |
|
154 | + fputs($fp, $s); |
|
155 | + fclose($fp); |
|
156 | + $this->debug("Put $wsdl_instance->wsdl ($filename) in cache"); |
|
157 | + $this->releaseMutex($filename); |
|
158 | + return true; |
|
159 | + } else { |
|
160 | + $this->debug("Unable to obtain mutex for $filename in put"); |
|
161 | + } |
|
162 | + return false; |
|
163 | + } |
|
164 | 164 | |
165 | - /** |
|
166 | - * releases the local mutex |
|
167 | - * |
|
168 | - * @param string $filename The Filename of the Cache to lock |
|
169 | - * @return boolean Lock successfully released |
|
170 | - * @access private |
|
171 | - */ |
|
172 | - function releaseMutex($filename) { |
|
173 | - $ret = flock($this->fplock[md5($filename)], LOCK_UN); |
|
174 | - fclose($this->fplock[md5($filename)]); |
|
175 | - unset($this->fplock[md5($filename)]); |
|
176 | - if (! $ret) { |
|
177 | - $this->debug("Not able to release lock for $filename"); |
|
178 | - } |
|
179 | - return $ret; |
|
180 | - } |
|
165 | + /** |
|
166 | + * releases the local mutex |
|
167 | + * |
|
168 | + * @param string $filename The Filename of the Cache to lock |
|
169 | + * @return boolean Lock successfully released |
|
170 | + * @access private |
|
171 | + */ |
|
172 | + function releaseMutex($filename) { |
|
173 | + $ret = flock($this->fplock[md5($filename)], LOCK_UN); |
|
174 | + fclose($this->fplock[md5($filename)]); |
|
175 | + unset($this->fplock[md5($filename)]); |
|
176 | + if (! $ret) { |
|
177 | + $this->debug("Not able to release lock for $filename"); |
|
178 | + } |
|
179 | + return $ret; |
|
180 | + } |
|
181 | 181 | |
182 | - /** |
|
183 | - * removes a wsdl instance from the cache |
|
184 | - * |
|
185 | - * @param string $wsdl The URL of the wsdl instance |
|
186 | - * @return boolean Whether there was an instance to remove |
|
187 | - * @access public |
|
188 | - */ |
|
189 | - function remove($wsdl) { |
|
190 | - $filename = $this->createFilename($wsdl); |
|
191 | - if (!file_exists($filename)) { |
|
192 | - $this->debug("$wsdl ($filename) not in cache to be removed"); |
|
193 | - return false; |
|
194 | - } |
|
195 | - // ignore errors obtaining mutex |
|
196 | - $this->obtainMutex($filename, "w"); |
|
197 | - $ret = unlink($filename); |
|
198 | - $this->debug("Removed ($ret) $wsdl ($filename) from cache"); |
|
199 | - $this->releaseMutex($filename); |
|
200 | - return $ret; |
|
201 | - } |
|
182 | + /** |
|
183 | + * removes a wsdl instance from the cache |
|
184 | + * |
|
185 | + * @param string $wsdl The URL of the wsdl instance |
|
186 | + * @return boolean Whether there was an instance to remove |
|
187 | + * @access public |
|
188 | + */ |
|
189 | + function remove($wsdl) { |
|
190 | + $filename = $this->createFilename($wsdl); |
|
191 | + if (!file_exists($filename)) { |
|
192 | + $this->debug("$wsdl ($filename) not in cache to be removed"); |
|
193 | + return false; |
|
194 | + } |
|
195 | + // ignore errors obtaining mutex |
|
196 | + $this->obtainMutex($filename, "w"); |
|
197 | + $ret = unlink($filename); |
|
198 | + $this->debug("Removed ($ret) $wsdl ($filename) from cache"); |
|
199 | + $this->releaseMutex($filename); |
|
200 | + return $ret; |
|
201 | + } |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited |
45 | 45 | * @access public |
46 | 46 | */ |
47 | - function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) { |
|
47 | + function nusoap_wsdlcache($cache_dir = '.', $cache_lifetime = 0) { |
|
48 | 48 | $this->fplock = array(); |
49 | 49 | $this->cache_dir = $cache_dir != '' ? $cache_dir : '.'; |
50 | 50 | $this->cache_lifetime = $cache_lifetime; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @access private |
59 | 59 | */ |
60 | 60 | function createFilename($wsdl) { |
61 | - return $this->cache_dir.'/wsdlcache-' . md5($wsdl); |
|
61 | + return $this->cache_dir.'/wsdlcache-'.md5($wsdl); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param string $string debug data |
68 | 68 | * @access private |
69 | 69 | */ |
70 | - function debug($string){ |
|
70 | + function debug($string) { |
|
71 | 71 | $this->debug_str .= get_class($this).": $string\n"; |
72 | 72 | } |
73 | 73 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $s = serialize($wsdl_instance); |
147 | 147 | if ($this->obtainMutex($filename, "w")) { |
148 | 148 | $fp = fopen($filename, "w"); |
149 | - if (! $fp) { |
|
149 | + if (!$fp) { |
|
150 | 150 | $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache"); |
151 | 151 | $this->releaseMutex($filename); |
152 | 152 | return false; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $ret = flock($this->fplock[md5($filename)], LOCK_UN); |
174 | 174 | fclose($this->fplock[md5($filename)]); |
175 | 175 | unset($this->fplock[md5($filename)]); |
176 | - if (! $ret) { |
|
176 | + if (!$ret) { |
|
177 | 177 | $this->debug("Not able to release lock for $filename"); |
178 | 178 | } |
179 | 179 | return $ret; |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | $params['session_id'] = api_get_session_id(); |
78 | 78 | $params['category_id'] = isset($params['category_id']) ? $params['category_id'] : 0; |
79 | 79 | |
80 | - $sql = "SELECT MAX(display_order) |
|
80 | + $sql = "SELECT MAX(display_order) |
|
81 | 81 | FROM ".$this->table." |
82 | 82 | WHERE |
83 | 83 | c_id = $courseId AND |
84 | - category_id = '" . intval($params['category_id'])."'"; |
|
84 | + category_id = '".intval($params['category_id'])."'"; |
|
85 | 85 | $result = Database:: query($sql); |
86 | 86 | list ($orderMax) = Database:: fetch_row($result); |
87 | 87 | $order = $orderMax + 1; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | // We ensure URL to be absolute. |
187 | 187 | if (strpos($urllink, '://') === false) { |
188 | - $urllink = 'http://' . $urllink; |
|
188 | + $urllink = 'http://'.$urllink; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | // If the title is empty, we use the URL as title. |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | 'c_id' => $course_id, |
208 | 208 | 'url' => $urllink, |
209 | 209 | 'title' => $title, |
210 | - 'description' => $description , |
|
210 | + 'description' => $description, |
|
211 | 211 | 'category_id' => $selectcategory, |
212 | 212 | 'on_homepage' => $onhomepage, |
213 | 213 | 'target' => $target, |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | if ((api_get_setting('search_enabled') == 'true') && |
221 | 221 | $link_id && extension_loaded('xapian') |
222 | 222 | ) { |
223 | - require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'; |
|
224 | - require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'; |
|
225 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
223 | + require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'; |
|
224 | + require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'; |
|
225 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
226 | 226 | |
227 | 227 | $course_int_id = $_course['real_id']; |
228 | 228 | $courseCode = $_course['code']; |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | if (isset ($_REQUEST[$specific_field['code']])) { |
236 | 236 | $sterms = trim($_REQUEST[$specific_field['code']]); |
237 | 237 | if (!empty ($sterms)) { |
238 | - $all_specific_terms .= ' ' . $sterms; |
|
238 | + $all_specific_terms .= ' '.$sterms; |
|
239 | 239 | $sterms = explode(',', $sterms); |
240 | 240 | foreach ($sterms as $sterm) { |
241 | 241 | $ic_slide->addTerm( |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | SE_COURSE_ID => $courseCode, |
263 | 263 | SE_TOOL_ID => TOOL_LINK, |
264 | 264 | SE_DATA => array( |
265 | - 'link_id' => (int)$link_id |
|
265 | + 'link_id' => (int) $link_id |
|
266 | 266 | ), |
267 | - SE_USER => (int)api_get_user_id(), |
|
267 | + SE_USER => (int) api_get_user_id(), |
|
268 | 268 | ); |
269 | 269 | $ic_slide->xapian_data = serialize($xapian_data); |
270 | - $description = $all_specific_terms . ' ' . $description; |
|
270 | + $description = $all_specific_terms.' '.$description; |
|
271 | 271 | $ic_slide->addValue('content', $description); |
272 | 272 | |
273 | 273 | // Add category name if set. |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $sql_cat = sprintf( |
280 | 280 | $sql_cat, |
281 | 281 | $table_link_category, |
282 | - (int)$selectcategory, |
|
282 | + (int) $selectcategory, |
|
283 | 283 | $course_int_id |
284 | 284 | ); |
285 | 285 | $result = Database:: query($sql_cat); |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | // This will make a restore function possible for the platform administrator. |
400 | 400 | |
401 | 401 | $sql = "UPDATE $tbl_link SET on_homepage='0' |
402 | - WHERE c_id = $course_id AND id='" . $id . "'"; |
|
402 | + WHERE c_id = $course_id AND id='".$id."'"; |
|
403 | 403 | Database:: query($sql); |
404 | 404 | |
405 | 405 | api_item_property_update( |
@@ -415,12 +415,12 @@ discard block |
||
415 | 415 | break; |
416 | 416 | case 'category': |
417 | 417 | // First we delete the category itself and afterwards all the links of this category. |
418 | - $sql = "DELETE FROM " . $tbl_categories . " |
|
419 | - WHERE c_id = $course_id AND id='" . $id . "'"; |
|
418 | + $sql = "DELETE FROM ".$tbl_categories." |
|
419 | + WHERE c_id = $course_id AND id='".$id."'"; |
|
420 | 420 | Database:: query($sql); |
421 | 421 | |
422 | - $sql = "DELETE FROM " . $tbl_link . " |
|
423 | - WHERE c_id = $course_id AND category_id='" . $id . "'"; |
|
422 | + $sql = "DELETE FROM ".$tbl_link." |
|
423 | + WHERE c_id = $course_id AND category_id='".$id."'"; |
|
424 | 424 | Database:: query($sql); |
425 | 425 | |
426 | 426 | api_item_property_update( |
@@ -459,16 +459,16 @@ discard block |
||
459 | 459 | $row = Database:: fetch_array($res); |
460 | 460 | require_once api_get_path( |
461 | 461 | LIBRARY_PATH |
462 | - ) . 'search/ChamiloIndexer.class.php'; |
|
462 | + ).'search/ChamiloIndexer.class.php'; |
|
463 | 463 | $di = new ChamiloIndexer(); |
464 | - $di->remove_document((int)$row['search_did']); |
|
464 | + $di->remove_document((int) $row['search_did']); |
|
465 | 465 | } |
466 | 466 | $sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1'; |
467 | 467 | $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_LINK, $link_id); |
468 | 468 | Database:: query($sql); |
469 | 469 | |
470 | 470 | // Remove terms from db. |
471 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
471 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
472 | 472 | delete_all_values_for_item($course_id, TOOL_DOCUMENT, $link_id); |
473 | 473 | } |
474 | 474 | } |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | { |
485 | 485 | $tbl_link = Database:: get_course_table(TABLE_LINK); |
486 | 486 | $course_id = api_get_course_int_id(); |
487 | - $sql = "SELECT * FROM " . $tbl_link . " |
|
488 | - WHERE c_id = $course_id AND id='" . intval($id) . "' "; |
|
487 | + $sql = "SELECT * FROM ".$tbl_link." |
|
488 | + WHERE c_id = $course_id AND id='".intval($id)."' "; |
|
489 | 489 | $result = Database::query($sql); |
490 | 490 | $data = array(); |
491 | 491 | if (Database::num_rows($result)) { |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | |
515 | 515 | // We ensure URL to be absolute. |
516 | 516 | if (strpos($values['url'], '://') === false) { |
517 | - $values['url'] = 'http://' . $_POST['url']; |
|
517 | + $values['url'] = 'http://'.$_POST['url']; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | // If the title is empty, we use the URL as title. |
@@ -532,18 +532,18 @@ discard block |
||
532 | 532 | } |
533 | 533 | |
534 | 534 | // Finding the old category_id. |
535 | - $sql = "SELECT * FROM " . $tbl_link . " |
|
536 | - WHERE c_id = $course_id AND id='" . $id . "'"; |
|
535 | + $sql = "SELECT * FROM ".$tbl_link." |
|
536 | + WHERE c_id = $course_id AND id='".$id."'"; |
|
537 | 537 | $result = Database:: query($sql); |
538 | 538 | $row = Database:: fetch_array($result); |
539 | 539 | $category_id = $row['category_id']; |
540 | 540 | |
541 | 541 | if ($category_id != $values['category_id']) { |
542 | 542 | $sql = "SELECT MAX(display_order) |
543 | - FROM " . $tbl_link . " |
|
543 | + FROM " . $tbl_link." |
|
544 | 544 | WHERE |
545 | 545 | c_id = $course_id AND |
546 | - category_id='" . intval($values['category_id']) . "'"; |
|
546 | + category_id='".intval($values['category_id'])."'"; |
|
547 | 547 | $result = Database:: query($sql); |
548 | 548 | list ($max_display_order) = Database:: fetch_row($result); |
549 | 549 | $max_display_order++; |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | 'target' => $values['target'], |
561 | 561 | 'category_id' => $values['category_id'], |
562 | 562 | ]; |
563 | - Database::update($tbl_link, $params, ['c_id = ? AND id = ?' => [$course_id, $id] ]); |
|
563 | + Database::update($tbl_link, $params, ['c_id = ? AND id = ?' => [$course_id, $id]]); |
|
564 | 564 | |
565 | 565 | // Update search enchine and its values table if enabled. |
566 | 566 | if (api_get_setting('search_enabled') == 'true') { |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | $_REQUEST[$specific_field['code']] |
614 | 614 | ); |
615 | 615 | if (!empty ($sterms)) { |
616 | - $all_specific_terms .= ' ' . $sterms; |
|
616 | + $all_specific_terms .= ' '.$sterms; |
|
617 | 617 | $sterms = explode(',', $sterms); |
618 | 618 | foreach ($sterms as $sterm) { |
619 | 619 | $ic_slide->addTerm( |
@@ -640,13 +640,13 @@ discard block |
||
640 | 640 | SE_COURSE_ID => $course_id, |
641 | 641 | SE_TOOL_ID => TOOL_LINK, |
642 | 642 | SE_DATA => array( |
643 | - 'link_id' => (int)$id |
|
643 | + 'link_id' => (int) $id |
|
644 | 644 | ), |
645 | - SE_USER => (int)api_get_user_id(), |
|
645 | + SE_USER => (int) api_get_user_id(), |
|
646 | 646 | |
647 | 647 | ); |
648 | 648 | $ic_slide->xapian_data = serialize($xapian_data); |
649 | - $link_description = $all_specific_terms . ' ' . $link_description; |
|
649 | + $link_description = $all_specific_terms.' '.$link_description; |
|
650 | 650 | $ic_slide->addValue('content', $link_description); |
651 | 651 | |
652 | 652 | // Add category name if set. |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | $di = new ChamiloIndexer(); |
675 | 675 | isset ($_POST['language']) ? $lang = Database:: escape_string($_POST['language']) : $lang = 'english'; |
676 | 676 | $di->connectDb(null, null, $lang); |
677 | - $di->remove_document((int)$se_ref['search_did']); |
|
677 | + $di->remove_document((int) $se_ref['search_did']); |
|
678 | 678 | $di->addChunk($ic_slide); |
679 | 679 | |
680 | 680 | // Index and return search engine document id. |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | $sql = "SELECT *, linkcat.id |
792 | 792 | FROM $tblLinkCategory linkcat |
793 | 793 | WHERE |
794 | - linkcat.c_id = " . $courseId . " |
|
794 | + linkcat.c_id = ".$courseId." |
|
795 | 795 | $sessionCondition |
796 | 796 | ORDER BY linkcat.display_order DESC"; |
797 | 797 | |
@@ -803,10 +803,10 @@ discard block |
||
803 | 803 | INNER JOIN $tblItemProperty itemproperties |
804 | 804 | ON (linkcat.id = itemproperties.ref AND linkcat.c_id = itemproperties.c_id) |
805 | 805 | WHERE |
806 | - itemproperties.tool = '" . TOOL_LINK_CATEGORY . "' AND |
|
806 | + itemproperties.tool = '".TOOL_LINK_CATEGORY."' AND |
|
807 | 807 | (itemproperties.visibility = '0' OR itemproperties.visibility = '1') |
808 | 808 | $sessionCondition AND |
809 | - linkcat.c_id = " . $courseId . " |
|
809 | + linkcat.c_id = ".$courseId." |
|
810 | 810 | ORDER BY linkcat.display_order DESC"; |
811 | 811 | |
812 | 812 | $result = Database::query($sql); |
@@ -829,10 +829,10 @@ discard block |
||
829 | 829 | INNER JOIN $tblItemProperty itemproperties |
830 | 830 | ON (linkcat.id = itemproperties.ref AND linkcat.c_id = itemproperties.c_id) |
831 | 831 | WHERE |
832 | - itemproperties.tool = '" . TOOL_LINK_CATEGORY . "' AND |
|
832 | + itemproperties.tool = '".TOOL_LINK_CATEGORY."' AND |
|
833 | 833 | (itemproperties.visibility = '0' OR itemproperties.visibility = '1') |
834 | 834 | $sessionCondition AND |
835 | - linkcat.c_id = " . $courseId . " |
|
835 | + linkcat.c_id = ".$courseId." |
|
836 | 836 | ORDER BY linkcat.display_order DESC |
837 | 837 | "; |
838 | 838 | $result = Database::query($sql); |
@@ -864,12 +864,12 @@ discard block |
||
864 | 864 | INNER JOIN $TABLE_ITEM_PROPERTY itemproperties |
865 | 865 | ON (link.id=itemproperties.ref AND link.c_id = itemproperties.c_id ) |
866 | 866 | WHERE |
867 | - itemproperties.tool='" . TOOL_LINK . "' AND |
|
868 | - link.category_id='" . $catid . "' AND |
|
867 | + itemproperties.tool='".TOOL_LINK."' AND |
|
868 | + link.category_id='" . $catid."' AND |
|
869 | 869 | (itemproperties.visibility='0' OR itemproperties.visibility='1') |
870 | 870 | $condition_session AND |
871 | - link.c_id = " . $course_id . " AND |
|
872 | - itemproperties.c_id = " . $course_id . " |
|
871 | + link.c_id = ".$course_id." AND |
|
872 | + itemproperties.c_id = " . $course_id." |
|
873 | 873 | ORDER BY link.display_order DESC"; |
874 | 874 | $result = Database:: query($sql); |
875 | 875 | $numberoflinks = Database:: num_rows($result); |
@@ -892,14 +892,14 @@ discard block |
||
892 | 892 | 'retweet', |
893 | 893 | 'default btn-sm', |
894 | 894 | array( |
895 | - 'onclick' => "check_url('" . $myrow['id'] . "', '" . addslashes($myrow['url']) . "');", |
|
895 | + 'onclick' => "check_url('".$myrow['id']."', '".addslashes($myrow['url'])."');", |
|
896 | 896 | 'title' => get_lang('CheckURL') |
897 | 897 | ) |
898 | 898 | ); |
899 | 899 | $link_validator .= Display::span( |
900 | 900 | '', |
901 | 901 | array( |
902 | - 'id' => 'url_id_' . $myrow['id'], |
|
902 | + 'id' => 'url_id_'.$myrow['id'], |
|
903 | 903 | 'class' => 'check-link' |
904 | 904 | ) |
905 | 905 | ); |
@@ -909,10 +909,10 @@ discard block |
||
909 | 909 | if (api_is_allowed_to_edit(null, true)) { |
910 | 910 | |
911 | 911 | if ($session_id == $myrow['session_id']) { |
912 | - $url = api_get_self() . '?' . api_get_cidreq() . |
|
913 | - '&action=editlink&category=' . (!empty ($category) ? $category : '') . |
|
914 | - '&id=' . $myrow['id'] . |
|
915 | - '&category_id=' . $myrow['id']; |
|
912 | + $url = api_get_self().'?'.api_get_cidreq(). |
|
913 | + '&action=editlink&category='.(!empty ($category) ? $category : ''). |
|
914 | + '&id='.$myrow['id']. |
|
915 | + '&category_id='.$myrow['id']; |
|
916 | 916 | $title = get_lang('Edit'); |
917 | 917 | $toolbar .= Display::toolbarButton( |
918 | 918 | '', |
@@ -940,10 +940,10 @@ discard block |
||
940 | 940 | }*/ |
941 | 941 | |
942 | 942 | if ($myrow['visibility'] == '1') { |
943 | - $url .= 'link.php?' . api_get_cidreq() . |
|
944 | - '&sec_token=' . $token . |
|
945 | - '&action=invisible&id=' . $myrow['id'] . |
|
946 | - '&scope=link&category_id=' . $myrow['category_id']; |
|
943 | + $url .= 'link.php?'.api_get_cidreq(). |
|
944 | + '&sec_token='.$token. |
|
945 | + '&action=invisible&id='.$myrow['id']. |
|
946 | + '&scope=link&category_id='.$myrow['category_id']; |
|
947 | 947 | $title = get_lang('MakeInvisible'); |
948 | 948 | $toolbar .= Display::toolbarButton( |
949 | 949 | '', |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | |
958 | 958 | } |
959 | 959 | if ($myrow['visibility'] == '0') { |
960 | - $url .= 'link.php?' . api_get_cidreq() .'&sec_token=' . $token .'&action=visible&id=' . $myrow['id'] .'&scope=link&category_id=' . $myrow['category_id']; |
|
960 | + $url .= 'link.php?'.api_get_cidreq().'&sec_token='.$token.'&action=visible&id='.$myrow['id'].'&scope=link&category_id='.$myrow['category_id']; |
|
961 | 961 | $title = get_lang('MakeVisible'); |
962 | 962 | $toolbar .= Display::toolbarButton( |
963 | 963 | '', |
@@ -970,8 +970,8 @@ discard block |
||
970 | 970 | ); |
971 | 971 | } |
972 | 972 | |
973 | - $url .= api_get_self() . '?' . api_get_cidreq() .'&sec_token=' . $token .'&action=deletelink&id=' . $myrow['id'] .'&category_id=' . $myrow['category_id']; |
|
974 | - $event = "javascript: if(!confirm('" . get_lang('LinkDelconfirm') . "'))return false;"; |
|
973 | + $url .= api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=deletelink&id='.$myrow['id'].'&category_id='.$myrow['category_id']; |
|
974 | + $event = "javascript: if(!confirm('".get_lang('LinkDelconfirm')."'))return false;"; |
|
975 | 975 | $title = get_lang('Delete'); |
976 | 976 | |
977 | 977 | $toolbar .= Display::toolbarButton( |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | $content .= '<div class="pull-right"><div class="btn-group">'.$toolbar.'</div></div>'; |
1013 | 1013 | $content .= '<h4 class="list-group-item-heading">'; |
1014 | 1014 | $content .= $iconLink; |
1015 | - $url = 'link_goto.php?' . api_get_cidreq() .'&link_id=' . $myrow['id'] .'&link_url=' . urlencode($myrow['url']); |
|
1015 | + $url = 'link_goto.php?'.api_get_cidreq().'&link_id='.$myrow['id'].'&link_url='.urlencode($myrow['url']); |
|
1016 | 1016 | $content .= Display::tag( |
1017 | 1017 | 'a', |
1018 | 1018 | Security:: remove_XSS($myrow['title']), |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | $content .= $session_img; |
1026 | 1026 | $content .= '</h4>'; |
1027 | 1027 | |
1028 | - $content .= '<p class="list-group-item-text">' . $myrow['description'] . '</p>'; |
|
1028 | + $content .= '<p class="list-group-item-text">'.$myrow['description'].'</p>'; |
|
1029 | 1029 | $content .= '</div>'; |
1030 | 1030 | } else { |
1031 | 1031 | if (api_is_allowed_to_edit(null, true)) { |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | $content .= '<div class="pull-right"><div class="btn-group">'.$toolbar.'</div></div>'; |
1034 | 1034 | $content .= '<h4 class="list-group-item-heading">'; |
1035 | 1035 | $content .= $iconLink; |
1036 | - $url = 'link_goto.php?' . api_get_cidreq() .'&link_id=' . $myrow['id'] . "&link_url=" . urlencode($myrow['url']); |
|
1036 | + $url = 'link_goto.php?'.api_get_cidreq().'&link_id='.$myrow['id']."&link_url=".urlencode($myrow['url']); |
|
1037 | 1037 | $content .= Display::tag( |
1038 | 1038 | 'a', |
1039 | 1039 | Security:: remove_XSS($myrow['title']), |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | $content .= $link_validator; |
1047 | 1047 | $content .= $session_img; |
1048 | 1048 | $content .= '</h4>'; |
1049 | - $content .= '<p class="list-group-item-text">' . $myrow['description'] . '</p>'; |
|
1049 | + $content .= '<p class="list-group-item-text">'.$myrow['description'].'</p>'; |
|
1050 | 1050 | $content .= '</div>'; |
1051 | 1051 | } |
1052 | 1052 | } |
@@ -1068,58 +1068,58 @@ discard block |
||
1068 | 1068 | { |
1069 | 1069 | $categoryId = $category['id']; |
1070 | 1070 | $token = null; |
1071 | - $tools = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&sec_token=' . $token . '&action=editcategory&id=' . $categoryId . '&category_id=' . $categoryId . '" title=' . get_lang('Modify') . '">' . |
|
1071 | + $tools = '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=editcategory&id='.$categoryId.'&category_id='.$categoryId.'" title='.get_lang('Modify').'">'. |
|
1072 | 1072 | Display:: return_icon( |
1073 | 1073 | 'edit.png', |
1074 | 1074 | get_lang('Modify'), |
1075 | 1075 | array(), |
1076 | 1076 | ICON_SIZE_SMALL |
1077 | - ) . '</a>'; |
|
1077 | + ).'</a>'; |
|
1078 | 1078 | |
1079 | 1079 | // DISPLAY MOVE UP COMMAND only if it is not the top link. |
1080 | 1080 | if ($currentCategory != 0) { |
1081 | - $tools .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&sec_token=' . $token . '&action=up&up='.$categoryId.'&category_id='.$categoryId.'" title="'.get_lang('Up').'">'. |
|
1081 | + $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=up&up='.$categoryId.'&category_id='.$categoryId.'" title="'.get_lang('Up').'">'. |
|
1082 | 1082 | Display:: return_icon( |
1083 | 1083 | 'up.png', |
1084 | 1084 | get_lang('Up'), |
1085 | 1085 | array(), |
1086 | 1086 | ICON_SIZE_SMALL |
1087 | - ) . '</a>'; |
|
1087 | + ).'</a>'; |
|
1088 | 1088 | } else { |
1089 | 1089 | $tools .= Display:: return_icon( |
1090 | 1090 | 'up_na.png', |
1091 | 1091 | get_lang('Up'), |
1092 | 1092 | array(), |
1093 | 1093 | ICON_SIZE_SMALL |
1094 | - ) . '</a>'; |
|
1094 | + ).'</a>'; |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | // DISPLAY MOVE DOWN COMMAND only if it is not the bottom link. |
1098 | - if ($currentCategory < $countCategories-1) { |
|
1099 | - $tools .= '<a href="' . api_get_self() . '?' . api_get_cidreq() .'&sec_token=' . $token .'&action=down&down=' . $categoryId .'&category_id=' . $categoryId . '">'. |
|
1098 | + if ($currentCategory < $countCategories - 1) { |
|
1099 | + $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=down&down='.$categoryId.'&category_id='.$categoryId.'">'. |
|
1100 | 1100 | Display:: return_icon( |
1101 | 1101 | 'down.png', |
1102 | 1102 | get_lang('Down'), |
1103 | 1103 | array(), |
1104 | 1104 | ICON_SIZE_SMALL |
1105 | - ) . '</a>'; |
|
1105 | + ).'</a>'; |
|
1106 | 1106 | } else { |
1107 | 1107 | $tools .= Display:: return_icon( |
1108 | 1108 | 'down_na.png', |
1109 | 1109 | get_lang('Down'), |
1110 | 1110 | array(), |
1111 | 1111 | ICON_SIZE_SMALL |
1112 | - ) . '</a>'; |
|
1112 | + ).'</a>'; |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | - $tools .= '<a href="' . api_get_self() . '?' . api_get_cidreq() .'&sec_token=' . $token .'&action=deletecategory&id='.$categoryId. "&category_id=$categoryId\" |
|
1116 | - onclick=\"javascript: if(!confirm('" . get_lang('CategoryDelconfirm') . "')) return false;\">". |
|
1115 | + $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=deletecategory&id='.$categoryId."&category_id=$categoryId\" |
|
1116 | + onclick=\"javascript: if(!confirm('".get_lang('CategoryDelconfirm')."')) return false;\">". |
|
1117 | 1117 | Display:: return_icon( |
1118 | 1118 | 'delete.png', |
1119 | 1119 | get_lang('Delete'), |
1120 | 1120 | array(), |
1121 | 1121 | ICON_SIZE_SMALL |
1122 | - ) . '</a>'; |
|
1122 | + ).'</a>'; |
|
1123 | 1123 | |
1124 | 1124 | return $tools; |
1125 | 1125 | } |
@@ -1166,7 +1166,7 @@ discard block |
||
1166 | 1166 | $movetable = $tbl_link; |
1167 | 1167 | // Getting the category of the link. |
1168 | 1168 | if (!empty ($thiscatlinkId)) { |
1169 | - $sql = "SELECT category_id FROM " . $movetable . " |
|
1169 | + $sql = "SELECT category_id FROM ".$movetable." |
|
1170 | 1170 | WHERE c_id = $courseId AND id='$thiscatlinkId'"; |
1171 | 1171 | $result = Database:: query($sql); |
1172 | 1172 | $catid = Database:: fetch_array($result); |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | ORDER BY display_order $sortDirection"; |
1187 | 1187 | } else { |
1188 | 1188 | $sql = "SELECT id, display_order FROM $movetable |
1189 | - WHERE c_id = $courseId AND category_id='" . $catid[0] . "' |
|
1189 | + WHERE c_id = $courseId AND category_id='".$catid[0]."' |
|
1190 | 1190 | ORDER BY display_order $sortDirection"; |
1191 | 1191 | } |
1192 | 1192 | $linkresult = Database:: query($sql); |
@@ -1200,12 +1200,12 @@ discard block |
||
1200 | 1200 | $nextlinkOrder = $sortrow['display_order']; |
1201 | 1201 | |
1202 | 1202 | Database:: query( |
1203 | - "UPDATE " . $movetable . " |
|
1203 | + "UPDATE ".$movetable." |
|
1204 | 1204 | SET display_order = '$nextlinkOrder' |
1205 | 1205 | WHERE c_id = $courseId AND id = '$thiscatlinkId'" |
1206 | 1206 | ); |
1207 | 1207 | Database:: query( |
1208 | - "UPDATE " . $movetable . " |
|
1208 | + "UPDATE ".$movetable." |
|
1209 | 1209 | SET display_order = '$thislinkOrder' |
1210 | 1210 | WHERE c_id = $courseId AND id = '$nextlinkId'" |
1211 | 1211 | ); |
@@ -1233,10 +1233,10 @@ discard block |
||
1233 | 1233 | $course_id = api_get_course_int_id(); |
1234 | 1234 | |
1235 | 1235 | $result = Database:: query( |
1236 | - "SELECT id FROM " . $tbl_categories . " |
|
1237 | - WHERE c_id = $course_id AND category_title='" . Database::escape_string( |
|
1236 | + "SELECT id FROM ".$tbl_categories." |
|
1237 | + WHERE c_id = $course_id AND category_title='".Database::escape_string( |
|
1238 | 1238 | $catname |
1239 | - ) . "'" |
|
1239 | + )."'" |
|
1240 | 1240 | ); |
1241 | 1241 | if (Database:: num_rows($result) >= 1 && ($row = Database:: fetch_array( |
1242 | 1242 | $result |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | } |
1247 | 1247 | |
1248 | 1248 | $result = Database:: query( |
1249 | - "SELECT MAX(display_order) FROM " . $tbl_categories . " WHERE c_id = $course_id " |
|
1249 | + "SELECT MAX(display_order) FROM ".$tbl_categories." WHERE c_id = $course_id " |
|
1250 | 1250 | ); |
1251 | 1251 | list ($max_order) = Database:: fetch_row($result); |
1252 | 1252 | |
@@ -1273,12 +1273,12 @@ discard block |
||
1273 | 1273 | $tbl_link = Database:: get_course_table(TABLE_LINK); |
1274 | 1274 | $course_id = api_get_course_int_id(); |
1275 | 1275 | |
1276 | - $urleq = "url='" . Database:: escape_string($url) . "'"; |
|
1277 | - $cateq = "category_id=" . intval($cat); |
|
1276 | + $urleq = "url='".Database:: escape_string($url)."'"; |
|
1277 | + $cateq = "category_id=".intval($cat); |
|
1278 | 1278 | |
1279 | 1279 | $result = Database:: query(" |
1280 | 1280 | SELECT id FROM $tbl_link |
1281 | - WHERE c_id = $course_id AND " . $urleq . ' AND ' . $cateq |
|
1281 | + WHERE c_id = $course_id AND ".$urleq.' AND '.$cateq |
|
1282 | 1282 | ); |
1283 | 1283 | |
1284 | 1284 | if (Database:: num_rows($result) >= 1 && ($row = Database:: fetch_array( |
@@ -1286,14 +1286,14 @@ discard block |
||
1286 | 1286 | )) |
1287 | 1287 | ) { |
1288 | 1288 | Database:: query( |
1289 | - "UPDATE $tbl_link set title='" . Database:: escape_string( |
|
1289 | + "UPDATE $tbl_link set title='".Database:: escape_string( |
|
1290 | 1290 | $title |
1291 | - ) . "', description='" . Database:: escape_string( |
|
1291 | + )."', description='".Database:: escape_string( |
|
1292 | 1292 | $description |
1293 | - ) . "' |
|
1294 | - WHERE c_id = $course_id AND id='" . Database:: escape_string( |
|
1293 | + )."' |
|
1294 | + WHERE c_id = $course_id AND id='".Database:: escape_string( |
|
1295 | 1295 | $row['id'] |
1296 | - ) . "'" |
|
1296 | + )."'" |
|
1297 | 1297 | ); |
1298 | 1298 | |
1299 | 1299 | $ipu = 'LinkUpdated'; |
@@ -1302,18 +1302,18 @@ discard block |
||
1302 | 1302 | // Add new link |
1303 | 1303 | $result = Database:: query( |
1304 | 1304 | "SELECT MAX(display_order) FROM $tbl_link |
1305 | - WHERE c_id = $course_id AND category_id='" . intval($cat) . "'" |
|
1305 | + WHERE c_id = $course_id AND category_id='".intval($cat)."'" |
|
1306 | 1306 | ); |
1307 | 1307 | list ($max_order) = Database:: fetch_row($result); |
1308 | 1308 | |
1309 | 1309 | Database:: query( |
1310 | 1310 | "INSERT INTO $tbl_link (c_id, url, title, description, category_id, display_order, on_homepage) |
1311 | - VALUES (" . api_get_course_int_id() . ", |
|
1312 | - '" . Database:: escape_string($url) . "', |
|
1313 | - '" . Database:: escape_string($title) . "', |
|
1314 | - '" . Database:: escape_string($description) . "', |
|
1315 | - '" . intval($cat) . "','" . (intval($max_order) + 1) . "', |
|
1316 | - '" . intval($on_homepage) . |
|
1311 | + VALUES (".api_get_course_int_id().", |
|
1312 | + '" . Database:: escape_string($url)."', |
|
1313 | + '" . Database:: escape_string($title)."', |
|
1314 | + '" . Database:: escape_string($description)."', |
|
1315 | + '" . intval($cat)."','".(intval($max_order) + 1)."', |
|
1316 | + '" . intval($on_homepage). |
|
1317 | 1317 | "')" |
1318 | 1318 | ); |
1319 | 1319 | |
@@ -1391,30 +1391,30 @@ discard block |
||
1391 | 1391 | ) |
1392 | 1392 | ) { // possibly in <...> |
1393 | 1393 | if (($kwlist = trim($regs[1])) != '') { |
1394 | - $kw = '<i kw="' . htmlspecialchars($kwlist) . '">'; |
|
1394 | + $kw = '<i kw="'.htmlspecialchars($kwlist).'">'; |
|
1395 | 1395 | } else { |
1396 | 1396 | $kw = ''; |
1397 | 1397 | } |
1398 | 1398 | // i.e. assume only one of the $hide_fields will be present |
1399 | 1399 | // and if found, hide the value as expando property of an <i> tag |
1400 | 1400 | } elseif (trim($value)) { |
1401 | - $d .= ', ' . $key . ':' . $value; |
|
1401 | + $d .= ', '.$key.':'.$value; |
|
1402 | 1402 | } |
1403 | 1403 | } |
1404 | 1404 | } |
1405 | 1405 | if (!empty($d)) { |
1406 | - $d = substr($d, 2) . ' - '; |
|
1406 | + $d = substr($d, 2).' - '; |
|
1407 | 1407 | } |
1408 | 1408 | |
1409 | 1409 | return Link::put_link( |
1410 | 1410 | $url, |
1411 | 1411 | $cat, |
1412 | 1412 | $title, |
1413 | - $kw . ereg_replace( |
|
1413 | + $kw.ereg_replace( |
|
1414 | 1414 | '\[((/?(b|big|i|small|sub|sup|u))|br/)\]', |
1415 | 1415 | '<\\1>', |
1416 | - htmlspecialchars($d . $linkdata['description']) |
|
1417 | - ) . ($kw ? '</i>' : ''), |
|
1416 | + htmlspecialchars($d.$linkdata['description']) |
|
1417 | + ).($kw ? '</i>' : ''), |
|
1418 | 1418 | $linkdata['on_homepage'] ? '1' : '0', |
1419 | 1419 | $linkdata['hidden'] ? '1' : '0' |
1420 | 1420 | ); |
@@ -1535,19 +1535,19 @@ discard block |
||
1535 | 1535 | echo '<div class="actions">'; |
1536 | 1536 | if (api_is_allowed_to_edit(null, true)) { |
1537 | 1537 | echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addlink&category_id='.$categoryId.'">'. |
1538 | - Display::return_icon('new_link.png', get_lang('LinkAdd'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
1538 | + Display::return_icon('new_link.png', get_lang('LinkAdd'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
1539 | 1539 | echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addcategory&category_id='.$categoryId.'">'. |
1540 | - Display::return_icon('new_folder.png', get_lang('CategoryAdd'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
1540 | + Display::return_icon('new_folder.png', get_lang('CategoryAdd'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
1541 | 1541 | } |
1542 | 1542 | |
1543 | 1543 | $categories = Link::getLinkCategories($course_id, $session_id); |
1544 | 1544 | $count = count($categories); |
1545 | 1545 | if (!empty($count)) { |
1546 | 1546 | echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=list&show=none">'; |
1547 | - echo Display::return_icon('forum_listview.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . ' </a>'; |
|
1547 | + echo Display::return_icon('forum_listview.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).' </a>'; |
|
1548 | 1548 | |
1549 | 1549 | echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=list&show=all">'; |
1550 | - echo Display::return_icon('forum_nestedview.png', get_lang('NestedView'), '', ICON_SIZE_MEDIUM) . '</a>'; |
|
1550 | + echo Display::return_icon('forum_nestedview.png', get_lang('NestedView'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
1551 | 1551 | } |
1552 | 1552 | echo '</div>'; |
1553 | 1553 | |
@@ -1579,12 +1579,12 @@ discard block |
||
1579 | 1579 | $strVisibility = ''; |
1580 | 1580 | $visibilityClass = null; |
1581 | 1581 | if ($myrow['visibility'] == '1') { |
1582 | - $strVisibility = '<a href="link.php?' . api_get_cidreq() . '&sec_token='.$token.'&action=invisible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Hide') . '">' . |
|
1583 | - Display :: return_icon('visible.png', get_lang('Hide'), array (), ICON_SIZE_SMALL) . '</a>'; |
|
1582 | + $strVisibility = '<a href="link.php?'.api_get_cidreq().'&sec_token='.$token.'&action=invisible&id='.$myrow['id'].'&scope='.TOOL_LINK_CATEGORY.'" title="'.get_lang('Hide').'">'. |
|
1583 | + Display :: return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).'</a>'; |
|
1584 | 1584 | } elseif ($myrow['visibility'] == '0') { |
1585 | 1585 | $visibilityClass = 'invisible'; |
1586 | - $strVisibility = ' <a href="link.php?' . api_get_cidreq() . '&sec_token='.$token.'&action=visible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Show') . '">' . |
|
1587 | - Display :: return_icon('invisible.png', get_lang('Show'), array (), ICON_SIZE_SMALL) . '</a>'; |
|
1586 | + $strVisibility = ' <a href="link.php?'.api_get_cidreq().'&sec_token='.$token.'&action=visible&id='.$myrow['id'].'&scope='.TOOL_LINK_CATEGORY.'" title="'.get_lang('Show').'">'. |
|
1587 | + Display :: return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).'</a>'; |
|
1588 | 1588 | } |
1589 | 1589 | |
1590 | 1590 | $header = ''; |
@@ -477,6 +477,7 @@ discard block |
||
477 | 477 | * |
478 | 478 | * Get link info |
479 | 479 | * @param int link id |
480 | + * @param integer $id |
|
480 | 481 | * @return array link info |
481 | 482 | * |
482 | 483 | **/ |
@@ -1061,7 +1062,9 @@ discard block |
||
1061 | 1062 | /** |
1062 | 1063 | * Displays the edit, delete and move icons |
1063 | 1064 | * @param int Category ID |
1064 | - * @return void |
|
1065 | + * @param integer $currentCategory |
|
1066 | + * @param integer $countCategories |
|
1067 | + * @return string |
|
1065 | 1068 | * @author Patrick Cool <[email protected]>, Ghent University |
1066 | 1069 | */ |
1067 | 1070 | public static function showCategoryAdminTools($category, $currentCategory, $countCategories) |
@@ -1225,6 +1228,7 @@ discard block |
||
1225 | 1228 | /** |
1226 | 1229 | * CSV file import functions |
1227 | 1230 | * @author René Haentjens , Ghent University |
1231 | + * @param string $catname |
|
1228 | 1232 | */ |
1229 | 1233 | public static function get_cat($catname) |
1230 | 1234 | { |
@@ -1264,6 +1268,11 @@ discard block |
||
1264 | 1268 | /** |
1265 | 1269 | * CSV file import functions |
1266 | 1270 | * @author René Haentjens , Ghent University |
1271 | + * @param string $url |
|
1272 | + * @param string $title |
|
1273 | + * @param string $description |
|
1274 | + * @param string $on_homepage |
|
1275 | + * @param string $hidden |
|
1267 | 1276 | */ |
1268 | 1277 | public static function put_link($url, $cat, $title, $description, $on_homepage, $hidden) |
1269 | 1278 | { |
@@ -1622,7 +1631,6 @@ discard block |
||
1622 | 1631 | /** |
1623 | 1632 | * @param int $linkId |
1624 | 1633 | * @param $action |
1625 | - * @param null $urlview |
|
1626 | 1634 | * @param null $token |
1627 | 1635 | * @return FormValidator |
1628 | 1636 | */ |