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

@ -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() {