コード例 #1
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);
コード例 #2
0
ファイル: Salic.php プロジェクト: TeNNoX/Salic
 protected function doRenderPage($templatefile, $vars)
 {
     $vars['debug_mode'] = GeneralSettings::get()->debugMode;
     $vars['baseurl'] = $this->baseUrl;
     $vars['baseurl_international'] = $this->baseUrlInternational;
     $vars['nav_pages'] = Utils::getNavPageList($this->baseUrl, $this->current_lang);
     $vars['language'] = $this->current_lang;
     $vars['languages'] = Settings\LangSettings::get()->available;
     $vars['default_page'] = Settings\NavSettings::get()->homepage;
     echo $this->twig->render($templatefile, $vars);
 }
コード例 #3
0
ファイル: Utils.php プロジェクト: TeNNoX/Salic
 /**
  * Gets the pagelist for nav
  * - without hidden pages
  * - with title and href values generated
  *
  * eg: ['page1' => ['title' => "Page 1", 'href' => "/page1"]]
  *
  * @param $baseUrl
  * @param $lang
  * @return array
  * @throws SalicSettingsException
  */
 public static function getNavPageList($baseUrl, $lang)
 {
     $navSettings = NavSettings::get();
     $nav_array = array();
     $pages = $navSettings->displayed;
     $external = $navSettings->external_links;
     foreach ($pages as $key) {
         $title = PageSettings::get($key)->title->get($lang);
         //TODO: what to do about titles for external pages
         $href = array_key_exists($key, $external) ? $external[$key] : $baseUrl . $key . "/";
         $nav_array[$key] = array('key' => $key, 'title' => $title, 'href' => $href);
     }
     return $nav_array;
 }
コード例 #4
0
ファイル: backend.php プロジェクト: TeNNoX/Salic
require_once 'Salic.php';
if (!Utils::validAuthentication()) {
    exit;
    // Utils should call exit(), but just to be sure...
}
// TODO: ? backend language support
$salic = new SalicMng(LangSettings::get()->default);
$salic->initTwig();
try {
    $section = @$_GET['section'];
    if (empty($section)) {
        // no section selected
        $salic->renderBackendPage('@salic/backend.html.twig');
        exit;
    }
    if ($section == 'nav') {
        $salic->renderBackendPage('@salic/backend_nav.html.twig', array('navSettings' => NavSettings::get(), 'available_pages' => PageSettings::listAvailablePages()));
        exit;
    } else {
        if ($section == 'pages') {
            if (empty($_GET['page'])) {
                $salic->renderBackendPage('@salic/backend_pages.html.twig', array());
            }
        } else {
            throw new \Exception("Invalid section: '{$section}'");
        }
    }
} catch (\Exception $e) {
    Utils::dieWithError($e, 'Rendering backend', $salic);
    exit;
}