Пример #1
0
 public function site()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.config.site', true, '/configuration');
     $site = \Rebond\Core\Site\Data::loadById(1);
     if (!isset($site)) {
         \Rebond\Util\Error::kill(\Rebond\Util\Error::SITE_NOT_FOUND, 'id: 1', __FILE__, __LINE__);
     }
     $siteForm = new \Rebond\Core\Site\Form($site);
     // action
     if (isset($_POST['save'])) {
         Auth::isAdminAuthorized($this->signedUser, 'admin.config.site.edit', true, '/');
         if ($siteForm->setFromPost()->validate()->isValid()) {
             $siteForm->getModel()->save();
             \Rebond\Core\Site\Service::updateIsCms($siteForm->getModel()->getIsCms());
             Session::adminSuccess('saved', '/configuration/site');
         } else {
             Session::set('adminError', $siteForm->getValidation()->getMessage());
         }
     }
     // view
     $this->setTpl();
     // main
     $tplMain = new Template(Template::MODULE, ['core', 'site']);
     $tplMain->set('item', $siteForm);
     // layout
     if (Auth::isAdminAuthorized($this->signedUser, 'admin.config.site.edit', false)) {
         $this->tplLayout->set('column1', $tplMain->render('editor'));
     } else {
         $this->tplLayout->set('column1', $tplMain->render('view'));
     }
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     return $this->tplMaster->render('tpl-default');
 }
Пример #2
0
 public function reinitialize()
 {
     // auth
     Util\Auth::isAdminAuthorized($this->signedUser, 'admin.dev', true, '/');
     // check
     $action = Util\Converter::string('action');
     if (isset($action)) {
         $result = [];
         $result['status'] = true;
         $result['message'] = '';
         $site = \Rebond\Core\Site\Data::loadById(1);
         $db = new \Rebond\Util\Data();
         switch ($action) {
             case 'file':
                 \Rebond\Core\Site\Service::resetFiles();
                 break;
             case 'restore':
                 $files = \Rebond\Util\File::getFiles('files/backup');
                 $fileFound = false;
                 foreach ($files as $file) {
                     if (stripos($file, 'launch') !== false) {
                         $fileFound = true;
                         $result = $db->restore($file);
                         break;
                     }
                 }
                 if (!$fileFound) {
                     $result['status'] = false;
                     $result['message'] = Util\Lang::lang('dbLaunchFileNotFound');
                 } else {
                     \Rebond\Core\Site\Service::resetFiles();
                 }
                 break;
             case 'full':
                 \Rebond\Core\Site\Service::resetFiles();
                 $result = $db->reset();
                 Util\Session::adminSuccess('resetSuccessful', '/');
                 break;
         }
         if ($result['status']) {
             Util\Session::set('adminSuccess', Util\Lang::lang('resetSuccessful'));
         } else {
             Util\Session::set('adminError', $result['message']);
         }
     }
     // view
     $this->setTpl();
     // main
     $tplMain = new Util\Template(Util\Template::SITE, ['admin', 'dev']);
     // layout
     $this->tplLayout->set('column1', $tplMain->render('reinitialize'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     $this->tplMaster->set('jsLauncher', 'dev');
     return $this->tplMaster->render('tpl-default');
 }
Пример #3
0
 public function site()
 {
     if ($this->step != Config::STEP_RUNNING) {
         return new \Rebond\Core\Site\Model();
     }
     if (!isset($this->site)) {
         $this->site = \Rebond\Core\Site\Data::loadById(1);
     }
     if (!isset($this->site)) {
         Error::kill(Error::SITE_NOT_FOUND, 'id: 1', __FILE__, __LINE__);
     }
     return $this->site;
 }