/** * PHP magic method * * @param string $strName * @param string $mixValue * * @return mixed * @throws Exception|QCallerException|QInvalidCastException|Exception */ public function __set($strName, $mixValue) { $this->blnModified = true; switch ($strName) { case "MinDate": try { $this->datMinDate = QType::Cast($mixValue, QType::DateTime); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "MaxDate": $blnMaxDate = true; try { $this->datMaxDate = QType::Cast($mixValue, QType::DateTime); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "DefaultDate": $blnDefaultDate = true; try { $this->datDefaultDate = QType::Cast($mixValue, QType::DateTime); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "FirstDay": $blnFirstDay = true; try { $this->intFirstDay = QType::Cast($mixValue, QType::Integer); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "GotoCurrent": try { $this->blnGotoCurrent = QType::Cast($mixValue, QType::Boolean); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "IsRTL": try { $this->blnIsRTL = QType::Cast($mixValue, QType::Boolean); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "NumberOfMonths": $blnNumberOfMonths = true; if (!is_array($mixValue) && !is_numeric($mixValue)) { throw new exception('NumberOfMonths must be an integer or an array'); } $this->mixNumberOfMonths = $mixValue; break; case "AutoSize": try { $this->blnAutoSize = QType::Cast($mixValue, QType::Boolean); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "JqDateFormat": try { $this->strJqDateFormat = QType::Cast($mixValue, QType::String); parent::__set('DateTimeFormat', QCalendar::qcFrmt($this->strJqDateFormat)); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case "DateTimeFormat": case "DateFormat": parent::__set('DateTimeFormat', $mixValue); $this->strJqDateFormat = QCalendar::jqFrmt($this->strDateTimeFormat); break; case "ShowButtonPanel": try { $this->blnShowButtonPanel = QType::Cast($mixValue, QType::Boolean); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } default: try { parent::__set($strName, $mixValue); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; } }
public function __set($strName, $mixValue) { switch ($strName) { case 'MaxDate': case 'Maximum': try { if (is_string($mixValue)) { $mixValue = new QDateTime($mixValue); } parent::__set('MaxDate', QType::Cast($mixValue, QType::DateTime)); } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; case 'MinDate': case 'Minimum': try { if (is_string($mixValue)) { $mixValue = new QDateTime($mixValue); } parent::__set('MinDate', QType::Cast($mixValue, QType::DateTime)); } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; case 'DateTime': try { $this->dttDateTime = QType::Cast($mixValue, QType::DateTime); if ($this->dttDateTime && $this->dttDateTime->IsNull()) { $this->dttDateTime = null; $this->blnModified = true; } if (!$this->dttDateTime || !$this->strDateTimeFormat) { parent::__set('Text', ''); } else { parent::__set('Text', $this->dttDateTime->qFormat($this->strDateTimeFormat)); } } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; case 'JqDateFormat': try { parent::__set($strName, $mixValue); $this->strDateTimeFormat = QCalendar::qcFrmt($this->JqDateFormat); // trigger an update to reformat the text with the new format $this->DateTime = $this->dttDateTime; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; case 'DateTimeFormat': case 'DateFormat': try { $this->strDateTimeFormat = QType::Cast($mixValue, QType::String); parent::__set('JqDateFormat', QCalendar::jqFrmt($this->strDateTimeFormat)); // trigger an update to reformat the text with the new format $this->DateTime = $this->dttDateTime; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; case 'Text': parent::__set($strName, $mixValue); $this->dttDateTime = new QDateTime($this->strText); break; default: try { parent::__set($strName, $mixValue); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; } }
/** * PHP magic method * * @param string $strName Property name * @param string $mixValue Property value * * @return mixed|void * @throws Exception|QCallerException|QInvalidCastException */ public function __set($strName, $mixValue) { switch ($strName) { case 'MaxDate': case 'Maximum': if (is_string($mixValue)) { if (preg_match('/[+-][0-9]+[dDwWmMyY]/', $mixValue)) { parent::__set($strName, $mixValue); break; } $mixValue = new QDateTime($mixValue); } parent::__set('MaxDate', QType::Cast($mixValue, QType::DateTime)); break; case 'MinDate': case 'Minimum': if (is_string($mixValue)) { if (preg_match('/[+-][0-9]+[dDwWmMyY]/', $mixValue)) { parent::__set($strName, $mixValue); break; } $mixValue = new QDateTime($mixValue); } parent::__set('MinDate', QType::Cast($mixValue, QType::DateTime)); break; case 'DateTime': try { $this->dttDateTime = new QDateTime($mixValue, null, QDateTime::DateOnlyType); parent::SetDate($this->dttDateTime); break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'JqDateFormat': try { parent::__set($strName, $mixValue); $this->strDateTimeFormat = QCalendar::qcFrmt($this->JqDateFormat); // trigger an update to reformat the text with the new format $this->DateTime = $this->dttDateTime; break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'DateTimeFormat': case 'DateFormat': try { $this->strDateTimeFormat = QType::Cast($mixValue, QType::String); parent::__set('JqDateFormat', QCalendar::jqFrmt($this->strDateTimeFormat)); // trigger an update to reformat the text with the new format $this->DateTime = $this->dttDateTime; break; } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Text': // Set the selected date with a text value $this->DateTime = $mixValue; break; case '_Text': // Internal only. Do not use. Called by JS above to keep track of user selection. $this->dttDateTime = new QDateTime($mixValue); break; case 'OnSelect': // Since we are using the OnSelect event already, and Datepicker doesn't allow binding, so there can be // only one event, we will make sure our js is part of any new OnSelect js. $mixValue = $this->OnSelectJs() . ';' . $mixValue; parent::__set('OnSelect', $mixValue); break; default: try { parent::__set($strName, $mixValue); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } break; } }