Browse Source

Move output code to renderer

SABERES_37_STABLE
Johannes Burk 9 years ago
committed by test
parent
commit
39dc5a568c
  1. 55
      manage.php
  2. 89
      renderer.php

55
manage.php

@ -13,6 +13,7 @@
require_once ('../../config.php');
require_once($CFG->dirroot.'/enrol/apply/lib.php');
require_once($CFG->dirroot.'/enrol/apply/manage_table.php');
require_once($CFG->dirroot.'/enrol/apply/renderer.php');
$id = optional_param('id', null, PARAM_INT);
$userenrolments = optional_param_array('userenrolments', null, PARAM_INT);
@ -63,58 +64,8 @@ if ($userenrolments != null) {
redirect($manageurl);
}
echo $OUTPUT->header ();
echo $OUTPUT->heading ( get_string ( 'confirmusers', 'enrol_apply' ) );
echo get_string('confirmusers_desc', 'enrol_apply');
$table = new enrol_apply_manage_table($id);
$table->define_baseurl($manageurl);
$columns = array(
'checkboxcolumn',
'course',
'fullname', // Magic happens here: The column heading will automatically be set.
'email',
'applydate',
'applycomment');
$headers = array(
'',
get_string('course'),
'fullname', // Magic happens here: The column heading will automatically be set due to column name 'fullname'.
get_string('email'),
get_string('applydate', 'enrol_apply'),
get_string('comment', 'enrol_apply'));
$table->define_columns($columns);
$table->define_headers($headers);
$table->sortable(true, 'id');
echo html_writer::start_tag('form', array('id' => 'enrol_apply_manage_form', 'method' => 'post', 'action' => $manageurl->out()));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'id' => 'type', 'name' => 'type', 'value' => 'confirm'));
$table->out(50, true);
echo html_writer::start_tag('p', array('align' => 'center'));
echo html_writer::empty_tag('input', array(
'type' => 'button',
'onclick' => 'doSubmit("confirm");',
'value' => get_string('btnconfirm', 'enrol_apply')));
echo html_writer::empty_tag('input', array(
'type' => 'button',
'onclick' => 'doSubmit("wait");',
'value' => get_string('btnwait', 'enrol_apply')));
echo html_writer::empty_tag('input', array(
'type' => 'button',
'onclick' => 'doSubmit("cancel");',
'value' => get_string('btncancel', 'enrol_apply')));
echo html_writer::end_tag('p');
echo html_writer::end_tag('form');
$js = "
function doSubmit(type){
document.getElementById('type').value=type;
document.getElementById('enrol_apply_manage_form').submit();
}";
echo html_writer::tag('script', $js, array('type' => 'text/javascript'));
echo $OUTPUT->footer ();
$renderer = $PAGE->get_renderer('enrol_apply');
$renderer->manage_page($table, $manageurl);

89
renderer.php

@ -0,0 +1,89 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
*
* @package enrol_apply
* @copyright 2015 sudile GbR (http://www.sudile.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Johannes Burk <johannes.burk@sudile.com>
*/
defined('MOODLE_INTERNAL') || die();
class enrol_apply_renderer extends plugin_renderer_base {
public function manage_page($table, $manageurl) {
echo $this->header();
echo $this->heading(get_string('confirmusers', 'enrol_apply'));
echo get_string('confirmusers_desc', 'enrol_apply');
$this->manage_form($table, $manageurl);
echo $this->footer();
}
public function manage_form($table, $manageurl) {
echo html_writer::start_tag('form', array('id' => 'enrol_apply_manage_form', 'method' => 'post', 'action' => $manageurl->out()));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'id' => 'type', 'name' => 'type', 'value' => 'confirm'));
$this->manage_table($table);
echo html_writer::start_tag('p', array('align' => 'center'));
echo html_writer::empty_tag('input', array(
'type' => 'button',
'onclick' => 'doSubmit("confirm");',
'value' => get_string('btnconfirm', 'enrol_apply')));
echo html_writer::empty_tag('input', array(
'type' => 'button',
'onclick' => 'doSubmit("wait");',
'value' => get_string('btnwait', 'enrol_apply')));
echo html_writer::empty_tag('input', array(
'type' => 'button',
'onclick' => 'doSubmit("cancel");',
'value' => get_string('btncancel', 'enrol_apply')));
echo html_writer::end_tag('p');
echo html_writer::end_tag('form');
$js = "
function doSubmit(type){
document.getElementById('type').value=type;
document.getElementById('enrol_apply_manage_form').submit();
}";
echo html_writer::tag('script', $js, array('type' => 'text/javascript'));
}
public function manage_table($table) {
$columns = array(
'checkboxcolumn',
'course',
'fullname', // Magic happens here: The column heading will automatically be set.
'email',
'applydate',
'applycomment');
$headers = array(
'',
get_string('course'),
'fullname', // Magic happens here: The column heading will automatically be set due to column name 'fullname'.
get_string('email'),
get_string('applydate', 'enrol_apply'),
get_string('comment', 'enrol_apply'));
$table->define_columns($columns);
$table->define_headers($headers);
$table->sortable(true, 'id');
$table->out(50, true);
}
}
Loading…
Cancel
Save