public function setup() { parent::setup(); unset($this['type'], $this['filesize'], $this['created_at'], $this['updated_at']); $this->widgetSchema['folder_id'] = new sfWidgetFormInputHidden(); $this->validatorSchema['folder_id'] = new sfValidatorInteger(); $this->widgetSchema['filename'] = new sfWidgetFormInputFile(); $this->validatorSchema['filename'] = new lyMediaValidatorFile(array('required' => 'true', 'path' => lyMediaTools::getBasePath() . $this->getOption('folder')->getRelativePath(), 'mime_types' => lyMediaTools::getAllowedMimeTypes(), 'allowed_extensions' => lyMediaTools::getAllowedExtensions())); $this->widgetSchema['filename']->setLabel('Upload file'); }
/** * Checks if asset file and thumbnails exist in filesystem. * * @param string $folder asset folder (relative path) * @param string $file asset filename * @param boolean $check_thumbs check existence/non-existence of thumbnail files * @param boolean $exist true=must exist, false=must not exist * * @return lyMediaTestFunctional current lyMediaTestFunctional instance */ protected function checkFile($folder, $file, $check_thumbs = true, $exist = true) { $file_path = lyMediaTools::getBasePath() . $folder . $file; $this->test()->is(is_file($file_path), $exist, 'File ' . $folder . $file . ($exist ? ' has ' : ' has not ') . 'been found'); if ($check_thumbs) { foreach (lyMediaTools::getThumbnailSettings() as $key => $params) { $file_path = lyMediaTools::getThumbnailPath($folder, $file, $key, false); $this->test()->is(is_file($file_path), $exist, 'Thumbnail ' . $key . '_' . $file . ($exist ? ' has ' : ' has not ') . 'been found'); } } return $this; }