public function saveButtonClicked($sender, $param) { if ($this->IsValid) { $postRecord = new PostRecord(); $postRecord->Title = $this->Title->SafeText; $postRecord->Content = $this->Content->SafeText; if ($this->DraftMode->Checked) { $postRecord->Status = PostRecord::STATUS_DRAFT; } else { if (!$this->User->IsAdmin && TPropertyValue::ensureBoolean($this->Application->Parameters['PostApproval'])) { $postRecord->Status = PostRecord::STATUS_PENDING; } else { $postRecord->Status = PostRecord::STATUS_PUBLISHED; } } $postRecord->CreateTime = time(); $postRecord->ModifyTime = $postRecord->CreateTime; $postRecord->AuthorID = $this->User->ID; $cats = array(); foreach ($this->Categories->SelectedValues as $value) { $cats[] = TPropertyValue::ensureInteger($value); } $this->DataAccess->insertPost($postRecord, $cats); $this->gotoPage('Posts.ViewPost', array('id' => $postRecord->ID)); } }
/** * Initialize the TTranslate translation components */ public static function init($catalogue = 'messages') { static $saveEventHandlerAttached = false; //initialized the default class wide formatter if (!isset(self::$formatters[$catalogue])) { $app = Prado::getApplication()->getGlobalization(); $config = $app->getTranslationConfiguration(); $source = MessageSource::factory($config['type'], $config['source'], $config['filename']); $source->setCulture($app->getCulture()); if (TPropertyValue::ensureBoolean($config['cache'])) { $source->setCache(new MessageCache($config['cache'])); } self::$formatters[$catalogue] = new MessageFormat($source, $app->getCharset()); //mark untranslated text if ($ps = $config['marker']) { self::$formatters[$catalogue]->setUntranslatedPS(array($ps, $ps)); } //save the message on end request // Do it only once ! if (!$saveEventHandlerAttached && TPropertyValue::ensureBoolean($config['autosave'])) { Prado::getApplication()->attachEventHandler('OnEndRequest', array('Translation', 'saveMessages')); $saveEventHandlerAttached = true; } } }
protected function createBooleanControl($container, $column, $record) { $value = $this->getRecordPropertyValue($column, $record); $control = new TCheckBox(); $control->setChecked(TPropertyValue::ensureBoolean($value)); $control->setCssClass('boolean-checkbox'); $this->setDefaultProperty($container, $control, $column, $record); return $control; }
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(); } }
public function onLoad($param) { parent::onLoad($param); if (!$this->IsPostBack) { $parameters = $this->Application->Parameters; $this->SiteTitle->Text = $parameters['SiteTitle']; $this->SiteSubtitle->Text = $parameters['SiteSubtitle']; $this->SiteOwner->Text = $parameters['SiteOwner']; $this->AdminEmail->Text = $parameters['AdminEmail']; $this->MultipleUser->Checked = TPropertyValue::ensureBoolean($parameters['MultipleUser']); $this->AccountApproval->Checked = TPropertyValue::ensureBoolean($parameters['AccountApproval']); $this->PostPerPage->Text = $parameters['PostPerPage']; $this->RecentComments->Text = $parameters['RecentComments']; $this->PostApproval->Checked = TPropertyValue::ensureBoolean($parameters['PostApproval']); $themes = $this->Service->ThemeManager->AvailableThemes; $this->ThemeName->DataSource = $themes; $this->ThemeName->dataBind(); $this->ThemeName->SelectedValue = array_search($parameters['ThemeName'], $themes); } }
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 createUser($sender, $param) { if ($this->IsValid) { $userRecord = new UserRecord(); $userRecord->Name = strtolower($this->Username->Text); $userRecord->FullName = $this->FullName->Text; $userRecord->Role = 0; $userRecord->Password = md5($this->Password->Text); $userRecord->Email = $this->Email->Text; $userRecord->CreateTime = time(); $userRecord->Website = $this->Website->Text; if (TPropertyValue::ensureBoolean($this->Application->Parameters['AccountApproval'])) { $userRecord->Status = UserRecord::STATUS_PENDING; } else { $userRecord->Status = UserRecord::STATUS_NORMAL; } $this->DataAccess->insertUser($userRecord); $authManager = $this->Application->getModule('auth'); $authManager->login($this->Username->Text, $this->Password->Text); $this->gotoDefaultPage(); } }
/** * Set the option to trim the contents. * @param boolean trim or not. */ public function setTrim($value) { $this->setViewState('Trim', TPropertyValue::ensureBoolean($value), true); }
/** * @param boolean whether this accordion view is active. */ public function setActive($value) { $this->_active = TPropertyValue::ensureBoolean($value); }
/** * Set to true to enable the callback response to enable the viewstate * update. This will automatically set HasPrority to true. * @param boolean true enables the callback response to update the * viewstate. */ public function setEnablePageStateUpdate($value) { $enabled = TPropertyValue::ensureBoolean($value); $this->setOption('EnablePageStateUpdate', $enabled); if ($enabled) { $this->setHasPriority(true); } }
/** * @param boolean whether the subdirectories of the directory will also be checked. */ public function setRecursiveCheck($value) { $this->_recursiveCheck = TPropertyValue::ensureBoolean($value); }
/** * @param boolean whether to allow custom paging */ public function setCustomPaging($value) { $this->_customPaging = TPropertyValue::ensureBoolean($value); }
public function setTranslateDefaultCulture($value) { $this->_translateDefaultCulture = TPropertyValue::ensureBoolean($value); }
/** * @param boolean whether the cache DB table should be automatically created if not exists. * @see setCacheTableName */ public function setAutoCreateCacheTable($value) { $this->_autoCreate = TPropertyValue::ensureBoolean($value); }
/** * @param boolean whether page state should be compressed. * @since 3.1.6 */ public function setEnableStateCompression($value) { $this->_enableStateCompression = TPropertyValue::ensureBoolean($value); }
/** * Set true to cache the table meta data. * @param boolean true to cache sqlmap instance. */ public function setEnableCache($value) { $this->_enableCache = TPropertyValue::ensureBoolean($value); }
/** * Sets the value indicating whether the content wraps within the table item. * @param boolean whether the content wraps within the panel. */ public function setWrap($value) { $this->_wrap = TPropertyValue::ensureBoolean($value); }
public function setColapse($value) { $this->setViewState('Colapse', TPropertyValue::ensureBoolean($value), false); }
/** * Sets the value indicating whether the text content wraps within a multiline text box. * @param boolean whether the text content wraps within a multiline text box. */ public function setWrap($value) { $this->setViewState('Wrap', TPropertyValue::ensureBoolean($value), true); }
/** * @param boolean whether this list is read-only or not */ protected function setReadOnly($value) { $this->_r = TPropertyValue::ensureBoolean($value); }
/** * @param boolean whether the column is visible */ public function setVisible($value) { $this->setViewState('Visible', TPropertyValue::ensureBoolean($value), true); }
/** * @param boolean whether the keyboard should be hidden when the textbox is not in focus. */ public function setAutoHide($value) { $this->setViewState('AutoHide', TPropertyValue::ensureBoolean($value), true); }
/** * Sets a value indicating whether to enable custom constructUrl using this pattern * @param boolean whether to enable custom constructUrl. */ public function setEnableCustomUrl($value) { $this->_customUrl = TPropertyValue::ensureBoolean($value); }
/** * Loads configuration from an XML element * @param TXmlElement configuration node * @throws TConfigurationException if log route class or type is not specified */ private function loadConfig($xml) { if ($xml instanceof TXmlElement) { foreach ($xml->getElementsByTagName('server') as $serverConfig) { $properties = $serverConfig->getAttributes(); if (($host = $properties->remove('Host')) === null) { throw new TConfigurationException('memcache_serverhost_required'); } if (($port = $properties->remove('Port')) === null) { throw new TConfigurationException('memcache_serverport_required'); } if (!is_numeric($port)) { throw new TConfigurationException('memcache_serverport_invalid'); } $server = array('Host' => $host, 'Port' => $port, 'Weight' => 1, 'Timeout' => 1800, 'RetryInterval' => 15, 'Persistent' => true); $checks = array('Weight' => 'memcache_serverweight_invalid', 'Timeout' => 'memcache_servertimeout_invalid', 'RetryInterval' => 'memcach_serverretryinterval_invalid'); foreach ($checks as $property => $exception) { $value = $properties->remove($property); if ($value !== null && is_numeric($value)) { $server[$property] = $value; } else { if ($value !== null) { throw new TConfigurationException($exception); } } } $server['Persistent'] = TPropertyValue::ensureBoolean($properties->remove('Persistent')); $this->_servers[] = $server; } } }
/** * @param boolean whether the keys are case-sensitive. */ public function setCaseSensitive($value) { $this->_caseSensitive = TPropertyValue::ensureBoolean($value); }
/** * @param boolean whether postback event trigger by edit or update button will cause input validation */ public function setCausesValidation($value) { $this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true); }
/** * Checks the radio button. * Updates radio button checked state on the client-side if the * {@link setEnableUpdate EnableUpdate} property is set to true. * @param boolean whether the radio button is to be checked or not. */ public function setChecked($value) { $value = TPropertyValue::ensureBoolean($value); parent::setChecked($value); if ($this->getActiveControl()->canUpdateClientSide()) { $this->getPage()->getCallbackClient()->check($this, $value); } }
/** * @param boolean whether to render javascript. */ public function setEnableClientScript($value) { $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); }
/** * Sets whether to pop up the color picker when the button is clicked. * @param boolean whether to show the color picker popup */ public function setShowColorPicker($value) { $this->setViewState('ShowColorPicker', TPropertyValue::ensureBoolean($value), true); }
/** * @param boolean ether the cookie should only be transmitted over a secure HTTPS connection */ public function setSecure($value) { $this->_secure = TPropertyValue::ensureBoolean($value); }