예제 #1
0
파일: SalicMng.php 프로젝트: TeNNoX/Salic
 public function savePage($pagekey)
 {
     $result = array("success" => false);
     try {
         if (!array_key_exists('regions', $_POST)) {
             Utils::returnHttpError(400, "Error: missing regions in POST data");
         }
         $regions = $_POST['regions'];
         if ($pagekey !== '404' && !PageSettings::pageExists($pagekey)) {
             //TODO: sanitize pagekey
             //TODO: error handling
             Utils::returnHttpError(400, "Error: Unknown pagekey '{$pagekey}'");
         }
         $this->doSavePage($pagekey, $regions);
         $result['success'] = true;
     } catch (SalicApiException $e) {
         $result['error'] = "APIException - " . $e->getMessage();
         $result['debugData'] = $e->debugData;
         //TODO: send api debug data only in debug mode
     } catch (\Exception $e) {
         $result['error'] = "PHPException - " . $e->getMessage();
     }
     header('Content-Type: application/json');
     echo json_encode($result);
 }
예제 #2
0
파일: Salic.php 프로젝트: TeNNoX/Salic
 public function renderPage($pagekey)
 {
     try {
         if (!PageSettings::pageExists($pagekey)) {
             // when querying an invalid page, go to 404
             $this->render404();
             return;
         }
         // load template and field data
         $pageSettings = Settings\PageSettings::get($pagekey);
         $template = $this->getTemplate($pageSettings->template, $pagekey);
         $data = $this->loadData($pagekey, $template);
         $data['pagetitle'] = $pageSettings->title->get($this->current_lang);
         $this->doRenderPage($template->filename, $data);
     } catch (\Exception $e) {
         Utils::dieWithError($e, 'page rendering', $this);
     }
 }
예제 #3
0
 public function validate()
 {
     // check homepage
     if (!PageSettings::pageExists($this->homepage)) {
         // make sure the specified homepage exists
         throw new SalicSettingsException("Page '{$this->homepage}' not found found in pages/", $this->file . self::fis . 'homepage');
     }
     // check displayed pages
     $externals = array_keys($this->external_links);
     foreach ($this->displayed as $page) {
         if (in_array($page, $externals)) {
             continue;
         }
         // if it is an external link, it doesn't need to exist
         if (!PageSettings::pageExists($page)) {
             // make sure the specified page exists
             throw new SalicSettingsException("Page '{$page}' is neither in data/ nor an external_link", $this->file . self::fis . 'displayed');
         }
     }
 }