Exemplo n.º 1
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $config = FajrConfigLoader::getConfiguration();
         $twigOptions = array('cache' => $config->get(FajrConfigOptions::USE_CACHE) ? $config->getDirectory(FajrConfigOptions::PATH_TO_TEMPLATE_CACHE) : false, 'strict_variables' => true);
         $router = Router::getInstance();
         $skinSettings = SkinSettings::getInstance();
         $twig = new Twig_Environment(null, $twigOptions);
         $twig->addExtension(new Twig_Extension_Escaper());
         $twig->addExtension(new FajrExtension($router));
         self::$instance = new DisplayManager($twig);
         self::$instance->setSkin($skinSettings->getUserSkin());
     }
     return self::$instance;
 }
Exemplo n.º 2
0
 /**
  * Sets dafault template fields.
  * TODO: set as twig globals?
  */
 private function setResponseFields(Request $request)
 {
     $skinSettings = SkinSettings::getInstance();
     if ($request->isMobileBrowser()) {
         $skinSettings->setDefaultSkinName('mobile');
     }
     $this->displayManager->setSkin($skinSettings->getUserSkin());
     $params = array();
     $referrer = $request->getHeader('Referer');
     $pageMovedCookie = isset($_COOKIE['FajrPageMoved']);
     $pageMovedReferer = preg_match('#^https?://fajr.dcs.fmph.uniba.sk#', $referrer) === 1;
     if ($pageMovedCookie || $pageMovedReferer) {
         Warnings::getInstance()->addWarning(array('type' => 'pageMoved'));
     }
     $params['version'] = new Version();
     $params['banner_debug'] = $this->config->get(FajrConfigOptions::DEBUG_BANNER);
     if ($request->isDoNotTrack()) {
         $params['google_analytics'] = null;
     } else {
         $params['google_analytics'] = $this->config->get(FajrConfigOptions::GOOGLE_ANALYTICS_ACCOUNT);
     }
     $params['base'] = FajrUtils::basePath();
     $params['language'] = 'sk';
     $params['availableServers'] = array();
     $params['currentServer'] = array('isBeta' => false, 'instanceName' => 'Chyba');
     $server = $this->serverManager->getActiveServer();
     $serverList = $this->config->get(FajrConfigOptions::AIS_SERVERLIST);
     $params['availableServers'] = $serverList;
     $params['currentServer'] = $server;
     $params['backendType'] = $server->getBackendType();
     $params['aisVersion'] = null;
     $params['aisVersionIncompatible'] = false;
     $params['loggedIn'] = false;
     $params['developmentVersion'] = $this->config->get(FajrConfigOptions::IS_DEVEL);
     $params['statistics'] = Statistics::getInstance();
     $params['warnings'] = Warnings::getInstance();
     $this->displayManager->setDefaultParams($params);
 }