2008-05-14 07:54:11 +02:00
|
|
|
<?php
|
2008-08-06 05:31:42 +02:00
|
|
|
/**
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage model
|
|
|
|
*/
|
|
|
|
|
2008-05-14 07:54:11 +02:00
|
|
|
/**
|
|
|
|
* Represents a single year field.
|
|
|
|
*
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage model
|
|
|
|
*/
|
|
|
|
class Year extends DBField {
|
|
|
|
|
|
|
|
function requireField() {
|
2008-08-06 05:31:42 +02:00
|
|
|
DB::requireField($this->tableName, $this->name, "year");
|
2008-05-14 07:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function scaffoldFormField($title = null) {
|
|
|
|
$selectBox = new DropdownField($this->name, $title);
|
|
|
|
$selectBox->setSource($this->getDefaultOptions());
|
|
|
|
return $selectBox;
|
|
|
|
}
|
|
|
|
|
2008-08-06 05:31:42 +02:00
|
|
|
private function getDefaultOptions() {
|
|
|
|
$start = (int)date('Y');
|
|
|
|
$end = 1900;
|
2008-05-14 07:54:11 +02:00
|
|
|
$years = array();
|
|
|
|
for($i=$start;$i>=$end;$i--) {
|
|
|
|
$years[] = $i;
|
|
|
|
}
|
|
|
|
return $years;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|