From 7658bd1015bf7d3715e4c64fbb0c9c8518f05cc2 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Fri, 29 Dec 2017 13:55:11 +0100 Subject: [PATCH] Minor - format code --- main/exercise/export/qti2/qti2_export.php | 2 +- main/inc/lib/api.lib.php | 22 ++++++++++++------ main/inc/lib/browser/Browser.php | 4 ++-- main/inc/lib/search/xapian/XapianQuery.php | 26 ++++++++++++---------- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/main/exercise/export/qti2/qti2_export.php b/main/exercise/export/qti2/qti2_export.php index afbd9689a3..1eca4a8577 100755 --- a/main/exercise/export/qti2/qti2_export.php +++ b/main/exercise/export/qti2/qti2_export.php @@ -394,7 +394,7 @@ class ImsItem * @return string string, the XML flow for an Item. * @author Amand Tihon */ - public function export($standalone = False) + public function export($standalone = false) { global $charset; $head = $foot = ""; diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 42d6aa1519..f07e130257 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -4901,7 +4901,9 @@ function rmdirr($dirname, $delete_only_content_in_folder = false, $strict = fals */ function copyr($source, $dest, $exclude = [], $copied_files = []) { - if (empty($dest)) { return false; } + if (empty($dest)) { + return false; + } // Simple copy for a file if (is_file($source)) { $path_info = pathinfo($source); @@ -5422,7 +5424,9 @@ function api_set_settings_category($category, $value = null, $access_url = 1, $f $category = Database::escape_string($category); $t_s = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); $access_url = (int) $access_url; - if (empty($access_url)) { $access_url = 1; } + if (empty($access_url)) { + $access_url = 1; + } if (isset($value)) { $value = Database::escape_string($value); $sql = "UPDATE $t_s SET selected_value = '$value' @@ -5742,8 +5746,7 @@ function api_is_course_visible_for_user($userid = null, $cid = null) if ($row[0]['id_coach'] == $userid) { $is_courseMember = true; $is_courseAdmin = false; - } - elseif ($row[0]['session_admin_id'] == $userid) { + } elseif ($row[0]['session_admin_id'] == $userid) { $is_courseMember = false; $is_courseAdmin = false; } else { @@ -7019,7 +7022,9 @@ function api_check_ip_in_range($ip, $range) } foreach ($ranges as $range) { $range = trim($range); - if (empty($range)) { continue; } + if (empty($range)) { + continue; + } if (strpos($range, '/') === false) { if (strcmp($ip, $range) === 0) { return true; // there is a direct IP match, return OK @@ -7266,6 +7271,10 @@ function api_coach_can_edit_view_results($courseId = null, $session_id = null) } } +/** + * @param string $file + * @return string + */ function api_get_js_simple($file) { return ''."\n"; @@ -7357,8 +7366,7 @@ function api_set_settings_and_plugins() /** * Tries to set memory limit, if authorized and new limit is higher than current - * @param string New memory limit - * @param string $mem + * @param string $mem New memory limit * @return bool True on success, false on failure or current is higher than suggested * @assert (null) === false * @assert (-1) === false diff --git a/main/inc/lib/browser/Browser.php b/main/inc/lib/browser/Browser.php index 8d336902c0..af3b5335ee 100755 --- a/main/inc/lib/browser/Browser.php +++ b/main/inc/lib/browser/Browser.php @@ -142,9 +142,9 @@ class Browser * @param string $browserName * @return bool True if the browser is the specified browser */ - function isBrowser($browserName) + public function isBrowser($browserName) { - return (0 == strcasecmp($this->_browser_name, trim($browserName))); + return 0 == strcasecmp($this->_browser_name, trim($browserName)); } /** diff --git a/main/inc/lib/search/xapian/XapianQuery.php b/main/inc/lib/search/xapian/XapianQuery.php index aeab8646c7..5218637a56 100755 --- a/main/inc/lib/search/xapian/XapianQuery.php +++ b/main/inc/lib/search/xapian/XapianQuery.php @@ -26,8 +26,8 @@ define('XAPIAN_DB', api_get_path(SYS_UPLOAD_PATH).'plugins/xapian/searchdb/'); * @param int $count_type Number of items to retrieve * @return array An array of nids corresponding to the results. */ -function xapian_query($query_string, $db = NULL, $start = 0, $length = 10, $extra = array(), $count_type = 0) { - +function xapian_query($query_string, $db = null, $start = 0, $length = 10, $extra = [], $count_type = 0) +{ try { if (!is_object($db)) { $db = new XapianDatabase(XAPIAN_DB); @@ -41,10 +41,8 @@ function xapian_query($query_string, $db = NULL, $start = 0, $length = 10, $extr } } - - $query = NULL; + $query = null; $enquire = new XapianEnquire($db); - if (!empty($query_string)) { $query_parser = new XapianQueryParser(); //TODO: choose stemmer @@ -118,14 +116,15 @@ function xapian_query($query_string, $db = NULL, $start = 0, $length = 10, $extr return array($count, $results); } catch (Exception $e) { display_xapian_error($e->getMessage()); - return NULL; + return null; } } /** * build a boolean query */ -function xapian_get_boolean_query($term) { +function xapian_get_boolean_query($term) +{ return new XapianQuery($term); } @@ -137,7 +136,8 @@ function xapian_get_boolean_query($term) { * @param XapianDatabase $db Xapian database to connect * @return array */ -function xapian_get_all_terms($count = 0, $prefix, $db = NULL) { +function xapian_get_all_terms($count = 0, $prefix, $db = null) +{ try { if (!is_object($db)) { $db = new XapianDatabase(XAPIAN_DB); @@ -161,7 +161,7 @@ function xapian_get_all_terms($count = 0, $prefix, $db = NULL) { return $terms; } catch (Exception $e) { display_xapian_error($e->getMessage()); - return NULL; + return null; } } @@ -171,7 +171,8 @@ function xapian_get_all_terms($count = 0, $prefix, $db = NULL) { * @param XapianDocument document searched * @return array */ -function xapian_get_doc_terms($doc = NULL, $prefix) { +function xapian_get_doc_terms($doc = null, $prefix) +{ try { if (!is_a($doc, 'XapianDocument')) { return; @@ -194,7 +195,7 @@ function xapian_get_doc_terms($doc = NULL, $prefix) { return $terms; } catch (Exception $e) { display_xapian_error($e->getMessage()); - return NULL; + return null; } } @@ -206,7 +207,8 @@ function xapian_get_doc_terms($doc = NULL, $prefix) { * @param string $op * @return XapianQuery query joined */ -function xapian_join_queries($query1, $query2 = NULL, $op = 'or') { +function xapian_join_queries($query1, $query2 = null, $op = 'or') +{ // let decide how to join, avoiding include xapian.php outside switch ($op) { case 'or':