MDL-42512 finally fix the indentation of filter management page
authorPetr Škoda <commits@skodak.org>
Mon, 4 Nov 2013 07:28:51 +0000 (08:28 +0100)
committerPetr Škoda <commits@skodak.org>
Mon, 4 Nov 2013 07:28:51 +0000 (08:28 +0100)
admin/filters.php

index df345df..6313d08 100644 (file)
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-    require_once(dirname(__FILE__) . '/../config.php');
-    require_once($CFG->libdir . '/adminlib.php');
-
-    $action = optional_param('action', '', PARAM_ALPHA);
-    $filterpath = optional_param('filterpath', '', PARAM_PLUGIN);
-
-    require_login();
-    $systemcontext = context_system::instance();
-    require_capability('moodle/site:config', $systemcontext);
-
-    admin_externalpage_setup('managefilters');
-
-    // Clean up bogus filter states first.
-    $plugininfos = core_plugin_manager::instance()->get_plugins_of_type('filter');
-    $filters = array();
-    $states = filter_get_global_states();
-    foreach ($states as $state) {
-        if (!isset($plugininfos[$state->filter]) and !get_config('filter_'.$state->filter, 'version')) {
-            // Purge messy leftovers after incorrectly uninstalled plugins and unfinished installs.
-            $DB->delete_records('filter_active', array('filter' => $state->filter));
-            $DB->delete_records('filter_config', array('filter' => $state->filter));
-            error_log('Deleted bogus "filter_'.$state->filter.'" states and config data.');
-        } else {
-            $filters[$state->filter] = $state;
-        }
+require_once(dirname(__FILE__) . '/../config.php');
+require_once($CFG->libdir . '/adminlib.php');
+
+$action = optional_param('action', '', PARAM_ALPHA);
+$filterpath = optional_param('filterpath', '', PARAM_PLUGIN);
+
+require_login();
+$systemcontext = context_system::instance();
+require_capability('moodle/site:config', $systemcontext);
+
+admin_externalpage_setup('managefilters');
+
+// Clean up bogus filter states first.
+$plugininfos = core_plugin_manager::instance()->get_plugins_of_type('filter');
+$filters = array();
+$states = filter_get_global_states();
+foreach ($states as $state) {
+    if (!isset($plugininfos[$state->filter]) and !get_config('filter_'.$state->filter, 'version')) {
+        // Purge messy leftovers after incorrectly uninstalled plugins and unfinished installs.
+        $DB->delete_records('filter_active', array('filter' => $state->filter));
+        $DB->delete_records('filter_config', array('filter' => $state->filter));
+        error_log('Deleted bogus "filter_'.$state->filter.'" states and config data.');
+    } else {
+        $filters[$state->filter] = $state;
     }
+}
 
-    // Add properly installed and upgraded filters to the global states table.
-    foreach ($plugininfos as $filter => $info) {
-        if (isset($filters[$filter])) {
-            continue;
-        }
-        /** @var \core\plugininfo\base $info */
-        if ($info->is_installed_and_upgraded()) {
-            filter_set_global_state($filter, TEXTFILTER_DISABLED);
-            $states = filter_get_global_states();
-            foreach ($states as $state) {
-                if ($state->filter === $filter) {
-                    $filters[$filter] = $state;
-                    break;
-                }
+// Add properly installed and upgraded filters to the global states table.
+foreach ($plugininfos as $filter => $info) {
+    if (isset($filters[$filter])) {
+        continue;
+    }
+    /** @var \core\plugininfo\base $info */
+    if ($info->is_installed_and_upgraded()) {
+        filter_set_global_state($filter, TEXTFILTER_DISABLED);
+        $states = filter_get_global_states();
+        foreach ($states as $state) {
+            if ($state->filter === $filter) {
+                $filters[$filter] = $state;
+                break;
             }
         }
     }
+}
 
-    if ($action) {
-        require_sesskey();
-    }
+if ($action) {
+    require_sesskey();
+}
 
-    // Process actions.
-    switch ($action) {
+// Process actions.
+switch ($action) {
 
     case 'setstate':
         if (isset($filters[$filterpath]) and $newstate = optional_param('newstate', '', PARAM_INT)) {
             filter_set_global_state($filterpath, $filters[$filterpath]->active, -1);
         }
         break;
-    }
+}
 
-    // Reset caches and return.
-    if ($action) {
-        reset_text_filters_cache();
-        core_plugin_manager::reset_caches();
-        redirect(new moodle_url('/admin/filters.php'));
-    }
+// Reset caches and return.
+if ($action) {
+    reset_text_filters_cache();
+    core_plugin_manager::reset_caches();
+    redirect(new moodle_url('/admin/filters.php'));
+}
 
-    // Print the page heading.
-    echo $OUTPUT->header();
-    echo $OUTPUT->heading(get_string('filtersettings', 'admin'));
-
-    $states = filter_get_global_states();
-    $stringfilters = filter_get_string_filters();
-
-    $table = new html_table();
-    $table->head  = array(get_string('filter'), get_string('isactive', 'filters'),
-            get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('uninstallplugin', 'core_admin'));
-    $table->colclasses = array ('leftalign', 'leftalign', 'centeralign', 'leftalign', 'leftalign', 'leftalign');
-    $table->attributes['class'] = 'admintable generaltable';
-    $table->id = 'filterssetting';
-    $table->data  = array();
-
-    $lastactive = null;
-    foreach ($states as $state) {
-        if ($state->active != TEXTFILTER_DISABLED) {
-            $lastactive = $state->filter;
-        }
+// Print the page heading.
+echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('filtersettings', 'admin'));
+
+$states = filter_get_global_states();
+$stringfilters = filter_get_string_filters();
+
+$table = new html_table();
+$table->head  = array(get_string('filter'), get_string('isactive', 'filters'),
+        get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('uninstallplugin', 'core_admin'));
+$table->colclasses = array ('leftalign', 'leftalign', 'centeralign', 'leftalign', 'leftalign', 'leftalign');
+$table->attributes['class'] = 'admintable generaltable';
+$table->id = 'filterssetting';
+$table->data  = array();
+
+$lastactive = null;
+foreach ($states as $state) {
+    if ($state->active != TEXTFILTER_DISABLED) {
+        $lastactive = $state->filter;
     }
+}
 
-    // Iterate through filters adding to display table.
-    $firstrow = true;
-    foreach ($states as $state) {
-        $filter = $state->filter;
-        if (!isset($plugininfos[$filter])) {
-            continue;
-        }
-        $plugininfo = $plugininfos[$filter];
-        $applytostrings = isset($stringfilters[$filter]) && $state->active != TEXTFILTER_DISABLED;
-        $row = get_table_row($plugininfo, $state, $firstrow, $filter == $lastactive, $applytostrings);
-        $table->data[] = $row;
-        if ($state->active == TEXTFILTER_DISABLED) {
-            $table->rowclasses[] = 'dimmed_text';
-        } else {
-            $table->rowclasses[] = '';
-        }
-        $firstrow = false;
+// Iterate through filters adding to display table.
+$firstrow = true;
+foreach ($states as $state) {
+    $filter = $state->filter;
+    if (!isset($plugininfos[$filter])) {
+        continue;
+    }
+    $plugininfo = $plugininfos[$filter];
+    $applytostrings = isset($stringfilters[$filter]) && $state->active != TEXTFILTER_DISABLED;
+    $row = get_table_row($plugininfo, $state, $firstrow, $filter == $lastactive, $applytostrings);
+    $table->data[] = $row;
+    if ($state->active == TEXTFILTER_DISABLED) {
+        $table->rowclasses[] = 'dimmed_text';
+    } else {
+        $table->rowclasses[] = '';
     }
+    $firstrow = false;
+}
 
-    echo html_writer::table($table);
-    echo '<p class="filtersettingnote">' . get_string('filterallwarning', 'filters') . '</p>';
-    echo $OUTPUT->footer();
+echo html_writer::table($table);
+echo '<p class="filtersettingnote">' . get_string('filterallwarning', 'filters') . '</p>';
+echo $OUTPUT->footer();
+die;
 
 
+/**
+ * Return action URL.
+ *
+ * @param string $filterpath
+ * @param string $action
+ * @return moodle_url
+ */
 function filters_action_url($filterpath, $action) {
     if ($action === 'delete') {
         return core_plugin_manager::instance()->get_uninstall_url('filter_'.$filterpath, 'manage');
@@ -164,6 +172,16 @@ function filters_action_url($filterpath, $action) {
     return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action));
 }
 
+/**
+ * Construct table record.
+ *
+ * @param \core\plugininfo\filter $plugininfo
+ * @param stdClass $state
+ * @param bool $isfirstrow
+ * @param bool $islastactive
+ * @param bool $applytostrings
+ * @return array data
+ */
 function get_table_row(\core\plugininfo\filter $plugininfo, $state, $isfirstrow, $islastactive, $applytostrings) {
     global $OUTPUT;
     $row = array();