Merge branch 'MDL-37564' of https://github.com/nebgor/moodle
authorDamyon Wiese <damyon@moodle.com>
Tue, 3 Sep 2013 06:49:42 +0000 (14:49 +0800)
committerDamyon Wiese <damyon@moodle.com>
Tue, 3 Sep 2013 06:49:42 +0000 (14:49 +0800)
1  2 
admin/renderer.php

diff --combined admin/renderer.php
@@@ -140,13 -140,12 +140,13 @@@ class core_admin_renderer extends plugi
      public function upgrade_confirm_page($strnewversion, $maturity) {
          $output = '';
  
 -        $continueurl = new moodle_url('index.php', array('confirmupgrade' => 1));
 -        $cancelurl = new moodle_url('index.php');
 +        $continueurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1));
 +        $continue = new single_button($continueurl, get_string('continue'), 'get');
 +        $cancelurl = new moodle_url('/admin/index.php');
  
          $output .= $this->header();
          $output .= $this->maturity_warning($maturity);
 -        $output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continueurl, $cancelurl);
 +        $output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continue, $cancelurl);
          $output .= $this->footer();
  
          return $output;
              $output .= $this->output->container(get_string('updatepluginconfirmexternal', 'core_plugin', $repotype), 'updatepluginconfirmexternal');
          }
  
 -        $widget = $deployer->make_execution_widget($data['updateinfo']);
 +        $widget = $deployer->make_execution_widget($data['updateinfo'], $data['returnurl']);
          $output .= $this->output->render($widget);
  
 -        $output .= $this->output->single_button($data['returnurl'], get_string('cancel', 'core'), 'get');
 +        $output .= $this->output->single_button($data['callerurl'], get_string('cancel', 'core'), 'get');
  
          $output .= $this->container_end();
          $output .= $this->footer();
          return $output;
      }
  
 +    /**
 +     * Display a page to confirm the plugin uninstallation.
 +     *
 +     * @param plugin_manager $pluginman
 +     * @param plugininfo_base $pluginfo
 +     * @param moodle_url $continueurl URL to continue after confirmation
 +     * @return string
 +     */
 +    public function plugin_uninstall_confirm_page(plugin_manager $pluginman, plugininfo_base $pluginfo, moodle_url $continueurl) {
 +        $output = '';
 +
 +        $pluginname = $pluginman->plugin_name($pluginfo->component);
 +
 +        $confirm = '<p>' . get_string('uninstallconfirm', 'core_plugin', array('name' => $pluginname)) . '</p>';
 +        if ($extraconfirm = $pluginfo->get_uninstall_extra_warning()) {
 +            $confirm .= $extraconfirm;
 +        }
 +
 +        $output .= $this->output->header();
 +        $output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
 +        $output .= $this->output->confirm($confirm, $continueurl, $this->page->url);
 +        $output .= $this->output->footer();
 +
 +        return $output;
 +    }
 +
 +    /**
 +     * Display a page with results of plugin uninstallation and offer removal of plugin files.
 +     *
 +     * @param plugin_manager $pluginman
 +     * @param plugininfo_base $pluginfo
 +     * @param progress_trace_buffer $progress
 +     * @param moodle_url $continueurl URL to continue to remove the plugin folder
 +     * @return string
 +     */
 +    public function plugin_uninstall_results_removable_page(plugin_manager $pluginman, plugininfo_base $pluginfo,
 +                                                            progress_trace_buffer $progress, moodle_url $continueurl) {
 +        $output = '';
 +
 +        $pluginname = $pluginman->plugin_name($pluginfo->component);
 +
 +        // Do not show navigation here, they must click one of the buttons.
 +        $this->page->set_pagelayout('maintenance');
 +        $this->page->set_cacheable(false);
 +
 +        $output .= $this->output->header();
 +        $output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
 +
 +        $output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
 +
 +        $confirm = $this->output->container(get_string('uninstalldeleteconfirm', 'core_plugin',
 +            array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'uninstalldeleteconfirm');
 +
 +        if ($repotype = $pluginman->plugin_external_source($pluginfo->component)) {
 +            $confirm .= $this->output->container(get_string('uninstalldeleteconfirmexternal', 'core_plugin', $repotype),
 +                'uninstalldeleteconfirmexternal');
 +        }
 +
 +        // After any uninstall we must execute full upgrade to finish the cleanup!
 +        $output .= $this->output->confirm($confirm, $continueurl, new moodle_url('/admin/index.php'));
 +        $output .= $this->output->footer();
 +
 +        return $output;
 +    }
 +
 +    /**
 +     * Display a page with results of plugin uninstallation and inform about the need to remove plugin files manually.
 +     *
 +     * @param plugin_manager $pluginman
 +     * @param plugininfo_base $pluginfo
 +     * @param progress_trace_buffer $progress
 +     * @return string
 +     */
 +    public function plugin_uninstall_results_page(plugin_manager $pluginman, plugininfo_base $pluginfo, progress_trace_buffer $progress) {
 +        $output = '';
 +
 +        $pluginname = $pluginfo->component;
 +
 +        $output .= $this->output->header();
 +        $output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
 +
 +        $output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
 +
 +        $output .= $this->output->box(get_string('uninstalldelete', 'core_plugin',
 +            array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'generalbox uninstalldelete');
 +        $output .= $this->output->continue_button(new moodle_url('/admin/index.php'));
 +        $output .= $this->output->footer();
 +
 +        return $output;
 +    }
 +
      /**
       * Display the plugin management page (admin/environment.php).
       * @param array $versions
          }
  
          $updateinfo .= $this->container_start('checkforupdates');
 -        $updateinfo .= $this->single_button(new moodle_url($this->page->url, array('fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin'));
 +        $fetchurl = new moodle_url('/admin/index.php', array('fetchupdates' => 1, 'sesskey' => sesskey(), 'cache' => 1));
 +        $updateinfo .= $this->single_button($fetchurl, get_string('checkforupdates', 'core_plugin'));
          if ($fetch) {
              $updateinfo .= $this->container(get_string('checkforupdateslast', 'core_plugin',
                  userdate($fetch, get_string('strftimedatetime', 'core_langconfig'))));
  
          if (!$registered) {
  
 -            $registerbutton = $this->single_button(new moodle_url('registration/register.php',
 +            $registerbutton = $this->single_button(new moodle_url('/admin/registration/register.php',
                      array('huburl' =>  HUB_MOODLEORGHUBURL, 'hubname' => 'Moodle.org')),
                      get_string('register', 'admin'));
  
                          continue;
                      }
  
 -                } else if ($isstandard and $statusisboring and $dependenciesok and empty($availableupdates)) {
 +                } else if ($statusisboring and $dependenciesok and empty($availableupdates)) {
                      // no change is going to happen to the plugin - display it only
                      // if the user wants to see the full list
                      if (empty($options['full'])) {
              } else {
                  $str = 'otherplugin';
              }
+             $componenturl = new moodle_url('https://moodle.org/plugins/view.php?plugin='.$component);
+             $componenturl = html_writer::tag('a', $component, array('href' => $componenturl->out()));
              $requires[] = html_writer::tag('li',
                      get_string($str, 'core_plugin',
-                             array('component' => $component, 'version' => $requiredversion)),
+                             array('component' => $componenturl, 'version' => $requiredversion)),
                      array('class' => $class));
          }
  
              get_string('actions', 'core_plugin'),
              get_string('notes','core_plugin'),
          );
 +        $table->headspan = array(1, 1, 1, 1, 2, 1);
          $table->colclasses = array(
 -            'pluginname', 'source', 'version', 'availability', 'actions', 'notes'
 +            'pluginname', 'source', 'version', 'availability', 'settings', 'uninstall', 'notes'
          );
  
          foreach ($plugininfo as $type => $plugins) {
  
              $header = new html_table_cell($pluginman->plugintype_name_plural($type));
              $header->header = true;
 -            $header->colspan = count($table->head);
 +            $header->colspan = array_sum($table->headspan);
              $header = new html_table_row(array($header));
              $header->attributes['class'] = 'plugintypeheader type-' . $type;
              $table->data[] = $header;
  
              if (empty($plugins)) {
                  $msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
 -                $msg->colspan = count($table->head);
 +                $msg->colspan = array_sum($table->headspan);
                  $row = new html_table_row(array($msg));
                  $row->attributes['class'] .= 'msg msg-noneinstalled';
                  $table->data[] = $row;
                  } else {
                      $icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'icon pluginicon noicon'));
                  }
 -                if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
 -                    $msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'notifyproblem'));
 -                    $row->attributes['class'] .= ' missingfromdisk';
 +                $status = $plugin->get_status();
 +                $row->attributes['class'] .= ' status-'.$status;
 +                if ($status === plugin_manager::PLUGIN_STATUS_MISSING) {
 +                    $msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'statusmsg'));
 +                } else if ($status === plugin_manager::PLUGIN_STATUS_NEW) {
 +                    $msg = html_writer::tag('span', get_string('status_new', 'core_plugin'), array('class' => 'statusmsg'));
                  } else {
                      $msg = '';
                  }
                      $availability = new html_table_cell(get_string('plugindisabled', 'core_plugin'));
                  }
  
 -                $actions = array();
 -
                  $settingsurl = $plugin->get_settings_url();
                  if (!is_null($settingsurl)) {
 -                    $actions[] = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
 +                    $settings = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
 +                } else {
 +                    $settings = '';
                  }
 +                $settings = new html_table_cell($settings);
  
 -                $uninstallurl = $plugin->get_uninstall_url();
 -                if (!is_null($uninstallurl)) {
 -                    $actions[] = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'), array('class' => 'uninstall'));
 +                if ($pluginman->can_uninstall_plugin($plugin->component)) {
 +                    $uninstallurl = $plugin->get_uninstall_url();
 +                    $uninstall = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'));
 +                } else {
 +                    $uninstall = '';
                  }
 -
 -                $actions = new html_table_cell(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $actions));
 +                $uninstall = new html_table_cell($uninstall);
  
                  $requriedby = $pluginman->other_plugins_that_require($plugin->component);
                  if ($requriedby) {
                  $notes = new html_table_cell($requiredby.$updateinfo);
  
                  $row->cells = array(
 -                    $pluginname, $source, $version, $availability, $actions, $notes
 +                    $pluginname, $source, $version, $availability, $settings, $uninstall, $notes
                  );
                  $table->data[] = $row;
              }
              get_string('report'),
              get_string('status'),
          );
 -        $servertable->align = array('center', 'center', 'left', 'center');
 -        $servertable->wrap  = array('nowrap', '', '', 'nowrap');
 -        $servertable->size  = array('10', 10, '100%', '10');
 -        $servertable->attributes['class'] = 'environmenttable generaltable';
 +        $servertable->colclasses = array('centeralign name', 'centeralign status', 'leftalign report', 'centeralign info');
 +        $servertable->attributes['class'] = 'admintable environmenttable generaltable';
 +        $servertable->id = 'serverstatus';
  
          $serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
  
              get_string('report'),
              get_string('status'),
          );
 -        $othertable->align = array('center', 'left', 'center');
 -        $othertable->wrap  = array('', '', 'nowrap');
 -        $othertable->size  = array(10, '100%', '10');
 -        $othertable->attributes['class'] = 'environmenttable generaltable';
 +        $othertable->colclasses = array('aligncenter info', 'alignleft report', 'aligncenter status');
 +        $othertable->attributes['class'] = 'admintable environmenttable generaltable';
 +        $othertable->id = 'otherserverstatus';
  
          $otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());