-<?php
+<?php // $Id$
+
+///////////////////////////////////////////////////////////////////////////
+// //
+// NOTICE OF COPYRIGHT //
+// //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment //
+// http://moodle.org //
+// //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// //
+// This program is free software; you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation; either version 2 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details: //
+// //
+// http://www.gnu.org/copyleft/gpl.html //
+// //
+///////////////////////////////////////////////////////////////////////////
+
global $CFG;
-require_once "$CFG->libdir/form/group.php";
-require_once "$CFG->libdir/formslib.php";
+require_once($CFG->libdir . '/form/group.php');
+require_once($CFG->libdir . '/formslib.php');
/**
* Class for a group of elements used to input a date.
*
* Emulates moodle print_date_selector function
*
- * @author Jamie Pratt <me@jamiep.org>
- * @access public
+ * @package formslib
*/
class MoodleQuickForm_date_selector extends MoodleQuickForm_group
{
* applydst => apply users daylight savings adjustment?
* optional => if true, show a checkbox beside the date to turn it on (or off)
*/
- var $_options = array('startyear'=>1970, 'stopyear'=>2020,
- 'timezone'=>99, 'applydst'=>true, 'optional'=>false);
+ protected $_options = array('startyear' => 1970, 'stopyear' => 2020,
+ 'timezone' => 99, 'applydst' => true, 'optional' => false);
/**
* These complement separators, they are appended to the resultant HTML
* @access private
* @var array
*/
- var $_wrap = array('', '');
+ protected $_wrap = array('', '');
/**
* Class constructor
$this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes(), true);
// If optional we add a checkbox which the user can use to turn if on
if($this->_options['optional']) {
- $this->_elements[] =& MoodleQuickForm::createElement('checkbox', 'off', null, get_string('disable'), $this->getAttributes(), true);
+ $this->_elements[] =& MoodleQuickForm::createElement('checkbox', 'enabled', null, get_string('enable'), $this->getAttributes(), true);
}
foreach ($this->_elements as $element){
if (method_exists($element, 'setHiddenLabel')){
'year' => $currentdate['year']);
// If optional, default to off, unless a date was provided
if($this->_options['optional']) {
- $value['off'] = ($requestvalue == 0) ? true : false;
+ $value['enabled'] = $requestvalue != 0;
}
} else {
- $value['off'] = (isset($value['off'])) ? true : false;
+ $value['enabled'] = isset($value['enabled']);
}
if (null !== $value){
$this->setValue($value);
break;
case 'createElement':
if($arg[2]['optional']) {
- $caller->disabledIf($arg[0], $arg[0].'[off]', 'checked');
+ $caller->disabledIf($arg[0], $arg[0].'[enabled]');
}
return parent::onQuickFormEvent($event, $arg, $caller);
break;
if (count($valuearray)){
if($this->_options['optional']) {
// If checkbox is on, the value is zero, so go no further
- if(!empty($valuearray['off'])) {
- $value[$this->getName()]=0;
+ if(empty($valuearray['enabled'])) {
+ $value[$this->getName()] = 0;
return $value;
}
}
- $value[$this->getName()]=make_timestamp($valuearray['year'],
+ $value[$this->getName()] = make_timestamp($valuearray['year'],
$valuearray['month'],
$valuearray['day'],
- 0,0,0,
+ 0, 0, 0,
$this->_options['timezone'],
$this->_options['applydst']);
-<?php
+<?php // $Id$
+
+///////////////////////////////////////////////////////////////////////////
+// //
+// NOTICE OF COPYRIGHT //
+// //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment //
+// http://moodle.org //
+// //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// //
+// This program is free software; you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation; either version 2 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details: //
+// //
+// http://www.gnu.org/copyleft/gpl.html //
+// //
+///////////////////////////////////////////////////////////////////////////
+
global $CFG;
-require_once "$CFG->libdir/form/group.php";
-require_once "$CFG->libdir/formslib.php";
+require_once($CFG->libdir . '/form/group.php');
+require_once($CFG->libdir . '/formslib.php');
/**
* Class for a group of elements used to input a date and time.
*
* Emulates moodle print_date_selector function and also allows you to select a time.
*
- * @author Jamie Pratt <me@jamiep.org>
- * @access public
+ * @package formslib
*/
class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group{
/**
* timezone => float/string timezone
* applydst => apply users daylight savings adjustment?
* step => step to increment minutes by
+ * optional => if true, show a checkbox beside the date to turn it on (or off)
*/
- var $_options = array('startyear'=>1970, 'stopyear'=>2020,
- 'timezone'=>99, 'applydst'=>true, 'step'=>5, 'optional'=>false);
+ var $_options = array('startyear' => 1970, 'stopyear' => 2020,
+ 'timezone' => 99, 'applydst' => true, 'step' => 5, 'optional' => false);
/**
* These complement separators, they are appended to the resultant HTML
}
// If optional we add a checkbox which the user can use to turn if on
if($this->_options['optional']) {
- $this->_elements[] =& MoodleQuickForm::createElement('checkbox', 'off', null, get_string('disable'), $this->getAttributes(), true);
+ $this->_elements[] =& MoodleQuickForm::createElement('checkbox', 'enabled', null, get_string('enable'), $this->getAttributes(), true);
}
foreach ($this->_elements as $element){
if (method_exists($element, 'setHiddenLabel')){
'year' => $currentdate['year']);
// If optional, default to off, unless a date was provided
if($this->_options['optional']) {
- $value['off'] = ($requestvalue == 0) ? true : false;
+ $value['enabled'] = $requestvalue != 0;
}
} else {
- $value['off'] = (isset($value['off'])) ? true : false;
+ $value['enabled'] = isset($value['off']);
}
if (null !== $value){
$this->setValue($value);
break;
case 'createElement':
if($arg[2]['optional']) {
- $caller->disabledIf($arg[0], $arg[0].'[off]', 'checked');
+ $caller->disabledIf($arg[0], $arg[0].'[enabled]');
}
return parent::onQuickFormEvent($event, $arg, $caller);
break;
if (count($valuearray)){
if($this->_options['optional']) {
// If checkbox is on, the value is zero, so go no further
- if(!empty($valuearray['off'])) {
- $value[$this->getName()]=0;
+ if(empty($valuearray['enabled'])) {
+ $value[$this->getName()] = 0;
return $value;
}
}
- $valuearray=$valuearray + array('year'=>1970, 'month'=>1, 'day'=>1, 'hour'=>0, 'minute'=>0);
- $value[$this->getName()]=make_timestamp(
+ $valuearray=$valuearray + array('year' => 1970, 'month' => 1, 'day' => 1, 'hour' => 0, 'minute' => 0);
+ $value[$this->getName()] = make_timestamp(
$valuearray['year'],
$valuearray['month'],
$valuearray['day'],