Ejemplo n.º 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 = editors_get_available();
     $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->pix_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->pix_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->pix_url('t/up') . "\" alt=\"up\" /></a>&nbsp;";
             } else {
                 $updown .= "<img src=\"" . $OUTPUT->pix_url('spacer') . "\" class=\"icon\" alt=\"\" />&nbsp;";
             }
             if ($updowncount < $editorcount) {
                 $updown .= "<a href=\"{$url}&amp;action=down&amp;editor={$editor}\">";
                 $updown .= "<img src=\"" . $OUTPUT->pix_url('t/down') . "\" alt=\"down\" /></a>";
             } else {
                 $updown .= "<img src=\"" . $OUTPUT->pix_url('spacer') . "\" class=\"icon\" alt=\"\" />";
             }
             ++$updowncount;
         }
         // settings link
         if (file_exists($CFG->dirroot . '/lib/editor/' . $editor . '/settings.php')) {
             $eurl = new moodle_url('/admin/settings.php', array('section' => 'editorsettings' . $editor));
             $settings = "<a href='{$eurl}'>{$txt->settings}</a>";
         } else {
             $settings = '';
         }
         // add a row to the table
         $table->data[] = array($displayname, $hideshow, $updown, $settings);
     }
     $return .= html_writer::table($table);
     $return .= get_string('configeditorplugins', 'editor') . '<br />' . get_string('tablenosave', 'admin');
     $return .= $OUTPUT->box_end();
     return highlight($query, $return);
 }
Ejemplo n.º 2
0
/**
 * Allows admin to configure editors.
 */
require_once '../config.php';
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->libdir . '/tablelib.php';
$action = required_param('action', PARAM_ALPHANUMEXT);
$editor = required_param('editor', PARAM_PLUGIN);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$PAGE->set_url('/admin/editors.php', array('action' => $action, 'editor' => $editor));
$PAGE->set_context(context_system::instance());
require_login();
require_capability('moodle/site:config', context_system::instance());
$returnurl = "{$CFG->wwwroot}/{$CFG->admin}/settings.php?section=manageeditors";
// get currently installed and enabled auth plugins
$available_editors = editors_get_available();
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);
}
$return = true;
Ejemplo n.º 3
0
            $ADMIN->add('enrolments', $settings);
        }

    }
    unset($enabled);
    unset($enrols);


/// Editor plugins
    $ADMIN->add('modules', new admin_category('editorsettings', get_string('editors', 'editor')));
    $temp = new admin_settingpage('manageeditors', get_string('editorsettings', 'editor'));
    $temp->add(new admin_setting_manageeditors());
    $htmleditors = editors_get_available();
    $ADMIN->add('editorsettings', $temp);

    $editors_available = editors_get_available();
    foreach ($editors_available as $editor=>$editorstr) {
        if (file_exists($CFG->dirroot . '/lib/editor/'.$editor.'/settings.php')) {
            $settings = new admin_settingpage('editorsettings'.$editor, get_string('pluginname', 'editor_'.$editor), 'moodle/site:config');
            // settings.php may create a subcategory or unset the settings completely
            include($CFG->dirroot . '/lib/editor/'.$editor.'/settings.php');
            if ($settings) {
                $ADMIN->add('editorsettings', $settings);
            }
        }
    }

/// License types
    $ADMIN->add('modules', new admin_category('licensesettings', get_string('licenses')));
    $temp = new admin_settingpage('managelicenses', get_string('managelicenses', 'admin'));
Ejemplo n.º 4
0
 function action($action)
 {
     // Get currently installed and enabled auth plugins.
     $available_editors = editors_get_available();
     if (empty($available_editors[$this->plugin])) {
         return get_string('unavailableeditor');
     }
     $active_editors = explode(',', $CFG->texteditors);
     foreach ($active_editors as $key => $active) {
         if (empty($available_editors[$active])) {
             unset($active_editors[$key]);
         }
     }
     switch ($action) {
         case 'enable':
             // Add to enabled list.
             if (!in_array($this->plugin, $active_editors)) {
                 $active_editors[] = $this->plugin;
                 $active_editors = array_unique($active_editors);
             }
             break;
         case 'disable':
             // Remove from enabled list.
             $key = array_search($this->plugin, $active_editors);
             unset($active_editors[$key]);
             break;
     }
     return 0;
 }