/**
  * @see sfProjectConfiguration
  */
 public function initConfiguration()
 {
     $configCache = $this->getConfigCache();
     // in debug mode, start global timer
     if ($this->isDebug() && !sfWebDebugPanelTimer::isStarted()) {
         sfWebDebugPanelTimer::startTime();
     }
     // required core classes for the framework
     if (!sfConfig::get('sf_debug') && !sfConfig::get('sf_test') && !self::$coreLoaded) {
         $configCache->import('config/core_compile.yml', false);
     }
     $this->dispatcher->connect('autoload.filter_config', array($this, 'filterAutoloadConfig'));
     sfAutoload::getInstance()->register();
     // load base settings
     include $configCache->checkConfig('config/settings.yml');
     if ($file = $configCache->checkConfig('config/app.yml', true)) {
         include $file;
     }
     if (false !== sfConfig::get('sf_csrf_secret')) {
         sfForm::enableCSRFProtection(sfConfig::get('sf_csrf_secret'));
     }
     sfWidget::setCharset(sfConfig::get('sf_charset'));
     sfValidatorBase::setCharset(sfConfig::get('sf_charset'));
     // force setting default timezone if not set
     if ($default_timezone = sfConfig::get('sf_default_timezone')) {
         date_default_timezone_set($default_timezone);
     } else {
         if (sfConfig::get('sf_force_default_timezone', true)) {
             date_default_timezone_set(@date_default_timezone_get());
         }
     }
     // error settings
     ini_set('display_errors', $this->isDebug() ? 'on' : 'off');
     error_reporting(sfConfig::get('sf_error_reporting'));
     // initialize plugin configuration objects
     $this->initializePlugins();
     // Disabled by default in symfony 1.1 because it causes problems with Doctrine.
     // If you want to enable it in your application, just copy the spl_autoload_register() line
     // in your configuration class.
     if (0 && $this->isDebug()) {
         spl_autoload_register(array(sfAutoload::getInstance(), 'autoloadAgain'));
     }
     // compress output
     if (!self::$coreLoaded) {
         ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : '');
     }
     self::$coreLoaded = true;
 }
Example #2
0
$t->diag('::escapeOnce()');
$t->is(sfWidget::escapeOnce('This a > text to "escape"'), 'This a > text to "escape"', '::escapeOnce() escapes an HTML strings');
$t->is(sfWidget::escapeOnce(sfWidget::escapeOnce('This a > text to "escape"')), 'This a > text to "escape"', '::escapeOnce() does not escape an already escaped string');
$t->is(sfWidget::escapeOnce('This a > text to "escape"'), 'This a > text to "escape"', '::escapeOnce() does not escape an already escaped string');
class MyClass
{
    public function __toString()
    {
        return 'mycontent';
    }
}
$t->is(sfWidget::escapeOnce(new MyClass()), 'mycontent', '::escapeOnce() converts objects to string');
// ::fixDoubleEscape()
$t->diag('::fixDoubleEscape()');
$t->is(sfWidget::fixDoubleEscape(htmlspecialchars(htmlspecialchars('This a > text to "escape"'), ENT_QUOTES, sfWidget::getCharset()), ENT_QUOTES, sfWidget::getCharset()), 'This a > text to "escape"', '::fixDoubleEscape() fixes double escaped strings');
// ::getCharset() ::setCharset()
$t->diag('::getCharset() ::setCharset()');
$t->is(sfWidget::getCharset(), 'UTF-8', '::getCharset() returns the charset to use for widgets');
sfWidget::setCharset('ISO-8859-1');
$t->is(sfWidget::getCharset(), 'ISO-8859-1', '::setCharset() changes the charset to use for widgets');
// ::setXhtml() ::isXhtml()
$t->diag('::setXhtml() ::isXhtml()');
$w = new MyWidget();
$t->is(sfWidget::isXhtml(), true, '::isXhtml() return true if the widget must returns XHTML tags');
sfWidget::setXhtml(false);
$t->is($w->renderTag('input', array('value' => 'Test')), '<input value="Test">', '::setXhtml() changes the value of the XHTML tag');
// ->getJavaScripts() ->getStylesheets()
$t->diag('->getJavaScripts() ->getStylesheets()');
$w = new MyWidget();
$t->is($w->getJavaScripts(), array(), '->getJavaScripts() returns an array of stylesheets');
$t->is($w->getStylesheets(), array(), '->getStylesheets() returns an array of JavaScripts');
  /**
   * Various initializations.
   */
  public function initConfiguration()
  {
    $configCache = $this->getConfigCache();

    // in debug mode, start global timer
    if ($this->isDebug() && !sfWebDebugPanelTimer::isStarted())
    {
      sfWebDebugPanelTimer::startTime();
    }

    // required core classes for the framework
    if (!$this->isDebug() && !sfConfig::get('sf_test') && !self::$coreLoaded)
    {
      $configCache->import('config/core_compile.yml', false);
    }

    // autoloader(s)
    $this->dispatcher->connect('autoload.filter_config', array($this, 'filterAutoloadConfig'));
    sfAutoload::getInstance()->register();
    if ($this->isDebug())
    {
      sfAutoloadAgain::getInstance()->register();
    }

    // load base settings
    $this->beforeSettingsConfiguration();
    include($configCache->checkConfig('config/settings.yml'));
    if ($file = $configCache->checkConfig('config/app.yml', true))
    {
      include($file);
    }

    if (false !== sfConfig::get('sf_csrf_secret'))
    {
      sfForm::enableCSRFProtection(sfConfig::get('sf_csrf_secret'));
    }

    sfWidget::setCharset(sfConfig::get('sf_charset'));
    sfValidatorBase::setCharset(sfConfig::get('sf_charset'));

    // force setting default timezone if not set
    if ($default_timezone = sfConfig::get('sf_default_timezone'))
    {
      date_default_timezone_set($default_timezone);
    }
    else if (sfConfig::get('sf_force_default_timezone', true))
    {
      date_default_timezone_set(@date_default_timezone_get());
    }

    // error settings
    ini_set('display_errors', $this->isDebug() ? 'on' : 'off');
    error_reporting(sfConfig::get('sf_error_reporting'));


    // initialize plugin configuration objects
    $this->initializePlugins();

    // compress output
    if (!self::$coreLoaded)
    {
      ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : null);
    }

    self::$coreLoaded = true;
  }