Development

Changeset 10627

You must first sign up to be able to contribute.

Changeset 10627

Show
Ignore:
Timestamp:
08/03/08 10:52:28 (6 years ago)
Author:
fabien
Message:

refactored sfRequest

  • removed the dependency on sfConfig by adding an $options argument to the constructor
  • moved all 1.0 methods to a sfRequestCompat10 class in sfCompat10Plugin
  • moved path_info_array, path_info_key, and relative_url_root configuration from settings.yml to factories.yml
  • added a logging option
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/config/config/factories.yml

    r9285 r10627  
    66    class: sfWebRequest 
    77    param: 
     8      logging:         %SF_LOGGING_ENABLED% 
     9      path_info_array: SERVER 
     10      path_info_key:   PATH_INFO 
    811      formats: 
    912        txt:  text/plain 
  • branches/1.2/lib/config/config/settings.yml

    r10124 r10627  
    6464    strip_comments:         on         # Remove comments in core framework classes as defined in the core_compile.yml 
    6565    max_forwards:           5 
    66     path_info_array:        SERVER 
    67     path_info_key:          PATH_INFO 
    6866    url_format:             PATH 
    6967 
  • branches/1.2/lib/config/sfFactoryConfigHandler.class.php

    r9159 r10627  
    9191 
    9292        case 'request': 
    93           $instances[] = sprintf("  \$class = sfConfig::get('sf_factory_request', '%s');\n   \$this->factories['request'] = new \$class(\$this->dispatcher, array(), sfConfig::get('sf_factory_request_parameters', %s), sfConfig::get('sf_factory_request_attributes', array()));", $class, var_export($parameters, true)); 
     93          $instances[] = sprintf("  \$class = sfConfig::get('sf_factory_request', '%s');\n   \$this->factories['request'] = new \$class(\$this->dispatcher, array(), array(), sfConfig::get('sf_factory_request_parameters', %s), sfConfig::get('sf_factory_request_attributes', array()));", $class, var_export($parameters, true)); 
    9494          break; 
    9595 
  • branches/1.2/lib/plugins/sfCompat10Plugin/config/config.php

    r8596 r10627  
    77    class sfCompatAutoload extends sfSimpleAutoload 
    88    { 
    9  
    109    } 
    1110 
     
    2221  sfProjectConfiguration::getActive()->getConfigCache()->registerConfigHandler('modules/*/config/mailer.yml', 'sfDefineEnvironmentConfigHandler', array('prefix' => 'sf_mailer_', 'module' => 'yes')); 
    2322 
     23  // register request compat methods 
     24  if ($this instanceof sfConfigCache) 
     25  { 
     26    // here if we are included from an admin generator module (for 1.0) 
     27    sfProjectConfiguration::getActive()->getEventDispatcher()->connect('request.method_not_found', array('sfRequestCompat10', 'call')); 
     28  } 
     29  else 
     30  { 
     31    $this->dispatcher->connect('request.method_not_found', array('sfRequestCompat10', 'call')); 
     32  } 
     33 
    2434  // register the validation execution filter 
    2535  sfConfig::set('sf_execution_filter', array('sfValidationExecutionFilter', array())); 
  • branches/1.2/lib/plugins/sfCompat10Plugin/test/unit/request/sfRequestTest.php

    r5493 r10627  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 sfConfig::set('sf_compat_10', true); 
    14  
    1513class myRequest extends sfRequest 
    1614{ 
     
    2422 
    2523$dispatcher = new sfEventDispatcher(); 
     24$dispatcher->connect('request.method_not_found', array('sfRequestCompat10', 'call')); 
     25 
    2626$request = new myRequest($dispatcher); 
    2727 
  • branches/1.2/lib/request/sfRequest.class.php

    r9098 r10627  
    6060 
    6161  protected 
    62     $errors          = array(), 
    6362    $dispatcher      = null, 
    6463    $method          = null, 
     64    $options         = array(), 
    6565    $parameterHolder = null, 
    66     $config          = null, 
    6766    $attributeHolder = null; 
    6867 
     
    7271   * @see initialize() 
    7372   */ 
    74   public function __construct(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array()
    75   { 
    76     $this->initialize($dispatcher, $parameters, $attributes); 
     73  public function __construct(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array(), $options = array()
     74  { 
     75    $this->initialize($dispatcher, $parameters, $attributes, $options); 
    7776  } 
    7877 
     
    8887   * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfRequest 
    8988   */ 
    90   public function initialize(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array()
     89  public function initialize(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array(), $options = array()
    9190  { 
    9291    $this->dispatcher = $dispatcher; 
     92 
     93    $this->options = $options; 
     94 
     95    if (!isset($this->options['logging'])) 
     96    { 
     97      $this->options['logging'] = false; 
     98    } 
    9399 
    94100    // initialize parameter and attribute holders 
     
    126132 
    127133  /** 
    128    * Retrieves an error message. 
    129    * 
    130    * @param  string $name  An error name 
    131    * 
    132    * @return string An error message, if the error exists, otherwise null 
    133    */ 
    134   public function getError($name) 
    135   { 
    136     if (!sfConfig::get('sf_compat_10')) 
    137     { 
    138       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    139     } 
    140  
    141     return isset($this->errors[$name]) ? $this->errors[$name] : null; 
    142   } 
    143  
    144   /** 
    145    * Retrieves an array of error names. 
    146    * 
    147    * @return array An indexed array of error names 
    148    */ 
    149   public function getErrorNames() 
    150   { 
    151     if (!sfConfig::get('sf_compat_10')) 
    152     { 
    153       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    154     } 
    155  
    156     return array_keys($this->errors); 
    157   } 
    158  
    159   /** 
    160    * Retrieves an array of errors. 
    161    * 
    162    * @return array An associative array of errors 
    163    */ 
    164   public function getErrors() 
    165   { 
    166     if (!sfConfig::get('sf_compat_10')) 
    167     { 
    168       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    169     } 
    170  
    171     return $this->errors; 
    172   } 
    173  
    174   /** 
    175134   * Retrieves this request's method. 
    176135   * 
     
    182141  { 
    183142    return $this->method; 
    184   } 
    185  
    186   /** 
    187    * Indicates whether or not an error exists. 
    188    * 
    189    * @param  string $name  An error name 
    190    * 
    191    * @return bool true, if the error exists, otherwise false 
    192    */ 
    193   public function hasError($name) 
    194   { 
    195     if (!sfConfig::get('sf_compat_10')) 
    196     { 
    197       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    198     } 
    199  
    200     return array_key_exists($name, $this->errors); 
    201   } 
    202  
    203   /** 
    204    * Indicates whether or not any errors exist. 
    205    * 
    206    * @return bool true, if any error exist, otherwise false 
    207    */ 
    208   public function hasErrors() 
    209   { 
    210     if (!sfConfig::get('sf_compat_10')) 
    211     { 
    212       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    213     } 
    214  
    215     return count($this->errors) > 0; 
    216   } 
    217  
    218   /** 
    219    * Removes an error. 
    220    * 
    221    * @param  string $name  An error name 
    222    * 
    223    * @return string An error message, if the error was removed, otherwise null 
    224    */ 
    225   public function removeError($name) 
    226   { 
    227     if (!sfConfig::get('sf_compat_10')) 
    228     { 
    229       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    230     } 
    231  
    232     $retval = null; 
    233  
    234     if (isset($this->errors[$name])) 
    235     { 
    236       $retval = $this->errors[$name]; 
    237  
    238       unset($this->errors[$name]); 
    239     } 
    240  
    241     return $retval; 
    242   } 
    243  
    244   /** 
    245    * Sets an error. 
    246    * 
    247    * @param string $name     An error name 
    248    * @param string $message  An error message 
    249    * 
    250    */ 
    251   public function setError($name, $message) 
    252   { 
    253     if (!sfConfig::get('sf_compat_10')) 
    254     { 
    255       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    256     } 
    257  
    258     if (sfConfig::get('sf_logging_enabled')) 
    259     { 
    260       $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Error in form for parameter "%s" (with message "%s")', $name, $message)))); 
    261     } 
    262  
    263     $this->errors[$name] = $message; 
    264   } 
    265  
    266   /** 
    267    * Sets an array of errors 
    268    * 
    269    * If an existing error name matches any of the keys in the supplied 
    270    * array, the associated message will be overridden. 
    271    * 
    272    * @param array $erros An associative array of errors and their associated messages 
    273    * 
    274    */ 
    275   public function setErrors($errors) 
    276   { 
    277     if (!sfConfig::get('sf_compat_10')) 
    278     { 
    279       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    280     } 
    281  
    282     $this->errors = array_merge($this->errors, $errors); 
    283143  } 
    284144 
  • branches/1.2/lib/request/sfWebRequest.class.php

    r10060 r10627  
    4646   * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfRequest 
    4747   */ 
    48   public function initialize(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array()
    49   { 
    50     parent::initialize($dispatcher, $parameters, $attributes); 
     48  public function initialize(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array(), $options = array()
     49  { 
     50    parent::initialize($dispatcher, $parameters, $attributes, $options); 
    5151 
    5252    if (isset($_SERVER['REQUEST_METHOD'])) 
     
    8484    } 
    8585 
    86     foreach ($this->getAttribute('formats', array()) as $format => $mimeTypes) 
    87     { 
    88       $this->setFormat($format, $mimeTypes); 
     86    if (isset($this->options['formats'])) 
     87    { 
     88      foreach ($this->options['formats'] as $format => $mimeTypes) 
     89      { 
     90        $this->setFormat($format, $mimeTypes); 
     91      } 
     92    } 
     93 
     94    if (!isset($this->options['path_info_key'])) 
     95    { 
     96      $this->options['path_info_key'] = 'PATH_INFO'; 
     97    } 
     98 
     99    if (!isset($this->options['path_info_array'])) 
     100    { 
     101      $this->options['path_info_array'] = 'SERVER'; 
    89102    } 
    90103 
     
    94107 
    95108  /** 
    96    * Retrieves an array of file information. 
    97    * 
    98    * @param  string $name  A file name 
    99    * 
    100    * @return array An associative array of file information, if the file exists, otherwise null 
    101    */ 
    102   public function getFile($name) 
    103   { 
    104     if (!sfConfig::get('sf_compat_10')) 
    105     { 
    106       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    107     } 
    108  
    109     return $this->hasFile($name) ? $this->getFileValues($name) : null; 
    110   } 
    111  
    112   /** 
    113    * Retrieves a file error. 
    114    * 
    115    * @param  string $name  A file name 
    116    * 
    117    * @return int One of the following error codes: 
    118    * 
    119    *             - <b>UPLOAD_ERR_OK</b>        (no error) 
    120    *             - <b>UPLOAD_ERR_INI_SIZE</b>  (the uploaded file exceeds the 
    121    *                                           upload_max_filesize directive 
    122    *                                           in php.ini) 
    123    *             - <b>UPLOAD_ERR_FORM_SIZE</b> (the uploaded file exceeds the 
    124    *                                           MAX_FILE_SIZE directive that 
    125    *                                           was specified in the HTML form) 
    126    *             - <b>UPLOAD_ERR_PARTIAL</b>   (the uploaded file was only 
    127    *                                           partially uploaded) 
    128    *             - <b>UPLOAD_ERR_NO_FILE</b>   (no file was uploaded) 
    129    */ 
    130   public function getFileError($name) 
    131   { 
    132     if (!sfConfig::get('sf_compat_10')) 
    133     { 
    134       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    135     } 
    136  
    137     return $this->hasFile($name) ? $this->getFileValue($name, 'error') : UPLOAD_ERR_NO_FILE; 
    138   } 
    139  
    140   /** 
    141    * Retrieves a file name. 
    142    * 
    143    * @param  string $name  A file nam. 
    144    * 
    145    * @return string A file name, if the file exists, otherwise null 
    146    */ 
    147   public function getFileName($name) 
    148   { 
    149     if (!sfConfig::get('sf_compat_10')) 
    150     { 
    151       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    152     } 
    153  
    154     return $this->hasFile($name) ? $this->getFileValue($name, 'name') : null; 
    155   } 
    156  
    157   /** 
    158    * Retrieves an array of file names. 
    159    * 
    160    * @return array An indexed array of file names 
    161    */ 
    162   public function getFileNames() 
    163   { 
    164     if (!sfConfig::get('sf_compat_10')) 
    165     { 
    166       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    167     } 
    168  
    169     return array_keys($_FILES); 
    170   } 
    171  
    172   /** 
    173    * Retrieves an array of files. 
    174    * 
    175    * @param  string $key  A key 
    176    * @return array  An associative array of files 
    177    */ 
    178   public function getFiles($key = null) 
    179   { 
    180     return is_null($key) ? $_FILES : (isset($_FILES[$key]) ? $_FILES[$key] : array()); 
    181   } 
    182  
    183   /** 
    184    * Retrieves a file path. 
    185    * 
    186    * @param  string $name  A file name 
    187    * 
    188    * @return string A file path, if the file exists, otherwise null 
    189    */ 
    190   public function getFilePath($name) 
    191   { 
    192     if (!sfConfig::get('sf_compat_10')) 
    193     { 
    194       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    195     } 
    196  
    197     return $this->hasFile($name) ? $this->getFileValue($name, 'tmp_name') : null; 
    198   } 
    199  
    200   /** 
    201    * Retrieve a file size. 
    202    * 
    203    * @param  string $name  A file name 
    204    * 
    205    * @return int A file size, if the file exists, otherwise null 
    206    */ 
    207   public function getFileSize($name) 
    208   { 
    209     if (!sfConfig::get('sf_compat_10')) 
    210     { 
    211       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    212     } 
    213  
    214     return $this->hasFile($name) ? $this->getFileValue($name, 'size') : null; 
    215   } 
    216  
    217   /** 
    218    * Retrieves a file type. 
    219    * 
    220    * This may not be accurate. This is the mime-type sent by the browser 
    221    * during the upload. 
    222    * 
    223    * @param  string $name  A file name 
    224    * 
    225    * @return string A file type, if the file exists, otherwise null 
    226    */ 
    227   public function getFileType($name) 
    228   { 
    229     if (!sfConfig::get('sf_compat_10')) 
    230     { 
    231       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    232     } 
    233  
    234     return $this->hasFile($name) ? $this->getFileValue($name, 'type') : null; 
    235   } 
    236  
    237   /** 
    238    * Indicates whether or not a file exists. 
    239    * 
    240    * @param  string $name  A file name 
    241    * 
    242    * @return bool true, if the file exists, otherwise false 
    243    */ 
    244   public function hasFile($name) 
    245   { 
    246     if (!sfConfig::get('sf_compat_10')) 
    247     { 
    248       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    249     } 
    250  
    251     if (preg_match('/^(.+?)\[(.+?)\]$/', $name, $match)) 
    252     { 
    253       return isset($_FILES[$match[1]]['name'][$match[2]]); 
    254     } 
    255     else 
    256     { 
    257       return isset($_FILES[$name]); 
    258     } 
    259   } 
    260  
    261   /** 
    262    * Indicates whether or not a file error exists. 
    263    * 
    264    * @param  string $name  A file name 
    265    * 
    266    * @return bool true, if the file error exists, otherwise false 
    267    */ 
    268   public function hasFileError($name) 
    269   { 
    270     if (!sfConfig::get('sf_compat_10')) 
    271     { 
    272       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    273     } 
    274  
    275     return $this->hasFile($name) ? ($this->getFileValue($name, 'error') != UPLOAD_ERR_OK) : false; 
    276   } 
    277  
    278   /** 
    279    * Indicates whether or not any file errors occured. 
    280    * 
    281    * @return bool true, if any file errors occured, otherwise false 
    282    */ 
    283   public function hasFileErrors() 
    284   { 
    285     if (!sfConfig::get('sf_compat_10')) 
    286     { 
    287       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    288     } 
    289  
    290     foreach ($this->getFileNames() as $name) 
    291     { 
    292       if ($this->hasFileError($name) === true) 
    293       { 
    294         return true; 
    295       } 
    296     } 
    297  
    298     return false; 
    299   } 
    300  
    301   /** 
    302    * Indicates whether or not any files exist. 
    303    * 
    304    * @return boolean true, if any files exist, otherwise false 
    305    */ 
    306   public function hasFiles() 
    307   { 
    308     if (!sfConfig::get('sf_compat_10')) 
    309     { 
    310       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    311     } 
    312  
    313     return (count($_FILES) > 0); 
    314   } 
    315  
    316   /** 
    317    * Retrieves a file value. 
    318    * 
    319    * @param string $name A file name 
    320    * @param string $key Value to search in the file 
    321    *  
    322    * @return string File value 
    323    */ 
    324   public function getFileValue($name, $key) 
    325   { 
    326     if (!sfConfig::get('sf_compat_10')) 
    327     { 
    328       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    329     } 
    330  
    331     if (preg_match('/^(.+?)\[(.+?)\]$/', $name, $match)) 
    332     { 
    333       return $_FILES[$match[1]][$key][$match[2]]; 
    334     } 
    335     else 
    336     { 
    337       return $_FILES[$name][$key]; 
    338     } 
    339   } 
    340  
    341   /** 
    342    * Retrieves all the values from a file. 
    343    * 
    344    * @param  string $name  A file name 
    345    * 
    346    * @return array Associative list of the file values 
    347    */ 
    348   public function getFileValues($name) 
    349   { 
    350     if (!sfConfig::get('sf_compat_10')) 
    351     { 
    352       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    353     } 
    354  
    355     if (preg_match('/^(.+?)\[(.+?)\]$/', $name, $match)) 
    356     { 
    357       return array( 
    358         'name'     => $_FILES[$match[1]]['name'][$match[2]], 
    359         'type'     => $_FILES[$match[1]]['type'][$match[2]], 
    360         'tmp_name' => $_FILES[$match[1]]['tmp_name'][$match[2]], 
    361         'error'    => $_FILES[$match[1]]['error'][$match[2]], 
    362         'size'     => $_FILES[$match[1]]['size'][$match[2]], 
    363       ); 
    364     } 
    365     else 
    366     { 
    367       return $_FILES[$name]; 
    368     } 
    369   } 
    370  
    371   /** 
    372    * Retrieves an extension for a given file. 
    373    * 
    374    * @param  string $name  A file name 
    375    * 
    376    * @return string Extension for the file 
    377    */ 
    378   public function getFileExtension($name) 
    379   { 
    380     if (!sfConfig::get('sf_compat_10')) 
    381     { 
    382       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    383     } 
    384  
    385     static $mimeTypes = null; 
    386  
    387     $fileType = $this->getFileType($name); 
    388  
    389     if (!$fileType) 
    390     { 
    391       return '.bin'; 
    392     } 
    393  
    394     if (is_null($mimeTypes)) 
    395     { 
    396       $mimeTypes = unserialize(file_get_contents(sfConfig::get('sf_symfony_lib_dir').'/plugins/sfCompat10Plugin/data/mime_types.dat')); 
    397     } 
    398  
    399     return isset($mimeTypes[$fileType]) ? '.'.$mimeTypes[$fileType] : '.bin'; 
    400   } 
    401  
    402   /** 
    403109   * Retrieves the uniform resource identifier for the current web request. 
    404110   * 
     
    474180 
    475181    // simulate PATH_INFO if needed 
    476     $sf_path_info_key = sfConfig::get('sf_path_info_key', 'PATH_INFO')
     182    $sf_path_info_key = $this->options['path_info_key']
    477183    if (!isset($pathArray[$sf_path_info_key]) || !$pathArray[$sf_path_info_key]) 
    478184    { 
     
    491197    { 
    492198      $pathInfo = $pathArray[$sf_path_info_key]; 
    493       if ($sf_relative_url_root = $this->getRelativeUrlRoot()) 
    494       { 
    495         $pathInfo = preg_replace('/^'.str_replace('/', '\\/', $sf_relative_url_root).'\//', '', $pathInfo); 
     199      if ($relativeUrlRoot = $this->getRelativeUrlRoot()) 
     200      { 
     201        $pathInfo = preg_replace('/^'.str_replace('/', '\\/', $relativeUrlRoot).'\//', '', $pathInfo); 
    496202      } 
    497203    } 
     
    524230  { 
    525231    return $this->requestParameters; 
    526   } 
    527  
    528   /** 
    529    * Moves an uploaded file. 
    530    * 
    531    * @param string $name      A file name 
    532    * @param string $file      An absolute filesystem path to where you would like the 
    533    *                          file moved. This includes the new filename as well, since 
    534    *                          uploaded files are stored with random names 
    535    * @param int    $fileMode  The octal mode to use for the new file 
    536    * @param bool   $create    Indicates that we should make the directory before moving the file 
    537    * @param int    $dirMode   The octal mode to use when creating the directory 
    538    * 
    539    * @return bool true, if the file was moved, otherwise false 
    540    * 
    541    * @throws <b>sfFileException</b> If a major error occurs while attempting to move the file 
    542    */ 
    543   public function moveFile($name, $file, $fileMode = 0666, $create = true, $dirMode = 0777) 
    544   { 
    545     if (!sfConfig::get('sf_compat_10')) 
    546     { 
    547       throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.'); 
    548     } 
    549  
    550     if ($this->hasFile($name) && $this->getFileValue($name, 'error') == UPLOAD_ERR_OK && $this->getFileValue($name, 'size') > 0) 
    551     { 
    552       // get our directory path from the destination filename 
    553       $directory = dirname($file); 
    554  
    555       if (!is_readable($directory)) 
    556       { 
    557         $fmode = 0777; 
    558  
    559         if ($create && !@mkdir($directory, $dirMode, true)) 
    560         { 
    561           // failed to create the directory 
    562           throw new sfFileException(sprintf('Failed to create file upload directory "%s".', $directory)); 
    563         } 
    564  
    565         // chmod the directory since it doesn't seem to work on 
    566         // recursive paths 
    567         @chmod($directory, $dirMode); 
    568       } 
    569       else if (!is_dir($directory)) 
    570       { 
    571         // the directory path exists but it's not a directory 
    572         throw new sfFileException(sprintf('File upload path "%s" exists, but is not a directory.', $directory)); 
    573       } 
    574       else if (!is_writable($directory)) 
    575       { 
    576         // the directory isn't writable 
    577         throw new sfFileException(sprintf('File upload path "%s" is not writable.', $directory)); 
    578       } 
    579  
    580       if (@move_uploaded_file($this->getFileValue($name, 'tmp_name'), $file)) 
    581       { 
    582         // chmod our file 
    583         @chmod($file, $fileMode); 
    584  
    585         return true; 
    586       } 
    587     } 
    588  
    589     return false; 
    590232  } 
    591233 
     
    849491  public function getRelativeUrlRoot() 
    850492  { 
    851     if ($this->relativeUrlRoot === null) 
    852     { 
    853       $this->relativeUrlRoot = sfConfig::get('sf_relative_url_root', preg_replace('#/[^/]+\.php5?$#', '', $this->getScriptName())); 
     493    if (is_null($this->relativeUrlRoot)) 
     494    { 
     495      if (!isset($this->options['relative_url_root'])) 
     496      { 
     497        $this->relativeUrlRoot = preg_replace('#/[^/]+\.php5?$#', '', $this->getScriptName()); 
     498      } 
     499      else 
     500      { 
     501        $this->relativeUrlRoot = $this->options['relative_url_root']; 
     502      } 
    854503    } 
    855504 
     
    908557    { 
    909558      // parse PATH_INFO 
    910       switch (sfConfig::get('sf_path_info_array', 'SERVER')
     559      switch ($this->options['path_info_array']
    911560      { 
    912561        case 'SERVER': 
     
    1007656 
    1008657  /** 
     658   * Retrieves an array of files. 
     659   * 
     660   * @param  string $key  A key 
     661   * @return array  An associative array of files 
     662   */ 
     663  static public function getFiles($key = null) 
     664  { 
     665    return is_null($key) ? $_FILES : (isset($_FILES[$key]) ? $_FILES[$key] : array()); 
     666  } 
     667 
     668  /** 
    1009669   * Returns the value of a GET parameter. 
    1010670   * 
     
    1138798    } 
    1139799 
    1140     if (sfConfig::get('sf_logging_enabled')
     800    if ($this->options['logging']
    1141801    { 
    1142802      $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Request parameters %s', str_replace("\n", '', var_export($this->getParameterHolder()->getAll(), true)))))); 
  • branches/1.2/lib/task/generator/skeleton/app/app/config/settings.yml

    r10124 r10627  
    8787#    strip_comments:         on         # Remove comments in core framework classes as defined in the core_compile.yml 
    8888#    max_forwards:           5 
    89 #    path_info_array:        SERVER 
    90 #    path_info_key:          PATH_INFO 
    9189#    url_format:             PATH 
    9290#