Example #1
0
 /**
  * Builds the XHTML to display the control
  *
  * @param string $data Unused
  * @param string $query
  * @return string
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $OUTPUT;
     // display strings
     $txt = get_strings(array('administration', 'settings', 'edit', 'name', 'enable', 'disable', 'up', 'down', 'none'));
     $txt->updown = "{$txt->up}/{$txt->down}";
     $editors_available = get_available_editors();
     $active_editors = explode(',', $CFG->texteditors);
     $active_editors = array_reverse($active_editors);
     foreach ($active_editors as $key => $editor) {
         if (empty($editors_available[$editor])) {
             unset($active_editors[$key]);
         } else {
             $name = $editors_available[$editor];
             unset($editors_available[$editor]);
             $editors_available[$editor] = $name;
         }
     }
     if (empty($active_editors)) {
         //$active_editors = array('textarea');
     }
     $editors_available = array_reverse($editors_available, true);
     $return = $OUTPUT->heading(get_string('acteditorshhdr', 'editor'), 3, 'main', true);
     $return .= $OUTPUT->box_start('generalbox editorsui');
     $table = new html_table();
     $table->head = array($txt->name, $txt->enable, $txt->updown, $txt->settings);
     $table->align = array('left', 'center', 'center', 'center');
     $table->width = '90%';
     $table->data = array();
     // iterate through auth plugins and add to the display table
     $updowncount = 1;
     $editorcount = count($active_editors);
     $url = "editors.php?sesskey=" . sesskey();
     foreach ($editors_available as $editor => $name) {
         // hide/show link
         if (in_array($editor, $active_editors)) {
             $hideshow = "<a href=\"{$url}&amp;action=disable&amp;editor={$editor}\">";
             $hideshow .= "<img src=\"" . $OUTPUT->old_icon_url('i/hide') . "\" class=\"icon\" alt=\"disable\" /></a>";
             // $hideshow = "<a href=\"$url&amp;action=disable&amp;editor=$editor\"><input type=\"checkbox\" checked /></a>";
             $enabled = true;
             $displayname = "<span>{$name}</span>";
         } else {
             $hideshow = "<a href=\"{$url}&amp;action=enable&amp;editor={$editor}\">";
             $hideshow .= "<img src=\"" . $OUTPUT->old_icon_url('i/show') . "\" class=\"icon\" alt=\"enable\" /></a>";
             // $hideshow = "<a href=\"$url&amp;action=enable&amp;editor=$editor\"><input type=\"checkbox\" /></a>";
             $enabled = false;
             $displayname = "<span class=\"dimmed_text\">{$name}</span>";
         }
         // up/down link (only if auth is enabled)
         $updown = '';
         if ($enabled) {
             if ($updowncount > 1) {
                 $updown .= "<a href=\"{$url}&amp;action=up&amp;editor={$editor}\">";
                 $updown .= "<img src=\"" . $OUTPUT->old_icon_url('t/up') . "\" alt=\"up\" /></a>&nbsp;";
             } else {
                 $updown .= "<img src=\"" . $OUTPUT->old_icon_url('spacer.gif') . "\" class=\"icon\" alt=\"\" />&nbsp;";
             }
             if ($updowncount < $editorcount) {
                 $updown .= "<a href=\"{$url}&amp;action=down&amp;editor={$editor}\">";
                 $updown .= "<img src=\"" . $OUTPUT->old_icon_url('t/down') . "\" alt=\"down\" /></a>";
             } else {
                 $updown .= "<img src=\"" . $OUTPUT->old_icon_url('spacer.gif') . "\" class=\"icon\" alt=\"\" />";
             }
             ++$updowncount;
         }
         // settings link
         if (file_exists($CFG->dirroot . '/editor/' . $editor . '/settings.php')) {
             $settings = "<a href=\"settings.php?section=editorsetting{$editor}\">{$txt->settings}</a>";
         } else {
             $settings = '';
         }
         // add a row to the table
         $table->data[] = array($displayname, $hideshow, $updown, $settings);
     }
     $return .= $OUTPUT->table($table);
     $return .= get_string('configeditorplugins', 'editor') . '<br />' . get_string('tablenosave', 'filters');
     $return .= $OUTPUT->box_end();
     return highlight($query, $return);
 }
Example #2
0
<?php

/**
 * Allows admin to configure editors.
 */
require_once '../config.php';
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->libdir . '/tablelib.php';
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
$returnurl = "{$CFG->wwwroot}/{$CFG->admin}/settings.php?section=manageeditors";
$action = optional_param('action', '', PARAM_ACTION);
$editor = optional_param('editor', '', PARAM_SAFEDIR);
// get currently installed and enabled auth plugins
$available_editors = get_available_editors();
if (!empty($editor) and empty($available_editors[$editor])) {
    redirect($returnurl);
}
$active_editors = explode(',', $CFG->texteditors);
foreach ($active_editors as $key => $active) {
    if (empty($available_editors[$active])) {
        unset($active_editors[$key]);
    }
}
////////////////////////////////////////////////////////////////////////////////
// process actions
if (!confirm_sesskey()) {
    redirect($returnurl);
}
switch ($action) {
    case 'disable':