MDL-21217, MDL-21198 simplified/improved outputlib help icon related apis + several fixed regresions

This commit is contained in:
Petr Skoda 2009-12-30 15:19:55 +00:00
parent 48a67d9f01
commit 4bcc51185c
113 changed files with 442 additions and 970 deletions

View file

@ -169,7 +169,7 @@ class completion_info {
global $PAGE, $OUTPUT;
if ($this->is_enabled() && !$PAGE->user_is_editing() && isloggedin() && !isguestuser()) {
echo '<span id = "completionprogressid" class="completionprogress">'.get_string('yourprogress','completion').' ';
echo $OUTPUT->help_icon(moodle_help_icon::make('completionicons',get_string('completionicons','completion'),'completion'));
echo $OUTPUT->help_icon('completionicons',get_string('completionicons','completion'),'completion');
echo '</span>';
}
}

View file

@ -2443,54 +2443,10 @@ function print_table($table, $return=false) {
* @param string $class class added to the element
* @return string html code to display a link to a popup window.
*/
function link_to_popup_window ($url, $name=null, $linkname=null,
$height=400, $width=500, $title=null,
$options=null, $return=false) {
global $OUTPUT;
function link_to_popup_window ($url, $name=null, $linkname=null, $height=400, $width=500, $title=null, $options=null, $return=false) {
debugging('link_to_popup_window() has been removed. Please change your code to use $OUTPUT->link(). Please note popups are discouraged for accessibility reasons');
debugging('link_to_popup_window() has been deprecated. Please change your code to use $OUTPUT->link().');
if ($options == 'none') {
$options = null;
}
if (empty($linkname)) {
throw new coding_exception('A link must have a descriptive text value! See $OUTPUT->link_to_popup() for usage.');
}
// Create a html_link object
$link = html_link::make($url, $linkname);
$link->title = $title;
// Parse the $options string
$popupparams = array();
if (!empty($options)) {
$optionsarray = explode(',', $options);
foreach ($optionsarray as $option) {
if (strstr($option, '=')) {
$parts = explode('=', $option);
if ($parts[1] == '0') {
$popupparams[$parts[0]] = false;
} else {
$popupparams[$parts[0]] = $parts[1];
}
} else {
$popupparams[$option] = true;
}
}
}
$popupaction = new popup_action('click', $url, $name, $popupparams);
$link->add_action($popupaction);
// Call the output method
$output = $OUTPUT->link($link);
if ($return) {
return $output;
} else {
echo $output;
}
return $OUTPUT->link($url, $name);
}
/**
@ -2523,7 +2479,7 @@ function button_to_popup_window ($url, $name=null, $linkname=null,
}
if (empty($linkname)) {
throw new coding_exception('A link must have a descriptive text value! See $OUTPUT->link_to_popup() for usage.');
throw new coding_exception('A link must have a descriptive text value! See $OUTPUT->link() for usage.');
}
// Create a html_button object
@ -2796,36 +2752,132 @@ function helpbutton($page, $title, $module='moodle', $image=true, $linktext=fals
global $OUTPUT;
if (!empty($text)) {
throw new coding_exception('The $text parameter has been deprecated. Please update your code and use $OUTPUT->help_icon() instead. <br />' .
"You will also need to copy the following text into a proper html help file if not already done so: <p>$text</p>");
}
$output = $OUTPUT->help_icon($page, $title, $module, $linktext);
if (!empty($imagetext)) {
throw new coding_exception('The $imagetext parameter has been deprecated. Please update your code and use $OUTPUT->help_icon() instead.');
}
$helpicon = new moodle_help_icon();
$helpicon->page = $page;
$helpicon->text = $title;
$helpicon->module = $module;
$helpicon->linktext = $linktext;
// If image is true, the defaults are handled by the helpicon's prepare method
if (!$image) {
$helpicon->image = false;
}
$output = $OUTPUT->help_icon($helpicon);
// hide image with CSS if needed
if ($return) {
return $output;
} else {
echo $output;
}
}
/**
* Print a help button.
*
* Prints a special help button that is a link to the "live" emoticon popup
*
* @todo Finish documenting this function
*
* @global object
* @global object
* @param string $form ?
* @param string $field ?
* @param boolean $return If true then the output is returned as a string, if false it is printed to the current page.
* @return string|void Depending on value of $return
*/
function emoticonhelpbutton($form, $field, $return = false) {
/// TODO: MDL-21215
debugging('emoticonhelpbutton() was removed, new text editors will implement this feature');
}
/**
* Returns a string of html with an image of a help icon linked to a help page on a number of help topics.
* Should be used only with htmleditor or textarea.
*
* @global object
* @global object
* @param mixed $helptopics variable amount of params accepted. Each param may be a string or an array of arguments for
* helpbutton.
* @return string Link to help button
*/
function editorhelpbutton(){
return '';
/// TODO: MDL-21215
global $CFG, $SESSION, $OUTPUT;
$items = func_get_args();
$i = 1;
$urlparams = array();
$titles = array();
foreach ($items as $item){
if (is_array($item)){
$urlparams[] = "keyword$i=".urlencode($item[0]);
$urlparams[] = "title$i=".urlencode($item[1]);
if (isset($item[2])){
$urlparams[] = "module$i=".urlencode($item[2]);
}
$titles[] = trim($item[1], ". \t");
} else if (is_string($item)) {
$urlparams[] = "button$i=".urlencode($item);
switch ($item) {
case 'reading' :
$titles[] = get_string("helpreading");
break;
case 'writing' :
$titles[] = get_string("helpwriting");
break;
case 'questions' :
$titles[] = get_string("helpquestions");
break;
case 'emoticons2' :
$titles[] = get_string("helpemoticons");
break;
case 'richtext2' :
$titles[] = get_string('helprichtext');
break;
case 'text2' :
$titles[] = get_string('helptext');
break;
default :
print_error('unknownhelp', '', '', $item);
}
}
$i++;
}
if (count($titles)>1){
//join last two items with an 'and'
$a = new object();
$a->one = $titles[count($titles) - 2];
$a->two = $titles[count($titles) - 1];
$titles[count($titles) - 2] = get_string('and', '', $a);
unset($titles[count($titles) - 1]);
}
$alttag = join (', ', $titles);
$paramstring = join('&', $urlparams);
$linkobject = '<img alt="'.$alttag.'" class="iconhelp" src="'.$OUTPUT->pix_url('help') . '" />';
$link = html_link::make(s('/lib/form/editorhelp.php?'.$paramstring), $linkobject);
$link->add_action(new popup_action('click', $link->url, 'popup', array('height' => 400, 'width' => 500)));
$link->title = $alttag;
return $OUTPUT->link($link);
}
/**
* Print a help button.
*
* Prints a special help button for html editors (htmlarea in this case)
*
* @todo Write code into this function! detect current editor and print correct info
* @global object
* @return string Only returns an empty string at the moment
*/
function editorshortcutshelpbutton() {
/// TODO: MDL-21215
global $CFG;
//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 '';
}
/**
* Returns an image of an up or down arrow, used for column sorting. To avoid unnecessary DB accesses, please
* provide this function with the language strings for sortasc and sortdesc.
@ -3143,10 +3195,10 @@ function choose_from_menu_nested($options,$name,$selected='',$nothing='choose',$
* @return string|bool Depending on value of $return
*/
function print_scale_menu_helpbutton($courseid, $scale, $return=false) {
// debugging('print_scale_menu_helpbutton() has been deprecated. Please change your code to use $OUTPUT->help_button($scaleselect).');
// debugging('print_scale_menu_helpbutton() has been deprecated. Please change your code to use $OUTPUT->help_scale($courseid, $scale).');
global $OUTPUT;
$output = $OUTPUT->help_button(help_button::make_scale_menu($courseid, $scale));
$output = $OUTPUT->help_icon_scale($courseid, $scale);
if ($return) {
return $output;
@ -3451,17 +3503,15 @@ function print_heading_with_help($text, $helppage, $module='moodle', $icon=false
global $OUTPUT;
$helpicon = new moodle_help_icon();
$helpicon->page = $helppage;
$helpicon->text = $text;
$helpicon->module = $module;
// Extract the src from $icon if it exists
if (preg_match('/src="([^"]*)"/', $icon, $matches)) {
$icon = $matches[1];
$icon = moodle_url($icon);
} else {
$icon = '';
}
$output = $OUTPUT->heading_with_help($helpicon, $icon);
$output = $OUTPUT->heading_with_help($text, $helppage, $module, $icon);
if ($return) {
return $output;

View file

@ -76,18 +76,7 @@ class MoodleQuickForm_advcheckbox extends HTML_QuickForm_advcheckbox{
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* get html for help button

View file

@ -47,18 +47,7 @@ class MoodleQuickForm_button extends HTML_QuickForm_button
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* get html for help button

View file

@ -25,18 +25,7 @@ class MoodleQuickForm_checkbox extends HTML_QuickForm_checkbox{
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* get html for help button

View file

@ -25,18 +25,7 @@ class MoodleQuickForm_file extends HTML_QuickForm_file{
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* set html for help button

View file

@ -97,18 +97,7 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element {
}
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
function getHelpButton() {

View file

@ -36,18 +36,7 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
}
function setHelpButton($helpbuttonargs, $function='helpbutton') {
if (!is_array($helpbuttonargs)) {
$helpbuttonargs = array($helpbuttonargs);
} else {
$helpbuttonargs = $helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs = array('', '', 'moodle', true, false, '', true);
$helpbuttonargs = $helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
function getHelpButton() {

View file

@ -51,34 +51,6 @@ class MoodleQuickForm_format extends MoodleQuickForm_select{
}
} //end constructor
/**
* Add a single button.
*
* @param string $elementname name of the element to add the item to
* @param array $button arguments to pass to function $function
* @param boolean $suppresscheck whether to throw an error if the element
* doesn't exist.
* @param string $function - function to generate html from the arguments in $button
* @param string $function
*/
function setHelpButton($button, $function='helpbutton'){
global $OUTPUT;
//_elements has a numeric index, this code accesses the elements by name
$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;
}
$this->_helpbutton = $OUTPUT->help_icon($helpicon);
}
/**
* Called by HTML_QuickForm whenever form event is made on this element
*
@ -95,7 +67,7 @@ class MoodleQuickForm_format extends MoodleQuickForm_select{
case 'createElement':
$menu = format_text_menu();
$this->load($menu);
$this->setHelpButton(array('textformat', get_string('helpformatting')));
//$this->setHelpButton(array('textformat', get_string('helpformatting')));
break;
case 'updateValue' :
$value = $this->_findValue($caller->_constantValues);

View file

@ -30,21 +30,7 @@ class MoodleQuickForm_group extends HTML_QuickForm_group{
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
global $OUTPUT;
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ($function == 'helpbutton') {
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
$this->_helpbutton=$OUTPUT->help_icon(call_user_func_array('moodle_help_icon::make', $helpbuttonargs));
} else {
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
}
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* set html for help button

View file

@ -43,18 +43,7 @@ class MoodleQuickForm_header extends HTML_QuickForm_header
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* get html for help button

View file

@ -47,18 +47,7 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!$this->_canUseHtmlEditor){
if ('editorhelpbutton' == $function){
$key = array_search('richtext2', $helpbuttonargs);
if ($key !== FALSE){
array_splice($helpbuttonargs, $key, 1, array('text2', 'emoticons2'));
}
} elseif ('helpbutton' == $function && $helpbuttonargs[0] == 'richtext2' && ((!isset($helpbuttonargs[2])) || $helpbuttonargs[2] == 'moodle')){
//replace single 'richtext' help button with text and emoticon button when htmleditor off.
return $this->setHelpButton(array('text2', 'emoticons2'), 'editorhelpbutton');
}
}
return parent::setHelpButton($helpbuttonargs, $function);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
function toHtml(){

View file

@ -62,7 +62,8 @@ class MoodleQuickForm_modgrade extends MoodleQuickForm_select{
$grades[$i] = $i;
}
$this->load($grades);
$this->setHelpButton(array($COURSE->id), 'modgradehelpbutton');
//TODO: rewrite mod grading support in modforms
// $this->setHelpButton(array($COURSE->id), 'modgradehelpbutton');
return $result;
}
return parent::onQuickFormEvent($event, $arg, $caller);

View file

@ -25,18 +25,7 @@ class MoodleQuickForm_password extends HTML_QuickForm_password{
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* get html for help button

View file

@ -25,18 +25,7 @@ class MoodleQuickForm_radio extends HTML_QuickForm_radio{
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* get html for help button

View file

@ -7,7 +7,6 @@
* @category Admin
* @package admin
* @author Nicolas Connault <nicolasconnault@gmail.com>
* @version $Id$
*/
@ -96,18 +95,7 @@ class MoodleQuickForm_recaptcha extends HTML_QuickForm_input {
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**

View file

@ -57,21 +57,7 @@ class MoodleQuickForm_select extends HTML_QuickForm_select{
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
global $OUTPUT;
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
$this->_helpbutton=$OUTPUT->help_icon(call_user_func_array('moodle_help_icon::make', $helpbuttonargs));
} else {
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
}
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* get html for help button

View file

@ -570,18 +570,7 @@ class MoodleQuickForm_selectgroups extends HTML_QuickForm_element {
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* get html for help button

View file

@ -90,18 +90,7 @@ class MoodleQuickForm_selectwithlink extends HTML_QuickForm_select{
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* get html for help button

View file

@ -26,18 +26,7 @@ class MoodleQuickForm_static extends HTML_QuickForm_static{
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* get html for help button

View file

@ -58,18 +58,7 @@ class MoodleQuickForm_text extends HTML_QuickForm_text{
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* get html for help button

View file

@ -34,29 +34,7 @@ class MoodleQuickForm_textarea extends HTML_QuickForm_textarea{
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
global $SESSION;
if (!is_array($helpbuttonargs)) {
$helpbuttonargs = array($helpbuttonargs);
} else {
$helpbuttonargs = $helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs = array('', '', 'moodle', true, false, '', true);
$helpbuttonargs = $helpbuttonargs + $defaultargs ;
if (in_array($helpbuttonargs[0], array('emoticons2', 'text2', 'richtext2'))) {
$SESSION->inserttextform = $this->_formid;
$SESSION->inserttextfield = $this->getAttribute('name');
}
} else if ('editorhelpbutton' == $function) {
$specialhelp = array_intersect($helpbuttonargs, array('emoticons2', 'text2', 'richtext2'));
if (!empty($specialhelp)) {
$SESSION->inserttextform = $this->_formid;
$SESSION->inserttextfield = $this->getAttribute('name');
}
}
$this->_helpbutton = call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* get html for help button

View file

@ -95,18 +95,7 @@ EOD;
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
/**
* get html for help button

View file

@ -34,18 +34,7 @@ class MoodleQuickForm_warning extends HTML_QuickForm_static{
* @param string $function function name to call to get html
*/
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
}else{
$helpbuttonargs=$helpbuttonargs;
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
if ('helpbutton' == $function){
$defaultargs=array('', '', 'moodle', true, false, '', true);
$helpbuttonargs=$helpbuttonargs + $defaultargs ;
}
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
}
function toHtml() {

View file

@ -1334,26 +1334,26 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
* @param string $function - function to generate html from the arguments in $button
* @param string $function
*/
function setHelpButton($elementname, $button, $suppresscheck=false, $function='helpbutton'){
function setHelpButton($elementname, $buttonargs, $suppresscheck=false, $function='helpbutton'){
global $OUTPUT;
if (array_key_exists($elementname, $this->_elementIndex)){
if ($function !== 'helpbutton') {
debugging('parameter $function in moodle_form::setHelpButton() is not supported any more');
}
$buttonargs = (array)$buttonargs;
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]];
$buttonparams = array('page', 'text', 'module', 'image', 'linktext', 'text', 'return', 'imagetext');
$helpiconoptions = array('page' => null, 'text' => null, 'module' => 'moodle', 'image' => null, 'linktext' => false);
$element = $this->_elements[$this->_elementIndex[$elementname]];
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;
}
$page = isset($buttonargs[0]) ? $buttonargs[0] : null;
$text = isset($buttonargs[1]) ? $buttonargs[1] : null;
$module = isset($buttonargs[2]) ? $buttonargs[2] : 'moodle';
$linktext = isset($buttonargs[3]) ? $buttonargs[3] : false;
$element->_helpbutton = $OUTPUT->help_icon($helpicon);
}elseif (!$suppresscheck){
$element->_helpbutton = $OUTPUT->help_icon($page, $text, $module, $linktext);
} else if (!$suppresscheck) {
print_error('nonexistentformelements', 'form', '', $elementname);
}
}

View file

@ -385,7 +385,7 @@ class html_select extends labelled_html_component {
*/
public $form;
/**
* @var moodle_help_icon $form An optional moodle_help_icon component
* @var help_icon $array help icon params
*/
public $helpicon;
/**
@ -621,34 +621,21 @@ class html_select extends labelled_html_component {
/**
* Adds a help icon next to the select menu.
*
* This can be used in two ways:
*
* <pre>
* $select->set_help_icon($page, $text, $linktext);
* // OR
* $helpicon = new moodle_help_icon();
* $helpicon->page = $page;
* $helpicon->text = $text;
* $helpicon->linktext = $linktext;
* $select->set_help_icon($helpicon);
* $select->set_help_icon($page, $text, $component);
* </pre>
*
* Use the second form when you need to add additional HTML attributes
* to the label and/or JS actions.
*
* @param mixed $page Either the keyword that defines a help page or a moodle_help_icon object
* @param string $helppage Either the keyword that defines a help page or a help_icon object
* @param text $text The text of the help icon
* @param component $component
* @param boolean $linktext Whether or not to show text next to the icon
* @return void
*/
public function set_help_icon($page, $text, $linktext=false) {
if ($page instanceof moodle_help_icon) {
$this->helpicon = $page;
} else if (!empty($page)) {
$this->helpicon = new moodle_help_icon();
$this->helpicon->page = $page;
$this->helpicon->text = $text;
$this->helpicon->linktext = $linktext;
public function set_help_icon($helppage='', $text='', $component='moodle') {
if ($helppage) {
$this->helpicon = array('helppage'=>$helppage, 'text'=>$text, 'component'=>$component);
} else {
$this->helpicon = null;
}
}
@ -1292,10 +1279,10 @@ class html_link extends html_component {
// to be filled later
} else if ($url instanceof moodle_url) {
$this->src = clone($url);
$this->url = clone($url);
} else if (is_string($url)) {
$this->src = new moodle_url($url);
$this->url = new moodle_url($url);
} else {
throw new coding_style_exception('Image can be constructed only from moodle_url or string url.');
@ -1403,17 +1390,17 @@ class html_image extends labelled_html_component {
* @param moodle_url|string $url url of the image
* @param array $options image attributes such as title, id, alt, widht, height
*/
public function __construct($url = null, array $options = null) {
public function __construct($src = null, array $options = null) {
parent::__construct($options);
if (is_null($url)) {
if (is_null($src)) {
// to be filled later
} else if ($url instanceof moodle_url) {
$this->src = clone($url);
} else if ($src instanceof moodle_url) {
$this->src = clone($src);
} else if (is_string($url)) {
$this->src = new moodle_url($url);
} else if (is_string($src)) {
$this->src = new moodle_url($src);
} else {
throw new coding_style_exception('Image can be constructed only from moodle_url or string url.');
@ -1443,8 +1430,8 @@ class html_image extends labelled_html_component {
*
* @param mixed $url The URL to the image (string or moodle_url)
*/
public static function make($url) {
return new html_image($url);
public static function make($src) {
return new html_image($src);
}
}
@ -2027,11 +2014,11 @@ class user_picture extends html_image {
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
*/
class moodle_help_icon extends labelled_html_component {
class help_icon extends html_image {
public $page;
/**
* @var html_link $link A html_link object that will hold the URL info
* @var string $module Which module is the page defined in
*/
public $link;
/**
* @var string $text A descriptive text
*/
@ -2039,29 +2026,46 @@ class moodle_help_icon extends labelled_html_component {
/**
* @var string $page The keyword that defines a help page
*/
public $page;
/**
* @var string $module Which module is the page defined in
*/
public $module = 'moodle';
public $component = 'moodle';
/**
* @var boolean $linktext Whether or not to show text next to the icon
*/
public $linktext = false;
/**
* @var mixed $image The help icon. Can be set to true (will use default help icon),
* false (will not use any icon), the URL to an image, or a full
* html_image object.
* @var html_link $link A html_link object that will hold the URL info
*/
public $image;
public $link;
/**
* Constructor: sets up the other components in case they are needed
* @param string $page The keyword that defines a help page
* @param string $text A descriptive text
* @param string $component
* @param bool $linktext add extra text to icon
* @return void
*/
public function __construct() {
public function __construct($helppage, $text, $component='moodle', $linktext=false) {
global $CFG;
if (empty($helppage)) {
throw new coding_exception('A help_icon object requires a $helppage parameter');
}
if (empty($text)) {
throw new coding_exception('A help_icon object requires a $text parameter');
}
parent::__construct(null, array('class'=>'iconhelp'));
$this->helppage = $helppage;
$this->text = $text;
$this->component = $component;
$this->linktext = $linktext;
$this->link = new html_link();
$this->image = new html_image();
$this->link->url = new moodle_url($CFG->wwwroot.'/help.php', array('module' => $this->component, 'file' => $this->helppage .'.html'));
// Warn users about new window for Accessibility
}
/**
@ -2071,98 +2075,25 @@ class moodle_help_icon extends labelled_html_component {
public function prepare(renderer_base $output, moodle_page $page, $target) {
global $CFG;
if (empty($this->page)) {
throw new coding_exception('A moodle_help_icon object requires a $page parameter');
if (empty($this->link->title)) {
$this->link->title = get_string('helpprefix2', '', trim($this->text, ". \t")) .' ('.get_string('newwindow').')';
}
if (empty($this->text) && empty($this->link->text)) {
throw new coding_exception('A moodle_help_icon object (or its $link attribute) requires a $text parameter');
} else if (!empty($this->text) && empty($this->link->text)) {
$this->link->text = $this->text;
if (empty($this->src)) {
$this->src = $output->pix_url('help');
}
// fix for MDL-7734
$this->link->url = new moodle_url($CFG->wwwroot.'/help.php', array('module' => $this->module, 'file' => $this->page .'.html'));
// fix for MDL-7734
if (!empty($page->course->lang)) {
$this->link->url->param('forcelang', $page->course->lang);
}
// Catch references to the old text.html and emoticons.html help files that
// were renamed in MDL-13233.
if (in_array($this->page, array('text', 'emoticons', 'richtext'))) {
$oldname = $this->page;
$this->page .= '2';
debugging("You are referring to the old help file '$oldname'. " .
"This was renamed to '$this->page' because of MDL-13233. " .
"Please update your code.", DEBUG_DEVELOPER);
}
if ($this->module == '') {
$this->module = 'moodle';
}
// Warn users about new window for Accessibility
$this->title = get_string('helpprefix2', '', trim($this->text, ". \t")) .' ('.get_string('newwindow').')';
// Prepare image and linktext
if ($this->image && !($this->image instanceof html_image)) {
$image = fullclone($this->image);
$this->image = new html_image();
if ($image instanceof moodle_url) {
$this->image->src = $image->out();
} else if ($image === true) {
$this->image->src = $output->pix_url('help');
} else if (is_string($image)) {
$this->image->src = $image;
}
if ($this->linktext) {
$this->image->alt = get_string('helpwiththis');
} else {
$this->image->alt = $this->text;
if ($this->linktext) {
$this->image->alt = get_string('helpwiththis');
} else {
$this->image->alt = $this->title;
}
$this->image->add_class('iconhelp');
} else if (empty($this->image->src)) {
if (!($this->image instanceof html_image)) {
$this->image = new html_image();
}
$this->image->src = $output->pix_url('help');
}
$popup = new popup_action('click', $this->link->url);
$this->link->add_action($popup);
parent::prepare($output, $page, $target);
}
/**
* This is a shortcut for creating a help_icon with only the 2 required params
* @param string $page The keyword that defines a help page
* @param string $text A descriptive text
* @return moodle_help_icon A moodle_help_icon object with the two common fields initialised.
*/
public static function make($page, $text, $module='moodle', $linktext=false) {
$helpicon = new moodle_help_icon();
$helpicon->page = $page;
$helpicon->text = $text;
$helpicon->module = $module;
$helpicon->linktext = $linktext;
return $helpicon;
}
public static function make_scale_menu($courseid, $scale) {
$helpbutton = new moodle_help_icon();
$strscales = get_string('scales');
$helpbutton->image->alt = $scale->name;
$helpbutton->link->url = new moodle_url('/course/scales.php', array('id' => $courseid, 'list' => true, 'scaleid' => $scale->id));
$popupaction = new popup_action('click', $helpbutton->url, 'ratingscale', $popupparams);
$popupaction->width = 500;
$popupaction->height = 400;
$helpbutton->link->add_action($popupaction);
$helpbutton->link->title = $scale->name;
return $helpbutton;
}
}

View file

@ -459,13 +459,13 @@ class core_renderer extends renderer_base {
*/
public function login_info() {
global $USER, $CFG, $DB;
if (during_initial_install()) {
return '';
}
$course = $this->page->course;
if (session_is_loggedinas()) {
$realuser = session_get_realuser();
$fullname = fullname($realuser, true);
@ -474,15 +474,15 @@ class core_renderer extends renderer_base {
} else {
$realuserinfo = '';
}
$loginurl = get_login_url();
if (empty($course->id)) {
// $course->id is not defined during installation
return '';
} else if (!empty($USER->id)) {
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$fullname = fullname($USER, true);
$username = "<a $CFG->frametarget href=\"$CFG->wwwroot/user/view.php?id=$USER->id&amp;course=$course->id\">$fullname</a>";
if (is_mnet_remote_user($USER) and $idprovider = $DB->get_record('mnet_host', array('id'=>$USER->mnethostid))) {
@ -507,9 +507,9 @@ class core_renderer extends renderer_base {
$loggedinas = get_string('loggedinnot', 'moodle').
" (<a $CFG->frametarget href=\"$loginurl\">".get_string('login').'</a>)';
}
$loggedinas = '<div class="logininfo">'.$loggedinas.'</div>';
if (isset($SESSION->justloggedin)) {
unset($SESSION->justloggedin);
if (!empty($CFG->displayloginfailures)) {
@ -530,7 +530,7 @@ class core_renderer extends renderer_base {
}
}
}
return $loggedinas;
}
@ -758,7 +758,7 @@ class core_renderer extends renderer_base {
$currlang = current_language();
$langs = get_list_of_languages();
if (count($langs) < 2) {
return '';
}
@ -1145,89 +1145,70 @@ class core_renderer extends renderer_base {
/*
* Centered heading with attached help button (same title text)
* and optional icon attached
* @param moodle_help_icon $helpicon A moodle_help_icon object
* @param mixed $image An image URL or a html_image object
* @param string $text A heading text
* @param string $page The keyword that defines a help page
* @param string $component component name
* @param string|moodle_url $icon
* @param string $iconalt icon alt text
* @return string HTML fragment
*/
public function heading_with_help($helpicon, $image=false) {
if (!($image instanceof html_image) && !empty($image)) {
$htmlimage = new html_image();
$htmlimage->src = $image;
$image = $htmlimage;
public function heading_with_help($text, $helppage, $component='moodle', $icon='', $iconalt='') {
$image = '';
if ($icon) {
if ($icon instanceof moodle_url) {
$image = $this->image($icon, array('class'=>'icon', 'alt'=>$iconalt));
} else {
$image = $this->image($this->pix_url($icon, $component), array('class'=>'icon', 'alt'=>$iconalt));
}
}
return $this->container($this->image($image) . $this->heading($helpicon->text, 2, 'main help') . $this->help_icon($helpicon), 'heading-with-help');
$help = $this->help_icon($helppage, $text, $component);
return $this->heading($image.$text.$help, 2, 'main help');
}
/**
* Print a help icon.
*
* @param moodle_help_icon $helpicon A moodle_help_icon object, subclass of html_link
*
* @param string $page The keyword that defines a help page
* @param string $text A descriptive text
* @param string $component component name
* @param bool $linktext show extra descriptive text
* @return string HTML fragment
*/
public function help_icon($icon) {
global $COURSE;
$icon = clone($icon);
public function help_icon($helppage, $text=null, $component='moodle', $linktext=false) {
$icon = new help_icon($helppage, $text, $component, $linktext);
$icon->prepare($this, $this->page, $this->target);
$popup = new popup_action('click', $icon->link->url);
$icon->link->add_action($popup);
$image = null;
if (!empty($icon->image)) {
$image = $icon->image;
$image->add_class('iconhelp');
$icon->link->text = $this->image($icon);
if ($icon->linktext) {
$icon->link->text .= $icon->text;
}
return $this->output_tag('span', array('class' => 'helplink'), $this->link_to_popup($icon->link, $image));
return $this->output_tag('span', array('class' => 'helplink'), $this->link($icon->link));
}
/**
* Creates and returns a button to a popup window
* Print scale help icon.
*
* @param html_link $link Subclass of html_component
* @param moodle_popup $popup A moodle_popup object
* @param html_image $image An optional image replacing the link text
*
* @return string HTML fragment
* @param int $courseid
* @param object $scale instance
* @return string HTML fragment
*/
public function link_to_popup($link, $image=null) {
//TODO: decide if this should be removed completely, because link() already handles this
// we could also add html_link::make_popup() factory method
$link = clone($link);
public function help_icon_scale($courseid, stdClass $scale) {
global $CFG;
// Use image if one is given
if (!empty($image) && $image instanceof html_image) {
$title = get_string('helpprefix2', '', $scale->name) .' ('.get_string('newwindow').')';
if (empty($image->alt) || $image->alt == HTML_ATTR_EMPTY) {
$image->alt = $link->text;
$image->title = $link->text;
}
$icon = $this->image($this->pix_url('help'), array('class'=>'iconhelp', 'alt'=>get_string('scales')));
$link->text = $this->image($image);
$link = new html_link(new moodle_url($CFG->wwwroot.'/course/scales.php', array('id' => $courseid, 'list' => true, 'scaleid' => $scale->id)), $icon);
$popupaction = new popup_action('click', $link->url, 'ratingscale');
$link->add_action($popupaction);
if (!empty($link->linktext)) { // TODO: this is weird!
$link->text = "$link->title &#160; $link->text";
}
}
$link->prepare($this, $this->page, $this->target);
$this->prepare_event_handlers($link);
if (empty($link->url)) {
throw new coding_exception('Called $OUTPUT->link_to_popup($link) method without $link->url set.');
}
$linkurl = prepare_url($link->url);
$tagoptions = array(
'title' => $link->title,
'id' => $link->id,
'href' => ($linkurl) ? $linkurl : prepare_url($popup->url),
'class' => $link->get_classes_string());
return $this->output_tag('a', $tagoptions, $link->text);
return $this->output_tag('span', array('class' => 'helplink'), $this->link($link));
}
/**
@ -1499,7 +1480,7 @@ class core_renderer extends renderer_base {
* html_select::set_label($label) passing a html_label object
*
* To add a help icon, use html_select::set_help($page, $text, $linktext) or
* html_select::set_help($helpicon) passing a moodle_help_icon object
* html_select::set_help($helpicon) passing a help_icon object
*
* If you html_select::$rendertype to "radio", it will render radio buttons
* instead of a <select> menu, unless $multiple is true, in which case it
@ -1558,8 +1539,8 @@ class core_renderer extends renderer_base {
$html .= $this->label($select->label);
}
if (!empty($select->helpicon) && $select->helpicon instanceof moodle_help_icon) {
$html .= $this->help_icon($select->helpicon);
if ($select->helpicon) {
$html .= $this->help_icon($select->helpicon['helppage'], $select->helpicon['text'], $select->helpicon['component']);
}
if ($select->rendertype == 'menu') {

View file

@ -890,7 +890,7 @@ class core_renderer_test extends UnitTestCase {
}
public function test_heading_with_help() {
$originalicon = new moodle_help_icon();
$originalicon = new help_icon();
$originalicon->page = 'myhelppage';
$originalicon->text = 'Cool help text';

View file

@ -920,7 +920,7 @@ class flexible_table {
$select = html_select::make($downloadoptions, 'download', $this->defaultdownloadformat, false);
$select->nothingvalue = '';
$html .= $OUTPUT->select($select);
$html .= $OUTPUT->help_icon(moodle_help_icon::make('tableexportformats', get_string('tableexportformats', 'table')));
$html .= $OUTPUT->help_icon('tableexportformats', get_string('tableexportformats', 'table'));
$html .= '</div></form>';
return $html;

View file

@ -2401,127 +2401,6 @@ function mdie($msg='', $errorcode=1) {
exit($errorcode);
}
/**
* Returns a string of html with an image of a help icon linked to a help page on a number of help topics.
* Should be used only with htmleditor or textarea.
*
* @global object
* @global object
* @param mixed $helptopics variable amount of params accepted. Each param may be a string or an array of arguments for
* helpbutton.
* @return string Link to help button
*/
function editorhelpbutton(){
global $CFG, $SESSION, $OUTPUT;
$items = func_get_args();
$i = 1;
$urlparams = array();
$titles = array();
foreach ($items as $item){
if (is_array($item)){
$urlparams[] = "keyword$i=".urlencode($item[0]);
$urlparams[] = "title$i=".urlencode($item[1]);
if (isset($item[2])){
$urlparams[] = "module$i=".urlencode($item[2]);
}
$titles[] = trim($item[1], ". \t");
} else if (is_string($item)) {
$urlparams[] = "button$i=".urlencode($item);
switch ($item) {
case 'reading' :
$titles[] = get_string("helpreading");
break;
case 'writing' :
$titles[] = get_string("helpwriting");
break;
case 'questions' :
$titles[] = get_string("helpquestions");
break;
case 'emoticons2' :
$titles[] = get_string("helpemoticons");
break;
case 'richtext2' :
$titles[] = get_string('helprichtext');
break;
case 'text2' :
$titles[] = get_string('helptext');
break;
default :
print_error('unknownhelp', '', '', $item);
}
}
$i++;
}
if (count($titles)>1){
//join last two items with an 'and'
$a = new object();
$a->one = $titles[count($titles) - 2];
$a->two = $titles[count($titles) - 1];
$titles[count($titles) - 2] = get_string('and', '', $a);
unset($titles[count($titles) - 1]);
}
$alttag = join (', ', $titles);
$paramstring = join('&', $urlparams);
$linkobject = '<img alt="'.$alttag.'" class="iconhelp" src="'.$OUTPUT->pix_url('help') . '" />';
$link = html_link::make(s('/lib/form/editorhelp.php?'.$paramstring), $linkobject);
$link->add_action(new popup_action('click', $link->url, 'popup', array('height' => 400, 'width' => 500)));
$link->title = $alttag;
return $OUTPUT->link($link);
}
/**
* Print a help button.
*
* Prints a special help button that is a link to the "live" emoticon popup
*
* @todo Finish documenting this function
*
* @global object
* @global object
* @param string $form ?
* @param string $field ?
* @param boolean $return If true then the output is returned as a string, if false it is printed to the current page.
* @return string|void Depending on value of $return
*/
function emoticonhelpbutton($form, $field, $return = false) {
global $SESSION, $OUTPUT;
$SESSION->inserttextform = $form;
$SESSION->inserttextfield = $field;
$helpicon = moodle_help_icon::make('emoticons2', get_string('helpemoticons'), 'moodle', true);
$helpicon->image->src = $OUTPUT->pix_url('s/smiley');
$helpicon->image->add_class('emoticon');
$helpicon->style = "margin-left:3px; padding-right:1px;width:15px;height:15px;";
$help = $OUTPUT->help_icon($helpicon);
if (!$return){
echo $help;
} else {
return $help;
}
}
/**
* Print a help button.
*
* Prints a special help button for html editors (htmlarea in this case)
*
* @todo Write code into this function! detect current editor and print correct info
* @global object
* @return string Only returns an empty string at the moment
*/
function editorshortcutshelpbutton() {
global $CFG;
//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 '';
}
/**
* Returns html code to be used as help icon of modgrade form element
*