public function configure($options = array(), $messages = array())
 {
     $this->addRequiredOption('gaufrette');
     parent::configure($options, $messages);
     $this->setOption('validated_file_class', 'sfGaufretteValidatedFile');
     $this->setOption('path', $options['gaufrette']);
 }
コード例 #2
0
 protected function configure($options = array(), $messages = array())
 {
     $this->addMessage('invalid_format', 'Invalid Xml file format <br /><u>Detail :</u>');
     $this->addMessage('invalid_line', '- %error%');
     $this->addMessage('unreadable_file', 'This file is unreadable.');
     $this->addOption('xml_path_file');
     parent::configure($options, $messages);
 }
コード例 #3
0
 protected function configure($options = array(), $messages = array())
 {
     // Default values
     $this->addOption('mime_types', array('application/x-bittorrent'));
     $this->addOption('private', 1);
     $this->addOption('announce', "http://" . $_SERVER['SERVER_NAME'] . "/announce");
     // Error messages
     $this->addMessage('private', "Your torrent file isn't set to private mode.");
     $this->addMessage('announce', "Your torrent file hasn't the correct announce URL (%announce%).");
     $this->addMessage('already', "A torrent file is already posted with the same hash (%hash%).");
     parent::configure($options, $messages);
 }
コード例 #4
0
 /**
  * Adds the following options to sfValidatorFile:
  * 
  * - max_width (default 3000px)
  * - max_height (default 3000px)
  * 
  * and the following error codes:
  * 
  * - max_width
  * - max_height
  *
  * @param unknown_type $options
  * @param unknown_type $messages
  */
 protected function configure($options = array(), $messages = array())
 {
     $this->addOption('required_width', false);
     $this->addOption('required_height', false);
     $this->addOption('max_width', 3000);
     $this->addOption('max_height', 3000);
     $this->addOption('resize', true);
     $this->addMessage('max_width', 'Image width (%width%px) is too big (maximum allowed is %max_width%px).');
     $this->addMessage('max_height', 'Image height (%height%px) is too big (maximum allowed is %max_height%px).');
     $this->addMessage('max_dimensions', 'Image dimensions (%width%px x %height%px) are too big (maximum allowed is %max_width%px &times; %max_height%px).');
     $this->addMessage('required_dimensions', 'Image dimensions must match %required_width%px &times; %required_height%px (it was %width%px &times; %height%px)');
     parent::configure($options, $messages);
 }
コード例 #5
0
 /**
  * @param array $options   An array of options
  * @param array $messages  An array of error messages
  *
  * @see sfValidatorFile
  */
 protected function configure($options = array(), $messages = array())
 {
     parent::configure($options, $messages);
     $this->addMessage('invalid_image', '%value% is an incorrect image file.');
     $this->addMessage('max_height', '"%value%" height is too long (%max_height% pixels max).');
     $this->addMessage('min_height', '"%value%" height is too short (%min_height% pixels min).');
     $this->addMessage('max_width', '"%value%" width is too long (%max_width% pixels max).');
     $this->addMessage('min_width', '"%value%" width is too short (%min_width% pixels min).');
     $this->addOption('max_height');
     $this->addOption('min_height');
     $this->addOption('max_width');
     $this->addOption('min_width');
     $this->addOption('is_only_image', false);
 }
コード例 #6
0
 /**
  * @param array $options   An array of options
  * @param array $messages  An array of error messages
  *
  * @see sfValidatorFile
  */
 protected function configure($options = array(), $messages = array())
 {
     parent::configure($options, $messages);
     $this->addMessage('invalid_image', '%value% n\'est pas un fichier image.');
     $this->addMessage('max_height', '"%value%" a une hauteur trop grande (%max_height% pixels max).');
     $this->addMessage('min_height', '"%value%" a une hauteur trop petite (%min_height% pixels min).');
     $this->addMessage('max_width', '"%value%" a une largeur trop grande (%max_width% pixels max).');
     $this->addMessage('min_width', '"%value%" a une largeur trop petite (%min_width% pixels min).');
     $this->addOption('max_height');
     $this->addOption('min_height');
     $this->addOption('max_width');
     $this->addOption('min_width');
     $this->addOption('is_only_image', false);
 }
コード例 #7
0
 protected function configure($options = array(), $messages = array())
 {
     $guessersSet = isset($options['mime_type_guessers']);
     parent::configure($options, $messages);
     if (!$guessersSet) {
         // Extend the default list from the parent class with a guesser that is
         // robust on rackspace cloud sites and works fine elsewhere as well.
         // Based on getimagesize. Also checks the PDF file signature. Everything
         // else falls back to the other guessers
         $mimeTypeGuessers = $this->getOption('mime_type_guessers');
         array_unshift($mimeTypeGuessers, array($this, 'guessFromImageconverter'));
         $this->setOption('mime_type_guessers', $mimeTypeGuessers);
     }
 }
コード例 #8
0
 protected function configure($options = array(), $messages = array())
 {
     parent::configure($options, $messages);
     $this->setOption('mime_types', 'web_images');
     $maxFilesize = opConfig::get('image_max_filesize');
     switch (strtoupper(substr($maxFilesize, -1))) {
         case 'K':
             $maxFilesize = (int) $maxFilesize * 1024;
             break;
         case 'M':
             $maxFilesize = (int) $maxFilesize * 1024 * 1024;
             break;
     }
     $this->setOption('max_size', (int) $maxFilesize);
 }
コード例 #9
0
 /**
  * DOCUMENT ME
  * @param mixed $options
  * @param mixed $messages
  */
 protected function configure($options = array(), $messages = array())
 {
     $guessersSet = isset($options['mime_type_guessers']);
     parent::configure($options, $messages);
     if (!$guessersSet) {
         // Extend the default list from the parent class with guessers that are more
         // robust about spotting files that can't be picked up if Unix file is
         // unavailable, mime type files are out of date, Unix file has a bug that
         // hates on certain valid MP3s, etc. Everything else falls back to the other guessers
         $mimeTypeGuessers = $this->getOption('mime_type_guessers');
         array_unshift($mimeTypeGuessers, array($this, 'guessFromImageconverter'));
         array_unshift($mimeTypeGuessers, array($this, 'guessFromID3'));
         array_unshift($mimeTypeGuessers, array($this, 'guessRTF'));
         $this->setOption('mime_type_guessers', $mimeTypeGuessers);
     }
 }
コード例 #10
0
 /**
  * Configures the current validator.
  *
  * The api for sfFilebasePluginValidatorFile is derived from sfValidatorFile.
  * So there are only little changes in handling, but the return value
  * is of type sfFilebaseUploadedFile, which have a few ways to deal with
  * uploaded files, move them, create thumbnails and so on...
  *
  * There are no mime guessers, the sfFilebasePluginUploadedFilesManager
  * deals with that when you call sfFilebasePlugin::getUploadedFiles().
  *
  * There is also no path to specify, you do that later directly by calling
  * sfFilebasePluginUploadedFile::moveUploadedFile
  *
  * As a compromise, you cannot specify your own fileclass anymore, beside
  * extending sfFilebaseUploadedFile and -manager.
  *
  * Available options:
  *
  *  * max_size:             The maximum file size
  *  * mime_types:           Allowed mime types array or category (available categories: web_images)
  *  * mime_type_guessers:   An array of mime type guesser PHP callables (must return the mime type or null)
  *  * mime_categories:      An array of mime type categories (web_images is defined by default)
  *  * path:                 The path where to save the file - as used by the sfValidatedFile class (optional)
  *  * validated_file_class: Name of the class that manages the cleaned uploaded file (optional)
  *  * allow_overwrite:       If set to true, existing files will be overwritten. Otherwise, an form field error will rise (optional)
  *                          This comes only in effect, if path is set (otherwise you'd to save the file manually)
  *  * filebase              Instance of filebase, needed if you want to save the file under another location than the
  *                          symfony default filebasePlugindDirectory (web/uploads) (optional)
  *
  * Available error codes:
  *
  *  * max_size
  *  * mime_types
  *  * partial
  *  * no_tmp_dir
  *  * cant_write
  *  * extension
  *
  * @param array $options   An array of options
  * @param array $messages  An array of error messages
  *
  * @see sfValidatorFile
  * @see sfValidatorBase
  */
 protected function configure($options = array(), $messages = array())
 {
     parent::configure($options, $messages);
     unset($this->options['mime_type_guessers']);
     $this->addOption('mime_categories', array('web_images' => sfFilebasePluginUtil::$WEB_IMAGES));
     $this->addOption('allow_overwrite', false);
     $this->addOption('filebase', sfFilebasePlugin::getInstance());
     $this->setOption('validated_file_class', 'sfFilebasePluginUploadedFile');
     $this->addMessage('file_exists', 'Destinated file %file% already exists.');
     // cleanup filebase option
     $fb = $this->getOption('filebase');
     if (is_string($fb)) {
         $this->setOption('filebase', sfFilebasePlugin::getInstance($fb));
     } elseif (!$this->getOption('filebase') instanceof sfFilebasePlugin) {
         $this->setOption('filebase', sfFilebasePlugin::getInstance());
     }
     // Calculate target path
     if (!$this->getOption('path')) {
         $this->setOption('path', $this->getOption('filebase')->getPathname());
     } else {
         $this->setOption('path', $this->getOption('filebase')->getFilebaseFile($path)->getPathname());
     }
 }
コード例 #11
0
 protected function configure($options = array(), $messages = array())
 {
     parent::configure($options, $messages);
     $this->addOption('allowed_extensions', null);
     $this->addMessage('invalid_extension', 'File extension is not allowed.');
 }
コード例 #12
0
 protected function configure($options = array(), $messages = array())
 {
     parent::configure($options, $messages);
     $this->setOption('mime_categories', 'web_images');
     $this->setOption('path', sfConfig::get('sf_web_dir') . '/images/store');
 }