Example #1
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();
 }
 public function setTotalRowCount($value)
 {
     if (($value = TPropertyValue::ensureInteger($value)) < 0) {
         $value = 0;
     }
     $this->_totalRowCount = $value;
 }
Example #3
0
 private function createParameter($id, $value)
 {
     $element = new TXmlElement('parameter');
     $element->Attributes['id'] = $id;
     $element->Attributes['value'] = TPropertyValue::ensureString($value);
     return $element;
 }
Example #4
0
 public function editRow($sender, $param)
 {
     if ($this->IsValid) {
         $rows = new nNewsletterRecord();
         $rows->Name = TPropertyValue::ensureString($this->Name->getSafeText());
         $rows->Status = 0;
         $rows->save();
         $lay = new nLayoutRecord();
         //$lay->PlaneText = TPropertyValue::ensureString ( $this->PlaneText->getText () );
         $lay->HtmlText = TPropertyValue::ensureString($this->HtmlText->getText());
         $lay->nNewsletterID = $rows->ID;
         $lay->save();
         $mailList = explode(";", $this->SendDescription->getText());
         foreach ($mailList as $email) {
             if (filter_var(trim($email), FILTER_VALIDATE_EMAIL)) {
                 if (!nSenderRecord::finder()->findBy_nLayoutID_AND_Email($lay->ID, trim($email))) {
                     $send = new nSenderRecord();
                     $send->Email = trim($email);
                     $send->Status = 0;
                     $send->nLayoutID = $lay->ID;
                     $send->save();
                 }
             }
         }
         $this->Response->redirect($this->Service->constructUrl("Newsletter.Data"));
     }
 }
Example #5
0
 private function getPageSize()
 {
     if (($limit = TPropertyValue::ensureInteger($this->Request['limit'])) <= 0) {
         $limit = TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']);
     }
     return $limit;
 }
Example #6
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;
         }
     }
 }
Example #7
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 #8
0
 public function editRow($sender, $param)
 {
     if ($this->IsValid) {
         $finder = CatalogueRecord::finder();
         $finder->DbConnection->Active = true;
         $transaction = $finder->DbConnection->beginTransaction();
         try {
             $rows = $finder->findBycat_id($this->getRequest()->itemAt("id"));
             $rows->MasterName = TPropertyValue::ensureString($this->Name->getSafeText());
             $rows->ShortName = TPropertyValue::ensureString($this->ShortName->getSafeText());
             $baseMethod = new BaseFunction();
             $d = dir($baseMethod->UploadFilePath);
             while ($entry = $d->read()) {
                 if (strlen($entry) > 2 && is_file($d->path . '/' . $entry) && $entry != '.htaccess') {
                     copy($baseMethod->UploadFilePath . $entry, Prado::getPathOfAlias('UserFiles') . '/Language/' . $this->getRequest()->itemAt("id") . '/' . $entry) or die("Błąd przy kopiowaniu");
                     $rows->Photo = $entry;
                 }
             }
             $d->close();
             $rows->save();
             $transaction->commit();
             $this->Response->redirect($this->Service->constructUrl("Language.Index", array("id" => $this->getRequest()->itemAt("id"))));
         } catch (Exception $e) {
             $transaction->rollBack();
         }
     }
 }
 /**
  * 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 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 #11
0
 private function getCategoryFilter()
 {
     if (($catID = $this->Request['cat']) !== null) {
         $catID = TPropertyValue::ensureInteger($catID);
         return "category_id={$catID}";
     } else {
         return '';
     }
 }
Example #12
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);
     }
 }
 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;
 }
Example #14
0
 public function editRow($sender, $param)
 {
     if ($this->IsValid) {
         $short = strtolower($this->ShortName->getSafeText());
         $rows = new CatalogueRecord();
         $rows->name = 'messages.' . $short;
         $rows->MasterName = TPropertyValue::ensureString($this->Name->getSafeText());
         $rows->ShortName = TPropertyValue::ensureString($short);
         $rows->save();
         if (!is_dir(Prado::getPathOfAlias('UserFiles') . '/Language/' . $rows->cat_id)) {
             $dirun = dir(Prado::getPathOfAlias('UserFiles'));
             mkdir($dirun->path . '/Language/' . $rows->cat_id, 0775);
             $dirun->close();
         }
         $baseMethod = new BaseFunction();
         $d = dir($baseMethod->UploadFilePath);
         while ($entry = $d->read()) {
             if (strlen($entry) > 2 && is_file($d->path . '/' . $entry) && $entry != '.htaccess') {
                 copy($baseMethod->UploadFilePath . $entry, Prado::getPathOfAlias('UserFiles') . '/Language/' . $rows->cat_id . '/' . $entry) or die("Błąd przy kopiowaniu");
                 $row = CatalogueRecord::finder()->findBycat_id($rows->cat_id);
                 $row->Photo = $entry;
                 $row->save();
             }
         }
         $statyczne = PagesRecord::finder()->findAll('PageID IS NULL AND LanguageID = 1');
         foreach ($statyczne as $page) {
             $new = new PagesRecord();
             $new->Name = $rows->ShortName . ' : ' . $page->Name;
             $new->LanguageID = $rows->cat_id;
             $new->LangCode = $short;
             $new->PageID = $page->PageID;
             $new->Protected = $page->Protected;
             $new->Position = $page->Position;
             $new->ShowMenu = $page->ShowMenu;
             $new->save();
         }
         $translation = TransUnitRecord::finder()->findAll('cat_id = 1');
         foreach ($translation as $page) {
             $new = new TransUnitRecord();
             $new->id = $page->id;
             $new->cat_id = $rows->cat_id;
             $new->source = $page->source;
             $new->save();
         }
         $settings = SettingsRecord::finder()->findAll('LanguageID = 1');
         foreach ($settings as $set) {
             $newS = new SettingsRecord();
             $newS->Key = $set->Key;
             $newS->Value = $rows->ShortName . ' : ' . $set->Value;
             $newS->LanguageID = $rows->cat_id;
             $newS->LangCode = $short;
             $newS->save();
         }
         $this->Response->redirect($this->Service->constructUrl("Language.Index", array('id' => $rows->cat_id)));
     }
 }
Example #15
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 #16
0
 public function loadTestTemplate($sender, $param)
 {
     $c = new TestTemplate();
     $this->Content->Controls[] = $c;
     $c->dataBind();
     $this->Content->render($param->newWriter);
     $value = $this->Page->getControlState('WebgisDynamicControls');
     $value[] = array('classname' => get_class($c), 'args' => null);
     $this->Page->setControlState('WebgisDynamicControls', TPropertyValue::ensureArray($value), 0);
 }
Example #17
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 #18
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 #19
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 #20
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 #21
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 #22
0
 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();
     }
 }
Example #23
0
 public function onLoad($param)
 {
     parent::onLoad($param);
     $url = $this->Request->RequestUri;
     if (strpos($url, '?') === false) {
         $url .= '?notheme=true';
     } else {
         $url .= '&amp;notheme=true';
     }
     $this->PrinterLink->NavigateUrl = $url;
     if (isset($this->Request['notheme'])) {
         $this->MainMenu->Visible = false;
         $this->TopicPanel->Visible = false;
     }
     $this->languages->DataSource = TPropertyValue::ensureArray($this->Application->Parameters['languages']);
     $this->languages->dataBind();
 }
 /**
  * Constructor, similar to the parent constructor. For parameters that
  * are of SimpleXmlElement, the tag name and its attribute names and values
  * are expanded into a string.
  */
 public function __construct($errorMessage)
 {
     $this->setErrorCode($errorMessage);
     $errorMessage = $this->translateErrorMessage($errorMessage);
     $args = func_get_args();
     array_shift($args);
     $n = count($args);
     $tokens = array();
     for ($i = 0; $i < $n; ++$i) {
         if ($args[$i] instanceof SimpleXmlElement) {
             $tokens['{' . $i . '}'] = $this->implodeNode($args[$i]);
         } else {
             $tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]);
         }
     }
     parent::__construct(strtr($errorMessage, $tokens));
 }
Example #25
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();
     }
 }
 public function changePassword2($sender, $param)
 {
     $finder = UserRecord::finder();
     $finder->DbConnection->Active = true;
     $transaction = $finder->DbConnection->beginTransaction();
     try {
         $baseMethod = new BaseFunction();
         $hash = $this->getRequest()->itemAt("amp;hash");
         if ($this->getRequest()->contains("amp;hash") == false) {
             $hash = $this->getRequest()->itemAt("hash");
         }
         $rows = $finder->findByUsername($hash);
         $rows->Password = TPropertyValue::ensureString($baseMethod->cryptString($this->ConfirmPassword->getSafeText()));
         $rows->save();
         $transaction->commit();
     } catch (Exception $e) {
         print_R($e->getMessage());
         $transaction->rollBack();
     }
     $this->Response->redirect($this->Service->constructUrl("Login"));
 }
Example #27
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 #28
0
 public function editRow($sender, $param)
 {
     if ($this->IsValid) {
         $rows = new SliderRecord();
         $rows->Name = TPropertyValue::ensureString($this->Name->getSafeText());
         $rows->Description = TPropertyValue::ensureString($this->Description->getText());
         $rows->save();
         $baseMethod = new BaseFunction();
         $d = dir($baseMethod->UploadFilePath);
         while ($entry = $d->read()) {
             if (strlen($entry) > 2 && is_file($d->path . '/' . $entry) && $entry != '.htaccess') {
                 $namePhoto = strtolower($entry);
                 $rowPhoto = SliderRecord::finder()->findByID($rows->ID);
                 $rowPhoto->Photo = $namePhoto;
                 $rowPhoto->save();
                 copy($baseMethod->UploadFilePath . $entry, Prado::getPathOfAlias('UserFiles') . '/Slider/' . $namePhoto) or die("Błąd przy kopiowaniu");
             }
         }
         $d->close();
         $this->Response->redirect($this->Service->constructUrl("Slider.Index", array("id" => $rows->ID)));
     }
 }
Example #29
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();
     }
 }
Example #30
0
 public function changePageSize($sender, $param)
 {
     $this->dgDescuentosDet->PageSize = TPropertyValue::ensureInteger($this->PageSize->Text);
     $this->dgDescuentosDet->CurrentPageIndex = 0;
     $this->dgDescuentosDet->dataBind();
 }