/** Return an instance of SkinSettings * @return SkinSettings */ public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new SkinSettings(FajrConfigLoader::getConfiguration(), SessionStorageProvider::getInstance()); } return self::$instance; }
public static function getInstance() { if (!isset(self::$instance)) { $config = FajrConfigLoader::getConfiguration(); $type = $config->get(FajrConfigOptions::DEBUG_TRACE); $uniqueID = sha1(uniqid('trace', true)); $header = 'Trace (id: ' . $uniqueID . ')'; $tags = array('unique-id' => $uniqueID); if ($type === FajrConfigOptions::DEBUG_TRACE_NONE) { self::$instance = new NullTrace(); } else { if ($type === FajrConfigOptions::DEBUG_TRACE_ARRAY) { self::$instance = new ArrayTrace(SystemTimer::getInstance(), $header); } else { // File-based trace $traceDir = $config->getDirectory(FajrConfigOptions::DEBUG_TRACE_DIR); if ($traceDir === null) { throw new \LogicException(FajrConfigOptions::DEBUG_TRACE_DIR . ' is not set, but is required for file-based traces'); } $ext = $type == FajrConfigOptions::DEBUG_TRACE_TEXT ? 'txt' : 'bin'; $filename = FajrUtils::joinPath($traceDir, 'trace' . $uniqueID . '.' . $ext); $file = @fopen($filename, 'ab'); if ($file === false) { throw new \Exception('Cannot open trace file'); } if ($type == FajrConfigOptions::DEBUG_TRACE_TEXT) { self::$instance = new FileTrace(SystemTimer::getInstance(), $file, 0, $header); } else { self::$instance = new BinaryFileTrace(SystemTimer::getInstance(), $file, $header, $tags); } } } } return self::$instance; }
public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new ServerManager(SessionStorageProvider::getInstance(), Request::getInstance(), FajrConfigLoader::getConfiguration()); } return self::$instance; }
public function getPath() { $dir = $this->config['path']; if (FajrUtils::isAbsolutePath($dir)) { return $dir; } // default resolve relative to Template.Directory $config = FajrConfigLoader::getConfiguration(); $relativeTo = $config->getDirectory('Template.Directory'); return FajrUtils::joinPath($relativeTo, $dir); }
/** @return Warnings */ public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new Warnings(); $config = FajrConfigLoader::getConfiguration(); $configWarnings = $config->get(FajrConfigOptions::WARNINGS); foreach ($configWarnings as $warning) { self::$instance->addWarning(array('type' => 'raw', 'message' => $warning)); } } return self::$instance; }
public static function getInstance() { if (!isset(self::$instance)) { $config = FajrConfigLoader::getConfiguration(); $lifeTimeSec = 36000; $options = array('session_cookie_lifetime' => $lifeTimeSec, 'session_cookie_path' => '/', 'session_cookie_secure' => $config->get(FajrConfigOptions::REQUIRE_SSL), 'session_cookie_httponly' => true, 'session_name' => $config->get(FajrConfigOptions::INSTANCE_NAME) . '_session_id'); // cache expire, server ini_set('session.gc_maxlifetime', $lifeTimeSec); ini_set('session.cookie_lifetime', $lifeTimeSec); // custom cache expire is possible only for custom session directory session_save_path($config->getDirectory(FajrConfigOptions::PATH_TO_SESSIONS)); self::$instance = new sfSessionStorage($options); } return self::$instance; }
/** Return an instance of Router * @return Router */ public static function getInstance() { if (!isset(self::$instance)) { $config = FajrConfigLoader::getConfiguration(); $cachePath = $config->getDirectory(FajrConfigOptions::PATH_TO_ROUTER_CACHE); $controllerPath = FajrUtils::joinPath(FajrUtils::getProjectRootDirectory(), '/src/controller'); $locator = new FileLocator(array($controllerPath)); $request = SymfonyRequest::createFromGlobals(); $requestContext = new RequestContext(); $requestContext->fromRequest($request); $sfRouter = new SymfonyRouter(new YamlFileLoader($locator), "routes.yml", array('cache_dir' => $config->get(FajrConfigOptions::USE_CACHE) ? $cachePath : null), $requestContext); self::$instance = new Router($sfRouter, $request); } return self::$instance; }
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; }
return; } $configurationFileName = self::getConfigurationFileName(); if (!file_exists($configurationFileName)) { // Leave fajr unconfigured, index.php will then show nice error message // to the user return; } // Don't suppress errors so parse errors are reported // TODO(anty): use yaml for configuration $result = (include $configurationFileName); if (!is_array($result)) { throw new Exception('Konfiguračný súbor nevrátil pole'); } self::$config = new FajrConfig($result); } /** * Check whether configuration is ready * @returns boolean true iff configuration was successfully loaded */ public static function isConfigured() { return self::$config !== null; } public static function getConfiguration() { return self::$config; } } FajrConfigLoader::load();
konfiguračných volieb by mali byť vhodné pre väčšinu inštalácií, no napriek tomu ponúkame možnosť ich pohodlne zmeniť na jednom mieste - v tomto súbore. </p> <p> <strong>Dôležité:</strong> Pred používaním aplikácie je ešte nutné správne nastaviť skupinu na <code>www-data</code> (alebo pod čím beží webserver) a práva na adresáre <code>./temp</code>, <code>./temp/cookies</code> a <code>./temp/sessions</code> (alebo na tie, čo ste nastavili v konfigurácii), tak, aby boli nastavené práva len na zapisovanie a použitie , t.j. <code>d----wx---</code>. </p> '); } $config = FajrConfigLoader::getConfiguration(); if ($config->get(FajrConfigOptions::REQUIRE_SSL) && !FajrUtils::isHTTPS()) { fajr_bootstrap_error(' <p> Pre túto inštanciu fajr-u je vyžadované HTTPS spojenie. Prosím skontrolujte prepisovacie pravidlá v <code>.htaccess</code> (alebo konfigurácii web servera), ktoré presmerovávajú HTTP spojenia na HTTPS. Ak nechcete vyžadovať SSL spojenie, je možné túto kontrolu vypnúť v konfiguračnom súbore, <strong>avšak na produkčných inštaláciách, alebo inštaláciách s funkčným SSL sa neodporúča túto kontrolu vypínať. </strong> </p> '); } // bootstrapping whole application // TODO: DEBUG_EXCEPTION_SHOWSTACKTRACE sa nejako vytratilo...
public static function getInstance() { return new LoginController(FajrConfigLoader::getConfiguration(), LoginManager::getInstance(), ServerManager::getInstance(), SessionStorageProvider::getInstance(), DisplayManager::getInstance(), Router::getInstance()); }
private static function provideCookieFile() { $config = FajrConfigLoader::getConfiguration(); return FajrUtils::joinPath($config->getDirectory('Path.Temporary.Cookies'), 'cookie_' . session_id()); }