Customises a file with additional details suitable for rendering in the
UploadField.ss template

@param File $file
@return ViewableData_Customised
764168
protected function customiseFile(File $file)
    {
        $customizedfile = $file->customise(array(
            'UploadFieldThumbnailURL' => $this->getThumbnailURLForFile($file),
            'UploadFieldDeleteLink' => $this->getItemHandler($file->ID)->DeleteLink(),
            'UploadFieldEditLink' => $this->getItemHandler($file->ID)->EditLink(),
            'UploadField' => $this
        ));

        // render file buttons
        return $customizedfile->customise(array(
                'UploadFieldFileButtons' => (string) $file->renderWith($this->getTemplateFileButtons(), array(
                    'IconRemove' => $this->IconRemove(),
                    'IconEdit' => $this->IconEdit(),
                    'EditEnabled' => $this->EditEnabled(),
                ))
        ));
    }
1157222
public function setFile($file)
    {

        //Return false if file does not exists;
        if (!$this->isFile($file)) {
            return false;
        }
        //Get the file info
        $this->file = $file;
        $this->pathinfo[$file] = pathinfo($file);

        //Return an instance of the file object;
        return $this;
    }
1324425
protected function getViewFile($file)
	{
		if($this->useRuntimePath)
		{
			$crc=sprintf('%x', crc32(get_class($this).Yii::getVersion().dirname($file)));
			$viewFile=Yii::app()->getRuntimePath().DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.$crc.DIRECTORY_SEPARATOR.basename($file);
			if(!is_file($viewFile))
				@mkdir(dirname($viewFile),$this->filePermission,true);
			return $viewFile;
		}
		else
			return $file.'c';
	}
393100
public function make(UploadedFile $file, array $attributes = [])
    {
        $image = app('image')
            ->make($file->getPathname())
            ->resize(
                config('media.maxwidth', 2560),
                config('media.maxheight', null),
                function ($constraint) {
                    if (config('media.aspectratio', true)) {
                        $constraint->aspectRatio();
                    }
                    if (config('media.upsize', true)) {
                        $constraint->upsize();
                    }
                }
            )
            ->encode(null, config('media.compression', 80));

        return $this->save($file->getClientOriginalName(), $image, $attributes);
    }
1169938
public function addRevFile($file)
    {
        // Load default rev file
        $this->getRevMap();

        if (is_file($file)) {
            $this->revMap = json_decode(file_get_contents($file), true) + $this->revMap;
        }

        return $this;
    }
472627
public function renderFile(File $file)
    {
        return $this->make(
            $file->getFileInfo()->getRelativePath().
            DIRECTORY_SEPARATOR.
            pathinfo($file->getFileInfo()->getFilename(), PATHINFO_FILENAME)
        )->renderFile($file);
    }
889078
public function htmlMinify($file, $type = 'file')
    {
        $file = $this->getFile($file, $type);
        $file = $this->cleanSpaces($file);
        $file = $this->fixMaster($file);
        $file = $this->removeComments($file);

        return $file;
    }
1215418
public function setFile($file)
    {
        $path = pathinfo((string) $file);

        if (!$path['extension'])
            $file .= '.'.static::$_defaultExt;

        $this->_file = trim($file, DIRECTORY_SEPARATOR);

        return $this;
    }
741922
protected function createFromArray($file)
	{
		$file = new SymfonyUploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']);

		return $this->createFromObject($file);
	}
706170
protected function createUploadedFile($file)
	{
		try {
			$imageManager = new ImageManager;
			$image = $imageManager->make($file);
			$extension = $this->getExtensionFromMime($image->mime());
			$fileName = $this->generateFileName($extension);
			$temporaryPath = $this->getTemporaryImageBasePath();
			$this->temporaryImage = $temporaryPath.'/'.$fileName;
			$image->save($this->temporaryImage);

			return new UploadedFile(
				$this->temporaryImage,
				$fileName, 
				$image->mime(),
				$image->filesize(),
				null,
				TRUE
			);
		} catch (Exception $e) {
			throw new ImageUploaderException("Error create uploaded file");
		}
	}
218506
public function setTemplateFile($file)
    {
        $this->onRender[] = function() use ($file) {
            $this->getTemplate()->add('gridoTemplate', $this->getTemplate()->getFile());
            $this->getTemplate()->setFile($file);
        };

        return $this;
    }
1268495
public static function createFromFile($file)
    {
        // If the file is not readable
        if (!is_readable($file)) {
            throw new InvalidArgumentException(
                sprintf(InvalidArgumentException::INVALID_FILE_STR, $file),
                InvalidArgumentException::INVALID_FILE
            );
        }

        return self::createFromString(file_get_contents($file));
    }
1003667
public function handle($file)
    {
        foreach ($this->view_extensions as $ext => $handler) {
            if ($file->exists($ext)) {
                $file = $file->withExtension($ext);
                $file->setMime($handler[1]);
                $file->setFound();
                $handle = $handler[0];
                if (!is_callable($handle)) {
                    $handle = [$this, $handle];
                }
                return call_user_func($handle, $file);
            }
        }

        return $file;
    }
577066
protected function _setCurrentFile($file)
    {
        $this->_currentFile = $file .((!is_link($file) && is_dir($file) && substr($file, -1) != DS) ? DS : '');
        return $this;
    }
97897
protected function addUploadedFile($file)
    {
        $this->clear();

        $this->uploaded_file = $this->getFileManager()->make($file);

        // Get the original values
        $filename = $this->uploaded_file->getClientOriginalName();
        $content_type = $this->uploaded_file->getMimeType();

        // Set model values
        $this->instanceWrite('file_name', $filename);
        $this->instanceWrite('file_size', $this->uploaded_file->getSize());
        $this->instanceWrite('content_type', $content_type);
        $this->instanceWrite('updated_at', date('Y-m-d H:i:s'));
        $this->instanceWrite('queued_file', null);

        // Queue all styles for writing
        $this->setQueue('write', $this->styles);
    }
821031
public function fileDownload($file)
    {
        $response = new SymfonyResponse();

        $response->headers->set('Content-Disposition', 
            $response->headers->makeDisposition(
                ResponseHeaderBag::DISPOSITION_ATTACHMENT,
                $file
            )
        );

        return $response;
    }
813466
public function setImageFromFile($file)
    {
        if (preg_match('/\.([^\.]+)$/', $file, $match) === 1) {
            $this->setMimeType('image/' . $match[1]);
        }
        return $this->setImageFromBlob(file_get_contents($file));
    }