Ejemplo n.º 1
0
 public function get($lang)
 {
     if (!$this->translated) {
         return $this->value;
     } else {
         if (!array_key_exists($lang, $this->value)) {
             // if translation not available...
             $lang = LangSettings::get()->default;
             // ... select default language...
             if (!array_key_exists($lang, $this->value)) {
                 return array_values($this->value)[0];
                 // ... or if that is not available either, return the first translation.
             }
         }
         return $this->value[$lang];
     }
 }
Ejemplo n.º 2
0
<?php

namespace 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;
Ejemplo n.º 3
0
 public static function dieWith404($reason = '', $salic = null)
 {
     if (empty($salic)) {
         $salic = new Salic(LangSettings::get()->default);
     }
     if (!empty($reason)) {
         echo "<!-- {$reason} -->";
         // TODO: display 404 reason
     }
     $salic->initTwig();
     $salic->render404();
     exit;
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
<?php

namespace Salic;

use Salic\Settings\LangSettings;
use Salic\Settings\NavSettings;
use Salic\Settings\PageSettings;
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 {