From: jamiesensei
Date: Thu, 4 Jan 2007 10:23:06 +0000 (+0000)
Subject: some bug fixes in setHelpButton internals.
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5ce73257ab81f55a1e008db53fe2557190fcea76;p=moodle.git
some bug fixes in setHelpButton internals.
added new editorhelpbutton function that can be used to refer to several help topics.
---
diff --git a/lang/en_utf8/moodle.php b/lang/en_utf8/moodle.php
index 0b1aea5453..6d77db4d58 100644
--- a/lang/en_utf8/moodle.php
+++ b/lang/en_utf8/moodle.php
@@ -108,6 +108,7 @@ $string['alphabet'] = 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z';
$string['alphanumerical'] = 'Can only contain alphabetical letters or numbers';
$string['alreadyconfirmed'] = 'Registration has already been confirmed';
$string['always'] = 'Always';
+$string['and'] = '$a->one and $a->two';
$string['answer'] = 'Answer';
$string['approve'] = 'Approve';
$string['areyousuretorestorethis'] = 'Do you want to continue?';
@@ -403,6 +404,7 @@ $string['editordefaultfont'] = 'Default font';
$string['editorenablespelling'] = 'Enable spellchecking';
$string['editorfontlist'] = 'Fontlist';
$string['editorfontsize'] = 'Default font-size';
+$string['editorhelptopics'] = 'Editor Help Topics.';
$string['editorresettodefaults'] = 'Reset to default values';
$string['editorsettings'] = 'Editor settings';
$string['editorshortcutkeys'] = 'Editor shortcut keys';
diff --git a/lib/form/button.php b/lib/form/button.php
index 514c687116..a58f8d079a 100644
--- a/lib/form/button.php
+++ b/lib/form/button.php
@@ -53,8 +53,10 @@ class MoodleQuickForm_button extends HTML_QuickForm_button
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
- $defaultargs=array('', '', 'moodle', true, false, '', true);
- $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ if ('helpbutton' == $function){
+ $defaultargs=array('', '', 'moodle', true, false, '', true);
+ $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ }
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
}
/**
diff --git a/lib/form/checkbox.php b/lib/form/checkbox.php
index f1eaaa4bd8..6308f4ab2b 100644
--- a/lib/form/checkbox.php
+++ b/lib/form/checkbox.php
@@ -29,8 +29,10 @@ class MoodleQuickForm_checkbox extends HTML_QuickForm_checkbox{
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
- $defaultargs=array('', '', 'moodle', true, false, '', true);
- $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ if ('helpbutton' == $function){
+ $defaultargs=array('', '', 'moodle', true, false, '', true);
+ $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ }
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
}
/**
diff --git a/lib/form/editorhelp.php b/lib/form/editorhelp.php
new file mode 100644
index 0000000000..9a574b60ca
--- /dev/null
+++ b/lib/form/editorhelp.php
@@ -0,0 +1,71 @@
+';
+foreach ($topics as $i => $topic){
+ echo(''.$topics[$i].'');
+}
+echo '';
+print_simple_box_end();
+// End of page.
+close_window_button();
+echo ''. get_string('helpindex') .'
';
+
+$CFG->docroot = ''; // We don't want a doc link here
+print_footer('none');
+die;
+/**
+ * A function to return a simple link to a help page. We don't want a popup here
+ * since these links are displayed in a pop up already.
+ *
+ * @param string $page
+ * @param string $linktext
+ * @param string $module
+ * @return string
+ */
+function helplink($page, $linktext='', $module='moodle'){
+ global $CFG;
+ return "wwwroot/help.php?module=$module&file=$page.html\">$linktext";
+}
+
+?>
\ No newline at end of file
diff --git a/lib/form/file.php b/lib/form/file.php
index 8790c22487..8c18830c6c 100644
--- a/lib/form/file.php
+++ b/lib/form/file.php
@@ -29,8 +29,10 @@ class MoodleQuickForm_file extends HTML_QuickForm_file{
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
- $defaultargs=array('', '', 'moodle', true, false, '', true);
- $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ if ('helpbutton' == $function){
+ $defaultargs=array('', '', 'moodle', true, false, '', true);
+ $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ }
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
}
/**
@@ -56,6 +58,6 @@ class MoodleQuickForm_file extends HTML_QuickForm_file{
}
return parent::onQuickFormEvent($event, $arg, $caller);
} // end func onQuickFormEvent
-
+
}
?>
\ No newline at end of file
diff --git a/lib/form/group.php b/lib/form/group.php
index 714bdddca4..af8be99528 100644
--- a/lib/form/group.php
+++ b/lib/form/group.php
@@ -35,8 +35,10 @@ class MoodleQuickForm_group extends HTML_QuickForm_group{
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
- $defaultargs=array('', '', 'moodle', true, false, '', true);
- $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ if ('helpbutton' == $function){
+ $defaultargs=array('', '', 'moodle', true, false, '', true);
+ $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ }
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
}
/**
diff --git a/lib/form/header.php b/lib/form/header.php
index d7ef023bc6..b2f6b7e408 100644
--- a/lib/form/header.php
+++ b/lib/form/header.php
@@ -47,8 +47,10 @@ class MoodleQuickForm_header extends HTML_QuickForm_header
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
- $defaultargs=array('', '', 'moodle', true, false, '', true);
- $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ if ('helpbutton' == $function){
+ $defaultargs=array('', '', 'moodle', true, false, '', true);
+ $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ }
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
}
/**
diff --git a/lib/form/htmleditor.php b/lib/form/htmleditor.php
index 5d5e2f7f4c..88fdf8f2dc 100644
--- a/lib/form/htmleditor.php
+++ b/lib/form/htmleditor.php
@@ -4,7 +4,7 @@ require_once("$CFG->libdir/form/textarea.php");
/**
* HTML class for htmleditor type element
- *
+ *
* @author Jamie Pratt
* @access public
*/
@@ -12,7 +12,7 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
var $_type;
var $_elementTemplateType='default';
var $_canUseHtmlEditor;
- var $_options=array('canUseHtmlEditor'=>'detect','rows'=>10, 'cols'=>65, 'width'=>0,'height'=>0, 'course'=>0);
+ var $_options=array('canUseHtmlEditor'=>'detect','rows'=>10, 'cols'=>45, 'width'=>0,'height'=>0, 'course'=>0);
function MoodleQuickForm_htmleditor($elementName=null, $elementLabel=null, $options=array(), $attributes=null){
parent::MoodleQuickForm_textarea($elementName, $elementLabel, $attributes);
// set the options, do not bother setting bogus ones
@@ -36,12 +36,31 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
}else{
$this->_type='textarea';
}
+ $this->_canUseHtmlEditor = $this->_options['canUseHtmlEditor'];
+ }
+ /**
+ * set html for help button
+ *
+ * @access public
+ * @param array $help array of arguments to make a help button
+ * @param string $function function name to call to get html
+ */
+ function setHelpButton($helpbuttonargs, $function='helpbutton'){
+ if (!$this->_canUseHtmlEditor){
+ if ('editorhelpbutton' == $function){
+ $key = array_search('richtext', $helpbuttonargs);
+ if ($key !== FALSE){
+ $helpbuttonargs[$key]='emoticons';
+ }
+ }
+ }
+ return parent::setHelpButton($helpbuttonargs, $function);
}
function getElementTemplateType(){
return $this->_elementTemplateType;
}
function toHtml(){
- if ($this->_options['canUseHtmlEditor'] && !$this->_flagFrozen){
+ if ($this->_canUseHtmlEditor && !$this->_flagFrozen){
ob_start();
use_html_editor($this->getName(), '', $this->getAttribute('id'));
$script=ob_get_clean();
@@ -52,7 +71,7 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
return $this->getFrozenHtml();
} else {
return $this->_getTabs() .
- print_textarea($this->_options['canUseHtmlEditor'],
+ print_textarea($this->_canUseHtmlEditor,
$this->_options['rows'],
$this->_options['cols'],
$this->_options['width'],
diff --git a/lib/form/password.php b/lib/form/password.php
index 183221d6f1..9c0cc08aff 100644
--- a/lib/form/password.php
+++ b/lib/form/password.php
@@ -29,8 +29,10 @@ class MoodleQuickForm_password extends HTML_QuickForm_password{
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
- $defaultargs=array('', '', 'moodle', true, false, '', true);
- $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ if ('helpbutton' == $function){
+ $defaultargs=array('', '', 'moodle', true, false, '', true);
+ $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ }
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
}
/**
diff --git a/lib/form/radio.php b/lib/form/radio.php
index f80244a232..2fb2cb5798 100644
--- a/lib/form/radio.php
+++ b/lib/form/radio.php
@@ -29,8 +29,10 @@ class MoodleQuickForm_radio extends HTML_QuickForm_radio{
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
- $defaultargs=array('', '', 'moodle', true, false, '', true);
- $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ if ('helpbutton' == $function){
+ $defaultargs=array('', '', 'moodle', true, false, '', true);
+ $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ }
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
}
/**
diff --git a/lib/form/select.php b/lib/form/select.php
index 245fa338a2..d4f3df8ac6 100644
--- a/lib/form/select.php
+++ b/lib/form/select.php
@@ -60,8 +60,10 @@ class MoodleQuickForm_select extends HTML_QuickForm_select{
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
- $defaultargs=array('', '', 'moodle', true, false, '', true);
- $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ if ('helpbutton' == $function){
+ $defaultargs=array('', '', 'moodle', true, false, '', true);
+ $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ }
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
}
/**
diff --git a/lib/form/static.php b/lib/form/static.php
index acc5e0bd09..dc0a05baf8 100644
--- a/lib/form/static.php
+++ b/lib/form/static.php
@@ -29,8 +29,10 @@ class MoodleQuickForm_static extends HTML_QuickForm_static{
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
- $defaultargs=array('', '', 'moodle', true, false, '', true);
- $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ if ('helpbutton' == $function){
+ $defaultargs=array('', '', 'moodle', true, false, '', true);
+ $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ }
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
}
/**
diff --git a/lib/form/text.php b/lib/form/text.php
index c517d1a111..dc9e0db5ba 100644
--- a/lib/form/text.php
+++ b/lib/form/text.php
@@ -60,8 +60,10 @@ class MoodleQuickForm_text extends HTML_QuickForm_text{
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
- $defaultargs=array('', '', 'moodle', true, false, '', true);
- $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ if ('helpbutton' == $function){
+ $defaultargs=array('', '', 'moodle', true, false, '', true);
+ $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ }
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
}
/**
diff --git a/lib/form/textarea.php b/lib/form/textarea.php
index ebd04cf3e5..597cb328bd 100644
--- a/lib/form/textarea.php
+++ b/lib/form/textarea.php
@@ -8,6 +8,12 @@ require_once('HTML/QuickForm/textarea.php');
* @access public
*/
class MoodleQuickForm_textarea extends HTML_QuickForm_textarea{
+ /**
+ * Need to store id of form as we may need it for helpbutton
+ *
+ * @var string
+ */
+ var $_formid = '';
/**
* html for help button, if empty then no help
*
@@ -29,8 +35,15 @@ class MoodleQuickForm_textarea extends HTML_QuickForm_textarea{
}
//we do this to to return html instead of printing it
//without having to specify it in every call to make a button.
- $defaultargs=array('', '', 'moodle', true, false, '', true);
- $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ if ('helpbutton' == $function){
+ $defaultargs=array('', '', 'moodle', true, false, '', true);
+ $helpbuttonargs=$helpbuttonargs + $defaultargs ;
+ } elseif ('editorhelpbutton' == $function){
+ if (in_array('emoticons', $helpbuttonargs)){
+ $SESSION->inserttextform = $this->_formid;
+ $SESSION->inserttextfield = 'id_'.$this->getAttribute('id');
+ }
+ }
$this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
}
/**
@@ -42,5 +55,24 @@ class MoodleQuickForm_textarea extends HTML_QuickForm_textarea{
function getHelpButton(){
return $this->_helpbutton;
}
+ /**
+ * Called by HTML_QuickForm whenever form event is made on this element
+ *
+ * @param string $event Name of event
+ * @param mixed $arg event arguments
+ * @param object $caller calling object
+ * @since 1.0
+ * @access public
+ * @return void
+ */
+ function onQuickFormEvent($event, $arg, &$caller)
+ {
+ switch ($event) {
+ case 'createElement':
+ $this->_formid = $caller->getAttribute('id');
+ break;
+ }
+ return parent::onQuickFormEvent($event, $arg, $caller);
+ } // end func onQuickFormEvent
}
?>
\ No newline at end of file
diff --git a/lib/weblib.php b/lib/weblib.php
index 7be801e0bd..378cf3ff80 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -137,8 +137,8 @@ function p($var, $strip=false) {
/**
* Does proper javascript quoting.
- * Do not use addslashes anymore, because it does not work when magic_quotes_sybase is enabled.
- *
+ * Do not use addslashes anymore, because it does not work when magic_quotes_sybase is enabled.
+ *
* @param mixed value
* @return mixed quoted result
*/
@@ -184,7 +184,7 @@ function get_referer() {
if (isset($_SERVER['HTTP_REFERER'])) {
return strip_querystring($_SERVER['HTTP_REFERER']);
} else {
- return '';
+ return '';
}
}
@@ -1368,14 +1368,14 @@ function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL
if ($oldcacheitem) { // See bug 4677 for discussion
$newcacheitem->id = $oldcacheitem->id;
@update_record('cache_text', $newcacheitem); // Update existing record in the cache table
- // It's unlikely that the cron cache cleaner could have
+ // It's unlikely that the cron cache cleaner could have
// deleted this entry in the meantime, as it allows
// some extra time to cover these cases.
} else {
@insert_record('cache_text', $newcacheitem); // Insert a new record in the cache table
// Again, it's possible that another user has caused this
- // record to be created already in the time that it took
- // to traverse this function. That's OK too, as the
+ // record to be created already in the time that it took
+ // to traverse this function. That's OK too, as the
// call above handles duplicate entries, and eventually
// the cron cleaner will delete them.
}
@@ -1556,14 +1556,14 @@ function trusttext_present($text) {
* Please be carefull not to use stripslashes on data from database
* or twice stripslashes when processing data recieved from user.
*
- * @param string $text text that may contain TRUSTTEXT marker
+ * @param string $text text that may contain TRUSTTEXT marker
* @return text without any TRUSTTEXT marker
*/
function trusttext_strip($text) {
global $CFG;
while (true) { //removing nested TRUSTTEXT
- $orig = $text;
+ $orig = $text;
$text = str_replace(TRUSTTEXT, '', $text);
if (strcmp($orig, $text) === 0) {
return $text;
@@ -2154,7 +2154,7 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
}
@header('Accept-Ranges: none');
- if (empty($usexml)) {
+ if (empty($usexml)) {
$direction = ' xmlns="http://www.w3.org/1999/xhtml"'. $direction; // See debug_header
} else {
$currentlanguage = current_language();
@@ -2245,7 +2245,7 @@ function force_strict_header($output) {
$ctype = 'Content-Type: ';
$prolog= "\n";
- if (isset($_SERVER['HTTP_ACCEPT'])
+ if (isset($_SERVER['HTTP_ACCEPT'])
&& false !== strpos($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml')) {
//|| false !== strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') //Safari "Entity 'copy' not defined".
// Firefox et al.
@@ -2302,7 +2302,7 @@ function force_strict_header($output) {
function print_header_simple($title='', $heading='', $navigation='', $focus='', $meta='',
$cache=true, $button=' ', $menu='', $usexml=false, $bodytags='', $return=false) {
- global $COURSE, $CFG;
+ global $COURSE, $CFG;
$shortname ='';
if ($COURSE->id != SITEID) {
@@ -2690,7 +2690,7 @@ function user_login_string($course=NULL, $user=NULL) {
if (empty($course->id)) {
// $course->id is not defined during installation
return '';
- } else if (isset($user->id) and $user->id) {
+ } else if (isset($user->id) and $user->id) {
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$fullname = fullname($user, true);
@@ -2725,13 +2725,13 @@ function user_login_string($course=NULL, $user=NULL) {
* If not it applies sensible defaults.
*
* Accessibility: right and left arrow Unicode characters for breadcrumb, calendar,
- * search forum block, etc. Important: these are 'silent' in a screen-reader
+ * search forum block, etc. Important: these are 'silent' in a screen-reader
* (unlike > »), and must be accompanied by text.
* @uses $THEME
*/
function check_theme_arrows() {
global $THEME;
-
+
if (!isset($THEME->rarrow) and !isset($THEME->larrow)) {
// Default, looks good in Win XP/IE 6, Win/Firefox 1.5, Win/Netscape 8...
// Also OK in Win 9x/2K/IE 5.x
@@ -2771,7 +2771,7 @@ function check_theme_arrows() {
function print_navigation ($navigation, $separator=0, $return=false) {
global $CFG, $THEME;
$output = '';
-
+
check_theme_arrows();
if (0 === $separator) {
$separator = $THEME->rarrow;
@@ -2796,7 +2796,7 @@ function print_navigation ($navigation, $separator=0, $return=false) {
$navigation = "$separator ". str_replace('->', "\n$separator", $navigation) ."\n";
$output .= ''. $site->shortname ."\n". $navigation;
- $output .= "\n";
+ $output .= "\n";
}
if ($return) {
@@ -2916,7 +2916,7 @@ function print_continue($link, $return=false) {
* See, {@link print_simple_box_start}.
*
* @param string $align string, alignment of the box, not the text (default center, left, right).
- * @param string $width string, width of the box, including units %, for example '100%'.
+ * @param string $width string, width of the box, including units %, for example '100%'.
* @param string $color string, background colour of the box, for example '#eee'.
* @param int $padding integer, padding in pixels, specified without units.
* @param string $class string, space-separated class names.
@@ -3138,7 +3138,7 @@ function print_user_picture($userid, $courseid, $picture, $size=0, $return=false
$imagealt = $user->imagealt;
} else {
$imagealt = get_string('pictureof','',fullname($user));
- }
+ }
}
$output .= "
editorsrc) ) { // for backward compatibility.
if (empty($courseid)) {
if (!empty($course->id)) { // search for it in global context
@@ -3684,7 +3684,7 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
if ($usehtmleditor) {
if (!empty($courseid) and has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $courseid))) {
- // needed for course file area browsing in image insert plugin
+ // needed for course file area browsing in image insert plugin
$str .= ($scriptcount < 1) ? ''."\n" : '';
} else {
@@ -3714,7 +3714,7 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
$str .= s($value);
}
$str .= ''."\n";
-
+
if ($usehtmleditor) {
$str .= editorshortcutshelpbutton();
}
@@ -3770,9 +3770,9 @@ function use_html_editor($name='', $editorhidebuttons='', $id='') {
function print_editor_config($editorhidebuttons='', $return=false) {
global $CFG;
-
+
$str = "config.pageStyle = \"body {";
-
+
if (!(empty($CFG->editorbackgroundcolor))) {
$str .= " background-color: $CFG->editorbackgroundcolor;";
}
@@ -3790,7 +3790,7 @@ function print_editor_config($editorhidebuttons='', $return=false) {
$str .= (empty($CFG->editorkillword)) ? "false":"true";
$str .= ';'."\n";
$str .= 'config.fontname = {'."\n";
-
+
$fontlist = isset($CFG->editorfontlist) ? explode(';', $CFG->editorfontlist) : array();
$i = 1; // Counter is used to get rid of the last comma.
@@ -3816,7 +3816,7 @@ function print_editor_config($editorhidebuttons='', $return=false) {
if (!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) {
$str .= print_speller_code($usehtmleditor=true, true);
}
-
+
if ($return) {
return $str;
}
@@ -3881,7 +3881,7 @@ function switchroles_form($courseid) {
if (!$roles = get_assignable_roles($context)) {
return ''; // Nothing to show!
}
- return popup_form($CFG->wwwroot.'/course/view.php?id='.$courseid.'&sesskey='.sesskey().'&switchrole=',
+ return popup_form($CFG->wwwroot.'/course/view.php?id='.$courseid.'&sesskey='.sesskey().'&switchrole=',
$roles, 'switchrole', '', get_string('switchroleto'), 'switchrole', '', true);
} else {
return '';
@@ -3892,7 +3892,7 @@ function switchroles_form($courseid) {
$options['sesskey'] = sesskey();
$options['switchrole'] = 0;
- return print_single_button($CFG->wwwroot.'/course/view.php', $options,
+ return print_single_button($CFG->wwwroot.'/course/view.php', $options,
get_string('switchrolereturn'), 'post', '_self', true);
}
}
@@ -4235,7 +4235,7 @@ function navmenu($course, $cm=NULL, $targetwindow='self') {
if ($mod->section > 0 and $section <> $mod->section) {
$thissection = $sections[$mod->section];
- if ($thissection->visible or !$course->hiddensections or
+ if ($thissection->visible or !$course->hiddensections or
has_capability('moodle/course:viewhiddensections', $context)) {
$thissection->summary = strip_tags(format_string($thissection->summary,true));
if ($course->format == 'weeks' or empty($thissection->summary)) {
@@ -4253,7 +4253,7 @@ function navmenu($course, $cm=NULL, $targetwindow='self') {
$section = $mod->section;
//Only add visible or teacher mods to jumpmenu
- if ($mod->visible or has_capability('moodle/course:viewhiddenactivities',
+ if ($mod->visible or has_capability('moodle/course:viewhiddenactivities',
get_context_instance(CONTEXT_MODULE, $mod->cm))) {
$url = $mod->mod .'/view.php?id='. $mod->cm;
if ($flag) { // the current mod is the "next" mod
@@ -4297,14 +4297,14 @@ function navmenu($course, $cm=NULL, $targetwindow='self') {
'
';
}
- if ($backmod) {
+ if ($backmod) {
$backtext= get_string('activityprev', 'access');
$backmod = '';
}
- if ($nextmod) {
+ if ($nextmod) {
$nexttext= get_string('activitynext', 'access');
$nextmod = '
';
error($message, $link);
}
+function editorhelpbutton(){
+ global $CFG, $SESSION;
+ $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");
+ }elseif (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 'emoticons' :
+ $SESSION->inserttextform = 'mod-forum-post';
+ $SESSION->inserttextfield = 'message';
+ $titles[] = get_string("helpemoticons");
+ break;
+ case 'richtext' :
+ $titles[] = get_string("helprichtext");
+ break;
+ default :
+ error('Unknown help topic '.$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 = '
';
+ return link_to_popup_window(s("/lib/form/editorhelp.php?".$paramstring), $alttag, $linkobject, 400, 500, $alttag, 'none', true);
+}
+/* $helptext = '- ';
+ $helptext .= helpbutton("reading", get_string("helpreading"), "moodle", true, false, '', true);
+ $helptext .= "
- ";
+ $helptext .= helpbutton("writing", get_string("helpwriting"), "moodle", true, false, '', true);
+ $helptext .= "
- ";
+ $helptext .= helpbutton("questions", get_string("helpquestions"), "moodle", true, false, '', true);
+ $helptext .= "
- ";
+ if ($usehtmleditor) {
+ $helptext .= helpbutton("richtext", get_string("helprichtext"), "moodle", true, false, '', true);
+ } else {
+ $helptext .= emoticonhelpbutton("theform", "message", true);
+ }
+ $helptext .= "
";
+ return helpbutton('', get_string('editorhelp'), 'moodle', true, false, $helptext, true);
+}*/
/**
* Print a help button.
@@ -4721,14 +4790,14 @@ function helpbutton ($page, $title='', $module='moodle', $image=true, $linktext=
// Accessibility: prefix the alt text/title with 'Help with', strip distracting dots '...'
// PLEASE DO NOT CHANGE. ('...' is VERY distracting for non-visual users)
$tooltip = get_string('helpprefix2', '', trim($title, ". \t"));
-
+
$linkobject = '';
if ($image) {
if ($linktext) {
// MDL-7469 If text link is displayed with help icon, change to alt to "help with this".
$linkobject .= $title.' ';
- $tooltip = get_string('helpwiththis');
+ $tooltip = get_string('helpwiththis');
}
if ($imagetext) {
$linkobject .= $imagetext;
@@ -4747,7 +4816,7 @@ function helpbutton ($page, $title='', $module='moodle', $image=true, $linktext=
$url = '/help.php?module='. $module .'&file='. $page .'.html&forcelang='.$forcelang;
}
- $link = ''.
+ $link = ''.
link_to_popup_window ($url, 'popup', $linkobject, 400, 500, $tooltip, 'none', true).
'';
@@ -4768,7 +4837,7 @@ function helpbutton ($page, $title='', $module='moodle', $image=true, $linktext=
* @param string $field ?
* @todo Finish documenting this function
*/
-function emoticonhelpbutton($form, $field) {
+function emoticonhelpbutton($form, $field, $return = false) {
global $CFG, $SESSION;
@@ -4776,8 +4845,12 @@ function emoticonhelpbutton($form, $field) {
$SESSION->inserttextfield = $field;
$imagetext = '
';
-
- helpbutton('emoticons', get_string('helpemoticons'), 'moodle', true, true, '', false, $imagetext);
+ $help = helpbutton('emoticons', get_string('helpemoticons'), 'moodle', true, true, '', true, $imagetext);
+ if (!$return){
+ echo $help;
+ } else {
+ return $help;
+ }
}
/**
@@ -4820,13 +4893,13 @@ function notice ($message, $link='', $course=NULL, $adminroot='') {
echo '
';
print_simple_box($message, 'center', '50%', '', '20', 'generalbox', 'notice');
print_continue($link);
-
+
// xhtml strict fix, need to make sure it's the right footer
if ($adminroot) {
admin_externalpage_print_footer($adminroot);
exit;
}
-
+
if (empty($course)) {
print_footer($SITE);
} else {
@@ -4888,16 +4961,16 @@ function redirect($url, $message='', $delay=-1) {
$tmpstr = clean_text(''); //clean encoded URL
$encodedurl = substr($tmpstr, 9, strlen($tmpstr)-13);
$url = html_entity_decode($encodedurl);
- $surl = addslashes($url);
+ $surl = addslashes($url);
/// when no message and header printed yet, try to redirect
if (empty($message) and !defined('HEADER_PRINTED')) {
-
+
// Technically, HTTP/1.1 requires Location: header to contain
- // the absolute path. (In practice browsers accept relative
+ // the absolute path. (In practice browsers accept relative
// paths - but still, might as well do it properly.)
- // This code turns relative into absolute.
- if (!preg_match('|^[a-z]+:|', $url)) {
+ // This code turns relative into absolute.
+ if (!preg_match('|^[a-z]+:|', $url)) {
// Get host name http://www.wherever.com
$hostpart = preg_replace('|^(.*?[^:/])/.*$|', '$1', $CFG->wwwroot);
if (preg_match('|^/|', $url)) {
@@ -4939,7 +5012,7 @@ function redirect($url, $message='', $delay=-1) {
echo ''. $message .'
';
echo '( '. get_string('continue') .' )
';
echo '';
-// it might be better not to set timeout the same for both types of redirect, so that we can be sure which one wins
+// it might be better not to set timeout the same for both types of redirect, so that we can be sure which one wins
?>