Ejemplo n.º 1
0
 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));
     }
 }
Ejemplo n.º 2
0
 /**
  * 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;
         }
     }
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 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();
     }
 }
Ejemplo n.º 5
0
 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);
     }
 }
Ejemplo n.º 6
0
 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();
     }
 }
Ejemplo n.º 7
0
 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();
     }
 }
Ejemplo n.º 8
0
 /**
  * Set the option to trim the contents.
  * @param boolean trim or not.
  */
 public function setTrim($value)
 {
     $this->setViewState('Trim', TPropertyValue::ensureBoolean($value), true);
 }
Ejemplo n.º 9
0
 /**
  * @param boolean whether this accordion view is active.
  */
 public function setActive($value)
 {
     $this->_active = TPropertyValue::ensureBoolean($value);
 }
Ejemplo n.º 10
0
 /**
  * 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);
     }
 }
Ejemplo n.º 11
0
 /**
  * @param boolean whether the subdirectories of the directory will also be checked.
  */
 public function setRecursiveCheck($value)
 {
     $this->_recursiveCheck = TPropertyValue::ensureBoolean($value);
 }
Ejemplo n.º 12
0
 /**
  * @param boolean whether to allow custom paging
  */
 public function setCustomPaging($value)
 {
     $this->_customPaging = TPropertyValue::ensureBoolean($value);
 }
Ejemplo n.º 13
0
 public function setTranslateDefaultCulture($value)
 {
     $this->_translateDefaultCulture = TPropertyValue::ensureBoolean($value);
 }
Ejemplo n.º 14
0
 /**
  * @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);
 }
Ejemplo n.º 15
0
 /**
  * @param boolean whether page state should be compressed.
  * @since 3.1.6
  */
 public function setEnableStateCompression($value)
 {
     $this->_enableStateCompression = TPropertyValue::ensureBoolean($value);
 }
Ejemplo n.º 16
0
 /**
  * Set true to cache the table meta data.
  * @param boolean true to cache sqlmap instance.
  */
 public function setEnableCache($value)
 {
     $this->_enableCache = TPropertyValue::ensureBoolean($value);
 }
Ejemplo n.º 17
0
 /**
  * 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);
 }
Ejemplo n.º 18
0
 public function setColapse($value)
 {
     $this->setViewState('Colapse', TPropertyValue::ensureBoolean($value), false);
 }
Ejemplo n.º 19
0
 /**
  * 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);
 }
Ejemplo n.º 20
0
 /**
  * @param boolean whether this list is read-only or not
  */
 protected function setReadOnly($value)
 {
     $this->_r = TPropertyValue::ensureBoolean($value);
 }
Ejemplo n.º 21
0
 /**
  * @param boolean whether the column is visible
  */
 public function setVisible($value)
 {
     $this->setViewState('Visible', TPropertyValue::ensureBoolean($value), true);
 }
Ejemplo n.º 22
0
 /**
  * @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);
 }
Ejemplo n.º 23
0
 /**
  * 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);
 }
Ejemplo n.º 24
0
 /**
  * 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;
         }
     }
 }
Ejemplo n.º 25
0
 /**
  * @param boolean whether the keys are case-sensitive.
  */
 public function setCaseSensitive($value)
 {
     $this->_caseSensitive = TPropertyValue::ensureBoolean($value);
 }
Ejemplo n.º 26
0
 /**
  * @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);
 }
Ejemplo n.º 27
0
 /**
  * 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);
     }
 }
Ejemplo n.º 28
0
 /**
  * @param boolean whether to render javascript.
  */
 public function setEnableClientScript($value)
 {
     $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true);
 }
Ejemplo n.º 29
0
 /**
  * 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);
 }
Ejemplo n.º 30
0
 /**
  * @param boolean ether the cookie should only be transmitted over a secure HTTPS connection
  */
 public function setSecure($value)
 {
     $this->_secure = TPropertyValue::ensureBoolean($value);
 }