Source of file TimeDropdownField.php
Size: 1,631 Bytes - Last Modified: 2021-12-23T10:35:31+00:00
/var/www/docs.ssmods.com/process/src/code/TimeDropdownField.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 | <?php require_once 'Zend/Date.php'; class TimeDropdownField extends TimeField { static $default_config = array( 'interval' => 60 ); function __construct($name, $title = null, $value = ""){ parent::__construct($name, $title, $value); $this->config += self::$default_config; } /** * @todo This should be generated by JavaScript, but we don't have the date libraries' */ function Field($properties = array()) { $this->addExtraClass('timedropdownfield'); $html = parent::Field($properties); Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript('framework/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript('timedropdownfield/javascript/TimeDropdownField.js'); Requirements::css('timedropdownfield/css/TimeDropdownField.css'); $iteratedTime = new Zend_Date('00:00:00', 'h:mm:ss'); $options = array(); $count = 24*(60/$this->config['interval']); for($i=0; $i<$count; $i++) { $key = $iteratedTime->toString($this->getConfig('datavalueformat')); $options[$key] = $iteratedTime->toString($this->getConfig('timeformat')); $iteratedTime->add($this->config['interval'], Zend_Date::MINUTE); } $dropdownField = new DropdownField('dropdown_'.$this->getName(), false, $options, $this->Value()); $dropdownField->addExtraClass('presets'); $dropdownField->setHasEmptyDefault(true); $dropdownField->setForm($this->getForm()); $html .= $dropdownField->Field(); $html .= '<a href="#" class="presets-trigger"></a>'; return $html; } public function Type() { return 'timedropdown time text'; } } |