Beispiel #1
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();
         }
     }
 }
 public function fileDelete($sender, $param)
 {
     if ($this->pathName[1] == 'Index') {
         FilesRecord::finder()->deleteByID($param->CommandName);
         unlink(Prado::getPathOfAlias('UserFiles') . '/' . $this->pathName[0] . '/' . $this->getRequest()->itemAt("id") . '/' . $param->CommandParameter);
     }
     $this->Response->redirect($this->Service->constructUrl($this->pathName[0] . ".Index", array("id" => $this->getRequest()->itemAt("id"))));
 }
Beispiel #3
0
 protected function importZendNamespace()
 {
     if (is_null(Prado::getPathOfAlias('Zend'))) {
         $zendBase = !is_null($this->_ZF) ? $this->_ZF . '.*' : 'Application.index.*';
         $path = !is_null($this->_ZF) ? $this->_ZF . '.Zend.*' : 'Application.index.Zend.*';
         Prado::using($zendBase);
         Prado::setPathOfAlias('Zend', Prado::getPathOfNamespace($path));
     }
 }
Beispiel #4
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)));
     }
 }
Beispiel #5
0
 public function testSetTransformPathAsNamespace()
 {
     if (Prado::getPathOfAlias('UnitTest') === null) {
         Prado::setPathOfAlias('UnitTest', dirname(__FILE__) . '/data');
     }
     $expected = $this->transformPath;
     $transform = new TXmlTransform();
     $transform->setTransformPath('UnitTest.hello');
     $this->assertEquals($expected, $transform->getTransformPath());
 }
Beispiel #6
0
 public function editRow($sender, $param)
 {
     $baseMethod = new BaseFunction();
     $d = dir($baseMethod->UploadFilePath);
     while ($entry = $d->read()) {
         if (strlen($entry) > 2 && is_file($d->path . '/' . $entry) && $entry != '.htaccess') {
             $male = strtolower($entry);
             if (file_exists(Prado::getPathOfAlias('UserFiles') . '/Bg/' . $male)) {
                 unlink(Prado::getPathOfAlias('UserFiles') . '/Bg/' . $male);
             }
             copy($baseMethod->UploadFilePath . $entry, Prado::getPathOfAlias('UserFiles') . '/Bg/' . $male) or die("Błąd przy kopiowaniu");
             $rows->Photo = $entry;
         }
     }
     $d->close();
 }
Beispiel #7
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)));
     }
 }
 public function clearTempFile()
 {
     $d = dir(Prado::getPathOfAlias('UserFiles'));
     while ($entry = $d->read()) {
         if (strlen($entry) > 2 && is_file($d->path . '/' . $entry)) {
             unlink(Prado::getPathOfAlias('UserFiles') . '/' . $entry);
         }
     }
     $d->close();
     $f = dir('themes/Admin/jQuery-File-Upload/server/php/files/');
     while ($entry = $f->read()) {
         if (strlen($entry) > 2 && is_file($f->path . '/' . $entry) && $entry != '.htaccess') {
             unlink($f->path . '/' . $entry);
         }
     }
     $f->close();
     $g = dir('themes/Admin/jQuery-File-Upload/server/php/files/thumb/');
     while ($entry = $g->read()) {
         if (strlen($entry) > 2 && is_file($g->path . '/' . $entry) && $entry != '.htaccess') {
             unlink($g->path . '/' . $entry);
         }
     }
     $g->close();
 }
Beispiel #9
0
 public function editRow($sender, $param)
 {
     if ($this->IsValid) {
         $finder = PagesRecord::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->ShortDescription = TPropertyValue::ensureString($this->ShortDescription->getText());
             $rows->Seo = TPropertyValue::ensureString($this->Seo->getSafeText());
             $rows->MetaKeywords = TPropertyValue::ensureString($this->MetaKeywords->getSafeText());
             $rows->MetaDescription = TPropertyValue::ensureString($this->MetaDescription->getSafeText());
             $rows->ShowDate = TPropertyValue::ensureString($this->ShowDate->getSafeText());
             $rows->ShowDateDiff = strtotime($this->ShowDate->getSafeText());
             $rows->PageID = $this->OtherPages->getData();
             $rows->TitleDate = TPropertyValue::ensureString($this->TitleDate->getSafeText());
             $rows->ShowMenu = $this->ShowMenu->getChecked();
             $rows->ShowFooter = $this->ShowFooter->getChecked();
             $rows->ShowHome = $this->ShowHome->getChecked();
             if ($this->ShowHome->getChecked() == true) {
                 $rows->HideDate = TPropertyValue::ensureString($this->HideDate->getSafeText());
                 $rows->HideDateDiff = strtotime($this->HideDate->getSafeText());
             } else {
                 $rows->HideDate = null;
                 $rows->HideDateDiff = 0;
             }
             $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);
                     $row = new FilesRecord();
                     $row->Name = $namePhoto;
                     $row->IsParent = 0;
                     if (FilesRecord::finder()->count('PagesID = ? AND IsParent = 1', $this->getRequest()->itemAt("id")) == 0) {
                         $row->IsParent = 1;
                     }
                     $row->Position = 999;
                     //$row->PagesID = $this->getRequest ()->itemAt ( "id" );
                     $row->save();
                     copy($baseMethod->UploadFilePath . $entry, Prado::getPathOfAlias('UserFiles') . '/Pages/' . $this->getRequest()->itemAt("id") . '/' . $namePhoto) or die("Błąd przy kopiowaniu");
                     $baseMethod->createThumb($namePhoto, Prado::getPathOfAlias('UserFiles') . '/Pages/' . $this->getRequest()->itemAt("id") . '/', $baseMethod->GlobalWidth);
                 }
             }
             $d->close();
             $transaction->commit();
             $this->Response->redirect($this->Service->constructUrl("Pages.Index", array("id" => $this->getRequest()->itemAt("id"))));
         } catch (Exception $e) {
             $transaction->rollBack();
             print_r($e);
             echo 'a';
             die;
         }
     }
 }
Beispiel #10
0
 public function editRow($sender, $param)
 {
     if ($this->IsValid) {
         $session = Prado::getApplication()->getSession();
         $langID = $session->itemAt('jezyk');
         $rows = new PagesRecord();
         $rows->Name = TPropertyValue::ensureString($this->Name->getSafeText());
         /*
         if($this->User->PagesID == 0)
         $rows->PageID = $this->getRequest ()->itemAt ( "id" );
         else
         	$rows->PageID = $this->User->PagesID;
         */
         $rows->Description = TPropertyValue::ensureString($this->Description->getText());
         $rows->ShortDescription = TPropertyValue::ensureString($this->ShortDescription->getText());
         $rows->Seo = TPropertyValue::ensureString($this->Seo->getSafeText());
         $rows->MetaKeywords = TPropertyValue::ensureString($this->MetaKeywords->getSafeText());
         $rows->MetaDescription = TPropertyValue::ensureString($this->MetaDescription->getSafeText());
         $rows->LanguageID = $langID;
         $rows->LangCode = CatalogueRecord::finder()->find('cat_id = ?', $langID)->ShortName;
         $rows->ShowDate = TPropertyValue::ensureString($this->ShowDate->getSafeText());
         $rows->ShowDateDiff = strtotime($this->ShowDate->getSafeText());
         $rows->TitleDate = TPropertyValue::ensureString($this->TitleDate->getSafeText());
         $rows->ShowMenu = $this->ShowMenu->getChecked();
         $rows->ShowFooter = $this->ShowFooter->getChecked();
         $rows->ShowHome = $this->ShowHome->getChecked();
         if ($this->ShowHome->getChecked() == true) {
             $rows->HideDate = TPropertyValue::ensureString($this->HideDate->getSafeText());
             $rows->HideDateDiff = strtotime($this->HideDate->getSafeText());
         } else {
             $rows->HideDate = null;
             $rows->HideDateDiff = 0;
         }
         $rows->save();
         $pos = PagesRecord::finder()->findByID($rows->ID);
         $pos->Position = 0;
         $pos->save();
         if (!is_dir(Prado::getPathOfAlias('UserFiles') . '/Pages/' . $rows->ID)) {
             $dirun = dir(Prado::getPathOfAlias('UserFiles'));
             mkdir($dirun->path . '/Pages/' . $rows->ID, 0775);
             mkdir($dirun->path . '/Pages/' . $rows->ID . '/thumb/', 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') {
                 $namePhoto = strtolower($entry);
                 $row = new FilesRecord();
                 $row->Name = $namePhoto;
                 $row->IsParent = 0;
                 if (FilesRecord::finder()->count('PagesID = ? AND IsParent = 1', $rows->ID) == 0) {
                     $row->IsParent = 1;
                 }
                 $row->Position = 999;
                 $row->PagesID = $rows->ID;
                 $row->save();
                 copy($baseMethod->UploadFilePath . $entry, Prado::getPathOfAlias('UserFiles') . '/Pages/' . $rows->ID . '/' . $namePhoto) or die("Błąd przy kopiowaniu");
                 $baseMethod->createThumb($namePhoto, Prado::getPathOfAlias('UserFiles') . '/Pages/' . $rows->ID . '/', $baseMethod->GlobalWidth);
             }
         }
         $d->close();
         $this->Response->redirect($this->Service->constructUrl("Pages.Index", array("id" => $rows->ID)));
     }
 }