MDL-36749 lib Complete deprecation of old_help_icon

This deprecates the old_help_icon and helpbutton functions. Since they can
no longer be used, the renderers are removed altogether.
This commit is contained in:
Andrew Robert Nicols 2013-02-05 09:25:29 +00:00 committed by Andrew Robert Nicols
parent cce0d9a100
commit a6d81a73ac
5 changed files with 9 additions and 237 deletions

View file

@ -1883,33 +1883,9 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
* Print a help button. * Print a help button.
* *
* @deprecated since Moodle 2.0 * @deprecated since Moodle 2.0
*
* @param string $page The keyword that defines a help page
* @param string $title The title of links, rollover tips, alt tags etc
* 'Help with' (or the language equivalent) will be prefixed and '...' will be stripped.
* @param string $module Which module is the page defined in
* @param mixed $image Use a help image for the link? (true/false/"both")
* @param boolean $linktext If true, display the title next to the help icon.
* @param string $text If defined then this text is used in the page, and
* the $page variable is ignored. DEPRECATED!
* @param boolean $return If true then the output is returned as a string, if false it is printed to the current page.
* @param string $imagetext The full text for the helpbutton icon. If empty use default help.gif
* @return string|void Depending on value of $return
*/ */
function helpbutton($page, $title, $module='moodle', $image=true, $linktext=false, $text='', $return=false, $imagetext='') { 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().'); throw new coding_exception('helpbutton() can not be used any more, please see $OUTPUT->help_icon().');
global $OUTPUT;
$output = $OUTPUT->old_help_icon($page, $title, $module, $linktext);
// hide image with CSS if needed
if ($return) {
return $output;
} else {
echo $output;
}
} }
/** /**
@ -1962,10 +1938,6 @@ function editorshortcutshelpbutton() {
global $CFG; global $CFG;
//TODO: detect current editor and print correct info //TODO: detect current editor and print correct info
/* $imagetext = '<img src="' . $CFG->httpswwwroot . '/lib/editor/htmlarea/images/kbhelp.gif" alt="'.
get_string('editorshortcutkeys').'" class="iconkbhelp" />';
return helpbutton('editorshortcuts', get_string('editorshortcutkeys'), 'moodle', true, false, '', true, $imagetext);*/
return ''; return '';
} }
@ -2032,23 +2004,9 @@ function print_arrow($direction='up', $strsort=null, $return=false) {
* Also contains an icon by default. Shown to teachers and admin only. * Also contains an icon by default. Shown to teachers and admin only.
* *
* @deprecated since Moodle 2.0 * @deprecated since Moodle 2.0
*
* @global object
* @param string $path The page link after doc root and language, no leading slash.
* @param string $text The text to be displayed for the link
* @param string $iconpath The path to the icon to be displayed
* @return string Either the link or an empty string
*/ */
function doc_link($path='', $text='', $iconpath='ignored') { function doc_link($path='', $text='', $iconpath='ignored') {
global $CFG, $OUTPUT; throw new coding_exception('doc_link() can not be used any more, please see $OUTPUT->doc_link().');
debugging('doc_link() has been deprecated. Please change your code to use $OUTPUT->doc_link().');
if (empty($CFG->docroot)) {
return '';
}
return $OUTPUT->doc_link($path, $text);
} }
/** /**
@ -2347,67 +2305,10 @@ function print_date_selector($day, $month, $year, $currenttime=0, $return=false)
* Implements a complete little form with a dropdown menu. * Implements a complete little form with a dropdown menu.
* *
* @deprecated since Moodle 2.0 * @deprecated since Moodle 2.0
*
* When JavaScript is on selecting an option from the dropdown automatically
* submits the form (while avoiding the usual acessibility problems with this appoach).
* With JavaScript off, a 'Go' button is printed.
*
* @global object
* @global object
* @param string $baseurl The target URL up to the point of the variable that changes
* @param array $options A list of value-label pairs for the popup list
* @param string $formid id for the control. Must be unique on the page. Used in the HTML.
* @param string $selected The option that is initially selected
* @param string $nothing The label for the "no choice" option
* @param string $help The name of a help page if help is required
* @param string $helptext The name of the label for the help button
* @param boolean $return Indicates whether the function should return the HTML
* as a string or echo it directly to the page being rendered
* @param string $targetwindow The name of the target page to open the linked page in.
* @param string $selectlabel Text to place in a [label] element - preferred for accessibility.
* @param array $optionsextra an array with the same keys as $options. The values are added within the corresponding <option ...> tag.
* @param string $submitvalue Optional label for the 'Go' button. Defaults to get_string('go').
* @param boolean $disabled If true, the menu will be displayed disabled.
* @param boolean $showbutton If true, the button will always be shown even if JavaScript is available
* @return string|void If $return=true returns string, else echo's and returns void
*/ */
function popup_form($baseurl, $options, $formid, $selected='', $nothing='choose', $help='', $helptext='', $return=false, function popup_form($baseurl, $options, $formid, $selected='', $nothing='choose', $help='', $helptext='', $return=false,
$targetwindow='self', $selectlabel='', $optionsextra=NULL, $submitvalue='', $disabled=false, $showbutton=false) { $targetwindow='self', $selectlabel='', $optionsextra=NULL, $submitvalue='', $disabled=false, $showbutton=false) {
global $OUTPUT, $CFG; throw new coding_exception('popup_form() can not be used any more, please see $OUTPUT->single_select or $OUTPUT->url_select().');
debugging('popup_form() has been deprecated. Please change your code to use $OUTPUT->single_select() or $OUTPUT->url_select().');
if (empty($options)) {
return '';
}
$urls = array();
foreach ($options as $value=>$label) {
$url = $baseurl.$value;
$url = str_replace($CFG->wwwroot, '', $url);
$url = str_replace('&amp;', '&', $url);
$urls[$url] = $label;
if ($selected == $value) {
$active = $url;
}
}
$nothing = $nothing ? array(''=>$nothing) : null;
$select = new url_select($urls, $active, $nothing, $formid);
$select->disabled = $disabled;
$select->set_label($selectlabel);
$select->set_old_help_icon($help, $helptext);
$output = $OUTPUT->render($select);
if ($return) {
return $output;
} else {
echo $output;
}
} }
/** /**

View file

@ -411,58 +411,6 @@ class user_picture implements renderable {
} }
} }
/**
* Data structure representing a help icon.
*
* @copyright 2009 Nicolas Connault, 2010 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
* @package core
* @category output
*/
class old_help_icon implements renderable {
/**
* @var string Lang pack identifier
*/
public $helpidentifier;
/**
* @var string A descriptive text for title tooltip
*/
public $title = null;
/**
* @var string Component name, the same as in get_string()
*/
public $component = 'moodle';
/**
* @var string Extra descriptive text next to the icon
*/
public $linktext = null;
/**
* Constructor: sets up the other components in case they are needed
*
* @param string $helpidentifier The keyword that defines a help page
* @param string $title A descriptive text for accessibility only
* @param string $component
*/
public function __construct($helpidentifier, $title, $component = 'moodle') {
if (empty($title)) {
throw new coding_exception('A help_icon object requires a $text parameter');
}
if (empty($helpidentifier)) {
throw new coding_exception('A help_icon object requires a $helpidentifier parameter');
}
$this->helpidentifier = $helpidentifier;
$this->title = $title;
$this->component = $component;
}
}
/** /**
* Data structure representing a help icon. * Data structure representing a help icon.
* *
@ -807,12 +755,10 @@ class single_select implements renderable {
/** /**
* Adds help icon. * Adds help icon.
* *
* @param string $helppage The keyword that defines a help page * @deprecated since Moodle 2.0
* @param string $title A descriptive text for accessibility only
* @param string $component
*/ */
public function set_old_help_icon($helppage, $title, $component = 'moodle') { public function set_old_help_icon($helppage, $title, $component = 'moodle') {
$this->helpicon = new old_help_icon($helppage, $title, $component); throw new coding_exception('set_old_help_icon() can not be used any more, please see set_help_icon().');
} }
/** /**
@ -931,12 +877,10 @@ class url_select implements renderable {
/** /**
* Adds help icon. * Adds help icon.
* *
* @param string $helppage The keyword that defines a help page * @deprecated since Moodle 2.0
* @param string $title A descriptive text for accessibility only
* @param string $component
*/ */
public function set_old_help_icon($helppage, $title, $component = 'moodle') { public function set_old_help_icon($helppage, $title, $component = 'moodle') {
$this->helpicon = new old_help_icon($helppage, $title, $component); throw new coding_exception('set_old_help_icon() can not be used any more, please see set_help_icon().');
} }
/** /**

View file

@ -1518,8 +1518,6 @@ class core_renderer extends renderer_base {
if ($select->helpicon instanceof help_icon) { if ($select->helpicon instanceof help_icon) {
$output .= $this->render($select->helpicon); $output .= $this->render($select->helpicon);
} else if ($select->helpicon instanceof old_help_icon) {
$output .= $this->render($select->helpicon);
} }
$output .= html_writer::select($select->options, $select->name, $select->selected, $select->nothing, $select->attributes); $output .= html_writer::select($select->options, $select->name, $select->selected, $select->nothing, $select->attributes);
@ -1609,8 +1607,6 @@ class core_renderer extends renderer_base {
if ($select->helpicon instanceof help_icon) { if ($select->helpicon instanceof help_icon) {
$output .= $this->render($select->helpicon); $output .= $this->render($select->helpicon);
} else if ($select->helpicon instanceof old_help_icon) {
$output .= $this->render($select->helpicon);
} }
// For security reasons, the script course/jumpto.php requires URL starting with '/'. To keep // For security reasons, the script course/jumpto.php requires URL starting with '/'. To keep
@ -1880,66 +1876,9 @@ class core_renderer extends renderer_base {
* Returns HTML to display a help icon. * Returns HTML to display a help icon.
* *
* @deprecated since Moodle 2.0 * @deprecated since Moodle 2.0
* @param string $helpidentifier The keyword that defines a help page
* @param string $title A descriptive text for accessibility only
* @param string $component component name
* @param string|bool $linktext true means use $title as link text, string means link text value
* @return string HTML fragment
*/ */
public function old_help_icon($helpidentifier, $title, $component = 'moodle', $linktext = '') { public function old_help_icon($helpidentifier, $title, $component = 'moodle', $linktext = '') {
debugging('The method old_help_icon() is deprecated, please fix the code and use help_icon() method instead', DEBUG_DEVELOPER); throw new coding_exception('old_help_icon() can not be used any more, please see help_icon().');
$icon = new old_help_icon($helpidentifier, $title, $component);
if ($linktext === true) {
$icon->linktext = $title;
} else if (!empty($linktext)) {
$icon->linktext = $linktext;
}
return $this->render($icon);
}
/**
* Implementation of user image rendering.
*
* @param old_help_icon $helpicon A help icon instance
* @return string HTML fragment
*/
protected function render_old_help_icon(old_help_icon $helpicon) {
global $CFG;
// first get the help image icon
$src = $this->pix_url('help');
if (empty($helpicon->linktext)) {
$alt = $helpicon->title;
} else {
$alt = get_string('helpwiththis');
}
$attributes = array('src'=>$src, 'alt'=>$alt, 'class'=>'iconhelp');
$output = html_writer::empty_tag('img', $attributes);
// add the link text if given
if (!empty($helpicon->linktext)) {
// the spacing has to be done through CSS
$output .= $helpicon->linktext;
}
// now create the link around it - we need https on loginhttps pages
$url = new moodle_url($CFG->httpswwwroot.'/help.php', array('component' => $helpicon->component, 'identifier' => $helpicon->helpidentifier, 'lang'=>current_language()));
// note: this title is displayed only if JS is disabled, otherwise the link will have the new ajax tooltip
$title = get_string('helpprefix2', '', trim($helpicon->title, ". \t"));
$attributes = array('href'=>$url, 'title'=>$title, 'aria-haspopup' => 'true');
$id = html_writer::random_id('helpicon');
$attributes['id'] = $id;
$output = html_writer::tag('a', $output, $attributes);
$this->page->requires->js_init_call('M.util.help_icon.add', array(array('id'=>$id, 'url'=>$url->out(false))));
$this->page->requires->string_for_js('close', 'form');
// and finally span
return html_writer::tag('span', $output, array('class' => 'helptooltip'));
} }
/** /**

View file

@ -1310,17 +1310,7 @@ class page_wiki_history extends page_wiki {
$table->attributes['class'] = 'generaltable mdl-align'; $table->attributes['class'] = 'generaltable mdl-align';
$table->rowclasses = $rowclass; $table->rowclasses = $rowclass;
/*$table = new StdClass(); // Print the form.
$table->head = array(helpbutton('diff', 'diff', 'wiki', true, false, '', true, ''),
get_string('version'),
get_string('user'),
get_string('modified'),
'');
$table->data = $contents;
$table->class = 'mdl-align';
$table->rowclass = $rowclass;*/
///Print the form
echo html_writer::start_tag('form', array('action'=>new moodle_url('/mod/wiki/diff.php'), 'method'=>'get', 'id'=>'diff')); echo html_writer::start_tag('form', array('action'=>new moodle_url('/mod/wiki/diff.php'), 'method'=>'get', 'id'=>'diff'));
echo html_writer::tag('div', html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'pageid', 'value'=>$pageid))); echo html_writer::tag('div', html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'pageid', 'value'=>$pageid)));
echo html_writer::table($table); echo html_writer::table($table);

View file

@ -758,8 +758,6 @@ class theme_mymobile_core_renderer extends core_renderer {
if ($select->helpicon instanceof help_icon) { if ($select->helpicon instanceof help_icon) {
$output .= $this->render($select->helpicon); $output .= $this->render($select->helpicon);
} else if ($select->helpicon instanceof old_help_icon) {
$output .= $this->render($select->helpicon);
} }
$output .= html_writer::select($select->options, $select->name, $select->selected, $select->nothing, $select->attributes); $output .= html_writer::select($select->options, $select->name, $select->selected, $select->nothing, $select->attributes);