コード例 #1
0
ファイル: Add.php プロジェクト: venomproject/defaultCMS
 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)));
     }
 }
コード例 #2
0
ファイル: Index.php プロジェクト: venomproject/defaultCMS
 public function onLoad($param)
 {
     parent::onLoad($param);
     if ($this->getRequest()->contains("kopiaId")) {
         $clone = PagesRecord::finder()->findByPk($this->getRequest()->itemAt("kopiaId"));
         if (isset($clone)) {
             $rows = new PagesRecord();
             $rows->Name = $clone->Name;
             $rows->ShortDescription = $clone->ShortDescription;
             $rows->Description = $clone->Description;
             $rows->LanguageID = $clone->LanguageID;
             $rows->LangCode = $clone->LangCode;
             $rows->Protected = 0;
             $rows->ShowMenu = 0;
             $rows->ShowFooter = 0;
             $rows->ShowHome = 0;
             $rows->HideDate = null;
             $rows->ShowDate = $clone->ShowDate;
             $rows->TitleDate = $clone->TitleDate;
             $rows->Seo = $clone->Seo;
             $rows->MetaKeywords = $clone->MetaKeywords;
             $rows->MetaDescription = $clone->MetaDescription;
             //$rows->PageID = $clone->PageID;
             $rows->Other = $clone->Other;
             $rows->Position = $clone->Position;
             $rows->save();
             $this->Response->redirect($this->Service->constructUrl("Pages.Index", array("id" => $rows->ID)));
         } else {
             $this->Response->redirect($this->Service->constructUrl("Pages.Data"));
         }
     }
     $this->staticPage = PagesRecord::finder()->findByPk($this->getRequest()->itemAt("id"));
     if ($this->getRequest()->contains("id") == true && isset($this->staticPage) == true) {
         $m = $this->getRequest()->itemAt("id");
         if ($m != null) {
             do {
                 $b = PagesRecord::finder()->find('ID = ?', $m);
                 $m = $b->PageID;
                 $this->activeBreadcrumbs[$b->ID] = $b->Name;
             } while ($m != null);
         }
         ksort($this->activeBreadcrumbs);
         $session = Prado::getApplication()->getSession();
         $langID = $session->itemAt('jezyk');
         $parentID = $this->getRequest()->itemAt("id");
         if (!$this->getPage()->IsPostBack) {
             TPropertyValue::ensureString($this->Name->setText($this->staticPage->Name));
             TPropertyValue::ensureString($this->ShowDate->setText($this->staticPage->ShowDate));
             TPropertyValue::ensureString($this->TitleDate->setText($this->staticPage->TitleDate));
             TPropertyValue::ensureString($this->Seo->setText($this->staticPage->Seo));
             TPropertyValue::ensureString($this->Description->setText($this->staticPage->Description));
             TPropertyValue::ensureString($this->ShortDescription->setText($this->staticPage->ShortDescription));
             TPropertyValue::ensureString($this->MetaKeywords->setText($this->staticPage->MetaKeywords));
             TPropertyValue::ensureString($this->MetaDescription->setText($this->staticPage->MetaDescription));
             $this->ShowMenu->setChecked($this->staticPage->ShowMenu);
             $this->ShowFooter->setChecked($this->staticPage->ShowFooter);
             $this->ShowHome->setChecked($this->staticPage->ShowHome);
             if ($this->staticPage->ShowHome == true) {
                 TPropertyValue::ensureString($this->HideDate->setText($this->staticPage->HideDate));
             }
             $this->checkPosition($parentID, $langID);
             $this->PagesChildren->DataSource = PagesRecord::finder()->findAll('Protected = 0 AND PageID = ? AND LanguageID = ? ORDER BY Position', $parentID, $langID);
             $this->PagesChildren->dataBind();
             $this->OtherPages->DataSource = PagesRecord::finder()->findAll('ORDER BY Name');
             $this->OtherPages->dataBind();
             $this->OtherPages->setSelectedValue($this->staticPage->PageID);
         }
     } else {
         $this->Response->redirect($this->Service->constructUrl("Pages.Add"));
     }
 }
コード例 #3
0
ファイル: Add.php プロジェクト: venomproject/defaultCMS
 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)));
     }
 }