예제 #1
0
 public function validate()
 {
     foreach ($this->available as $key => $name) {
         if (!Validator::checkLangKey($key)) {
             throw new SalicSettingsException("Language format invalid: '{$key}'", $this->file . self::fis . 'available', $this->available);
         }
     }
     // check if default is in available
     if (!array_key_exists($this->default, $this->available)) {
         // make sure the specified homepage exists
         throw new SalicSettingsException("Default language '{$this->default}' not found found in available ", $this->file . self::fis . 'default', $this->available);
     }
 }
예제 #2
0
 public function __construct($pageKey)
 {
     if (!Validator::checkPageKey($pageKey)) {
         throw new SalicException("Invalid pagekey format: '{$pageKey}'");
     }
     $this->pageKey = $pageKey;
     //Utils::mkdirs(self::baseDir . "data/$pageKey");
     if (!is_dir(self::baseDir . "pages/{$pageKey}")) {
         throw new SalicSettingsException("No page config for: '{$pageKey}'", "pages/{$pageKey}");
     }
     $this->file = 'pages/' . $pageKey . '/page.json';
     parent::__construct();
 }
예제 #3
0
파일: edit.php 프로젝트: TeNNoX/Salic
use Salic\Settings\LangSettings;
require_once 'Salic.php';
if (!Utils::validAuthentication()) {
    exit;
    // Utils should call exit(), but just to be sure...
}
$lang = strtolower(@$_GET['lang']);
if (empty($lang)) {
    $lang = LangSettings::get()->default;
}
if (!LangSettings::get()->exists($lang)) {
    echo "Invalid Language: '{$lang}'";
    exit;
}
$salic = new SalicMng($lang);
$salic->initTwig();
$page = strtolower(@$_GET['page']);
if (!empty($page) && !Validator::checkPageKey($page)) {
    Utils::dieWith404('there\'s an invalid symbol in the pagekey.');
}
if (empty($page)) {
    // default page
    try {
        $page = Settings\NavSettings::get()->homepage;
    } catch (\Exception $e) {
        Utils::dieWithError($e, 'Homepage determination', $salic);
        exit;
    }
}
$salic->renderPage($page);
예제 #4
0
파일: save.php 프로젝트: TeNNoX/Salic
<?php

namespace Salic;

use Salic\Settings\LangSettings;
require_once 'Salic.php';
//TODO:? disable error_reporting
if (!Utils::validAuthentication()) {
    exit;
    // Utils should call exit(), but just to be sure...
}
$lang = strtolower($_GET['lang']);
if (!LangSettings::get()->exists($lang)) {
    die('{"success": false, "error": "APIException - Invalid Language: ' . $lang . '"}');
}
$salic = new SalicMng($lang);
$page = strtolower($_GET['page']);
if (empty($page)) {
    die('{"success": false, "error": "APIException - No pagekey given"}');
}
if (!Validator::checkPageKey($page)) {
    die('{"success": false, "error": "APIException - Invalid pagekey"}');
}
$salic->savePage($page);