Пример #1
0
 public function getPath()
 {
     $dir = $this->config['path'];
     if (FajrUtils::isAbsolutePath($dir)) {
         return $dir;
     }
     // default resolve relative to Template.Directory
     $relativeTo = FajrConfig::getDirectory('Template.Directory');
     return FajrUtils::joinPath($relativeTo, $dir);
 }
Пример #2
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);
 }
Пример #3
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');
     }
 }
 /**
  * Configure injection of DisplayManager.class
  *
  * @param sfServiceContainerBuilder $container Symfony container to configure
  */
 public function configure(sfServiceContainerBuilder $container)
 {
     $container->register('DisplayManager.class', '\\fajr\\rendering\\DisplayManager')->addArgument(new sfServiceReference('TwigFactory.class'))->addArgument('%Template.Skin.Default%');
     $skins = FajrConfig::get('Template.Skin.Skins');
     $skinName = FajrConfig::get('Template.Skin.Default');
     if (!isset($skins, $skinName)) {
         throw new RuntimeException("Default skin is not present!");
     }
     $container->setParameter('Template.Skin.Default', $skins[$skinName]);
     $container->register('TwigFactory.class', '\\fajr\\rendering\\TwigFactory')->addArgument('%Twig.Environment.options%')->addArgument('%Twig.Environment.extensions%');
     $container->setParameter('Twig.Environment.extensions', array(new Twig_Extension_Escaper(), new Extension()));
     $container->setParameter('Twig.Template.Directory', FajrConfig::getDirectory('Template.Directory'));
     if (FajrConfig::get('Template.Cache')) {
         $cache = FajrConfig::getDirectory('Template.Cache.Path');
     } else {
         $cache = false;
     }
     $container->setParameter('Twig.Environment.options', array('base_template_class' => '\\fajr\\rendering\\Template', 'cache' => $cache, 'strict_variables' => true));
 }
Пример #5
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());
 }
Пример #6
0
#!/usr/bin/php
<?php 
use fajr\config\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());
    }
}