瀏覽代碼

Minor - format code, rename function

- Rename "get_settings_form" to "getSettingsForm"
jmontoyaa 7 年之前
父節點
當前提交
3edf9eccc7
共有 2 個文件被更改,包括 16 次插入22 次删除
  1. 1 6
      main/admin/settings.lib.php
  2. 15 16
      main/inc/lib/plugin.class.php

+ 1 - 6
main/admin/settings.lib.php

@@ -40,7 +40,6 @@ function handleRegions()
     }
 
     $plugin_obj = new AppPlugin();
-    $possible_plugins  = $plugin_obj->read_plugins_from_path();
     $installed_plugins = $plugin_obj->get_installed_plugins();
 
     echo '<form name="plugins" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'">';
@@ -55,7 +54,6 @@ function handleRegions()
     echo '</tr>';
 
     /* We display all the possible plugins and the checkboxes */
-
     $plugin_region_list = array();
     $my_plugin_list = $plugin_obj->get_plugin_regions();
     foreach ($my_plugin_list as $plugin_item) {
@@ -81,9 +79,7 @@ function handleRegions()
             echo '<p>'.$plugin_info['comment'].'</p>';
             echo '</td><td>';
             $selected_plugins = $plugin_obj->get_areas_by_plugin($pluginName);
-
             $region_list = [];
-
             $isAdminPlugin = isset($plugin_info['is_admin_plugin']) && $plugin_info['is_admin_plugin'];
             $isCoursePlugin = isset($plugin_info['is_course_plugin']) && $plugin_info['is_course_plugin'];
 
@@ -97,6 +93,7 @@ function handleRegions()
                     $region_list['course_tool_plugin'] = 'course_tool_plugin';
                 }
             }
+
             echo Display::select(
                 'plugin_'.$pluginName.'[]',
                 $region_list,
@@ -660,10 +657,8 @@ function storeRegions()
 function storePlugins()
 {
     $appPlugin = new AppPlugin();
-
     // Get a list of all current 'Plugins' settings
     $plugin_list = $appPlugin->read_plugins_from_path();
-
     $installed_plugins = array();
 
     foreach ($plugin_list as $plugin) {

+ 15 - 16
main/inc/lib/plugin.class.php

@@ -47,7 +47,7 @@ class Plugin
     array('name' => 'big_blue_button_record_and_store', 'type' => 'checkbox')
     );
      */
-    public $course_settings = array();
+    public $course_settings = [];
     /**
      * This indicates whether changing the setting should execute the callback
      * function.
@@ -61,7 +61,7 @@ class Plugin
      * @param string $author    of this plugin
      * @param array  $settings  settings to be proposed to configure the plugin
      */
-    protected function __construct($version, $author, $settings = array())
+    protected function __construct($version, $author, $settings = [])
     {
         $this->version = $version;
         $this->author = $author;
@@ -77,7 +77,7 @@ class Plugin
      */
     public function get_info()
     {
-        $result = array();
+        $result = [];
         $result['obj'] = $this;
         $result['title'] = $this->get_title();
         $result['comment'] = $this->get_comment();
@@ -88,7 +88,7 @@ class Plugin
         $result['is_admin_plugin'] = $this->isAdminPlugin;
         $result['is_mail_plugin'] = $this->isMailPlugin;
 
-        if ($form = $this->get_settings_form()) {
+        if ($form = $this->getSettingsForm()) {
             $result['settings_form'] = $form;
 
             foreach ($this->fields as $name => $type) {
@@ -173,7 +173,7 @@ class Plugin
         if (!is_readable($path)) {
             return '';
         }
-        $css = array();
+        $css = [];
         $css[] = file_get_contents($path);
         $result = implode($css);
 
@@ -184,13 +184,13 @@ class Plugin
      * Returns an HTML form (generated by FormValidator) of the plugin settings
      * @return FormValidator FormValidator-generated form
      */
-    public function get_settings_form()
+    public function getSettingsForm()
     {
         $result = new FormValidator($this->get_name());
 
-        $defaults = array();
-        $checkboxGroup = array();
-        $checkboxCollection = array();
+        $defaults = [];
+        $checkboxGroup = [];
+        $checkboxCollection = [];
 
         if ($checkboxNames = array_keys($this->fields, 'checkbox')) {
             $pluginInfoCollection = api_get_settings('Plugins');
@@ -235,7 +235,7 @@ class Plugin
                     $result->addElement($type, $name, array($this->get_lang($name), $help));
                     break;
                 case 'boolean':
-                    $group = array();
+                    $group = [];
                     $group[] = $result->createElement(
                         'radio',
                         $name,
@@ -380,7 +380,7 @@ class Plugin
             $english_path = $root.$plugin_name."/lang/english.php";
 
             if (is_readable($english_path)) {
-                $strings = array();
+                $strings = [];
                 include $english_path;
                 $this->strings = $strings;
             }
@@ -644,7 +644,7 @@ class Plugin
      */
     public function getCourseSettings()
     {
-        $settings = array();
+        $settings = [];
         if (is_array($this->course_settings)) {
             foreach ($this->course_settings as $item) {
                 if (isset($item['group'])) {
@@ -666,7 +666,7 @@ class Plugin
      * @param array $values sent back from the course configuration script
      *
      */
-    public function course_settings_updated($values = array())
+    public function course_settings_updated($values = [])
     {
     }
 
@@ -755,9 +755,9 @@ class Plugin
      */
     public function deleteTab($key)
     {
-        $t = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
+        $table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
         $sql = "SELECT *
-                FROM $t
+                FROM $table
                 WHERE variable = 'show_tabs'
                 AND subkey <> '$key'
                 AND subkey like 'custom_tab_%'
@@ -786,7 +786,6 @@ class Plugin
                     }
 
                     $attributes = ['subkey' => $newSubKey];
-
                     $this->updateTab($row['subkey'], $attributes);
                     $i++;
                 }