From 1ae1941eb11d5e59ccee86defa4151c119ae8774 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Tue, 2 Sep 2008 12:14:58 +0000 Subject: [PATCH] MDL-14591 New "warning" form element --- lib/form/warning.php | 64 +++++++++++++++++++++++++++++++++ lib/formslib.php | 11 +++--- theme/standard/styles_color.css | 17 ++++++--- 3 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 lib/form/warning.php diff --git a/lib/form/warning.php b/lib/form/warning.php new file mode 100644 index 0000000000..125ad64712 --- /dev/null +++ b/lib/form/warning.php @@ -0,0 +1,64 @@ +_type = 'warning'; + } + + /** + * 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 (!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); + } + + function toHtml() { + return notify($this->_text, 'formwarning', 'center', true); + } + + /** + * get html for help button + * + * @access public + * @return string html for help button + */ + function getHelpButton(){ + return $this->_helpbutton; + } + + function getElementTemplateType(){ + return $this->_elementTemplateType; + } +} +?> diff --git a/lib/formslib.php b/lib/formslib.php index e5212ce61b..d186bf8973 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -548,7 +548,7 @@ class moodleform { * @param int $newuserid - new userid if required * @return mixed stored_file object or false if error; may throw exception if duplicate found */ - function save_stored_file($elname, $newcontextid, $newfilearea, $newitemid, $newfilepath, + function save_stored_file($elname, $newcontextid, $newfilearea, $newitemid, $newfilepath, $newfilename=null, $override=false, $newuserid=null) { global $USER; @@ -585,7 +585,7 @@ class moodleform { return $fs->create_file_from_pathname($file_record, $_FILES[$elname]['tmp_name']); } else if (isset($this->exportValues[$elname])) { // Submitted data contains itemid in user's draft_area - + $itemid = $this->exportValues[$elname]; if (!$context = get_context_instance(CONTEXT_USER, $USER->id)) { @@ -597,7 +597,7 @@ class moodleform { } $file = array_pop($files); // Get the one and only item out of the array - + $params = $file->get_params(); $fs = get_file_storage(); @@ -1801,6 +1801,8 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{ 'static'=>"\n\t\t".'
{error}
{element} 
', +'warning'=>"\n\t\t".'
{element}
', + 'nodisplay'=>''); parent::HTML_QuickForm_Renderer_Tableless(); @@ -1887,7 +1889,7 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{ //check if this is a group element first if (($this->_inGroup) and !empty($this->_groupElementTemplate)) { // so it gets substitutions for *each* element - $html = $this->_groupTemplates[$element->getName()]; + $html = $this->_groupTemplates[$element->getName()]; } elseif (method_exists($element, 'getElementTemplateType')){ $html = $this->_elementTemplates[$element->getElementTemplateType()]; @@ -2045,4 +2047,5 @@ MoodleQuickForm::registerElementType('submit', "$CFG->libdir/form/submit.php", ' MoodleQuickForm::registerElementType('questioncategory', "$CFG->libdir/form/questioncategory.php", 'MoodleQuickForm_questioncategory'); MoodleQuickForm::registerElementType('advcheckbox', "$CFG->libdir/form/advcheckbox.php", 'MoodleQuickForm_advcheckbox'); MoodleQuickForm::registerElementType('recaptcha', "$CFG->libdir/form/recaptcha.php", 'MoodleQuickForm_recaptcha'); +MoodleQuickForm::registerElementType('warning', "$CFG->libdir/form/warning.php", 'MoodleQuickForm_warning'); ?> diff --git a/theme/standard/styles_color.css b/theme/standard/styles_color.css index 2ede663ad1..a88b1382a9 100644 --- a/theme/standard/styles_color.css +++ b/theme/standard/styles_color.css @@ -648,7 +648,7 @@ table.minicalendar { /* .content should match the body background, sides are white. */ #course-view .weeks .content , -#course-view .topics .content, +#course-view .topics .content, #course-view .weeks .section, #course-view .topics .section { background: #FAFAFA; @@ -745,11 +745,11 @@ td.grade div.overridden { } .grade-report-grader table#user-grades td.cell span.gradepass { - background-color: #C2EBBD; + background-color: #C2EBBD; } .grade-report-grader table#user-grades td.cell span.gradefail { - background-color: #EBC4BD; + background-color: #EBC4BD; } /* grade edit */ @@ -1156,4 +1156,13 @@ form.mform .fdescription.required { } form.mform .required .fgroup span label { color:#000; -} \ No newline at end of file +} + +form.mform .formwarning { + background-color: red; + color: yellow; + margin-top: 15px; + padding: 10px 0px 10px 0px; + font-size: 110%; + font-weight: bold; +} -- 2.39.5