Esempio n. 1
0
 /**
  * Constructor
  *
  * @param string|moodle_url $pageurl
  */
 public function __construct($pageurl)
 {
     global $OUTPUT;
     parent::__construct();
     $this->attributes['class'] = 'generaltable tag-areas-table';
     $this->head = array(get_string('tagareaname', 'core_tag'), get_string('component', 'tag'), get_string('tagareaenabled', 'core_tag'), get_string('tagcollection', 'tag'), get_string('showstandard', 'tag') . $OUTPUT->help_icon('showstandard', 'tag'));
     $this->data = array();
     $this->rowclasses = array();
     $tagareas = core_tag_area::get_areas();
     $tagcollections = core_tag_collection::get_collections_menu(true);
     $tagcollectionsall = core_tag_collection::get_collections_menu();
     $standardchoices = array(core_tag_tag::BOTH_STANDARD_AND_NOT => get_string('standardsuggest', 'tag'), core_tag_tag::STANDARD_ONLY => get_string('standardforce', 'tag'), core_tag_tag::HIDE_STANDARD => get_string('standardhide', 'tag'));
     foreach ($tagareas as $itemtype => $it) {
         foreach ($it as $component => $record) {
             $areaname = core_tag_area::display_name($record->component, $record->itemtype);
             $tmpl = new \core_tag\output\tagareaenabled($record);
             $enabled = $OUTPUT->render_from_template('core/inplace_editable', $tmpl->export_for_template($OUTPUT));
             $tmpl = new \core_tag\output\tagareacollection($record);
             $collectionselect = $OUTPUT->render_from_template('core/inplace_editable', $tmpl->export_for_template($OUTPUT));
             $tmpl = new \core_tag\output\tagareashowstandard($record);
             $showstandardselect = $OUTPUT->render_from_template('core/inplace_editable', $tmpl->export_for_template($OUTPUT));
             $this->data[] = array($areaname, $record->component === 'core' || preg_match('/^core_/', $record->component) ? get_string('coresystem') : get_string('pluginname', $record->component), $enabled, $collectionselect, $showstandardselect);
             $this->rowclasses[] = $record->enabled ? '' : 'dimmed_text';
         }
     }
 }
Esempio n. 2
0
 /**
  * Constructor
  *
  * @param string|moodle_url $pageurl
  */
 public function __construct($pageurl)
 {
     global $OUTPUT;
     parent::__construct();
     $this->attributes['class'] = 'generaltable tag-areas-table';
     $this->head = array(get_string('tagareaname', 'core_tag'), get_string('component', 'tag'), get_string('tagareaenabled', 'core_tag'), get_string('tagcollection', 'tag'));
     $this->data = array();
     $this->rowclasses = array();
     $tagareas = core_tag_area::get_areas();
     $tagcollections = core_tag_collection::get_collections_menu(true);
     $tagcollectionsall = core_tag_collection::get_collections_menu();
     foreach ($tagareas as $itemtype => $it) {
         foreach ($it as $component => $record) {
             $areaname = core_tag_area::display_name($record->component, $record->itemtype);
             $baseurl = new moodle_url($pageurl, array('ta' => $record->id, 'sesskey' => sesskey()));
             if ($record->enabled) {
                 $enableurl = new moodle_url($baseurl, array('action' => 'areadisable'));
                 $enabled = html_writer::link($enableurl, $OUTPUT->pix_icon('i/hide', get_string('disable')));
             } else {
                 $enableurl = new moodle_url($baseurl, array('action' => 'areaenable'));
                 $enabled = html_writer::link($enableurl, $OUTPUT->pix_icon('i/show', get_string('enable')));
             }
             if ($record->enabled && empty($record->locked) && count($tagcollections) > 1) {
                 $changecollurl = new moodle_url($baseurl, array('action' => 'areasetcoll'));
                 $select = new single_select($changecollurl, 'areacollid', $tagcollections, $record->tagcollid, null);
                 $select->set_label(get_string('changetagcoll', 'core_tag', $areaname), array('class' => 'accesshide'));
                 $collectionselect = $OUTPUT->render($select);
             } else {
                 $collectionselect = $tagcollectionsall[$record->tagcollid];
             }
             $this->data[] = array($areaname, $record->component === 'core' || preg_match('/^core_/', $record->component) ? get_string('coresystem') : get_string('pluginname', $record->component), $enabled, $collectionselect);
             $this->rowclasses[] = $record->enabled ? '' : 'dimmed_text';
         }
     }
 }
Esempio n. 3
0
 /**
  * Updates the value in database and returns itself, called from inplace_editable callback
  *
  * @param int $itemid
  * @param mixed $newvalue
  * @return \self
  */
 public static function update($itemid, $newvalue)
 {
     global $DB;
     require_capability('moodle/tag:manage', \context_system::instance());
     $tagarea = $DB->get_record('tag_area', array('id' => $itemid), '*', MUST_EXIST);
     $newvalue = clean_param($newvalue, PARAM_INT);
     $tagcollections = \core_tag_collection::get_collections_menu(true);
     if (!array_key_exists($newvalue, $tagcollections)) {
         throw new \moodle_exception('invalidparameter', 'debug');
     }
     $data = array('tagcollid' => $newvalue);
     core_tag_area::update($tagarea, $data);
     $tagarea->tagcollid = $newvalue;
     $tmpl = new self($tagarea);
     return $tmpl;
 }
Esempio n. 4
0
 /**
  * Add the tag collection selector
  *
  * @param object $mform the form being built.
  */
 protected function add_collection_selector($mform)
 {
     $tagcolls = core_tag_collection::get_collections_menu(false, false, get_string('anycollection', 'block_tags'));
     if (count($tagcolls) <= 1) {
         return;
     }
     $tagcollssearchable = core_tag_collection::get_collections_menu(false, true);
     $hasunsearchable = false;
     foreach ($tagcolls as $id => $name) {
         if ($id && !array_key_exists($id, $tagcollssearchable)) {
             $hasunsearchable = true;
             $tagcolls[$id] = $name . '*';
         }
     }
     $mform->addElement('select', 'config_tagcoll', get_string('tagcollection', 'block_tags'), $tagcolls);
     if ($hasunsearchable) {
         $mform->addHelpButton('config_tagcoll', 'tagcollection', 'block_tags');
     }
     $mform->setDefault('config_tagcoll', 0);
 }
Esempio n. 5
0
 /**
  * Prints the tag search box
  *
  * @param string $query last search string
  * @param int $tagcollid last selected tag collection id
  * @return string
  */
 protected function search_form($query = '', $tagcollid = 0)
 {
     $searchurl = new moodle_url('/tag/search.php');
     $output = '<form action="' . $searchurl . '">';
     $output .= '<label class="accesshide" for="searchform_query">' . get_string('searchtags', 'tag') . '</label>';
     $output .= '<input id="searchform_query" name="query" type="text" size="40" value="' . s($query) . '" />';
     $tagcolls = core_tag_collection::get_collections_menu(false, true, get_string('inalltagcoll', 'tag'));
     if (count($tagcolls) > 1) {
         $output .= '<label class="accesshide" for="searchform_tc">' . get_string('selectcoll', 'tag') . '</label>';
         $output .= html_writer::select($tagcolls, 'tc', $tagcollid, null, array('id' => 'searchform_tc'));
     }
     $output .= '<input name="go" type="submit" size="40" value="' . s(get_string('search', 'tag')) . '" />';
     $output .= '</form>';
     return $output;
 }