public function definition() { global $CFG; $mform = $this->_form; // Don't forget the underscore! $tid = $this->_customdata['tid']; // this contains the data of this form $instanceid = $this->_customdata['instanceid']; // this contains the data of this form $componenttype = $this->_customdata['componenttype']; // this contains the data of this form $data = taxonomy_vocabulary_list(); //var_dump($data); foreach ($data as $vocabulary) { $terms = null; $terms[] = 'Faites votre choix'; $vocabularies[$vocabulary->id] = $vocabulary->name; // il nous faut la liste des termes pour ce vocabulaire $terms_list = taxonomy_term_list($vocabulary->id); // var_dump($terms_list); foreach ($terms_list as $term) { $terms[$term->id] = $term->name; } // var_dump($terms); $myselect = $mform->addElement('select', 'voc_id_' . $vocabulary->id, $vocabulary->name, $terms); $myselect->setMultiple(true); $mform->setType('voc_id_' . $vocabulary->id, PARAM_INT); // $mform->addRule('voc'.$vocabulary->id, get_string('error'), 'required'); //echo "ajout $vocabulary->id : $vocabulary->name"; } $this->add_action_buttons(); $mform->addElement('hidden', 'instanceid', $instanceid); $mform->setType('instanceid', PARAM_INT); $mform->addElement('hidden', 'componenttype', $componenttype); $mform->setType('componenttype', PARAM_INT); // Finally set the current form data //$this->set_data($id); }
$context = context_system::instance(); $PAGE->set_context($context); $PAGE->set_url('/local/taxonomy/viewterms.php'); $PAGE->set_pagelayout('standard'); $PAGE->navbar->add(get_string('navbartaxonomy', 'local_taxonomy'), new moodle_url('/local/taxonomy/index.php')); echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('termtitle', 'local_taxonomy')); $table = new html_table(); $table->head = array(); $table->head[] = 'ID'; $table->head[] = 'NAME'; $table->head[] = 'DESCRIPTION'; $table->head[] = 'WEIGHT'; $table->head[] = 'ACTIONS'; $table->size = array('5%', '35%', '40%', '5%', '10%'); $records = taxonomy_term_list($vid); if (!empty($records)) { foreach ($records as $key => $record) { $tid = $record->id; $actions = array(); $actions[] = html_writer::link(new moodle_url(sprintf('/local/taxonomy/forms/TermEditPage.php?id=%d', $tid)), get_string('modifyterm', 'local_taxonomy')); $actions[] = html_writer::link(new moodle_url(sprintf('/local/taxonomy/forms/TermDeletePage.php?id=%d', $tid)), get_string('deleteterm', 'local_taxonomy')); $table->data[] = array($tid, $record->name, $record->description, $record->weight, implode('<br/>', $actions)); } } else { $table->data[] = array('', get_string('term:notfound', 'local_taxonomy'), '', '', ''); } echo html_writer::table($table); $add_new_url = new moodle_url("/local/taxonomy/forms/TermEditPage.php?vid={$vid}"); echo html_writer::link($add_new_url, get_string('addnewterm', 'local_taxonomy')); echo $OUTPUT->footer();