コード例 #1
0
 /**
  * Prints an overview about the plugins - number of installed, number of extensions etc.
  *
  * @param core_plugin_manager $pluginman provides information about the plugins
  * @param array $options filtering options
  * @return string as usually
  */
 public function plugins_overview_panel(core_plugin_manager $pluginman, array $options = array())
 {
     $plugininfo = $pluginman->get_plugins();
     $numtotal = $numextension = $numupdatable = 0;
     foreach ($plugininfo as $type => $plugins) {
         foreach ($plugins as $name => $plugin) {
             if ($plugin->available_updates()) {
                 $numupdatable++;
             }
             if ($plugin->get_status() === core_plugin_manager::PLUGIN_STATUS_MISSING) {
                 continue;
             }
             $numtotal++;
             if (!$plugin->is_standard()) {
                 $numextension++;
             }
         }
     }
     $infoall = html_writer::link(new moodle_url($this->page->url, array('contribonly' => 0, 'updatesonly' => 0)), get_string('overviewall', 'core_plugin'), array('title' => get_string('filterall', 'core_plugin'))) . ' ' . html_writer::span($numtotal, 'badge number number-all');
     $infoext = html_writer::link(new moodle_url($this->page->url, array('contribonly' => 1, 'updatesonly' => 0)), get_string('overviewext', 'core_plugin'), array('title' => get_string('filtercontribonly', 'core_plugin'))) . ' ' . html_writer::span($numextension, 'badge number number-additional');
     if ($numupdatable) {
         $infoupdatable = html_writer::link(new moodle_url($this->page->url, array('contribonly' => 0, 'updatesonly' => 1)), get_string('overviewupdatable', 'core_plugin'), array('title' => get_string('filterupdatesonly', 'core_plugin'))) . ' ' . html_writer::span($numupdatable, 'badge badge-info number number-updatable');
     } else {
         // No updates, or the notifications disabled.
         $infoupdatable = '';
     }
     $out = html_writer::start_div('', array('id' => 'plugins-overview-panel'));
     if (!empty($options['updatesonly'])) {
         $out .= $this->output->heading(get_string('overviewupdatable', 'core_plugin'), 3);
     } else {
         if (!empty($options['contribonly'])) {
             $out .= $this->output->heading(get_string('overviewext', 'core_plugin'), 3);
         }
     }
     if ($numupdatable) {
         $installableupdates = $pluginman->filter_installable($pluginman->available_updates());
         if ($installableupdates) {
             $out .= $this->output->single_button(new moodle_url($this->page->url, array('installupdatex' => 1)), get_string('updateavailableinstallall', 'core_admin', count($installableupdates)), 'post', array('class' => 'singlebutton updateavailableinstallall'));
         }
     }
     $out .= html_writer::div($infoall, 'info info-all') . html_writer::div($infoext, 'info info-ext') . html_writer::div($infoupdatable, 'info info-updatable');
     $out .= html_writer::end_div();
     // End of #plugins-overview-panel block.
     return $out;
 }