public function upgrade()
 {
     if (!in_array('sfPropelPlugin', $this->configuration->getPlugins())) {
         if (file_exists($file = sfConfig::get('sf_config_dir') . '/propel.ini')) {
             $this->getFilesystem()->remove($file);
         }
         return;
     }
     if (file_exists($old = sfConfig::get('sf_lib_dir') . '/filter/base/BaseFormFilterPropel.class.php') && !file_exists($new = sfConfig::get('sf_lib_dir') . '/filter/BaseFormFilterPropel.class.php')) {
         $this->getFilesystem()->rename($old, $new);
     }
     if (file_exists($file = sfConfig::get('sf_config_dir') . '/propel.ini')) {
         // use phing to parse propel.ini
         sfPhing::startup();
         $this->properties = new Properties();
         $this->properties->load(new PhingFile($file));
         $modified = $original = file_get_contents($file);
         $modified = $this->upgradePropelIni($modified, self::$removes, false);
         $modified = $this->upgradePropelIni($modified, self::$inserts, true);
         if ($original != $modified) {
             $this->logSection('propel', 'Upgrading ' . sfDebug::shortenFilePath($file));
             file_put_contents($file, $modified);
         }
     }
 }
 public function upgrade()
 {
     $specVersion = sfYaml::getSpecVersion();
     $queue = array();
     $success = true;
     $finder = sfFinder::type('file')->name('*.yml')->prune('vendor');
     foreach ($finder->in(sfConfig::get('sf_root_dir')) as $file) {
         // attempt to upgrade booleans
         $original = file_get_contents($file);
         $upgraded = sfToolkit::pregtr($original, array('/^([^:]+: +)(?:on|y(?:es)?|\\+)(\\s*(#.*)?)$/im' => '\\1true\\2', '/^([^:]+: +)(?:off|no?|-)(\\s*(#.*)?)$/im' => '\\1false\\2'));
         try {
             sfYaml::setSpecVersion('1.1');
             $yaml11 = sfYaml::load($original);
             sfYaml::setSpecVersion('1.2');
             $yaml12 = sfYaml::load($upgraded);
         } catch (Exception $e) {
             // unable to load the YAML
             $yaml11 = 'foo';
             $yaml12 = 'bar';
         }
         if ($yaml11 == $yaml12) {
             if ($original != $upgraded) {
                 $this->getFilesystem()->touch($file);
                 file_put_contents($file, $upgraded);
             }
         } else {
             $this->logSection('yaml', 'Unable to upgrade ' . sfDebug::shortenFilePath($file), null, 'ERROR');
             // force project to use YAML 1.1 spec
             if ('1.1' != $specVersion) {
                 $specVersion = '1.1';
                 $class = sfClassManipulator::fromFile(sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php');
                 $original = $class->getCode();
                 $modified = $class->wrapMethod('setup', 'sfYaml::setSpecVersion(\'1.1\');');
                 if ($original != $modified && $this->askConfirmation(array('Unable to convert YAML file:', sfDebug::shortenFilePath($file), '', 'Would you like to force YAML to be parsed with the 1.1 specification? (Y/n)'), 'QUESTION_LARGE')) {
                     $this->logSection('yaml', 'Forcing YAML 1.1 spec');
                     $this->getFilesystem()->touch($class->getFile());
                     $class->save();
                 } else {
                     $this->logBlock(array('Unable to either upgrade YAML files or force 1.1 spec.', '(see UPGRADE_TO_1_3 file for more information)'), 'ERROR_LARGE');
                 }
             }
             $success = false;
         }
     }
     if ($success && '1.1' == $specVersion) {
         $file = sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php';
         $original = file_get_contents($file);
         $modified = preg_replace('/^\\s*sfYaml::setSpecVersion\\(\'1\\.1\'\\);\\n/im', '', $original);
         if ($original != $modified) {
             $this->logSection('yaml', 'Removing setting of YAML 1.1 spec');
             $this->getFilesystem()->touch($file);
             file_put_contents($file, $modified);
         }
     }
 }
 /**
  * Returns an array of exception traces.
  *
  * @param Exception $exception  An Exception implementation instance
  * @param string    $format     The trace format (txt or html)
  *
  * @return array An array of traces
  */
 protected static function getTraces($exception, $format = 'txt')
 {
     $traceData = $exception->getTrace();
     array_unshift($traceData, array('function' => '', 'file' => $exception->getFile() != null ? $exception->getFile() : null, 'line' => $exception->getLine() != null ? $exception->getLine() : null, 'args' => array()));
     $traces = array();
     if ($format == 'html') {
         $lineFormat = 'at <strong>%s%s%s</strong>(%s)<br />in <em>%s</em> line %s <a href="#" onclick="toggle(\'%s\'); return false;">...</a><br /><ul class="code" id="%s" style="display: %s">%s</ul>';
     } else {
         $lineFormat = 'at %s%s%s(%s) in %s line %s';
     }
     for ($i = 0, $count = count($traceData); $i < $count; $i++) {
         $line = isset($traceData[$i]['line']) ? $traceData[$i]['line'] : null;
         $file = isset($traceData[$i]['file']) ? $traceData[$i]['file'] : null;
         $args = isset($traceData[$i]['args']) ? $traceData[$i]['args'] : array();
         $traces[] = sprintf($lineFormat, isset($traceData[$i]['class']) ? $traceData[$i]['class'] : '', isset($traceData[$i]['type']) ? $traceData[$i]['type'] : '', $traceData[$i]['function'], self::formatArgs($args, false, $format), self::formatFile($file, $line, $format, null === $file ? 'n/a' : sfDebug::shortenFilePath($file)), null === $line ? 'n/a' : $line, 'trace_' . $i, 'trace_' . $i, $i == 0 ? 'block' : 'none', self::fileExcerpt($file, $line));
     }
     return $traces;
 }
 /**
  * Shortens an action's template path.
  * 
  * @param  string $path
  * 
  * @return string
  */
 protected function shortenTemplatePath($path)
 {
     $path = realpath($path);
     // application module
     $sep = preg_quote(DIRECTORY_SEPARATOR);
     if (preg_match('#modules' . $sep . '(\\w+)' . $sep . 'templates' . $sep . '(.*)$#', $path, $match)) {
         return $match[1] . '&nbsp;&hellip;&nbsp;' . $match[2];
     }
     return str_replace('SF_ROOT_DIR' . DIRECTORY_SEPARATOR, '', sfDebug::shortenFilePath($path));
 }
  /**
   * Formats a file link.
   *
   * @param  string  $file A file path or class name
   * @param  integer $line
   * @param  string  $text Text to use for the link
   *
   * @return string
   */
  public function formatFileLink($file, $line = null, $text = null)
  {
    // this method is called a lot so we avoid calling class_exists()
    if ($file && !sfToolkit::isPathAbsolute($file))
    {
      if (null === $text)
      {
        $text = $file;
      }

      // translate class to file name
      $r = new ReflectionClass($file);
      $file = $r->getFileName();
    }

    $shortFile = sfDebug::shortenFilePath($file);

    if ($linkFormat = sfConfig::get('sf_file_link_format', ini_get('xdebug.file_link_format')))
    {
      // return a link
      return sprintf(
        '<a href="%s" class="sfWebDebugFileLink" title="%s">%s</a>',
        htmlspecialchars(strtr($linkFormat, array('%f' => $file, '%l' => $line)), ENT_QUOTES, sfConfig::get('sf_charset')),
        htmlspecialchars($shortFile, ENT_QUOTES, sfConfig::get('sf_charset')),
        null === $text ? $shortFile : $text);
    }
    else if (null === $text)
    {
      // return the shortened file path
      return $shortFile;
    }
    else
    {
      // return the provided text with the shortened file path as a tooltip
      return sprintf('<span title="%s">%s</span>', $shortFile, $text);
    }
  }