$this->perpage = 10;
$count = $DB->count_records_sql('SELECT COUNT(*) FROM {comments} c');
$comments = $this->get_comments($page);
- $table = new stdclass;
+ $table = new html_table();
$table->head = array ('<input type="checkbox" id="comment_select_all"/>', 'author', 'content', 'action');
$table->align = array ('left', 'left', 'left', 'left');
$table->width = "95%";
}
$table->data[] = array($checkbox, $c->username, $c->content, $action);
}
- print_table($table);
+ echo $OUTPUT->table($table);
echo $OUTPUT->paging_bar(moodle_paging_bar::make($count, $page, $this->perpage, $CFG->wwwroot.'/comment/index.php'));
}
echo $OUTPUT->notification(get_string('deletecheckwarning').': '.s($file->get_filepath().$file->get_filename()));
$optionsno = array('itemid'=>$itemid, 'filepath'=>$filepath, 'subdirs'=>$subdirs);
$optionsyes = array('itemid'=>$itemid, 'filepath'=>$filepath, 'delete'=>$delete, 'sesskey'=>sesskey(), 'subdirs'=>$subdirs);
- notice_yesno (get_string('deletecheckfiles'), 'draftfiles.php', 'draftfiles.php', $optionsyes, $optionsno, 'post', 'get');
+ echo $OUTPUT->confirm(get_string('deletecheckfiles'), new moodle_url('draftfiles.php', $optionsyes), new moodle_url('draftfiles.php', $optionsno));
echo $OUTPUT->footer();
die;
$optionsyes['delete'] = 1;
$optionsyes['sesskey'] = sesskey();
- notice_yesno (get_string('deletecheckfiles'), 'index.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');
+ echo $OUTPUT->confirm(get_string('deletecheckfiles'), new moodle_url( 'index.php', $optionsyes), new moodle_url('index.php', $optionsno));
echo $OUTPUT->footer();
die;
}
$return = $OUTPUT->heading(get_string('actauthhdr', 'auth'), 3, 'main');
$return .= $OUTPUT->box_start('generalbox authsui');
- $table = new object();
+ $table = new html_table();
$table->head = array($txt->name, $txt->enable, $txt->updown, $txt->settings);
$table->align = array('left', 'center', 'center', 'center');
$table->width = '90%';
// add a row to the table
$table->data[] =array($displayname, $hideshow, $updown, $settings);
}
- $return .= print_table($table, true);
+ $return .= $OUTPUT->table($table);
$return .= get_string('configauthenticationplugins', 'admin').'<br />'.get_string('tablenosave', 'filters');
$return .= $OUTPUT->box_end();
return highlight($query, $return);
$return = $OUTPUT->heading(get_string('acteditorshhdr', 'editor'), 3, 'main', true);
$return .= $OUTPUT->box_start('generalbox editorsui');
- $table = new object();
+ $table = new html_table();
$table->head = array($txt->name, $txt->enable, $txt->updown, $txt->settings);
$table->align = array('left', 'center', 'center', 'center');
$table->width = '90%';
// add a row to the table
$table->data[] =array($displayname, $hideshow, $updown, $settings);
}
- $return .= print_table($table, true);
+ $return .= $OUTPUT->table($table);
$return .= get_string('configeditorplugins', 'editor').'<br />'.get_string('tablenosave', 'filters');
$return .= $OUTPUT->box_end();
return highlight($query, $return);
$output .= portfolio_report_insane($insane, null, true);
$output .= portfolio_report_insane($insaneinstances, $instances, true);
- $table = new StdClass;
+ $table = new html_table();
$table->head = array($namestr, $pluginstr, '');
$table->data = array();
}
}
- $output .= print_table($table, true);
+ $output .= $OUTPUT->table($table);
$instancehtml = '<br /><br />' . get_string('addnewportfolio', 'portfolio') . ': <br /><br />';
$addable = 0;
* @param string $focus focus element
*/
function admin_externalpage_print_header($focus='') {
- global $CFG, $PAGE, $SITE, $THEME;
+ global $CFG, $PAGE, $SITE, $THEME, $OUTPUT;
if (!is_string($focus)) {
$focus = ''; // BC compatibility, there used to be adminroot parameter
$caption = get_string('blocksediton');
$options['adminedit'] = 'on';
}
- $buttons = print_single_button($PAGE->url->out(false), $options, $caption, 'get', '', true);
+ $buttons = $OUTPUT->button(html_form::make_button($PAGE->url->out(false), $options, $caption, 'get'));
}
$navlinks = array();
$instances = repository::get_types();
$instancesnumber = count($instances);
$alreadyplugins = array();
- $table = new StdClass;
+ $table = new html_table();
$table->head = array($namestr, $updownstr, $hiddenstr, $deletestr, $settingsstr);
$table->align = array('left', 'center', 'center','center','center');
$table->data = array();
$alreadyplugins[] = $i->get_typename();
}
}
- $output .= print_table($table, true);
+ $output .= $OUTPUT->table($table);
$instancehtml = '<div><h3>';
$instancehtml .= get_string('addplugin', 'repository');
$instancehtml .= '</h3><ul>';
$hiddenstr = get_string('hiddenshow', 'repository');
require_once("../webservice/lib.php");
$protocols = webservice_lib::get_list_protocols();
- $table = new StdClass;
+ $table = new html_table();
$table->head = array($namestr, $hiddenstr, $settingsstr);
$table->align = array('left', 'center', 'center');
$table->data = array();
$table->rowclasses[] = '';
}
}
- $output = print_table($table, true);
+ $output = $OUTPUT->table($table);
return highlight($query, $output);
}
//search all web service users
$users = get_users(true, '', false, null, 'firstname ASC','', '', '', 1000);
- $table = new StdClass;
+ $table = new html_table();
$table->head = array('username', 'whitelist');
$table->align = array('left', 'center');
$table->data = array();
}
}
- $output .= print_table($table, true);
+ $output .= $OUTPUT->table($table);
return highlight($query, $output);
}
}
$user->lastname = $c->lastname;
$user->imagealt = $c->imagealt;
$c->content = format_text($c->content, $c->format);
- $userpic = new moodle_user_picture();
- $userpic->user = $user;
- $userpic->courseid = $this->course->id;
+ $userpic = moodle_user_picture::make($user, $this->course->id);
$userpic->link = true;
$userpic->size = 18;
$userpic->alttext = true;
* @return mixed
*/
public function add($content) {
- global $CFG, $DB, $USER;
+ global $CFG, $DB, $USER, $OUTPUT;
if (empty($this->postcap)) {
return COMMENT_ERROR_INSUFFICIENT_CAPS;
}
$newcmt->time = userdate($now, get_string('strftimerecent', 'langconfig'));
$newcmt->username = fullname($USER);
$newcmt->content = format_text($newcmt->content);
- $newcmt->avatar = print_user_picture($USER, $this->course->id, NULL, 16, true);
+ $userpic = moodle_user_picture::make($USER, $this->course->id);
+ $userpic->size = 16;
+ $newcmt->avatar = $OUTPUT->user_picture($userpic);
return $newcmt;
} else {
return COMMENT_ERROR_DB;
function print_table($table, $return=false) {
global $OUTPUT;
// TODO MDL-19755 turn debugging on once we migrate the current core code to use the new API
- // debugging('print_table() has been deprecated. Please change your code to use $OUTPUT->table().');
+ debugging('print_table() has been deprecated. Please change your code to use $OUTPUT->table().');
$newtable = new html_table();
foreach ($table as $property => $value) {
if (property_exists($newtable, $property)) {
$return=false, $tooltip='', $disabled = false, $jsconfirmmessage='', $formid = '') {
global $OUTPUT;
- // debugging('print_single_button() has been deprecated. Please change your code to use $OUTPUT->button().');
+ debugging('print_single_button() has been deprecated. Please change your code to use $OUTPUT->button().');
// Cast $options to array
$options = (array) $options;
function print_user_picture($user, $courseid, $picture=NULL, $size=0, $return=false, $link=true, $target='', $alttext=true) {
global $CFG, $DB, $OUTPUT;
- // debugging('print_user_picture() has been deprecated. Please change your code to use $OUTPUT->user_picture($user, $courseid).');
+ debugging('print_user_picture() has been deprecated. Please change your code to use $OUTPUT->user_picture($user, $courseid).');
$userpic = new moodle_user_picture();
$userpic->user = $user;
* @return string|void Depending on value of $return
*/
function helpbutton($page, $title, $module='moodle', $image=true, $linktext=false, $text='', $return=false, $imagetext='') {
- // debugging('helpbutton() has been deprecated. Please change your code to use $OUTPUT->help_icon().');
+ debugging('helpbutton() has been deprecated. Please change your code to use $OUTPUT->help_icon().');
global $OUTPUT;
*/
function notice_yesno($message, $linkyes, $linkno, $optionsyes=NULL, $optionsno=NULL, $methodyes='post', $methodno='post') {
- // debugging('notice_yesno() has been deprecated. Please change your code to use $OUTPUT->confirm($message, $buttoncontinue, $buttoncancel).');
+ debugging('notice_yesno() has been deprecated. Please change your code to use $OUTPUT->confirm($message, $buttoncontinue, $buttoncancel).');
global $OUTPUT;
- $formcontinue = new html_form();
- $formcontinue->url = new moodle_url($linkyes, $optionsyes);
- $formcontinue->button->text = get_string('yes');
- $formcontinue->method = $methodyes;
+ $buttoncontinue = html_form::make_button($linkyes, $optionsyes, get_string('yes'), $methodyes);
+ $buttoncancel = html_form::make_button($linkno, $optionsno, get_string('no'), $methodno);
- $formcancel = new html_form();
- $formcancel->url = new moodle_url($linkno, $optionsno);
- $formcancel->button->text = get_string('no');
- $formcancel->method = $methodno;
-
- echo $OUTPUT->confirm($message, $formcontinue, $formcancel);
+ echo $OUTPUT->confirm($message, $buttoncontinue, $buttoncancel);
}
/**
*/
function print_textfield ($name, $value, $alt = '',$size=50,$maxlength=0, $return=false) {
- // debugging('print_textfield() has been deprecated. Please change your code to use $OUTPUT->textfield($field).');
+ debugging('print_textfield() has been deprecated. Please change your code to use $OUTPUT->textfield($field).');
global $OUTPUT;
$strrestricted = get_string('restricted');
$strenvironmenterrortodo = get_string('environmenterrortodo', 'admin');
/// Table headers
- $servertable = new stdClass;//table for server checks
+ $servertable = new html_table();//table for server checks
$servertable->head = array ($strname, $strinfo, $strreport, $strstatus);
$servertable->align = array ('center', 'center', 'left', 'center');
$servertable->wrap = array ('nowrap', '', '', 'nowrap');
$servertable->size = array ('10', 10, '100%', '10');
$servertable->width = '90%';
- $servertable->class = 'environmenttable generaltable';
+ $servertable->add_class('environmenttable generaltable');
$serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
- $othertable = new stdClass;//table for custom checks
+ $othertable = new html_table();//table for custom checks
$othertable->head = array ($strinfo, $strreport, $strstatus);
$othertable->align = array ('center', 'left', 'center');
$othertable->wrap = array ('', '', 'nowrap');
$othertable->size = array (10, '100%', '10');
$othertable->width = '90%';
- $othertable->class = 'environmenttable generaltable';
+ $othertable->add_class('environmenttable generaltable');
$otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
/// Print table
echo $OUTPUT->heading(get_string('serverchecks', 'admin'));
- print_table($servertable);
+ echo $OUTPUT->table($servertable);
if (count($othertable->data)){
echo $OUTPUT->heading(get_string('customcheck', 'admin'));
- print_table($othertable);
+ echo $OUTPUT->table($othertable);
}
/// Finally, if any error has happened, print the summary box
* @param string $function
*/
function setHelpButton($elementname, $button, $suppresscheck=false, $function='helpbutton'){
+ global $OUTPUT;
if (array_key_exists($elementname, $this->_elementIndex)){
//_elements has a numeric index, this code accesses the elements by name
$element=&$this->_elements[$this->_elementIndex[$elementname]];
- if (method_exists($element, 'setHelpButton')){
- $element->setHelpButton($button, $function);
- }else{
- $a=new object();
- $a->name=$element->getName();
- $a->classname=get_class($element);
- print_error('nomethodforaddinghelpbutton', 'form', '', $a);
+ $buttonparams = array('page', 'text', 'module', 'image', 'linktext', 'text', 'return', 'imagetext');
+ $helpiconoptions = array('page' => null, 'text' => null, 'module' => 'moodle', 'image' => null, 'linktext' => false);
+
+ foreach ($button as $key => $val) {
+ if (isset($button[$key])) {
+ $helpiconoptions[$buttonparams[$key]] = $val;
+ }
}
+ $helpicon = moodle_help_icon::make($helpiconoptions['page'], $helpiconoptions['text'], $helpiconoptions['module'], $helpiconoptions['linktext']);
+ if (!$helpiconoptions['image']) {
+ $helpicon->image = false;
+ }
+
+ $element->_helpbutton = $OUTPUT->help_icon($helpicon);
}elseif (!$suppresscheck){
print_error('nonexistentformelements', 'form', '', $elementname);
}
* @return array the class names as an array.
*/
public static function clean_classes($classes) {
- if (is_array($classes)) {
+ if (empty($classes)) {
+ return '';
+ } else if (is_array($classes)) {
return $classes;
} else {
return explode(' ', trim($classes));
parent::prepare();
}
+
+ public static function make_button($url, $options, $label='OK', $method='post') {
+ $form = new html_form();
+ $form->url = new moodle_url($url, $options);
+ $form->button->text = $label;
+ $form->method = $method;
+ return $form;
+ }
}
/**
parent::prepare();
}
+
+ public static function make($user, $courseid) {
+ $userpic = new moodle_user_picture();
+ $userpic->user = $user;
+ $userpic->courseid = $courseid;
+ return $userpic;
+ }
}
/**
$isummary = array();
}
$mainsummary = array_merge($mainsummary, $csummary, $isummary);
- $table = new StdClass;
+ $table = new html_table();
$table->data = array();
foreach ($mainsummary as $string => $value) {
$table->data[] = array($string, $value);
}
- print_table($table);
- notice_yesno($strconfirm, $yesurl, $nourl);
+ echo $OUTPUT->table($table);
+ echo $OUTPUT->confirm($strconfirm, $yesurl, $nourl);
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
return false;
}
$output = $OUTPUT->notification($headerstr, 'notifyproblem');
- $table = new StdClass;
+ $table = new html_table();
$table->head = array($pluginstr, '');
$table->data = array();
foreach ($insane as $plugin => $reason) {
}
$table->data[] = array($name, get_string($reason, 'portfolio_' . $plugin));
}
- $output .= print_table($table, true);
+ $output .= $OUTPUT->table($table);
$output .= '<br /><br /><br />';
if ($return) {
* @return boolean
*/
function question_delete_course($course, $feedback=true) {
- global $DB;
+ global $DB, $OUTPUT;
//To store feedback to be showed at the end of the process
$feedbackdata = array();
}
//Inform about changes performed if feedback is enabled
if ($feedback) {
- $table = new stdClass;
+ $table = new html_table();
$table->head = array(get_string('category','quiz'), get_string('action'));
$table->data = $feedbackdata;
- print_table($table);
+ echo $OUTPUT->table($table);
}
}
return true;
// Output feedback if requested.
if ($feedback and $feedbackdata) {
- $table = new stdClass;
+ $table = new html_table();
$table->head = array(get_string('questioncategory','question'), get_string('action'));
$table->data = $feedbackdata;
- print_table($table);
+ echo $OUTPUT->table($table);
}
} else {
* @return boolean
*/
function question_delete_activity($cm, $feedback=true) {
- global $DB;
+ global $DB, $OUTPUT;
//To store feedback to be showed at the end of the process
$feedbackdata = array();
}
//Inform about changes performed if feedback is enabled
if ($feedback) {
- $table = new stdClass;
+ $table = new html_table();
$table->head = array(get_string('category','quiz'), get_string('action'));
$table->data = $feedbackdata;
- print_table($table);
+ echo $OUTPUT->table($table);
}
}
return true;
$DB = $realdb;
-echo '<div>';
-print_single_button($baseurl, array('action' => 'setup'), 'Set up test tables', 'get', '', false, '', $issetup > 0);
-print_single_button($baseurl, array('action' => 'teardown'), 'Drop test tables', 'get', '', false, '', $issetup == 0);
-print_single_button($baseurl, array('action' => 'test'), 'Run tests', 'get', '', false, '', $issetup != count($requiredtables));
-echo '</div>';
+echo $OUTPUT->container_start();
+
+$form = html_form::make_button($baseurl, array('action' => 'setup'), 'Set up test tables', 'get');
+$form->button->disabled = $issetup > 0;
+echo $OUTPUT->button($form);
+
+$form = html_form::make_button($baseurl, array('action' => 'teardown'), 'Drop test tables', 'get');
+$form->button->disabled = $issetup == 0;
+echo $OUTPUT->button($form);
+
+$form = html_form::make_button($baseurl, array('action' => 'test'), 'Run tests', 'get');
+$form->button->disabled = $issetup != count($requiredtables);
+echo $OUTPUT->button($form);
+
+echo $OUTPUT->container_end();
echo $OUTPUT->footer();
if ($data = unserialize(file_get_contents($serfilepath))) {
// return one table with all the totals (we avoid individual file results here)
$result = '';
- $table = new object();
+ $table = new html_table();
$table->align = array('right', 'left');
$table->tablealign = 'center';
- $table->class = 'codecoveragetable';
+ $table->add_class('codecoveragetable');
$table->id = 'codecoveragetable_' . $type;
$table->rowclasses = array('label', 'value');
$table->data = array(
$result .= $OUTPUT->heading($data->title, 3, 'main codecoverageheading');
$result .= $OUTPUT->heading('<a href="' . $url . '" onclick="javascript:window.open(' . "'" . $url . "'" . ');return false;"' .
' title="">' . get_string('codecoveragecompletereport', 'simpletest') . '</a>', 4, 'main codecoveragelink');
- $result .= print_table($table, true);
+ $result .= $OUTPUT->table($table);
return $OUTPUT->box($result, 'generalbox boxwidthwide boxaligncenter codecoveragebox', '', true);
}
$options['sesskey'] = sesskey();
$options['switchrole'] = 0;
- return print_single_button($CFG->wwwroot.'/course/view.php', $options,
- get_string('switchrolereturn'), 'post', '_self', true);
+ return $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/course/view.php', $options, get_string('switchrolereturn')));
}
if (has_capability('moodle/role:switchroles', $context)) {
if (isguest()) {
print_header($strmymoodle);
- notice_yesno(get_string('noguest', 'my') . '<br /><br />' .
- get_string('liketologin'), get_login_url(), $CFG->wwwroot);
+ echo $OUTPUT->confirm(get_string('noguest', 'my') . '<br /><br />' . get_string('liketologin'), get_login_url(), $CFG->wwwroot);
echo $OUTPUT->footer();
die;
}