mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-14591 New "warning" form element
This commit is contained in:
parent
aae8cfdc5f
commit
1ae1941eb1
64
lib/form/warning.php
Normal file
64
lib/form/warning.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
require_once("HTML/QuickForm/static.php");
|
||||
|
||||
/**
|
||||
* HTML class for a text type element
|
||||
*
|
||||
* @author Jamie Pratt
|
||||
* @access public
|
||||
*/
|
||||
class MoodleQuickForm_warning extends HTML_QuickForm_static{
|
||||
var $_elementTemplateType='warning';
|
||||
/**
|
||||
* html for help button, if empty then no help
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $_helpbutton='';
|
||||
|
||||
function MoodleQuickForm_warning($elementName=null, $elementLabel=null, $text=null) {
|
||||
parent::HTML_QuickForm_static($elementName, $elementLabel, $text);
|
||||
$this->_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;
|
||||
}
|
||||
}
|
||||
?>
|
@ -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".'<div class="fitem {advanced}"><div class="fitemtitle"><div class="fstaticlabel"><label>{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} {help}</label></div></div><div class="felement fstatic <!-- BEGIN error --> error<!-- END error -->"><!-- BEGIN error --><span class="error">{error}</span><br /><!-- END error -->{element} </div></div>',
|
||||
|
||||
'warning'=>"\n\t\t".'<div class="fitem {advanced}">{element}</div>',
|
||||
|
||||
'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');
|
||||
?>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
form.mform .formwarning {
|
||||
background-color: red;
|
||||
color: yellow;
|
||||
margin-top: 15px;
|
||||
padding: 10px 0px 10px 0px;
|
||||
font-size: 110%;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user