Browse Source

Move function "trim_value" into text.lib.php

- Format code
- add function visibility
jmontoyaa 7 years ago
parent
commit
f2e82adf4c

+ 8 - 11
main/inc/lib/search/ChamiloIndexer.class.php

@@ -25,7 +25,7 @@ class ChamiloIndexer extends XapianIndexer
      * @param int $search_did Search engine document id from search_engine_ref table
      * @return  boolean False on error or nothing to do, true otherwise
      */
-    function set_terms(
+    public function set_terms(
         $terms_string,
         $prefix,
         $course_code,
@@ -82,22 +82,19 @@ class ChamiloIndexer extends XapianIndexer
      * Get the terms stored at database
      * @return  array Array of terms
      */
-    function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id)
+    public function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id)
     {
         require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
-        $terms = get_specific_field_values_list_by_prefix($prefix, $course_code, $tool_id, $ref_id);
+        $terms = get_specific_field_values_list_by_prefix(
+            $prefix,
+            $course_code,
+            $tool_id,
+            $ref_id
+        );
         $prefix_terms = array();
         foreach ($terms as $term) {
             $prefix_terms[] = $term['value'];
         }
         return $prefix_terms;
     }
-
-}
-
-if (!function_exists('trim_value')) {
-    function trim_value(&$value)
-    {
-        $value = trim($value);
-    }
 }

+ 12 - 12
main/inc/lib/search/xapian/XapianIndexer.class.php

@@ -67,7 +67,7 @@ abstract class XapianIndexer
     /**
      * Connect to the database, and create it if it doesn't exist
      */
-    function connectDb($path = null, $dbMode = null, $lang = 'english')
+    public function connectDb($path = null, $dbMode = null, $lang = 'english')
     {
         if ($this->db != null) {
             return $this->db;
@@ -102,7 +102,7 @@ abstract class XapianIndexer
      * Simple getter for the db attribute
      * @return  object  The db attribute
      */
-    function getDb()
+    public function getDb()
     {
         return $this->db;
     }
@@ -112,7 +112,7 @@ abstract class XapianIndexer
      * @param  string  Chunk of text
      * @return  void
      */
-    function addChunk($chunk)
+    public function addChunk($chunk)
     {
         $this->chunks[] = $chunk;
     }
@@ -122,7 +122,7 @@ abstract class XapianIndexer
      *
      * @return integer  New Xapian document ID or null upon failure
      */
-    function index()
+    public function index()
     {
         try {
             if (!empty($this->chunks)) {
@@ -163,7 +163,7 @@ abstract class XapianIndexer
      * @param   int     did     Xapian::docid
      * @return  mixed   XapianDocument, or false on error
      */
-    function get_document($did)
+    public function get_document($did)
     {
         if ($this->db == null) {
             $this->connectDb();
@@ -183,7 +183,7 @@ abstract class XapianIndexer
      * @param XapianDocument $doc xapian document to push into the db
      * @return mixed xapian document data or FALSE if error
      */
-    function get_document_data($doc)
+    public function get_document_data($doc)
     {
         if ($this->db == null) {
             $this->connectDb();
@@ -209,7 +209,7 @@ abstract class XapianIndexer
      * (usually 'T' for title, 'A' for author)
      * @return  boolean false on error
      */
-    function update_terms($did, $terms, $prefix)
+    public function update_terms($did, $terms, $prefix)
     {
         $doc = $this->get_document($did);
         if ($doc === false) {
@@ -231,7 +231,7 @@ abstract class XapianIndexer
      *
      * @param int   did     Xapian::docid
      */
-    function remove_document($did)
+    public function remove_document($did)
     {
         if ($this->db == null) {
             $this->connectDb();
@@ -252,7 +252,7 @@ abstract class XapianIndexer
      * @param XapianDocument $doc The xapian document where to add the term
      * @return  mixed   XapianDocument, or false on error
      */
-    function add_term_to_doc($term, $doc)
+    public function add_term_to_doc($term, $doc)
     {
         if (!is_a($doc, 'XapianDocument')) {
             return false;
@@ -272,7 +272,7 @@ abstract class XapianIndexer
      * @param XapianDocument $doc The xapian document where to add the term
      * @return  mixed   XapianDocument, or false on error
      */
-    function remove_term_from_doc($term, $doc)
+    public function remove_term_from_doc($term, $doc)
     {
         if (!is_a($doc, 'XapianDocument')) {
             return false;
@@ -292,7 +292,7 @@ abstract class XapianIndexer
      * @param int $did xapian document id of the document to replace
      * @return mixed
      */
-    function replace_document($doc, $did)
+    public function replace_document($doc, $did)
     {
         if (!is_a($doc, 'XapianDocument')) {
             return false;
@@ -312,7 +312,7 @@ abstract class XapianIndexer
     /**
      * Class destructor
      */
-    function __destruct()
+    public function __destruct()
     {
         unset($this->db);
         unset($this->stemmer);

+ 8 - 0
main/inc/lib/text.lib.php

@@ -861,3 +861,11 @@ function underScoreToCamelCase($string, $capitalizeFirstCharacter = true)
 
     return $str;
 }
+
+/**
+ * @param string $value
+ */
+function trim_value(& $value)
+{
+    $value = trim($value);
+}

+ 16 - 11
main/lp/learnpath.class.php

@@ -3158,9 +3158,9 @@ class learnpath
             'passed' => 'scorm_completed',
             'succeeded' => 'scorm_completed',
             'browsed' => 'scorm_completed',
-            ];
-        foreach ($toc_list as $item) {
+        ];
 
+        foreach ($toc_list as $item) {
             $list['id'] = $item['id'];
             $list['status'] = $item['status'];
             $cssStatus = null;
@@ -4175,9 +4175,9 @@ class learnpath
                 false,
                 $id
             );
-            $learPaths = $list->get_flat_list();
 
-            foreach ($learPaths as $lp) {
+            $lpList = $list->get_flat_list();
+            foreach ($lpList as $lp) {
                 learnpath::toggle_visibility($lp['iid'], 0);
             }
 
@@ -5924,13 +5924,23 @@ class learnpath
                         }
                     } else {
                         $edit_icon .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit_item&id='.$arrLP[$i]['id'].'&lp_id='.$this->lp_id.'&path_item='.$arrLP[$i]['path'].'" class="btn btn-default">';
-                        $edit_icon .= Display::return_icon('edit.png', get_lang('LearnpathEditModule'), array(), ICON_SIZE_TINY);
+                        $edit_icon .= Display::return_icon(
+                            'edit.png',
+                            get_lang('LearnpathEditModule'),
+                            array(),
+                            ICON_SIZE_TINY
+                        );
                         $edit_icon .= '</a>';
                     }
                 } else {
                     if ($arrLP[$i]['item_type'] == TOOL_LP_FINAL_ITEM) {
                         $edit_icon .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit_item&id='.$arrLP[$i]['id'].'&lp_id='.$this->lp_id.'" class="btn btn-default">';
-                        $edit_icon .= Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_TINY);
+                        $edit_icon .= Display::return_icon(
+                            'edit.png',
+                            get_lang('Edit'),
+                            array(),
+                            ICON_SIZE_TINY
+                        );
                         $edit_icon .= '</a>';
                     }
                 }
@@ -12064,8 +12074,3 @@ EOD;
     }
 }
 
-if (!function_exists('trim_value')) {
-    function trim_value(& $value) {
-        $value = trim($value);
-    }
-}