Example #1
0
 private function getPageSize()
 {
     if (($limit = TPropertyValue::ensureInteger($this->Request['limit'])) <= 0) {
         $limit = TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']);
     }
     return $limit;
 }
Example #2
0
 public function setTimeStamp($value)
 {
     $ts = TPropertyValue::ensureInteger($value);
     $this->DatePicker->TimeStamp = $ts;
     $this->HourPicker->SelectedValue = date('H', $ts);
     $this->MinutePicker->SelectedValue = date('i', $ts);
 }
 public function setTotalRowCount($value)
 {
     if (($value = TPropertyValue::ensureInteger($value)) < 0) {
         $value = 0;
     }
     $this->_totalRowCount = $value;
 }
Example #4
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));
     }
 }
Example #5
0
 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}";
 }
Example #6
0
 public function changePageSize($sender, $param)
 {
     $this->DataGrid->PageSize = TPropertyValue::ensureInteger($this->PageSize->Text);
     $this->DataGrid->CurrentPageIndex = 0;
     $this->DataGrid->DataSource = $this->Data;
     $this->DataGrid->dataBind();
 }
 /**
  * @param integer maximum number of page states that should be kept in session
  * @throws TInvalidDataValueException if the number is smaller than 1.
  */
 public function setHistorySize($value)
 {
     if (($value = TPropertyValue::ensureInteger($value)) > 0) {
         $this->_historySize = $value;
     } else {
         throw new TInvalidDataValueException('sessionpagestatepersister_historysize_invalid');
     }
 }
Example #8
0
 private function getCategoryFilter()
 {
     if (($catID = $this->Request['cat']) !== null) {
         $catID = TPropertyValue::ensureInteger($catID);
         return "category_id={$catID}";
     } else {
         return '';
     }
 }
Example #9
0
 public function onInit($param)
 {
     parent::onInit($param);
     $id = TPropertyValue::ensureInteger($this->Request['id']);
     $this->_category = $this->DataAccess->queryCategoryByID($id);
     if ($this->_category === null) {
         throw new BlogException(500, 'category_id_invalid', $id);
     }
 }
Example #10
0
 public function saveItem($sender, $param)
 {
     $item = $param->Item;
     $postID = $this->PostGrid->DataKeys[$item->ItemIndex];
     $postRecord = $this->DataAccess->queryPostByID($postID);
     $postRecord->Status = TPropertyValue::ensureInteger($item->Cells[2]->PostStatus->SelectedValue);
     $this->DataAccess->updatePost($postRecord);
     $this->PostGrid->EditItemIndex = -1;
     $this->bindData();
 }
Example #11
0
 public function saveItem($sender, $param)
 {
     $item = $param->Item;
     $userID = $this->UserGrid->DataKeys[$item->ItemIndex];
     $userRecord = $this->DataAccess->queryUserByID($userID);
     $userRecord->Role = TPropertyValue::ensureInteger($item->Cells[1]->UserRole->SelectedValue);
     $userRecord->Status = TPropertyValue::ensureInteger($item->Cells[2]->UserStatus->SelectedValue);
     $this->DataAccess->updateUser($userRecord);
     $this->UserGrid->EditItemIndex = -1;
     $this->bindData();
 }
Example #12
0
 public function selectLevel($sender, $param)
 {
     if (($selection = $this->LevelSelection->SelectedValue) === '') {
         $this->LevelError->Visible = true;
         return;
     } else {
         $this->Level = TPropertyValue::ensureInteger($selection);
     }
     $this->Word = $this->generateWord();
     $this->GuessWord = str_repeat('_', strlen($this->Word));
     $this->Misses = 0;
     $this->GameMultiView->ActiveView = $this->GuessView;
 }
Example #13
0
 public function onInit($param)
 {
     parent::onInit($param);
     if (($id = $this->Request['id']) !== null) {
         $id = TPropertyValue::ensureInteger($id);
     } else {
         $id = $this->User->ID;
     }
     if (($this->_userRecord = $this->DataAccess->queryUserByID($id)) === null) {
         throw new BlogException(500, 'profile_id_invalid', $id);
     }
     $this->_userRecord->Email = strtr(strtoupper($this->_userRecord->Email), array('@' => ' at ', '.' => ' dot '));
 }
Example #14
0
 public function onLoad($param)
 {
     parent::onLoad($param);
     $commentLimit = TPropertyValue::ensureInteger($this->Application->Parameters['RecentComments']);
     $comments = $this->Application->getModule('data')->queryComments('', 'ORDER BY create_time DESC', "LIMIT {$commentLimit}");
     foreach ($comments as $comment) {
         $comment->ID = $this->Service->constructUrl('Posts.ViewPost', array('id' => $comment->PostID)) . '#c' . $comment->ID;
         if (strlen($comment->Content) > 40) {
             $comment->Content = substr($comment->Content, 0, 40) . ' ...';
         }
     }
     $this->CommentList->DataSource = $comments;
     $this->CommentList->dataBind();
 }
Example #15
0
 public function onInit($param)
 {
     parent::onInit($param);
     if (($id = $this->Request['id']) !== null) {
         $id = TPropertyValue::ensureInteger($id);
         if (!$this->User->IsAdmin && $this->User->ID !== $id) {
             throw new BlogException(500, 'profile_edit_disallowed', $id);
         }
     } else {
         $id = $this->User->ID;
     }
     if (($this->_userRecord = $this->DataAccess->queryUserByID($id)) === null) {
         throw new BlogException(500, 'profile_id_invalid', $id);
     }
 }
Example #16
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();
     }
 }
Example #17
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();
     }
 }
Example #18
0
 /**
  * @param integer port number of the memcache server
  * @throws TInvalidOperationException if the module is already initialized
  */
 public function setPort($value)
 {
     if ($this->_initialized) {
         throw new TInvalidOperationException('memcache_port_unchangeable');
     } else {
         $this->_port = TPropertyValue::ensureInteger($value);
     }
 }
Example #19
0
 public function changePageSize($sender, $param)
 {
     $this->dgDescuentosDet->PageSize = TPropertyValue::ensureInteger($this->PageSize->Text);
     $this->dgDescuentosDet->CurrentPageIndex = 0;
     $this->dgDescuentosDet->dataBind();
 }
Example #20
0
 /**
  * @param integer Maximum height for the accordion views. If any of the accordion's views' content is larger, those views will be made scrollable when activated
  */
 public function setViewHeight($value)
 {
     $this->setViewState('ViewHeight', TPropertyValue::ensureInteger($value));
 }
Example #21
0
 public function setCacheTime($value)
 {
     $this->_cacheTime = TPropertyValue::ensureInteger($value);
 }
Example #22
0
 /**
  * Sets a value indicating the depth of the subdirectories to be checked.
  * This is meaningful only when {@link getRecursiveCheck RecursiveCheck}
  * is true.
  * @param int the depth of the subdirectories to be checked.
  * If the value is less than 0, it means unlimited depth.
  * If the value is 0, it means checking the files directly under the specified directory.
  */
 public function setRecursiveLevel($value)
 {
     $this->_recursiveLevel = TPropertyValue::ensureInteger($value);
 }
Example #23
0
 /**
  * @param integer callback request timeout
  */
 public function setRequestTimeOut($value)
 {
     $this->setOption('RequestTimeOut', TPropertyValue::ensureInteger($value));
 }
Example #24
0
 /**
  * @param integer max number of selections.
  */
 public function setMaxSelection($value)
 {
     if (($value = TPropertyValue::ensureInteger($value)) < 0) {
         $value = -1;
     }
     $this->setViewState('MaxSelection', $value, -1);
 }
Example #25
0
 /**
  * @param integer date picker ending year, default +10 years
  */
 public function setUpToYear($value)
 {
     $this->setViewState('UpToYear', TPropertyValue::ensureInteger($value), intval(@date('Y')) + 10);
 }
Example #26
0
 /**
  * @param integer the time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch.
  */
 public function setExpire($value)
 {
     $this->_expire = TPropertyValue::ensureInteger($value);
 }
Example #27
0
 /**
  * Sets the number of rows displayed in a multiline text box.
  * @param integer the number of rows
  */
 public function setRows($value)
 {
     $this->setViewState('Rows', TPropertyValue::ensureInteger($value), self::DEFAULT_ROWS);
 }
Example #28
0
 public function changePageSize($sender, $param)
 {
     $this->DataGridSpese->PageSize = TPropertyValue::ensureInteger($this->PageSize->Text);
     $this->DataGridSpese->CurrentPageIndex = 0;
     $this->CreateArray($this->FilterCollection_descrizione->getCondition(), $this->getViewState('sort', ''));
     $this->DataGridSpese->DataSource = $this->Data;
     $this->DataGridSpese->dataBind();
 }
Example #29
0
 /**
  * Maximum number of items to cache. Default size is 100.
  * @param int cache size.
  */
 public function setCacheSize($value)
 {
     $this->_cacheSize = TPropertyValue::ensureInteger($value, 100);
 }
Example #30
0
 /**
  * @param integer cellspacing of the table. A value equal to -1 clears up the setting.
  * @throws TInvalidDataValueException if the value is less than -1.
  */
 public function setCellSpacing($value)
 {
     if (($this->_cellSpacing = TPropertyValue::ensureInteger($value)) < -1) {
         throw new TInvalidDataValueException('tablestyle_cellspacing_invalid');
     }
 }