@@ -626,7 +626,7 @@ |
||
626 | 626 | |
627 | 627 | /** |
628 | 628 | * Get first SMS plugin name |
629 | - * @return string|boolean |
|
629 | + * @return string|false |
|
630 | 630 | */ |
631 | 631 | public function getSMSPluginName() |
632 | 632 | { |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | - * @param string $pluginName |
|
177 | - * @param int $urlId |
|
178 | - */ |
|
176 | + * @param string $pluginName |
|
177 | + * @param int $urlId |
|
178 | + */ |
|
179 | 179 | public function uninstall($pluginName, $urlId = null) |
180 | 180 | { |
181 | 181 | if (empty($urlId)) { |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
255 | - * @param string $region |
|
256 | - * @param string $template |
|
257 | - * @param bool $forced |
|
258 | - * |
|
259 | - * @return null|string |
|
260 | - */ |
|
255 | + * @param string $region |
|
256 | + * @param string $template |
|
257 | + * @param bool $forced |
|
258 | + * |
|
259 | + * @return null|string |
|
260 | + */ |
|
261 | 261 | public function load_region($region, $template, $forced = false) |
262 | 262 | { |
263 | 263 | if ($region == 'course_tool_plugin') { |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | // Extra options |
427 | 427 | $plugin_settings = api_get_settings_params( |
428 | 428 | array( |
429 | - "subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins','setting') |
|
429 | + "subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins', 'setting') |
|
430 | 430 | ) |
431 | 431 | ); |
432 | 432 | |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | if (!empty($obj->course_settings)) { |
533 | 533 | if (is_file(api_get_path(SYS_CODE_PATH).'img/icons/'.ICON_SIZE_SMALL.'/'.$plugin_name.'.png')) { |
534 | 534 | $icon = Display::return_icon( |
535 | - $plugin_name . '.png', |
|
535 | + $plugin_name.'.png', |
|
536 | 536 | Security::remove_XSS($pluginTitle), |
537 | 537 | '', |
538 | 538 | ICON_SIZE_SMALL |
@@ -548,18 +548,18 @@ discard block |
||
548 | 548 | |
549 | 549 | $form->addHtml('<div class="panel panel-default">'); |
550 | 550 | $form->addHtml(' |
551 | - <div class="panel-heading" role="tab" id="heading-' . $plugin_name . '-settings"> |
|
551 | + <div class="panel-heading" role="tab" id="heading-' . $plugin_name.'-settings"> |
|
552 | 552 | <h4 class="panel-title"> |
553 | - <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-' . $plugin_name . '-settings" aria-expanded="false" aria-controls="collapse-' . $plugin_name . '-settings"> |
|
553 | + <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-' . $plugin_name.'-settings" aria-expanded="false" aria-controls="collapse-'.$plugin_name.'-settings"> |
|
554 | 554 | '); |
555 | - $form->addHtml($icon . ' ' . $pluginTitle); |
|
555 | + $form->addHtml($icon.' '.$pluginTitle); |
|
556 | 556 | $form->addHtml(' |
557 | 557 | </a> |
558 | 558 | </h4> |
559 | 559 | </div> |
560 | 560 | '); |
561 | 561 | $form->addHtml(' |
562 | - <div id="collapse-' . $plugin_name . '-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-' . $plugin_name . '-settings"> |
|
562 | + <div id="collapse-' . $plugin_name.'-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-'.$plugin_name.'-settings"> |
|
563 | 563 | <div class="panel-body"> |
564 | 564 | '); |
565 | 565 |
@@ -126,6 +126,7 @@ discard block |
||
126 | 126 | * Returns a temporary url to download files and/or folders. |
127 | 127 | * |
128 | 128 | * @param string|array $ids |
129 | + * @param string $tool |
|
129 | 130 | * @return string |
130 | 131 | */ |
131 | 132 | public static function download_url($ids, $tool) |
@@ -293,7 +294,7 @@ discard block |
||
293 | 294 | /** |
294 | 295 | * The name of the porfolio where to send. |
295 | 296 | * |
296 | - * @return type |
|
297 | + * @return string |
|
297 | 298 | */ |
298 | 299 | function get_portfolio() |
299 | 300 | { |
@@ -391,7 +392,6 @@ discard block |
||
391 | 392 | * Create a "send to portfolio" button |
392 | 393 | * |
393 | 394 | * @param string $tool The name of the tool: document, work. |
394 | - * @param int $c_id The id of the course |
|
395 | 395 | * @param int $id The id of the object |
396 | 396 | * @param array $attributes Html attributes |
397 | 397 | * @return \PortfolioShare |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | /** |
406 | 406 | * Returns the current secuirty token. Used to avoid see surfing attacks. |
407 | 407 | * |
408 | - * @return type |
|
408 | + * @return string |
|
409 | 409 | */ |
410 | 410 | static function security_token() |
411 | 411 | { |
@@ -420,6 +420,10 @@ discard block |
||
420 | 420 | protected $attributes = array(); |
421 | 421 | protected $tool = ''; |
422 | 422 | |
423 | + /** |
|
424 | + * @param string $tool |
|
425 | + * @param integer $id |
|
426 | + */ |
|
423 | 427 | function __construct($tool, $id, $attributes = array()) |
424 | 428 | { |
425 | 429 | $this->tool = $tool; |
@@ -482,14 +482,14 @@ discard block |
||
482 | 482 | $attributes['z-index'] = 100000; |
483 | 483 | $s = ' '; |
484 | 484 | foreach ($attributes as $key => $value) { |
485 | - $s .= $key . '="' . $value . '" '; |
|
485 | + $s .= $key.'="'.$value.'" '; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | $result = array(); |
489 | - $result[] = '<span ' . $s . ' >'; |
|
489 | + $result[] = '<span '.$s.' >'; |
|
490 | 490 | $result[] = '<span class="dropdown" >'; |
491 | 491 | $result[] = '<a href="#" data-toggle="dropdown" class="dropdown-toggle">'; |
492 | - $result[] = Display::return_icon('document_send.png', get_lang('Send'), array(), ICON_SIZE_SMALL) . '<b class="caret"></b>'; |
|
492 | + $result[] = Display::return_icon('document_send.png', get_lang('Send'), array(), ICON_SIZE_SMALL).'<b class="caret"></b>'; |
|
493 | 493 | $result[] = '</a>'; |
494 | 494 | $result[] = '<ul class="dropdown-menu">'; |
495 | 495 | |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | $parameters[PortfolioController::PARAM_TOOL] = $tool; |
506 | 506 | $url = api_get_path(WEB_CODE_PATH).'portfolio/share.php?'; |
507 | 507 | $result[] = '<li>'; |
508 | - $result[] = '<a href="' . $url . '">' . $portfolio->get_title() . '</a>'; |
|
508 | + $result[] = '<a href="'.$url.'">'.$portfolio->get_title().'</a>'; |
|
509 | 509 | $result[] = '</li>'; |
510 | 510 | } |
511 | 511 | $result[] = '</ul>'; |
@@ -564,8 +564,8 @@ discard block |
||
564 | 564 | */ |
565 | 565 | public function __construct($portfolio) |
566 | 566 | { |
567 | - $this->name = md5(__CLASS__) . '_' . $portfolio->get_name(); |
|
568 | - $this->title = $portfolio->get_title() ? $portfolio->get_title() : get_lang('SendTo') . ' ' . $portfolio->get_name(); |
|
567 | + $this->name = md5(__CLASS__).'_'.$portfolio->get_name(); |
|
568 | + $this->title = $portfolio->get_title() ? $portfolio->get_title() : get_lang('SendTo').' '.$portfolio->get_name(); |
|
569 | 569 | $this->portfolio = $portfolio; |
570 | 570 | } |
571 | 571 |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
132 | - * @return array |
|
132 | + * @return string[] |
|
133 | 133 | */ |
134 | 134 | public function get_status_list() |
135 | 135 | { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | /** |
273 | 273 | * @param int $id |
274 | 274 | * |
275 | - * @return bool |
|
275 | + * @return null|false |
|
276 | 276 | */ |
277 | 277 | public function delete($id) |
278 | 278 | { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | case 'updated_at': |
64 | 64 | break; |
65 | 65 | case 'name': |
66 | - $val .= ' ' . get_lang('CopyLabelSuffix'); |
|
66 | + $val .= ' '.get_lang('CopyLabelSuffix'); |
|
67 | 67 | $new[$key] = $val; |
68 | 68 | break; |
69 | 69 | case 'created_at': |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | break; |
73 | 73 | case 'career_id': |
74 | 74 | if (!empty($career_id)) { |
75 | - $val = (int)$career_id; |
|
75 | + $val = (int) $career_id; |
|
76 | 76 | } |
77 | 77 | $new[$key] = $val; |
78 | 78 | break; |
@@ -160,22 +160,22 @@ discard block |
||
160 | 160 | { |
161 | 161 | // Action links |
162 | 162 | echo '<div class="actions" style="margin-bottom:20px">'; |
163 | - echo '<a href="career_dashboard.php">' . Display::return_icon('back.png', |
|
164 | - get_lang('Back'), '', '32') . '</a>'; |
|
165 | - echo '<a href="' . api_get_self() . '?action=add">' . |
|
163 | + echo '<a href="career_dashboard.php">'.Display::return_icon('back.png', |
|
164 | + get_lang('Back'), '', '32').'</a>'; |
|
165 | + echo '<a href="'.api_get_self().'?action=add">'. |
|
166 | 166 | Display::return_icon( |
167 | 167 | 'new_promotion.png', |
168 | 168 | get_lang('Add'), |
169 | 169 | '', |
170 | 170 | '32' |
171 | - ) . '</a>'; |
|
172 | - echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'session/session_add.php">' . |
|
171 | + ).'</a>'; |
|
172 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'session/session_add.php">'. |
|
173 | 173 | Display::return_icon( |
174 | 174 | 'new_session.png', |
175 | 175 | get_lang('AddSession'), |
176 | 176 | '', |
177 | 177 | '32' |
178 | - ) . '</a>'; |
|
178 | + ).'</a>'; |
|
179 | 179 | echo '</div>'; |
180 | 180 | echo Display::grid_html('promotions'); |
181 | 181 | } |
@@ -15,6 +15,10 @@ |
||
15 | 15 | |
16 | 16 | // warning the goal of this function is to enforce rights managment in Chamilo |
17 | 17 | // thus default return value is always true |
18 | + |
|
19 | + /** |
|
20 | + * @param string $handler |
|
21 | + */ |
|
18 | 22 | public static function hasRight($handler) { |
19 | 23 | if (array_key_exists($handler, self::$rights_cache)) |
20 | 24 | return self::$rights_cache[$handler]; |
@@ -5,42 +5,42 @@ |
||
5 | 5 | * @deprecated Don't use this class |
6 | 6 | */ |
7 | 7 | class Rights { |
8 | - private static $rights_cache = array(); |
|
9 | - private static $rights = array ( |
|
10 | - 'show_tabs:reports' => |
|
11 | - array ( |
|
12 | - 'type' => 'const', |
|
13 | - 'const' => 'true' ) |
|
14 | - ); |
|
8 | + private static $rights_cache = array(); |
|
9 | + private static $rights = array ( |
|
10 | + 'show_tabs:reports' => |
|
11 | + array ( |
|
12 | + 'type' => 'const', |
|
13 | + 'const' => 'true' ) |
|
14 | + ); |
|
15 | 15 | |
16 | - // warning the goal of this function is to enforce rights managment in Chamilo |
|
17 | - // thus default return value is always true |
|
18 | - public static function hasRight($handler) { |
|
19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
20 | - return self::$rights_cache[$handler]; |
|
16 | + // warning the goal of this function is to enforce rights managment in Chamilo |
|
17 | + // thus default return value is always true |
|
18 | + public static function hasRight($handler) { |
|
19 | + if (array_key_exists($handler, self::$rights_cache)) |
|
20 | + return self::$rights_cache[$handler]; |
|
21 | 21 | |
22 | - if (!array_key_exists($handler, self::$rights)) |
|
23 | - return true; // handler does not exists |
|
22 | + if (!array_key_exists($handler, self::$rights)) |
|
23 | + return true; // handler does not exists |
|
24 | 24 | |
25 | - if (self::$rights[$handler]['type'] == 'sql') { |
|
26 | - $result = Database::query(self::$rights[$handler]['sql']); |
|
27 | - if (Database::num_rows($result) > 0) |
|
28 | - $result = true; |
|
29 | - else |
|
30 | - $result = false; |
|
31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | - $result = self::$rights[$handler]['const']; |
|
33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
34 | - $result = self::$rights[$handler]['func'](); |
|
35 | - else // handler type not implemented |
|
36 | - return true; |
|
37 | - self::$rights_cache[$handler] = $result; |
|
38 | - return $result; |
|
39 | - } |
|
25 | + if (self::$rights[$handler]['type'] == 'sql') { |
|
26 | + $result = Database::query(self::$rights[$handler]['sql']); |
|
27 | + if (Database::num_rows($result) > 0) |
|
28 | + $result = true; |
|
29 | + else |
|
30 | + $result = false; |
|
31 | + } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | + $result = self::$rights[$handler]['const']; |
|
33 | + else if (self::$rights[$handler]['type'] == 'func') |
|
34 | + $result = self::$rights[$handler]['func'](); |
|
35 | + else // handler type not implemented |
|
36 | + return true; |
|
37 | + self::$rights_cache[$handler] = $result; |
|
38 | + return $result; |
|
39 | + } |
|
40 | 40 | |
41 | - public static function hasRightClosePageWithError($handler) { |
|
42 | - if (hasRight($handler) == false) |
|
43 | - die("You are not allowed here"); //FIXME |
|
44 | - } |
|
41 | + public static function hasRightClosePageWithError($handler) { |
|
42 | + if (hasRight($handler) == false) |
|
43 | + die("You are not allowed here"); //FIXME |
|
44 | + } |
|
45 | 45 | |
46 | 46 | } |
@@ -6,9 +6,9 @@ |
||
6 | 6 | */ |
7 | 7 | class Rights { |
8 | 8 | private static $rights_cache = array(); |
9 | - private static $rights = array ( |
|
9 | + private static $rights = array( |
|
10 | 10 | 'show_tabs:reports' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'type' => 'const', |
13 | 13 | 'const' => 'true' ) |
14 | 14 | ); |
@@ -16,31 +16,39 @@ |
||
16 | 16 | // warning the goal of this function is to enforce rights managment in Chamilo |
17 | 17 | // thus default return value is always true |
18 | 18 | public static function hasRight($handler) { |
19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
20 | - return self::$rights_cache[$handler]; |
|
19 | + if (array_key_exists($handler, self::$rights_cache)) { |
|
20 | + return self::$rights_cache[$handler]; |
|
21 | + } |
|
21 | 22 | |
22 | - if (!array_key_exists($handler, self::$rights)) |
|
23 | - return true; // handler does not exists |
|
23 | + if (!array_key_exists($handler, self::$rights)) { |
|
24 | + return true; |
|
25 | + } |
|
26 | + // handler does not exists |
|
24 | 27 | |
25 | 28 | if (self::$rights[$handler]['type'] == 'sql') { |
26 | 29 | $result = Database::query(self::$rights[$handler]['sql']); |
27 | - if (Database::num_rows($result) > 0) |
|
28 | - $result = true; |
|
29 | - else |
|
30 | - $result = false; |
|
31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | - $result = self::$rights[$handler]['const']; |
|
33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
34 | - $result = self::$rights[$handler]['func'](); |
|
35 | - else // handler type not implemented |
|
30 | + if (Database::num_rows($result) > 0) { |
|
31 | + $result = true; |
|
32 | + } else { |
|
33 | + $result = false; |
|
34 | + } |
|
35 | + } else if (self::$rights[$handler]['type'] == 'const') { |
|
36 | + $result = self::$rights[$handler]['const']; |
|
37 | + } else if (self::$rights[$handler]['type'] == 'func') { |
|
38 | + $result = self::$rights[$handler]['func'](); |
|
39 | + } else { |
|
40 | + // handler type not implemented |
|
36 | 41 | return true; |
42 | + } |
|
37 | 43 | self::$rights_cache[$handler] = $result; |
38 | 44 | return $result; |
39 | 45 | } |
40 | 46 | |
41 | 47 | public static function hasRightClosePageWithError($handler) { |
42 | - if (hasRight($handler) == false) |
|
43 | - die("You are not allowed here"); //FIXME |
|
48 | + if (hasRight($handler) == false) { |
|
49 | + die("You are not allowed here"); |
|
50 | + } |
|
51 | + //FIXME |
|
44 | 52 | } |
45 | 53 | |
46 | 54 | } |
@@ -71,6 +71,10 @@ |
||
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Get the terms stored at database |
74 | + * @param string $prefix |
|
75 | + * @param string $course_code |
|
76 | + * @param string $tool_id |
|
77 | + * @param integer $ref_id |
|
74 | 78 | * @return array Array of terms |
75 | 79 | */ |
76 | 80 | function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id) { |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * code |
9 | 9 | */ |
10 | -require_once dirname(__FILE__) . '/../../global.inc.php'; |
|
10 | +require_once dirname(__FILE__).'/../../global.inc.php'; |
|
11 | 11 | include_once 'xapian/XapianIndexer.class.php'; |
12 | 12 | |
13 | 13 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
40 | 40 | return FALSE; |
41 | 41 | |
42 | - require_once api_get_path(LIBRARY_PATH) . 'search/xapian/XapianQuery.php'; |
|
42 | + require_once api_get_path(LIBRARY_PATH).'search/xapian/XapianQuery.php'; |
|
43 | 43 | |
44 | 44 | // compare terms |
45 | 45 | $doc = $this->get_document($search_did); |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | |
56 | 56 | // save it to search engine |
57 | 57 | foreach ($missing_terms as $term) { |
58 | - $this->add_term_to_doc($prefix . $term, $doc); |
|
58 | + $this->add_term_to_doc($prefix.$term, $doc); |
|
59 | 59 | } |
60 | 60 | foreach ($deprecated_terms as $term) { |
61 | - $this->remove_term_from_doc($prefix . $term, $doc); |
|
61 | + $this->remove_term_from_doc($prefix.$term, $doc); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | // don't do anything if no change |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @return array Array of terms |
75 | 75 | */ |
76 | 76 | function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id) { |
77 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
77 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
78 | 78 | $terms = get_specific_field_values_list_by_prefix($prefix, $course_code, $tool_id, $ref_id); |
79 | 79 | $prefix_terms = array(); |
80 | 80 | foreach ($terms as $term) { |
@@ -36,8 +36,9 @@ discard block |
||
36 | 36 | $stored_terms = $this->get_terms_on_db($prefix, $course_code, $tool_id, $ref_id_high_level); |
37 | 37 | |
38 | 38 | // don't do anything if no change, verify only at DB, not the search engine |
39 | - if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
|
40 | - return FALSE; |
|
39 | + if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) { |
|
40 | + return FALSE; |
|
41 | + } |
|
41 | 42 | |
42 | 43 | require_once api_get_path(LIBRARY_PATH) . 'search/xapian/XapianQuery.php'; |
43 | 44 | |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | $doc = $this->get_document($search_did); |
46 | 47 | $xapian_terms = xapian_get_doc_terms($doc, $prefix); |
47 | 48 | $xterms = array(); |
48 | - foreach ($xapian_terms as $xapian_term) |
|
49 | - $xterms[] = substr($xapian_term['name'], 1); |
|
49 | + foreach ($xapian_terms as $xapian_term) { |
|
50 | + $xterms[] = substr($xapian_term['name'], 1); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | $dterms = $terms; |
52 | 54 |
@@ -23,6 +23,9 @@ discard block |
||
23 | 23 | return chamilo_preprocess_results($results); |
24 | 24 | } |
25 | 25 | |
26 | +/** |
|
27 | + * @param string $query_string |
|
28 | + */ |
|
26 | 29 | function chamilo_query_simple_query($query_string, $offset=0, $length=10, $extra=NULL) { |
27 | 30 | return xapian_query($query_string, NULL, $offset, $length, $extra); |
28 | 31 | } |
@@ -30,7 +33,7 @@ discard block |
||
30 | 33 | /** |
31 | 34 | * Wrapper for getting boolean queries |
32 | 35 | * |
33 | - * @param string $query_string The term string |
|
36 | + * @param string $term |
|
34 | 37 | */ |
35 | 38 | function chamilo_get_boolean_query($term) { |
36 | 39 | return xapian_get_boolean_query($term); |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | * @param array extra Extra queries to join with. Optional |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function chamilo_query_query($query_string, $offset=0, $length=10, $extra=NULL) { |
|
21 | +function chamilo_query_query($query_string, $offset = 0, $length = 10, $extra = NULL) { |
|
22 | 22 | list($count, $results) = xapian_query($query_string, NULL, $offset, $length, $extra); |
23 | 23 | return chamilo_preprocess_results($results); |
24 | 24 | } |
25 | 25 | |
26 | -function chamilo_query_simple_query($query_string, $offset=0, $length=10, $extra=NULL) { |
|
26 | +function chamilo_query_simple_query($query_string, $offset = 0, $length = 10, $extra = NULL) { |
|
27 | 27 | return xapian_query($query_string, NULL, $offset, $length, $extra); |
28 | 28 | } |
29 | 29 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | function chamilo_preprocess_results($results) { |
43 | 43 | // group by toolid |
44 | 44 | $results_by_tool = array(); |
45 | - if (count($results)>0) { |
|
45 | + if (count($results) > 0) { |
|
46 | 46 | |
47 | 47 | foreach ($results as $key => $row) { |
48 | 48 | $results_by_tool[$row['toolid']][] = $row; |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | |
51 | 51 | $processed_results = array(); |
52 | 52 | foreach ($results_by_tool as $toolid => $rows) { |
53 | - $tool_processor_class = $toolid .'_processor'; |
|
54 | - $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
53 | + $tool_processor_class = $toolid.'_processor'; |
|
54 | + $tool_processor_path = api_get_path(LIBRARY_PATH).'search/tool_processors/'.$tool_processor_class.'.class.php'; |
|
55 | 55 | if (file_exists($tool_processor_path)) { |
56 | 56 | require_once($tool_processor_path); |
57 | 57 | $tool_processor = new $tool_processor_class($rows); |
@@ -71,6 +71,6 @@ discard block |
||
71 | 71 | * @param string $op |
72 | 72 | * @return XapianQuery query joined |
73 | 73 | */ |
74 | -function chamilo_join_queries($query1, $query2=NULL, $op='or') { |
|
74 | +function chamilo_join_queries($query1, $query2 = NULL, $op = 'or') { |
|
75 | 75 | return xapian_join_queries($query1, $query2, $op); |
76 | 76 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param string $query_string The term string |
34 | 34 | */ |
35 | 35 | function chamilo_get_boolean_query($term) { |
36 | - return xapian_get_boolean_query($term); |
|
36 | + return xapian_get_boolean_query($term); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -44,22 +44,22 @@ discard block |
||
44 | 44 | $results_by_tool = array(); |
45 | 45 | if (count($results)>0) { |
46 | 46 | |
47 | - foreach ($results as $key => $row) { |
|
48 | - $results_by_tool[$row['toolid']][] = $row; |
|
49 | - } |
|
47 | + foreach ($results as $key => $row) { |
|
48 | + $results_by_tool[$row['toolid']][] = $row; |
|
49 | + } |
|
50 | 50 | |
51 | - $processed_results = array(); |
|
52 | - foreach ($results_by_tool as $toolid => $rows) { |
|
53 | - $tool_processor_class = $toolid .'_processor'; |
|
54 | - $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
55 | - if (file_exists($tool_processor_path)) { |
|
56 | - require_once($tool_processor_path); |
|
57 | - $tool_processor = new $tool_processor_class($rows); |
|
58 | - $processed_results = array_merge($tool_processor->process(), $processed_results); |
|
59 | - } |
|
60 | - } |
|
51 | + $processed_results = array(); |
|
52 | + foreach ($results_by_tool as $toolid => $rows) { |
|
53 | + $tool_processor_class = $toolid .'_processor'; |
|
54 | + $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
55 | + if (file_exists($tool_processor_path)) { |
|
56 | + require_once($tool_processor_path); |
|
57 | + $tool_processor = new $tool_processor_class($rows); |
|
58 | + $processed_results = array_merge($tool_processor->process(), $processed_results); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - return array(count($processed_results), $processed_results); |
|
62 | + return array(count($processed_results), $processed_results); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -72,5 +72,5 @@ discard block |
||
72 | 72 | * @return XapianQuery query joined |
73 | 73 | */ |
74 | 74 | function chamilo_join_queries($query1, $query2=NULL, $op='or') { |
75 | - return xapian_join_queries($query1, $query2, $op); |
|
75 | + return xapian_join_queries($query1, $query2, $op); |
|
76 | 76 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Simple getter for the db attribute |
101 | - * @return object The db attribute |
|
101 | + * @return null|XapianWritableDatabase The db attribute |
|
102 | 102 | */ |
103 | 103 | function getDb() |
104 | 104 | { |
@@ -108,6 +108,7 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * Add this chunk to the chunk array attribute |
110 | 110 | * @param string Chunk of text |
111 | + * @param IndexableChunk $chunk |
|
111 | 112 | * @return void |
112 | 113 | */ |
113 | 114 | function addChunk($chunk) |
@@ -179,7 +180,7 @@ discard block |
||
179 | 180 | * Get document data on a xapian document |
180 | 181 | * |
181 | 182 | * @param XapianDocument $doc xapian document to push into the db |
182 | - * @return mixed xapian document data or FALSE if error |
|
183 | + * @return string xapian document data or FALSE if error |
|
183 | 184 | */ |
184 | 185 | function get_document_data($doc) |
185 | 186 | { |
@@ -286,7 +287,7 @@ discard block |
||
286 | 287 | * Replace a document in the actual db |
287 | 288 | * |
288 | 289 | * @param XapianDocument $doc xapian document to push into the db |
289 | - * @param Xapian::docid $did xapian document id of the document to replace |
|
290 | + * @param integer $did xapian document id of the document to replace |
|
290 | 291 | */ |
291 | 292 | function replace_document($doc, $did) |
292 | 293 | { |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | require_once 'xapian.php'; |
9 | -require_once dirname(__FILE__) . '/../IndexableChunk.class.php'; |
|
9 | +require_once dirname(__FILE__).'/../IndexableChunk.class.php'; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Abstract helper class |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | if (!empty($chunk->terms)) { |
131 | 131 | foreach ($chunk->terms as $term) { |
132 | 132 | /* FIXME: think of getting weight */ |
133 | - $doc->add_term($term['flag'] . $term['name'], 1); |
|
133 | + $doc->add_term($term['flag'].$term['name'], 1); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $doc->clear_terms(); |
216 | 216 | foreach ($terms as $term) { |
217 | 217 | //add directly |
218 | - $doc->add_term($prefix . $term, 1); |
|
218 | + $doc->add_term($prefix.$term, 1); |
|
219 | 219 | } |
220 | 220 | $this->db->replace_document($did, $doc); |
221 | 221 | $this->db->flush(); |
@@ -70,13 +70,16 @@ |
||
70 | 70 | */ |
71 | 71 | function connectDb($path = null, $dbMode = null, $lang = 'english') |
72 | 72 | { |
73 | - if ($this->db != null) |
|
74 | - return $this->db; |
|
75 | - if ($dbMode == null) |
|
76 | - $dbMode = Xapian::DB_CREATE_OR_OPEN; |
|
73 | + if ($this->db != null) { |
|
74 | + return $this->db; |
|
75 | + } |
|
76 | + if ($dbMode == null) { |
|
77 | + $dbMode = Xapian::DB_CREATE_OR_OPEN; |
|
78 | + } |
|
77 | 79 | |
78 | - if ($path == null) |
|
79 | - $path = api_get_path(SYS_UPLOAD_PATH).'plugins/xapian/searchdb/'; |
|
80 | + if ($path == null) { |
|
81 | + $path = api_get_path(SYS_UPLOAD_PATH).'plugins/xapian/searchdb/'; |
|
82 | + } |
|
80 | 83 | |
81 | 84 | try { |
82 | 85 | $this->db = new XapianWritableDatabase($path, $dbMode); |
@@ -45,6 +45,8 @@ discard block |
||
45 | 45 | * checker path (directory) |
46 | 46 | * @param string Absolute path to be checked (with trailing slash) |
47 | 47 | * @param string Checker path under which the path should be (absolute path, with trailing slash, get it from api_get_path(SYS_COURSE_PATH)) |
48 | + * @param string $abs_path |
|
49 | + * @param string $checker_path |
|
48 | 50 | * @return bool True if the path is under the checker, false otherwise |
49 | 51 | */ |
50 | 52 | public static function check_abs_path($abs_path, $checker_path) |
@@ -300,6 +302,7 @@ discard block |
||
300 | 302 | * @param string The variable to filter for XSS, this params can be a string or an array (example : array(x,y)) |
301 | 303 | * @param int The user status,constant allowed (STUDENT, COURSEMANAGER, ANONYMOUS, COURSEMANAGERLOWSECURITY) |
302 | 304 | * @param bool $filter_terms |
305 | + * @param integer $user_status |
|
303 | 306 | * @return mixed Filtered string or array |
304 | 307 | */ |
305 | 308 | public static function remove_XSS($var, $user_status = null, $filter_terms = false) |
@@ -453,7 +456,7 @@ discard block |
||
453 | 456 | * This method provides specific protection (against XSS and other kinds of attacks) for static images (icons) used by the system. |
454 | 457 | * Image paths are supposed to be given by programmers - people who know what they do, anyway, this method encourages |
455 | 458 | * a safe practice for generating icon paths, without using heavy solutions based on HTMLPurifier for example. |
456 | - * @param string $img_path The input path of the image, it could be relative or absolute URL. |
|
459 | + * @param string $image_path The input path of the image, it could be relative or absolute URL. |
|
457 | 460 | * @return string Returns sanitized image path or an empty string when the image path is not secure. |
458 | 461 | * @author Ivan Tcholakov, March 2011 |
459 | 462 | */ |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $rel_path = '/'.$rel_path; |
92 | 92 | } |
93 | 93 | $abs_path = $current_path.$rel_path; |
94 | - $true_path=str_replace("\\", '/', realpath($abs_path)); |
|
94 | + $true_path = str_replace("\\", '/', realpath($abs_path)); |
|
95 | 95 | $found = strpos($true_path.'/', $checker_path); |
96 | 96 | if ($found === 0) { |
97 | 97 | return true; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | } |
322 | 322 | |
323 | 323 | if ($user_status == COURSEMANAGERLOWSECURITY) { |
324 | - return $var; // No filtering. |
|
324 | + return $var; // No filtering. |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | static $purifier = array(); |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | } |
345 | 345 | |
346 | 346 | // Shows _target attribute in anchors |
347 | - $config->set('Attr.AllowedFrameTargets', array('_blank','_top','_self', '_parent')); |
|
347 | + $config->set('Attr.AllowedFrameTargets', array('_blank', '_top', '_self', '_parent')); |
|
348 | 348 | |
349 | 349 | if ($user_status == STUDENT) { |
350 | 350 | global $allowed_html_student; |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public static function remove_XSS($var, $user_status = null, $filter_terms = false) |
306 | 306 | { |
307 | - if ($filter_terms) { |
|
308 | - $var = self::filter_terms($var); |
|
309 | - } |
|
307 | + if ($filter_terms) { |
|
308 | + $var = self::filter_terms($var); |
|
309 | + } |
|
310 | 310 | |
311 | 311 | if (empty($user_status)) { |
312 | 312 | if (api_is_anonymous()) { |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | */ |
402 | 402 | public static function filter_terms($text) |
403 | 403 | { |
404 | - static $bad_terms = array(); |
|
404 | + static $bad_terms = array(); |
|
405 | 405 | |
406 | 406 | if (empty($bad_terms)) { |
407 | 407 | $list = api_get_setting('filter_terms'); |
@@ -422,14 +422,14 @@ discard block |
||
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | - $replace = '***'; |
|
426 | - if (!empty($bad_terms)) { |
|
427 | - // Fast way |
|
428 | - $new_text = str_ireplace($bad_terms, $replace, $text, $count); |
|
429 | - $text = $new_text; |
|
430 | - } |
|
425 | + $replace = '***'; |
|
426 | + if (!empty($bad_terms)) { |
|
427 | + // Fast way |
|
428 | + $new_text = str_ireplace($bad_terms, $replace, $text, $count); |
|
429 | + $text = $new_text; |
|
430 | + } |
|
431 | 431 | |
432 | - return $text; |
|
432 | + return $text; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 |
@@ -30,6 +30,9 @@ |
||
30 | 30 | $this->center_x = intval($offset_x + $this->canvas_x/2 - $this->block_size/2); |
31 | 31 | } |
32 | 32 | |
33 | + /** |
|
34 | + * @param string $class |
|
35 | + */ |
|
33 | 36 | function prepare_skill_box($skill, $position, $class) |
34 | 37 | { |
35 | 38 | $block_id = $skill['id']; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | $this->skills = $skills; |
29 | 29 | $this->type = $type; |
30 | - $this->center_x = intval($offset_x + $this->canvas_x/2 - $this->block_size/2); |
|
30 | + $this->center_x = intval($offset_x + $this->canvas_x / 2 - $this->block_size / 2); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | function prepare_skill_box($skill, $position, $class) |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | $extra_class = 'second_window'; |
40 | 40 | } |
41 | 41 | |
42 | - $this->html .= '<div id="block_'.$block_id.'" class = "open_block window '.$extra_class.' '.$class.'" style = "top:' . $position['y'] . 'px; left:' . $position['x'] . 'px;">'; |
|
42 | + $this->html .= '<div id="block_'.$block_id.'" class = "open_block window '.$extra_class.' '.$class.'" style = "top:'.$position['y'].'px; left:'.$position['x'].'px;">'; |
|
43 | 43 | |
44 | - $content = $skill['name']; |
|
44 | + $content = $skill['name']; |
|
45 | 45 | $content .= '<div class="btn-group">'; |
46 | 46 | $content .= Display::url(get_lang('Edit'), '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block btn')); |
47 | 47 | $content .= Display::url('+', '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block btn')); |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | } |
88 | 88 | //default_arrow_color |
89 | 89 | |
90 | - $this->js .= 'var e'.$block_id.' = prepare("block_' . $block_id.'", '.$end_point.');'."\n"; |
|
91 | - $this->js .= 'var e'.$skill['parent_id'].' = prepare("block_' . $skill['parent_id'].'", '.$end_point.');'."\n"; |
|
92 | - $this->js .= 'jsPlumb.connect({source: e'.$block_id.', target:e'.$skill['parent_id'].'});'."\n";; |
|
90 | + $this->js .= 'var e'.$block_id.' = prepare("block_'.$block_id.'", '.$end_point.');'."\n"; |
|
91 | + $this->js .= 'var e'.$skill['parent_id'].' = prepare("block_'.$skill['parent_id'].'", '.$end_point.');'."\n"; |
|
92 | + $this->js .= 'jsPlumb.connect({source: e'.$block_id.', target:e'.$skill['parent_id'].'});'."\n"; ; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | $brothers = array(); |
126 | 126 | |
127 | 127 | foreach ($this->skills as &$skill) { |
128 | - if (!in_array($skill['parent_id'], array(0,1))) { |
|
128 | + if (!in_array($skill['parent_id'], array(0, 1))) { |
|
129 | 129 | continue; |
130 | 130 | } |
131 | - $childs = isset($skill['children']) ? count($skill['children']) : 0 ; |
|
131 | + $childs = isset($skill['children']) ? count($skill['children']) : 0; |
|
132 | 132 | |
133 | 133 | //$x = round($this->offsetX * sin(deg2rad($corner * $count))); |
134 | 134 | //$y = round($this->offsetY * cos(deg2rad($corner * $count))); |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | if ($skill['parent_id'] == 0) { |
145 | 145 | //$x = 130*$childs/2; |
146 | 146 | //$x = $this->space_between_blocks_x*$childs/2; |
147 | - $x = $this->canvas_x/2 - $this->block_size/2; |
|
147 | + $x = $this->canvas_x / 2 - $this->block_size / 2; |
|
148 | 148 | } else { |
149 | 149 | $max = isset($this->skills[$skill['parent_id']]['children']) ? count($this->skills[$skill['parent_id']]['children']) : 0; |
150 | - foreach($this->skills[$skill['parent_id']]['children'] as $id => $sk) { |
|
150 | + foreach ($this->skills[$skill['parent_id']]['children'] as $id => $sk) { |
|
151 | 151 | if ($skill['id'] == $sk['id']) { |
152 | 152 | break; |
153 | 153 | } |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | } |
156 | 156 | $parent_x = isset($this->skills[$skill['parent_id']]['x']) ? $this->skills[$skill['parent_id']]['x'] : 0; |
157 | 157 | //$x = $my_count*$this->space_between_blocks_x + $parent_x + $this->block_size - ($this->space_between_blocks_x*$max/2) ; |
158 | - $x = $my_count*$this->space_between_blocks_x + $parent_x + $this->block_size - ($this->canvas_x/2 ) ; |
|
158 | + $x = $my_count * $this->space_between_blocks_x + $parent_x + $this->block_size - ($this->canvas_x / 2); |
|
159 | 159 | } |
160 | 160 | |
161 | - $y = $skill['level']*$this->space_between_blocks_y; |
|
161 | + $y = $skill['level'] * $this->space_between_blocks_y; |
|
162 | 162 | |
163 | 163 | $skill['x'] = $x; |
164 | 164 | $skill['y'] = $y; |
165 | 165 | |
166 | 166 | //$skill['description'] = "{$brothers[$skill['parent_id']]} $x - $y"; |
167 | 167 | //$skill['name'] = $skill['name']." | $x = $my_count * 150 + $parent_x - (150* $max/2) - 10*$childs "; |
168 | - $this->add_item($skill, array('x' => $this->offset_x + $x, 'y' => $this->offset_y +$y)); |
|
168 | + $this->add_item($skill, array('x' => $this->offset_x + $x, 'y' => $this->offset_y + $y)); |
|
169 | 169 | } |
170 | 170 | return $this->get_html(); |
171 | 171 | } |