Пример #1
0
 /**
  * Constructor.
  *
  * @param    string            $name          The name.
  * @param    string [optional] $class         The CSS-class to be used.
  * @param    string [optional] $classError    The CSS-class to be used when there is an error.
  * @see      SpoonFormFile::__construct()
  */
 public function __construct($name, $class = 'inputFilefield', $classError = 'inputFilefieldError')
 {
     // call the parent
     parent::__construct($name, $class, $classError);
     // mime type hinting
     $this->setAttribute('accept', 'image/*');
 }
Пример #2
0
 /**
  * Image Save
  *
  * @return	void
  * @param	SpoonFormImage $imageFile		ImageFile.
  * @param	string $module					Module name.
  * @param	string $filename				Filename.
  * @param	string[optional] $subDirectory	Subdirectory.
  * @param	array[optional] $fileSizes		Possible file sizes.
  */
 public static function imageSave($imageFile, $module, $filename, $subDirectory = '', $fileSizes = null)
 {
     // get fileSizes var from model
     if (empty($fileSizes)) {
         $model = get_class_vars('Backend' . SpoonFilter::toCamelCase($module) . 'Model');
         $fileSizes = $model['fileSizes'];
     }
     // loop all directories and create
     foreach ($fileSizes as $sizeDir => $size) {
         // set parameters
         $filepath = FRONTEND_FILES_PATH . '/' . $module . (empty($subDirectory) ? '/' : $subDirectory . '/') . $sizeDir . '/' . $filename;
         $width = $size['width'];
         $height = $size['height'];
         $allowEnlargement = empty($size['allowEnlargement']) ? null : $size['allowEnlargement'];
         $forceOriginalAspectRatio = empty($size['forceOriginalAspectRatio']) ? null : $size['forceOriginalAspectRatio'];
         // create
         $imageFile->createThumbnail($filepath, $width, $height, $allowEnlargement, $forceOriginalAspectRatio);
     }
     // save original
     $imageFile->moveFile(FRONTEND_FILES_PATH . '/' . $module . (empty($subDirectory) ? '/' : $subDirectory . '/') . 'source/' . $filename);
 }