Exemple #1
0
 public function editRow($sender, $param)
 {
     if ($this->IsValid) {
         $finder = SliderRecord::finder();
         $finder->DbConnection->Active = true;
         $transaction = $finder->DbConnection->beginTransaction();
         try {
             $rows = $finder->findByID($this->getRequest()->itemAt("id"));
             $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($this->getRequest()->itemAt("id"));
                     $rowPhoto->Photo = $namePhoto;
                     $rowPhoto->save();
                     copy($baseMethod->UploadFilePath . $entry, Prado::getPathOfAlias('UserFiles') . '/Slider/' . $namePhoto) or die("Błąd przy kopiowaniu");
                 }
             }
             $d->close();
             $transaction->commit();
             $this->Response->redirect($this->Service->constructUrl("Slider.Index", array("id" => $this->getRequest()->itemAt("id"))));
         } catch (Exception $e) {
             $transaction->rollBack();
             die;
         }
     }
 }
Exemple #2
0
 protected function checkPosition()
 {
     $i = 1;
     foreach (SliderRecord::finder()->findAll(' ORDER BY Position') as $row) {
         $rows = SliderRecord::finder()->findByID($row->ID);
         $rows->Position = $i * 10;
         $rows->save();
         $i++;
     }
     return $i - 1;
 }