-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from quantacms/aldo-dev
Aldo dev
- Loading branch information
Showing
9 changed files
with
101 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,76 @@ | ||
<?php | ||
define('INPUT_DATE_NOW', 'NOW'); | ||
/** | ||
* Class FormItemString | ||
* This class represents a Form Item of type dropdown Select | ||
*/ | ||
class FormItemDate extends FormItemString { | ||
public $type = 'date'; | ||
public $format = 'Y-m-d'; | ||
|
||
function loadAttributes() { | ||
$this->addData('class', array('hasDatePicker')); | ||
parent::loadAttributes(); // TODO: Change the autogenerated stub | ||
parent::loadAttributes(); | ||
if (!empty($this->getInputAttr('date_format'))) { | ||
$this->format = $this->getInputAttr('date_format'); | ||
} | ||
if (!empty($this->getInputAttr('date_min'))) { | ||
$this->setData('min', $this->parseDate($this->getInputAttr('date_min'), 'Y-m-d')); | ||
} | ||
if (!empty($this->getInputAttr('date_max'))) { | ||
$this->setData('max', $this->parseDate($this->getInputAttr('date_max'), 'Y-m-d')); | ||
} | ||
} | ||
|
||
public function parseDate($date, $format = NULL) { | ||
if (empty($format)) { | ||
$format = $this->getDateFormat(); | ||
} | ||
if ($date == INPUT_DATE_NOW) { | ||
$time = time(); | ||
} | ||
else { | ||
$time = strtotime($date); | ||
} | ||
return date($format, $time); | ||
} | ||
|
||
public function getDateFormat() { | ||
return $this->format; | ||
} | ||
/** | ||
* @return string | ||
*/ | ||
public function getHTMLType() { | ||
return 'date'; | ||
} | ||
|
||
/** | ||
* Renders the input item. | ||
* @return mixed | ||
*/ | ||
function render() { | ||
$rendered = ''; | ||
// TODO: data items should go in an array and be rendered all together | ||
// in order to be extendable by subclasses... | ||
|
||
$rendered .= '<input value="' . str_replace('"', '"', $this->getCurrentValue()) . '" type="' . $this->getHTMLType() . '" ' . | ||
($this->isDisabled() ? 'disabled ' : '') . | ||
($this->isRequired() ? 'required ' : '') . | ||
('class="' . $this->getClass() . '" ') . | ||
('placeholder="' . $this->getPlaceHolder() . '" ') . | ||
('name="' . $this->getName() . '" ') . | ||
('id="' . $this->getId() . '" ') . | ||
($this->isMultiple() ? 'data-multiple ' : ' ') . | ||
($this->isDistinct() ? 'data-distinct ' : ' ') . | ||
($this->isMultiple() ? 'data-limit="' . $this->getData('limit'). '" ' : ' ') . | ||
(!empty($this->getInputAttr('node')) ? (' data-node="' . $this->getInputAttr('node')) . '" ' : '') . | ||
(!empty($this->getData('min')) ? (' min="' . $this->getData('min')) . '" ' : '') . | ||
|
||
(!empty($this->getData('max')) ? (' max="' . $this->getData('max')) . '" ' : '') . | ||
|
||
'/>'; | ||
|
||
return $rendered; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters