Beispiel #1
0
 $catname = get_string('repositories', 'repository');
 $managerepo = get_string('manage', 'repository');
 $url = $CFG->wwwroot . '/' . $CFG->admin . '/repository.php';
 $ADMIN->add('modules', new admin_category('repositorysettings', $catname));
 $temp = new admin_settingpage('managerepositories', $managerepo);
 $temp->add(new admin_setting_heading('managerepositories', get_string('activerepository', 'repository'), ''));
 $temp->add(new admin_setting_managerepository());
 $temp->add(new admin_setting_heading('managerepositoriescommonheading', get_string('commonsettings', 'admin'), ''));
 $temp->add(new admin_setting_configtext('repositorycacheexpire', get_string('cacheexpire', 'repository'), get_string('configcacheexpire', 'repository'), 120));
 $ADMIN->add('repositorysettings', $temp);
 $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew', get_string('addplugin', 'repository'), $url, 'moodle/site:config', true), '', $url);
 $ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete', get_string('deleterepository', 'repository'), $url, 'moodle/site:config', true), '', $url);
 $ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller', get_string('managerepositories', 'repository'), $url, 'moodle/site:config', true), '', $url);
 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew', get_string('createrepository', 'repository'), $url, 'moodle/site:config', true), '', $url);
 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit', get_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true), '', $url);
 foreach (repository::get_types() as $repositorytype) {
     //display setup page for plugins with: general options or multiple instances (e.g. has instance config)
     $typeoptionnames = repository::static_function($repositorytype->get_typename(), 'get_type_option_names');
     $instanceoptionnames = repository::static_function($repositorytype->get_typename(), 'get_instance_option_names');
     if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
         $ADMIN->add('repositorysettings', new admin_externalpage('repositorysettings' . $repositorytype->get_typename(), $repositorytype->get_readablename(), $url . '?edit=' . $repositorytype->get_typename()), 'moodle/site:config');
     }
 }
 // Question type settings.
 $ADMIN->add('modules', new admin_category('qtypesettings', get_string('questiontypes', 'admin')));
 $ADMIN->add('qtypesettings', new admin_page_manageqtypes());
 require_once $CFG->libdir . '/questionlib.php';
 global $QTYPES;
 foreach ($QTYPES as $qtype) {
     $settingsfile = $qtype->plugin_dir() . '/settings.php';
     if (file_exists($settingsfile)) {
Beispiel #2
0
 /**
  * Builds XHTML to display the control
  *
  * @param string $data Unused
  * @param string $query
  * @return string XHTML
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $USER, $OUTPUT;
     // Get strings that are used
     $strshow = get_string('on', 'repository');
     $strhide = get_string('off', 'repository');
     $strdelete = get_string('disabled', 'repository');
     $actionchoicesforexisting = array('show' => $strshow, 'hide' => $strhide, 'delete' => $strdelete);
     $actionchoicesfornew = array('newon' => $strshow, 'newoff' => $strhide, 'delete' => $strdelete);
     $return = '';
     $return .= $OUTPUT->box_start('generalbox');
     // Set strings that are used multiple times
     $settingsstr = get_string('settings');
     $disablestr = get_string('disable');
     // Table to list plug-ins
     $table = new html_table();
     $table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr);
     $table->align = array('left', 'center', 'center', 'center', 'center');
     $table->data = array();
     // Get list of used plug-ins
     $instances = repository::get_types();
     if (!empty($instances)) {
         // Array to store plugins being used
         $alreadyplugins = array();
         $totalinstances = count($instances);
         $updowncount = 1;
         foreach ($instances as $i) {
             $settings = '';
             $typename = $i->get_typename();
             // Display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)
             $typeoptionnames = repository::static_function($typename, 'get_type_option_names');
             $instanceoptionnames = repository::static_function($typename, 'get_instance_option_names');
             if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
                 // Calculate number of instances in order to display them for the Moodle administrator
                 if (!empty($instanceoptionnames)) {
                     $params = array();
                     $params['context'] = array(get_system_context());
                     $params['onlyvisible'] = false;
                     $params['type'] = $typename;
                     $admininstancenumber = count(repository::static_function($typename, 'get_instances', $params));
                     // site instances
                     $admininstancenumbertext = get_string('instancesforsite', 'repository', $admininstancenumber);
                     $params['context'] = array();
                     $instances = repository::static_function($typename, 'get_instances', $params);
                     $courseinstances = array();
                     $userinstances = array();
                     foreach ($instances as $instance) {
                         if ($instance->context->contextlevel == CONTEXT_COURSE) {
                             $courseinstances[] = $instance;
                         } else {
                             if ($instance->context->contextlevel == CONTEXT_USER) {
                                 $userinstances[] = $instance;
                             }
                         }
                     }
                     // course instances
                     $instancenumber = count($courseinstances);
                     $courseinstancenumbertext = get_string('instancesforcourses', 'repository', $instancenumber);
                     // user private instances
                     $instancenumber = count($userinstances);
                     $userinstancenumbertext = get_string('instancesforusers', 'repository', $instancenumber);
                 } else {
                     $admininstancenumbertext = "";
                     $courseinstancenumbertext = "";
                     $userinstancenumbertext = "";
                 }
                 $settings .= '<a href="' . $this->baseurl . '&amp;action=edit&amp;repos=' . $typename . '">' . $settingsstr . '</a>';
                 $settings .= $OUTPUT->container_start('mdl-left');
                 $settings .= '<br/>';
                 $settings .= $admininstancenumbertext;
                 $settings .= '<br/>';
                 $settings .= $courseinstancenumbertext;
                 $settings .= '<br/>';
                 $settings .= $userinstancenumbertext;
                 $settings .= $OUTPUT->container_end();
             }
             // Get the current visibility
             if ($i->get_visible()) {
                 $currentaction = 'show';
             } else {
                 $currentaction = 'hide';
             }
             $select = new single_select($this->repository_action_url($typename, 'repos'), 'action', $actionchoicesforexisting, $currentaction, null, 'applyto' . basename($typename));
             // Display up/down link
             $updown = '';
             $spacer = $OUTPUT->spacer(array('height' => 15, 'width' => 15));
             // should be done with CSS instead
             if ($updowncount > 1) {
                 $updown .= "<a href=\"{$this->baseurl}&amp;action=moveup&amp;repos=" . $typename . "\">";
                 $updown .= "<img src=\"" . $OUTPUT->pix_url('t/up') . "\" alt=\"up\" /></a>&nbsp;";
             } else {
                 $updown .= $spacer;
             }
             if ($updowncount < $totalinstances) {
                 $updown .= "<a href=\"{$this->baseurl}&amp;action=movedown&amp;repos=" . $typename . "\">";
                 $updown .= "<img src=\"" . $OUTPUT->pix_url('t/down') . "\" alt=\"down\" /></a>";
             } else {
                 $updown .= $spacer;
             }
             $updowncount++;
             $table->data[] = array($i->get_readablename(), $OUTPUT->render($select), $updown, $settings);
             if (!in_array($typename, $alreadyplugins)) {
                 $alreadyplugins[] = $typename;
             }
         }
     }
     // Get all the plugins that exist on disk
     $plugins = get_plugin_list('repository');
     if (!empty($plugins)) {
         foreach ($plugins as $plugin => $dir) {
             // Check that it has not already been listed
             if (!in_array($plugin, $alreadyplugins)) {
                 $select = new single_select($this->repository_action_url($plugin, 'repos'), 'action', $actionchoicesfornew, 'delete', null, 'applyto' . basename($plugin));
                 $table->data[] = array(get_string('pluginname', 'repository_' . $plugin), $OUTPUT->render($select), '', '');
             }
         }
     }
     $return .= html_writer::table($table);
     $return .= $OUTPUT->box_end();
     return highlight($query, $return);
 }
Beispiel #3
0
 /**
  * Return all types that you a user can create/edit and which are also visible
  * Note: Mostly used in order to know if at least one editable type can be set
  *
  * @static
  * @param stdClass $context the context for which we want the editable types
  * @return array types
  */
 public static function get_editable_types($context = null)
 {
     if (empty($context)) {
         $context = context_system::instance();
     }
     $types = repository::get_types(true);
     $editabletypes = array();
     foreach ($types as $type) {
         $instanceoptionnames = repository::static_function($type->get_typename(), 'get_instance_option_names');
         if (!empty($instanceoptionnames)) {
             if ($type->get_contextvisibility($context)) {
                 $editabletypes[] = $type;
             }
         }
     }
     return $editabletypes;
 }
Beispiel #4
0
 $strhide = get_string('off', 'repository');
 $strdelete = get_string('disabled', 'repository');
 $actionchoicesforexisting = array('show' => $strshow, 'hide' => $strhide, 'delete' => $strdelete);
 $actionchoicesfornew = array('newon' => $strshow, 'newoff' => $strhide, 'delete' => $strdelete);
 $output = '';
 $output .= $OUTPUT->box_start('generalbox');
 // Set strings that are used multiple times
 $settingsstr = get_string('settings');
 $disablestr = get_string('disable');
 // Table to list plug-ins
 $table = new html_table();
 $table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr);
 $table->align = array('left', 'center', 'center', 'center', 'center');
 $table->data = array();
 // Get list of used plug-ins
 $instances = repository::get_types();
 if (!empty($instances)) {
     // Array to store plugins being used
     $alreadyplugins = array();
     $totalinstances = count($instances);
     $updowncount = 1;
     foreach ($instances as $i) {
         $settings = '';
         $typename = $i->get_typename();
         // Display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)
         $typeoptionnames = repository::static_function($typename, 'get_type_option_names');
         $instanceoptionnames = repository::static_function($typename, 'get_instance_option_names');
         if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
             // Calculate number of instances in order to display them for the Moodle administrator
             if (!empty($instanceoptionnames)) {
                 $params = array();
Beispiel #5
0
 /**
  * Builds XHTML to display the control
  *
  * @param string $data Unused
  * @param string $query
  * @return string XHTML
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $USER, $OUTPUT;
     $output = $OUTPUT->box_start('generalbox');
     $namestr = get_string('name');
     $settingsstr = get_string('settings');
     $updownstr = get_string('updown', 'repository');
     $hiddenstr = get_string('hiddenshow', 'repository');
     $deletestr = get_string('delete');
     $plugins = get_plugin_list('repository');
     $instances = repository::get_types();
     $instancesnumber = count($instances);
     $alreadyplugins = array();
     $table = new html_table();
     $table->head = array($namestr, $updownstr, $hiddenstr, $deletestr, $settingsstr);
     $table->align = array('left', 'center', 'center', 'center', 'center');
     $table->data = array();
     $updowncount = 1;
     foreach ($instances as $i) {
         $settings = '';
         //display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)
         $typeoptionnames = repository::static_function($i->get_typename(), 'get_type_option_names');
         $instanceoptionnames = repository::static_function($i->get_typename(), 'get_instance_option_names');
         if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
             //calculate number of instances in order to display them for the Moodle administrator
             if (!empty($instanceoptionnames)) {
                 $admininstancenumber = count(repository::static_function($i->get_typename(), 'get_instances', array(get_context_instance(CONTEXT_SYSTEM)), null, false, $i->get_typename()));
                 $admininstancenumbertext = " <br/> " . $admininstancenumber . " " . get_string('instancesforadmin', 'repository');
                 $instancenumber = count(repository::static_function($i->get_typename(), 'get_instances', array(), null, false, $i->get_typename())) - $admininstancenumber;
                 $instancenumbertext = "<br/>" . $instancenumber . " " . get_string('instancesforothers', 'repository');
             } else {
                 $admininstancenumbertext = "";
                 $instancenumbertext = "";
             }
             $settings .= '<a href="' . $this->baseurl . '&amp;edit=' . $i->get_typename() . '">' . $settingsstr . '</a>' . $admininstancenumbertext . $instancenumbertext . "\n";
         }
         $delete = '<a href="' . $this->baseurl . '&amp;delete=' . $i->get_typename() . '">' . $deletestr . '</a>' . "\n";
         $hidetitle = $i->get_visible() ? get_string('clicktohide', 'repository') : get_string('clicktoshow', 'repository');
         $hiddenshow = ' <a href="' . $this->baseurl . '&amp;hide=' . $i->get_typename() . '">' . '<img src="' . $OUTPUT->old_icon_url('i/' . ($i->get_visible() ? 'hide' : 'show')) . '"' . ' alt="' . $hidetitle . '" ' . ' title="' . $hidetitle . '" />' . '</a>' . "\n";
         // display up/down link
         $updown = '';
         if ($updowncount > 1) {
             $updown .= "<a href=\"{$this->baseurl}&amp;move=up&amp;type=" . $i->get_typename() . "\">";
             $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 < count($instances)) {
             $updown .= "<a href=\"{$this->baseurl}&amp;move=down&amp;type=" . $i->get_typename() . "\">";
             $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++;
         $table->data[] = array($i->get_readablename(), $updown, $hiddenshow, $delete, $settings);
         //display a grey row if the type is defined as not visible
         if (!$i->get_visible()) {
             $table->rowclasses[] = 'dimmed_text';
         } else {
             $table->rowclasses[] = '';
         }
         if (!in_array($i->get_typename(), $alreadyplugins)) {
             $alreadyplugins[] = $i->get_typename();
         }
     }
     $output .= $OUTPUT->table($table);
     $instancehtml = '<div><h3>';
     $instancehtml .= get_string('addplugin', 'repository');
     $instancehtml .= '</h3><ul>';
     $addable = 0;
     foreach ($plugins as $p => $dir) {
         if (!in_array($p, $alreadyplugins)) {
             $instancehtml .= '<li><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/repository.php?sesskey=' . sesskey() . '&amp;new=' . $p . '">' . get_string('add', 'repository') . ' "' . get_string('repositoryname', 'repository_' . $p) . '" ' . '</a></li>';
             $addable++;
         }
     }
     $instancehtml .= '</ul>';
     $instancehtml .= '</div>';
     if ($addable) {
         $output .= $instancehtml;
     }
     $output .= $OUTPUT->box_end();
     return highlight($query, $output);
 }
Beispiel #6
0
 $actionchoicesforexisting = array('show' => $strshow, 'hide' => $strhide, 'delete' => $strdelete);
 $actionchoicesfornew = array('newon' => $strshow, 'newoff' => $strhide, 'delete' => $strdelete);
 $output = '';
 $output .= $OUTPUT->box_start('generalbox');
 // Set strings that are used multiple times
 $settingsstr = get_string('settings');
 $disablestr = get_string('disable');
 // Table to list plug-ins
 $table = new html_table();
 $table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr);
 $table->colclasses = array('leftalign', 'centeralign', 'centeralign', 'centeralign', 'centeralign');
 $table->id = 'repositoriessetting';
 $table->data = array();
 $table->attributes['class'] = 'admintable generaltable';
 // Get list of used plug-ins
 $repositorytypes = repository::get_types();
 // Array to store plugins being used
 $alreadyplugins = array();
 if (!empty($repositorytypes)) {
     $totalrepositorytypes = count($repositorytypes);
     $updowncount = 1;
     foreach ($repositorytypes as $i) {
         $settings = '';
         $typename = $i->get_typename();
         // Display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)
         $typeoptionnames = repository::static_function($typename, 'get_type_option_names');
         $instanceoptionnames = repository::static_function($typename, 'get_instance_option_names');
         if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
             // Calculate number of instances in order to display them for the Moodle administrator
             if (!empty($instanceoptionnames)) {
                 $params = array();