/**
  * Configure injection of SessionInitializer.class
  *
  * @param sfServiceContainerBuilder $container Symfony container to configure
  */
 public function configure(sfServiceContainerBuilder $container)
 {
     $container->register('SessionInitializer.class', 'fajr\\SessionInitializer')->addArgument('%session.life_time_sec%')->addArgument('%session.save_path%')->addArgument('%session.path%')->addArgument('%session.domain%');
     $parameters = array('session.life_time_sec' => 36000, 'session.save_path' => FajrConfig::getDirectory('Path.Temporary.Sessions'), 'session.path' => '/', 'session.domain' => '.' . $_SERVER['HTTP_HOST']);
     // Note, we can't use setParameters as it will destroy previous values!
     $container->addParameters($parameters);
 }
 /**
  * Configure injection of DisplayManager.class
  *
  * @param sfServiceContainerBuilder $container Symfony container to configure
  */
 public function configure(sfServiceContainerBuilder $container)
 {
     $container->register('DisplayManager.class', '\\fajr\\DisplayManager')->addArgument(new sfServiceReference('Twig_Environment.class'));
     $container->register('Twig_Loader_Filesystem.class', 'Twig_Loader_Filesystem')->addArgument('%Twig.Template.Directory%');
     $container->register('Twig_Environment.class', 'Twig_Environment')->addArgument(new sfServiceReference('Twig_Loader_Filesystem.class'))->addArgument('%Twig.Environment.options%')->addMethodCall('addExtension', array(new Twig_Extension_Escaper()))->addMethodCall('addExtension', array(new Extension()));
     $container->setParameter('Twig.Template.Directory', FajrConfig::getDirectory('Template.Directory'));
     $container->setParameter('Twig.Environment.options', array('base_template_class' => '\\fajr\\rendering\\Template', 'strict_variables' => true));
 }
Exemplo n.º 3
0
 private function provideConnection()
 {
     $curlOptions = $this->injector->getParameter('CurlConnection.options');
     $connection = new connection\CurlConnection($curlOptions, FajrUtils::getCookieFile());
     $connection = $this->statistics->hookRawConnection($connection);
     $connection = new connection\GzipDecompressingConnection($connection, FajrConfig::getDirectory('Path.Temporary'));
     $connection = new connection\AIS2ErrorCheckingConnection($connection);
     return $this->statistics->hookFinalConnection($connection);
 }
Exemplo n.º 4
0
 /**
  * Configure injection of SessionInitializer.class
  *
  * @param sfServiceContainerBuilder $container Symfony container to configure
  */
 public function configure(sfServiceContainerBuilder $container)
 {
     $lifeTimeSec = 36000;
     $options = array('session_cookie_lifetime' => $lifeTimeSec, 'session_cookie_path' => '/', 'session_cookie_domain' => '.' . $_SERVER['HTTP_HOST'], 'session_cookie_secure' => FajrConfig::get('SSL.Require'), 'session_cookie_httponly' => true, 'session_name' => 'fajr_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(FajrConfig::getDirectory('Path.Temporary.Sessions'));
     // Note, we can't use setParameters as it will destroy previous values!
     $container->setParameter('session.options', $options);
     $container->register('Session.Storage.class', 'sfSessionStorage')->addArgument('%session.options%')->setShared(true);
 }
Exemplo n.º 5
0
 /**
  * Configures Trace.class for injection.
  *
  * @param sfServiceContainer $container Container to configure
  */
 public function configure(sfServiceContainerBuilder $container)
 {
     if (FajrConfig::get('Debug.Trace') === true) {
         $debugFile = FajrConfig::getDirectory('Debug.Trace.File');
         if ($debugFile !== null) {
             $container->setParameter('Debug.Trace.File', $debugFile);
             $container->setParameter('Debug.Trace.File.Mode', 'a');
             $container->register('Debug.Trace.File.class', 'fajr\\util\\PHPFile')->addArgument('%Debug.Trace.File%')->addArgument('%Debug.Trace.File.Mode%');
             $container->register('Trace.class', 'fajr\\FileTrace')->addArgument(new sfServiceReference('Timer.class'))->addArgument(new sfServiceReference('Debug.Trace.File.class'))->addArgument(0)->addArgument('--Trace--');
         } else {
             $container->register('Trace.class', 'fajr\\ArrayTrace')->addArgument(new sfServiceReference('Timer.class'))->addArgument('--Trace--');
         }
     } else {
         $container->register('Trace.class', 'fajr\\libfajr\\pub\\base\\NullTrace');
     }
 }
Exemplo n.º 6
0
 /**
  * Generate a page content
  * @param Response $response response data to use to generate output
  * @return string Generated output to be sent to the browser
  */
 public function display(Response $response)
 {
     if ($response->getTemplate() === null) {
         return;
     }
     $templateDir = FajrConfig::getDirectory('Template.Directory');
     $loader = new Twig_Loader_Filesystem($templateDir);
     $twig = new Twig_Environment($loader, array('base_template_class' => '\\fajr\\rendering\\Template', 'strict_variables' => true));
     $twig->addExtension(new Twig_Extension_Escaper());
     // Register fajr's rendering extension
     $twig->addExtension(new Extension());
     $templateName = 'pages/' . $response->getTemplate() . '.xhtml';
     $template = $twig->loadTemplate($templateName);
     $output = $template->render($response->getData());
     return $output;
 }
Exemplo n.º 7
0
#!/usr/bin/php
<?php 
use fajr\FajrConfig;
// register our autoloader
require_once __DIR__ . '/../src/libfajr/libfajr.php';
Loader::register();
Loader::searchForClasses(__DIR__ . '/../src', true);
if (!FajrConfig::isConfigured()) {
    echo 'Chyba: Fajr nie je nakonfigurovany' . "\n";
    return;
}
if (!FajrConfig::get('Template.Cache')) {
    echo 'Info: Template cache je vypnuta, nema zmysel ju mazat' . "\n";
    return;
}
$path = FajrConfig::getDirectory('Template.Cache.Path');
echo 'Info: Template cache je ' . $path . "\n";
foreach (new DirectoryIterator($path) as $fileInfo) {
    if (!$fileInfo->isDot() && $fileInfo->isFile()) {
        unlink($fileInfo->getPathname());
    }
}
Exemplo n.º 8
0
 private function provideConnection()
 {
     $connection = new connection\CurlConnection(FajrUtils::getCookieFile());
     $this->rawStatsConnection = new connection\StatsConnection($connection, new SystemTimer());
     $connection = new connection\GzipDecompressingConnection($this->rawStatsConnection, FajrConfig::getDirectory('Path.Temporary'));
     $connection = new connection\AIS2ErrorCheckingConnection($connection);
     $this->statsConnection = new connection\StatsConnection($connection, new SystemTimer());
     return $this->statsConnection;
 }
Exemplo n.º 9
0
 /**
  * Returns a cookie file path for current session.
  *
  * Cookie file name is not the same as session_id() so that if one
  * configures the same path for cookie and session directories,
  * the filenames do not clash.
  *
  * @returns string file path to use to store cookies into.
  */
 public static function getCookieFile()
 {
     return self::joinPath(FajrConfig::getDirectory('Path.Temporary.Cookies'), 'cookie_' . session_id());
 }
 /**
  * Configure injection of SessionInitializer.class
  *
  * @param sfServiceContainer $container Symfony container to configure
  */
 public function configure(sfServiceContainer $container)
 {
     $container->register('SessionInitializer.class', 'fajr\\SessionInitializer')->addArgument('%session.life_time_sec%')->addArgument('%session.save_path%')->addArgument('%session.path%')->addArgument('%session.domain%');
     $container->setParameters(array('session.life_time_sec' => 36000, 'session.save_path' => FajrConfig::getDirectory('Path.Temporary.Sessions'), 'session.path' => '/', 'session.domain' => '.' . $_SERVER['HTTP_HOST']));
 }