From 6db37df9ca4aaa6b346bec989481225a9cbfa8fe Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 11 Oct 2017 11:22:35 +0200 Subject: [PATCH] Minor - format code, replace "return_form" with "returnForm" --- main/auth/openid/login.php | 2 +- main/calendar/agenda.php | 2 +- main/exercise/hotpotatoes_exercise_report.php | 2 +- main/exercise/hotspot_admin.inc.php | 2 +- main/inc/lib/database.lib.php | 4 +- main/lp/learnpath.class.php | 74 ++++++++++--------- main/tracking/courseLog.php | 2 +- main/webservices/soap.test.php | 4 +- plugin/before_login/index.php | 4 +- plugin/sepe/src/sepe_plugin.class.php | 1 + 10 files changed, 49 insertions(+), 48 deletions(-) diff --git a/main/auth/openid/login.php b/main/auth/openid/login.php index 4d5129a16c..f3cda60ac6 100755 --- a/main/auth/openid/login.php +++ b/main/auth/openid/login.php @@ -26,7 +26,7 @@ function openid_form() $form -> addElement('text', 'openid_url', array(get_lang('OpenIDURL'), Display::url(get_lang('OpenIDWhatIs'), 'main/auth/openid/whatis.php')), array('class' => 'openid_input')); $form -> addElement('button', 'submit', get_lang('Login')); - return $form->return_form(); + return $form->returnForm(); } /** diff --git a/main/calendar/agenda.php b/main/calendar/agenda.php index abf252fe9a..aa5763abff 100755 --- a/main/calendar/agenda.php +++ b/main/calendar/agenda.php @@ -160,7 +160,7 @@ if ($allowToEdit) { header("Location: $agendaUrl"); exit; } else { - $content = $form->return_form(); + $content = $form->returnForm(); } break; case 'edit': diff --git a/main/exercise/hotpotatoes_exercise_report.php b/main/exercise/hotpotatoes_exercise_report.php index 5f60991ab6..cce7da2edf 100755 --- a/main/exercise/hotpotatoes_exercise_report.php +++ b/main/exercise/hotpotatoes_exercise_report.php @@ -153,7 +153,7 @@ $form->addElement('radio', 'export_format', null, get_lang('ExportAsCSV'), 'csv' //$form->addElement('radio', 'export_format', null, get_lang('ExportAsXLS'), 'xls', array('id' => 'export_format_xls_label')); //$form->addElement('checkbox', 'load_extra_data', null, get_lang('LoadExtraData'), '0', array('id' => 'export_format_xls_label')); $form->setDefaults(array('export_format' => 'csv')); -$extra .= $form->return_form(); +$extra .= $form->returnForm(); $extra .= ''; if ($is_allowedToEdit) { diff --git a/main/exercise/hotspot_admin.inc.php b/main/exercise/hotspot_admin.inc.php index 6017bd799b..f4e7a5faca 100755 --- a/main/exercise/hotspot_admin.inc.php +++ b/main/exercise/hotspot_admin.inc.php @@ -942,7 +942,7 @@ if ($modifyAnswers) { $renderer->setElementTemplate($element_template); $form->setDefaults(array('comment['.$i.']' => $commentValue)); - $return = $form->return_form(); + $return = $form->returnForm(); ?> diff --git a/main/inc/lib/database.lib.php b/main/inc/lib/database.lib.php index 4b3a0b7b6e..bcbb633b65 100755 --- a/main/inc/lib/database.lib.php +++ b/main/inc/lib/database.lib.php @@ -432,7 +432,7 @@ class Database * @param array $attributes * @param bool $show_query * - * @return false|string + * @return false|int */ public static function insert($table_name, $attributes, $show_query = false) { @@ -455,7 +455,7 @@ class Database } if ($result) { - return self::getManager()->getConnection()->lastInsertId(); + return (int) self::getManager()->getConnection()->lastInsertId(); } } diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php index 3b01f99658..30a7759b15 100755 --- a/main/lp/learnpath.class.php +++ b/main/lp/learnpath.class.php @@ -2061,7 +2061,10 @@ class learnpath if ($this->debug > 2) { error_log('New LP - Now looking at ordered_items['.($index).'] - type is '.$this->items[$this->ordered_items[$index]]->type, 0); } - while (!empty ($this->ordered_items[$index]) && ($this->items[$this->ordered_items[$index]]->get_type() == 'dir') && $index < $this->max_ordered_items) { + while ( + !empty($this->ordered_items[$index]) && ($this->items[$this->ordered_items[$index]]->get_type() == 'dir') && + $index < $this->max_ordered_items + ) { $index++; if ($index == $this->max_ordered_items) { if ($this->items[$this->ordered_items[$index]]->get_type() == 'dir') { @@ -2203,7 +2206,9 @@ class learnpath $index = $this->index; if (isset ($this->ordered_items[$index - 1])) { $index--; - while (isset($this->ordered_items[$index]) && ($this->items[$this->ordered_items[$index]]->get_type() == 'dir')) { + while (isset($this->ordered_items[$index]) && + ($this->items[$this->ordered_items[$index]]->get_type() == 'dir') + ) { $index--; if ($index < 0) { return $this->index; @@ -2538,10 +2543,12 @@ class learnpath { $text = $percentage.$text_add; $output = '
-
- '. $text.' -
-
'; +
+ '. $text.' +
+ '; return $output; } @@ -2563,7 +2570,7 @@ class learnpath * @param string $mode Mode of display (can be '%' or 'abs').abs means * we display a number of completed elements per total elements * @param integer $add Additional steps to fake as completed - * @return list array Percentage or number and symbol (% or /xx) + * @return array Percentage or number and symbol (% or /xx) */ public function get_progress_bar_text($mode = '', $add = 0) { @@ -3170,6 +3177,7 @@ class learnpath 'dir' ); } + /** * Uses the table generated by get_toc() and returns an HTML-formatted string ready to display * @return string HTML TOC ready to display @@ -3239,9 +3247,7 @@ class learnpath if (in_array($item['type'], $dirTypes)) { $list['css_level'] = 'level_'.$item['level']; } else { - $list['css_level'] = 'level_'.$item['level'] - .' scorm_type_' - .learnpath::format_scorm_type_item($item['type']); + $list['css_level'] = 'level_'.$item['level'].' scorm_type_'.learnpath::format_scorm_type_item($item['type']); } if (in_array($item['type'], $dirTypes)) { @@ -3512,8 +3518,7 @@ class learnpath // some contents use this form: resource.htm?resource=http://blablabla // which means we have to find a protocol at the path's start, otherwise // it should not be considered as an external URL. - - //if ($this->prerequisites_match($item_id)) { + // if ($this->prerequisites_match($item_id)) { if (preg_match('#^[a-zA-Z]{2,5}://#', $lp_item_path) != 0) { if ($this->debug > 2) { error_log('New LP - In learnpath::get_link() '.__LINE__.' - Found match for protocol in '.$lp_item_path, 0); @@ -4023,9 +4028,9 @@ class learnpath $max = $i; if ($row['display_order'] != $i) { // If we find a gap in the order, we need to fix it. - $sql_u = "UPDATE $lp_table SET display_order = $i + $sql = "UPDATE $lp_table SET display_order = $i WHERE c_id = ".$courseId." AND id = ".$row['id']; - Database::query($sql_u); + Database::query($sql); } $row['display_order'] = $i; $lps[$row['id']] = $row; @@ -4036,12 +4041,12 @@ class learnpath if ($num > 1) { // If there's only one element, no need to sort. $order = $lps[$lp_id]['display_order']; if ($order < $max) { // If it's the first element, no need to move up. - $sql_u1 = "UPDATE $lp_table SET display_order = $order - WHERE c_id = ".$courseId." AND id = ".$lp_order[$order + 1]; - Database::query($sql_u1); - $sql_u2 = "UPDATE $lp_table SET display_order = ".($order + 1)." - WHERE c_id = ".$courseId." AND id = ".$lp_id; - Database::query($sql_u2); + $sql = "UPDATE $lp_table SET display_order = $order + WHERE c_id = ".$courseId." AND id = ".$lp_order[$order + 1]; + Database::query($sql); + $sql = "UPDATE $lp_table SET display_order = ".($order + 1)." + WHERE c_id = ".$courseId." AND id = ".$lp_id; + Database::query($sql); } } @@ -4081,7 +4086,6 @@ class learnpath * Open a resource = initialise all local variables relative to this resource. Depending on the child * class, this might be redefined to allow several behaviours depending on the document type. * @param integer Resource ID - * @return boolean True on success, false otherwise */ public function open($id) { @@ -4386,8 +4390,7 @@ class learnpath $link = self::getCategoryLinkForTool($id); /** @var CTool $tool */ - $tool = $em - ->createQuery(" + $tool = $em->createQuery(" SELECT t FROM ChamiloCourseBundle:CTool t WHERE t.cId = :course AND @@ -4556,7 +4559,7 @@ class learnpath * Make sure the results are saved with anoter method. This method should probably be * redefined in children classes. * To use a similar method statically, use the create_new_attempt() method - * @return string URL to load in the viewer + * @return bool */ public function restart() { @@ -4633,9 +4636,9 @@ class learnpath /** * Saves the given item - * @param integer $item_id Optional (will take from $_REQUEST if null) - * @param boolean $from_outside Save from url params (true) or from current attributes (false). Optional. Defaults to true - * @return boolean + * @param integer $item_id Optional (will take from $_REQUEST if null) + * @param bool $from_outside Save from url params (true) or from current attributes (false). Default true + * @return bool */ public function save_item($item_id = null, $from_outside = true) { @@ -5138,7 +5141,7 @@ class learnpath /** * Sets use_max_score - * @param string $use_max_score Optional string giving the new location of this learnpath + * @param int $use_max_score Optional string giving the new location of this learnpath * @return boolean True on success / False on error */ public function set_use_max_score($use_max_score = 1) @@ -5601,7 +5604,6 @@ class learnpath /** * Switch between multiple attempt, single attempt or serious_game mode (only for scorm) * - * @return boolean * @author ndiechburg **/ public function switch_attempt_mode() @@ -7022,7 +7024,7 @@ class learnpath /** * Function that displays a list with al the resources that * could be added to the learning path - * @return string + * @return bool */ public function display_resources() { @@ -7455,11 +7457,13 @@ class learnpath for ($i = 0; $i < count($arrLP); $i++) { if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) { - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { + $selected = 'selected="selected" '; + } elseif ($action == 'add') { $selected = 'selected="selected" '; - elseif ($action == 'add') $selected = 'selected="selected" '; - else + } else { $selected = ''; + } $return .= ''; } @@ -7615,7 +7619,6 @@ class learnpath ['id' => 'idParent', 'onchange' => 'load_cbo(this.value);', 'class' => 'learnpath_item_form'] ); $selectParent->addOption($this->name, 0); - $arrHide = array( $id ); @@ -8192,7 +8195,7 @@ class learnpath $form->addElement('hidden', 'type', $item_type); $form->addElement('hidden', 'post_time', time()); $form->setDefaults($defaults); - return $form->return_form(); + return $form->returnForm(); } /** @@ -8546,7 +8549,6 @@ class learnpath // A new document, it is in the root of the repository. $relative_path = ''; $relative_prefix = ''; - if (is_array($extra_info) && $extra_info != 'new') { // The document already exists. Whe have to determine its relative path towards the repository root. $relative_path = explode('/', $extra_info['dir']); diff --git a/main/tracking/courseLog.php b/main/tracking/courseLog.php index dcfcb7ccf5..57afccb3a5 100755 --- a/main/tracking/courseLog.php +++ b/main/tracking/courseLog.php @@ -408,7 +408,7 @@ if (count($a_students) > 0) { $html .= $extra_field_select; } - $html .= $form->return_form(); + $html .= $form->returnForm(); if ($export_csv) { $csv_content = array(); diff --git a/main/webservices/soap.test.php b/main/webservices/soap.test.php index 64c16ce6d5..209d6fad3c 100755 --- a/main/webservices/soap.test.php +++ b/main/webservices/soap.test.php @@ -4,9 +4,7 @@ * @author Yannick Warnier * @package chamilo.webservices */ -/** - * Init - */ + exit; //remove to enable // Include the necessary files, assuming this script is located in main/lp/ or something like that require_once __DIR__.'/../inc/global.inc.php'; diff --git a/plugin/before_login/index.php b/plugin/before_login/index.php index b925bcecb8..83bca499bd 100755 --- a/plugin/before_login/index.php +++ b/plugin/before_login/index.php @@ -41,7 +41,7 @@ if (api_is_anonymous()) { $form->addElement('html', $option1); $form->addElement('checkbox', 'left', null, get_lang('Yes')); $form->addElement('button', 'submit', get_lang('Confirm'), array('class' => 'btn btn-primary')); - $formHtml = $form->return_form(); + $formHtml = $form->returnForm(); if ($form->validate()) { $result = $form->getSubmitValues(); if (isset($result['left']) && $result['left']) { @@ -62,7 +62,7 @@ if (api_is_anonymous()) { $form2->addElement('html', $option2); $form2->addElement('checkbox', 'right', null, get_lang('Yes')); $form2->addElement('button', 'submit', get_lang('Send')); - $formHtml2 = $form2->return_form(); + $formHtml2 = $form2->returnForm(); if ($form2->validate()) { $result = $form2->getSubmitValues(); diff --git a/plugin/sepe/src/sepe_plugin.class.php b/plugin/sepe/src/sepe_plugin.class.php index fdfe014955..a4a412f028 100644 --- a/plugin/sepe/src/sepe_plugin.class.php +++ b/plugin/sepe/src/sepe_plugin.class.php @@ -26,6 +26,7 @@ class SepePlugin extends Plugin const TABLE_SEPE_LOG = 'plugin_sepe_log'; public $isAdminPlugin = true; + /** * * @return StaticPlugin