From: nicolasconnault Date: Thu, 30 Jul 2009 06:09:45 +0000 (+0000) Subject: MDL-19756 Improved API of OUTPUT->confirm() X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=74623e0a3ad02ee5c97f155629a1d3aa83a32901;p=moodle.git MDL-19756 Improved API of OUTPUT->confirm() --- diff --git a/admin/index.php b/admin/index.php index 079decdc52..435db0bca6 100644 --- a/admin/index.php +++ b/admin/index.php @@ -189,13 +189,7 @@ if ($version > $CFG->version) { // upgrade if (empty($confirmupgrade)) { $navigation = build_navigation(array(array('name'=>$strdatabasechecking, 'link'=>null, 'type'=>'misc'))); print_header($strdatabasechecking, $stradministration, $navigation, '', '', false, ' ', ' '); - $formcontinue = new html_form(); - $formcontinue->button->label = get_string('yes'); - $formcontinue->url = new moodle_url('index.php', array('confirmupgrade' => 1)); - $formcancel = new html_form(); - $formcancel->url = new moodle_url('index.php'); - echo $OUTPUT->confirm(get_string('upgradesure', 'admin', $a->newversion), $formcontinue, $formcancel); - + echo $OUTPUT->confirm(get_string('upgradesure', 'admin', $a->newversion), new moodle_url('index.php', array('confirmupgrade' => 1)), 'index.php'); print_footer(); exit; diff --git a/course/lib.php b/course/lib.php index 95a925eae7..7257c27549 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1598,13 +1598,13 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false, } if (!empty($resources)) { - $output .= popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&sesskey=".sesskey()."&add=", + $output .= popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$section&sesskey=".sesskey()."&add=", $resources, "ressection$section", "", $straddresource, 'resource/types', $straddresource, true); } if (!empty($activities)) { $output .= ' '; - $output .= popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&sesskey=".sesskey()."&add=", + $output .= popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$section&sesskey=".sesskey()."&add=", $activities, "section$section", "", $straddactivity, 'mods', $straddactivity, true); } diff --git a/course/view.php b/course/view.php index afb9837409..735f16c5c9 100644 --- a/course/view.php +++ b/course/view.php @@ -240,7 +240,10 @@ // Content wrapper end. echo "\n\n"; - + $image = new html_image(); + $image->src = $OUTPUT->old_icon_url('help'); + $image->add_action('click', 'confirm_dialog', array('message' => 'Are you sure?')); + echo $OUTPUT->image($image); // Use AJAX? if ($useajax && has_capability('moodle/course:manageactivities', $context)) { // At the bottom because we want to process sections and activities diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 5783d6dce9..bf5dc87fb8 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -2070,6 +2070,8 @@ function notify($message, $classes = 'notifyproblem', $align = 'center', $return /** * Print a continue button that goes to a particular URL. * + * @deprecated since Moodle 2.0 + * * @param string $link The url to create a link to. * @param bool $return If set to true output is returned rather than echoed, default false * @return string|void HTML String if return=true nothing otherwise @@ -2098,6 +2100,8 @@ function print_continue($link, $return = false) { * Returns a string containing a link to the user documentation for the current * page. Also contains an icon by default. Shown to teachers and admin only. * + * @deprecated since Moodle 2.0 + * * @global object * @global object * @param string $text The text to be displayed for the link @@ -3310,8 +3314,6 @@ function print_date_selector($day, $month, $year, $currenttime=0, $return=false) * submits the form (while avoiding the usual acessibility problems with this appoach). * With JavaScript off, a 'Go' button is printed. * - * @todo Finish documenting this function - * * @global object * @global object * @param string $baseurl The target URL up to the point of the variable that changes @@ -3359,18 +3361,8 @@ function popup_form($baseurl, $options, $formid, $selected='', $nothing='choose' $selectmenu->nothinglabel = $nothing; } - if ($selectlabel) { - $selectmenu->label = new html_label(); - $selectmenu->label->text = $selectlabel; - $selectmenu->label->for = $selectmenu->id; - } - - if ($help) { - $selectmenu->helpicon = new help_icon(); - $selectmenu->helpicon->page = $help; - $selectmenu->helpicon->text = $helptext; - $selectmenu->helpicon->linktext = false; - } + $selectmenu->set_label($selectlabel, $selectmenu->id); + $selectmenu->set_help_icon($help, $helptext); $output = $OUTPUT->select_menu($selectmenu); diff --git a/lib/outputlib.php b/lib/outputlib.php index 227bad6731..a9a441a803 100644 --- a/lib/outputlib.php +++ b/lib/outputlib.php @@ -318,9 +318,9 @@ class theme_config { */ public $layouts = array(); - /* + /* * Time in seconds to cache the CSS style sheets for the chosen theme - * + * * @var integer */ public $csslifetime = 1800; @@ -2436,16 +2436,25 @@ class moodle_core_renderer extends moodle_renderer_base { $continueform = new html_form(); $continueform->url = new moodle_url($continue); $continue = $continueform; - } else if (!is_object($continue)) { - throw new coding_exception('The 2nd param to $OUTPUT->confirm must be either a URL (string/moodle_url) or a html_form object.'); + } else if ($continue instanceof moodle_url) { + $continueform = new html_form(); + $continueform->url = $continue; + $continue = $continueform; + } else { + throw new coding_exception('The continue param to $OUTPUT->confirm must be either a URL (string/moodle_url) or a html_form object.'); + } if (!($cancel instanceof html_form) && !is_object($cancel)) { $cancelform = new html_form(); $cancelform->url = new moodle_url($cancel); $cancel = $cancelform; - } else if (!is_object($cancel)) { - throw new coding_exception('The 3rd param to $OUTPUT->confirm must be either a URL (string/moodle_url) or a html_form object.'); + } else if ($cancel instanceof moodle_url) { + $cancelform = new html_form(); + $cancelform->url = $cancel; + $cancel = $cancelform; + } else { + throw new coding_exception('The cancel param to $OUTPUT->confirm must be either a URL (string/moodle_url) or a html_form object.'); } if (empty($continue->button->text)) { @@ -2640,11 +2649,14 @@ class moodle_core_renderer extends moodle_renderer_base { public function image($image) { $image->prepare(); + $this->prepare_event_handlers($image); + $attributes = array('class' => $image->get_classes_string(), 'style' => $this->prepare_legacy_width_and_height($image), 'src' => prepare_url($image->src), 'alt' => $image->alt, - 'title' => $image->title); + 'title' => $image->title, + 'id' => $image->id); return $this->output_empty_tag('img', $attributes); } @@ -2753,6 +2765,20 @@ class moodle_core_renderer extends moodle_renderer_base { /** * Output a