private function getValueAsString($value, $type) { switch ($type) { case 'integer': $value = TPropertyValue::ensureInteger($value); break; case 'float': $value = TPropertyValue::ensureFloat($value); break; case 'boolean': if (TPropertyValue::ensureBoolean($value)) { $value = 'true'; } else { $value = 'false'; } break; case 'enumerable': $value = "'{$value}'"; break; case 'mixed': $value = 'null'; break; case 'string': $value = "'{$value}'"; break; } return "{$value}"; }
/** * Sets the decay rate between callback. Default is 0; * @param float decay rate between callbacks. */ public function setDecayRate($value) { $decay = TPropertyValue::ensureFloat($value); if ($decay < 0) { throw new TConfigurationException('callback_decay_be_not_negative', $this->getID()); } $this->setViewState('Decay', $decay); }
/** * @param float seconds between callback requests, must be a positive number, default is 1 second. */ public function setInterval($value) { $interval = TPropertyValue::ensureFloat($value); if ($interval <= 0) { throw new TConfigurationException('callback_interval_be_positive', $this->getID()); } $this->setViewState('Interval', $interval, 1); if ($this->getActiveControl()->canUpdateClientSide()) { $client = $this->getPage()->getCallbackClient(); $client->callClientFunction('Prado.WebUI.TTimeTriggeredCallback.setTimerInterval', array($this, $interval)); } }
public function saveInput($sender, $param) { if ($this->IsValid) { $index = 0; $products = $this->Products; $data = array(); foreach ($this->Repeater->Items as $item) { $item = array('id' => $products[$index]['id'], 'name' => $item->ProductName->Text, 'category' => $item->ProductCategory->SelectedItem->Text, 'price' => TPropertyValue::ensureFloat($item->ProductPrice->Text), 'imported' => $item->ProductImported->Checked); $data[] = $item; $index++; } $this->Repeater2->DataSource = $data; $this->Repeater2->dataBind(); } }
protected function updateProduct($id, $name, $quantity, $price, $imported) { // In real applications, data should be saved to database using an SQL UPDATE statement if ($this->_data === null) { $this->loadData(); } $updateRow = null; foreach ($this->_data as $index => $row) { if ($row['id'] === $id) { $updateRow =& $this->_data[$index]; } } if ($updateRow !== null) { $updateRow['name'] = $name; $updateRow['quantity'] = TPropertyValue::ensureInteger($quantity); $updateRow['price'] = TPropertyValue::ensureFloat($price); $updateRow['imported'] = TPropertyValue::ensureBoolean($imported); $this->saveData(); } }
protected function updateBook($isbn, $title, $publisher, $price, $instock, $rating) { // In real applications, data should be saved to database using an SQL UPDATE statement if ($this->_data === null) { $this->loadData(); } $updateRow = null; foreach ($this->_data as $index => $row) { if ($row['ISBN'] === $isbn) { $updateRow =& $this->_data[$index]; } } if ($updateRow !== null) { $updateRow['title'] = $title; $updateRow['publisher'] = $publisher; $updateRow['price'] = TPropertyValue::ensureFloat(ltrim($price, '$')); $updateRow['instock'] = TPropertyValue::ensureBoolean($instock); $updateRow['rating'] = TPropertyValue::ensureInteger($rating); $this->saveData(); } }
public function remove($key, $priority = false) { if (!$this->_r) { if ($priority === null) { $priority = $this->getDefaultPriority(); } if ($priority === false) { $this->sortPriorities(); foreach ($this->_d as $priority => $items) { if (array_key_exists($key, $items)) { $value = $this->_d[$priority][$key]; unset($this->_d[$priority][$key]); $this->_c--; if (count($this->_d[$priority]) === 0) { unset($this->_d[$priority]); $this->_o = false; } $this->_fd = null; return $value; } } return null; } else { $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); if (isset($this->_d[$priority]) && (isset($this->_d[$priority][$key]) || array_key_exists($key, $this->_d[$priority]))) { $value = $this->_d[$priority][$key]; unset($this->_d[$priority][$key]); $this->_c--; if (count($this->_d[$priority]) === 0) { unset($this->_d[$priority]); $this->_o = false; } $this->_fd = null; return $value; } else { return null; } } } else { throw new TInvalidOperationException('map_readonly', get_class($this)); } }
/** * Sets the date for the date picker using timestamp. * @param float time stamp for the date picker */ public function setTimeStamp($value) { if ($value === null || is_string($value) && trim($value) === '') { $this->setText(''); } else { $date = TPropertyValue::ensureFloat($value); $formatter = Prado::createComponent('System.Util.TSimpleDateFormatter', $this->getDateFormat()); $this->setText($formatter->format($date)); } }
/** * Removes the item at a specific index within a priority. Override * and call this method to insert your own functionality. * @param integer index of item to remove within the priority. * @param numeric priority of the item to remove, defaults to null, or left blank, it is then set to the default priority * @return mixed the removed item. * @throws TInvalidDataValueException If the item does not exist */ public function removeAtIndexInPriority($index, $priority = null) { if ($this->getReadOnly()) { throw new TInvalidOperationException('list_readonly', get_class($this)); } if ($priority === null) { $priority = $this->getDefaultPriority(); } $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p); if (!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority])) { throw new TInvalidDataValueException('list_item_inexistent'); } // $value is an array of elements removed, only one $value = array_splice($this->_d[$priority], $index, 1); $value = $value[0]; if (!count($this->_d[$priority])) { unset($this->_d[$priority]); } $this->_c--; $this->_fd = null; return $value; }
/** * @param float rating value, also sets the selected Index */ public function setRating($value) { $value = TPropertyValue::ensureFloat($value); $this->setViewState('Rating', $value, null); $index = $this->getRatingIndex($value); parent::setSelectedIndex($index); }
/** * @param float maximum delay (in seconds) before requesting a suggestion. * Default is 0.4. */ public function setFrequency($value) { $this->setViewState('frequency', TPropertyValue::ensureFloat($value), ''); }
/** * @param float minimum amount of savings to actually store the value compressed * @throws TInvalidOperationException if the module is already initialized */ public function setMinSavings($value) { if ($this->_initialized) { throw new TInvalidOperationException('memcache_min_savings_unchangeable'); } else { $this->_minSavings = TPropertyValue::ensureFloat($value); } }
/** * @param float current value of slider */ public function setValue($value) { $this->setViewState('Value', TPropertyValue::ensureFloat($value), 0.0); }
/** * Set the opacity on a html element or control. * @param TControl control element or element id * @param float opacity value between 1 and 0 */ public function setOpacity($element, $value) { if ($element instanceof ISurroundable) { $element = $element->getSurroundingTagID(); } $value = TPropertyValue::ensureFloat($value); $this->callClientFunction('Element.setOpacity', array($element, $value)); }
/** * Set the opacity on a html element or control. * This effect doesn't need jQueryUI. * @param TControl control element or element id * @param float opacity value between 1 and 0 */ public function fadeTo($element, $value, $duration = 500) { $value = TPropertyValue::ensureFloat($value); $this->visualEffect('fadeTo', $element, array($duration, $value)); }
/** * @param integer the current number of stars selected. */ public function setStarRating($value) { $value = TPropertyValue::ensureFloat($value); $max = $this->getMaxStars(); if ($value >= 0 && $value <= $max) { $default = $this->getDefaultStars(); $this->setViewState('StarRating', $value, $default); } else { throw new TApplicationException("StarRating must be between 0 and MaxStars inclusive."); } }