<commit_before><?php
/*
 * This file is part of the gumnut package.
 * (c) 2009-2010 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * rtSearchForm handles the search form..
 *
 * @package    gumnut
 * @subpackage form
 * @author     <NAME> <<EMAIL>>
 */
class rtAssetUploadForm extends PluginrtAssetForm
{
  public function setup()
  {
    parent::setup();

    $this->useFields(array('model', 'model_id', 'filename'));

    $this->setWidgets(array(
      'model_id'   => new sfWidgetFormInputHidden(),
      'model'      => new sfWidgetFormInputHidden(),
      'filename'   => new sfWidgetFormInputFile(),
    ));

    $this->setValidators(array(
      'model_id'   => new sfValidatorInteger(array('required' => false)),
      'model'      => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'filename'   => new sfValidatorFile(array(
      'path' => sfConfig::get('sf_upload_dir'),
      'mime_types' => $this->getAllowedMimeTypes()
    )),
    ));

    $this->enableCSRFProtection();
    $this->widgetSchema->setNameFormat('rt_asset[%s]');
  }

  /**
   * Return a list of allowed mime-types allowed for upload.
   *
   * @return array
   */
  public function getAllowedMimeTypes()
  {
    return sfConfig::get('app_rt_asset_allowed_mime_types', rtAssetToolkit::getCommonMimeTypes());
  }
}<commit_msg>Added optional mime-types in getAllowedMimeTypes method<commit_after><?php
/*
 * This file is part of the gumnut package.
 * (c) 2009-2010 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * rtSearchForm handles the search form..
 *
 * @package    gumnut
 * @subpackage form
 * @author     <NAME> <<EMAIL>>
 */
class rtAssetUploadForm extends PluginrtAssetForm
{
  public function setup()
  {
    parent::setup();

    $this->useFields(array('model', 'model_id', 'filename'));

    $this->setWidgets(array(
      'model_id'   => new sfWidgetFormInputHidden(),
      'model'      => new sfWidgetFormInputHidden(),
      'filename'   => new sfWidgetFormInputFile(),
    ));

    $this->setValidators(array(
      'model_id'   => new sfValidatorInteger(array('required' => false)),
      'model'      => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'filename'   => new sfValidatorFile(array(
      'path' => sfConfig::get('sf_upload_dir'),
      'mime_types' => $this->getAllowedMimeTypes()
    )),
    ));

    $this->enableCSRFProtection();
    $this->widgetSchema->setNameFormat('rt_asset[%s]');
  }

  /**
   * Return a list of allowed mime-types allowed for upload.
   *
   * @return array
   */
  public function getAllowedMimeTypes()
  {
    if($this->getOption('allowed_mime_types'))
    {
      return $this->getOption('allowed_mime_types');
    }
    return sfConfig::get('app_rt_asset_allowed_mime_types', rtAssetToolkit::getCommonMimeTypes());
  }
}
{'fraction_non_alphanumeric': 0.1492439184746877, 'fraction_numerical': 0.007232084155161078, 'mean_word_length': 3.569069069069069, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6026795', 'n_tokens_mistral': 977, 'n_tokens_neox': 942, 'n_words': 212}