Author: joshiausdemwald
Date: 2009-05-12 16:49:10 +0200 (Tue, 12 May 2009)
New Revision: 18172
Removed:
plugins/sfFilebasePlugin/lib/README
Modified:
plugins/sfFilebasePlugin/README
plugins/sfFilebasePlugin/lib/sfFilebasePlugin.php
plugins/sfFilebasePlugin/lib/sfFilebasePluginUploadedFile.php
plugins/sfFilebasePlugin/makedoc
plugins/sfFilebasePlugin/package.xml
Log:
Added sfFilebasePluginValidatorFile
Modified: plugins/sfFilebasePlugin/README
===================================================================
--- plugins/sfFilebasePlugin/README 2009-05-12 14:39:17 UTC (rev 18171)
+++ plugins/sfFilebasePlugin/README 2009-05-12 14:49:10 UTC (rev 18172)
@@ -45,6 +45,19 @@
image-manipulation capabilities). Included is a hidden cache layer which
automatically stores generated binary data.
+Recent chances
+--------------
+
+* Addes sfFilebasePluginValidatorFile. See sfValidatorFile, it uses nearly the
+ same API. The difference is, that you'll have to use
+ sfFilebasePlugin::getUploadedFiles() instead of
+ sfWebRequest::getUploadedFileswhen you pass Files to sfForm:
+
+ sfForm::bind($my_params, $my_filebase->getUploadedFiles())
+
+ With sfFilebasePluginValidatorFile, you can easily move the uploaded files,
+ create thumbnail out of recently uploaded images and so on...
+
Installation
------------
Deleted: plugins/sfFilebasePlugin/lib/README
===================================================================
--- plugins/sfFilebasePlugin/lib/README 2009-05-12 14:39:17 UTC (rev 18171)
+++ plugins/sfFilebasePlugin/lib/README 2009-05-12 14:49:10 UTC (rev 18172)
@@ -1,192 +0,0 @@
-sfFilebasePlugin
-================
-
-sfFilebasePlugin provides an unified API for filesystem related operations with
-focus on web based applications.
-
-It consists of a set of classes based on built in SPL classes (SplFileInfo/
--Object, DirectoryIterator ...) written by Marcus Boerger.
-
-Documentation for these classes may be found in the
-[API-docs](http://www.php.net/~helly/php/ext/spl/).
-
-It extends the built in SPL-Classes by dissociating more and different files or
-types. Resulting in a collection of classes like "sfFilebasePluginDirectory",
-"sfFilebasePluginImage", "sfFilebasePluginThumbnail" ... planning
-sfFilebasePluginZIP or something like that. Additionally, the plugin provides
an
-extension of SplFileObject named "sfFilebasePluginFileObject".
-
-SfFilebasePlugin can help you if you want to
-
-* upload files,
-
-* search and retrieve files from filesystem,
-
-* read/write/execute files,
-
-* do architecture dependent filesystem operations like chmod, mkdir, touch.
-
-* easily convert path names from absolute to relative, web root based or
filebase
- root based. Each file related plugin method has an overloaded signature, so
- that it does not matter whether you pass an absolute, relative pathname or
an
- instance of sfFilebasePluginFile or one of its children.
-
-* manipulate images, generating thumbnails (please help to implement much more
- image-manipulation capabilities). Included is a hidden cache layer which
- automatically stores generated binary data.
-
-Installation
-------------
-
-_(Install instructions taken from README in sfThumbnailPlugin, (c) Fabien
Potencier)_
-
-To install the plugin for a symfony project, the usual process is to use the
-symfony command line.
-
-With symfony 1.0, use:
-
- $ symfony plugin-install
http://plugins.symfony-project.com/sfFilebasePlugin
-
-With symfony 1.1/1.2, use:
-
- $ symfony plugin:install sfFilebasePlugin
-
-Alternatively, if you don't have PEAR installed, you can download the latest
-package attached to this plugin's wiki page and extract it under your project's
-`plugins/` directory.
-
-Clear the cache to enable the autoloading to find the new classes:
-
- $ php symfony cc
-
-You're done.
-
-*Note*: If the [GD library](http://php.net/gd) is not activated, you might
-have to uncomment the related line in your `php.ini` and restart your web
-server to enable PHP image handling functions.
-
-*Note*: To use !ImageMagick, you'll need to install the pecl
-[imagick extension](http://php.net/imagick). On debian/ubuntu, do something
-like
-
- sudo apt-get install php5-imagick
-
-On Windows, you'll probably have to activate the extension in your php.ini.
-
-Contents
---------
-
-The plugin contains a set of classes, that are all instanciated by a file
-controller called sfFilebasePlugin. Please take a look at the phpdocs to see
how
-it works. There is a static utility class named sfFilebasePluginUtil that
-provides general worker methods.
-
-Examples
---------
-
-There is a sample project under version control:
-[http://svn.symfony-project.com/plugins/sfFilebasePlugin/apps/](http://svn.symfony-project.com/plugins/sfFilebasePlugin/apps/)
-Simple create a new symfony project, copy the apps-folder, thats it (i think).
-You'll see some forms, can upload files, create directories and see some image
-transformations in action. Perhaps it can be useful.
-
-Short code samples
-------------------
-
-Create a new sfFilebasePlugin:
-
- $filebase = new sfFilebasePlugin('/var/www/my_filebase_dir');
-
-Create a new sfFilebasePlugin in sf_project/web/uploads:
-
- $filebase = new sfFilebasePlugin()
-
-The sfFilebasePlugin "root"-directory must be writable by php. In standard php
-configurations with mod_php you usually have to chmod(777) it or change the
-ownership to wwwrun or something like that.
-
-Iterate over sub-directories:
-
- foreach($filebase AS $file)
- {
- //lets create thumbnails for all images
- $thumbnails = array();
- if($file instanceof sfFilebasePluginImage)
- {
- $thumbnails[] = $file->getThumbnail(array('width'=>120));
- }
-
- // Make a few stupid things to show up
- $file->copy('my_new_filename.ext');
- $file->copy('/path/to/folder/in/filebase/filename.ext');
- $file->copy($filebase->getFilebaseFile('my_folder/file.ext'));
- }
- // do something with the thumbnails.
-
-File-Uploads:
-
- $destination_directory = "my_uploads";
- $files = $filebase->getUploadedFiles();
- $filebase->moveUploadedFile($files[0], $destination_directory);
-
- // Or by handling all uploaded files:
- $filebase->moveAllUploadedFiles($destination_directory);
-
-Error-Handling
---------------
-The above code is incomplete because it does not show any error handling.
-SfFilebasePlugin handles errors by insanely throwing sfFilebasePluginException
-that can be caught for merely any operation. Please give me a hint if you think
-that there is an exception that makes no sense in the context or if you miss
one
-in another part of the code or this particular runtime situation.
-
-Developement
-------------
-
-SfFilebasePlugin is in developement state. Standard methods to deal with files
-are meant to be stable, but there is space for a lot of improvements. Code
-contributions and -improvements, error reportings as bugfixes are very
welcomed!
-
-Roadmap
--------
-I'd love to see some file compression support in the sfFilebasePlugin - but i
-think at the moment it'd be better to work on improving stability and testing.
-
-This plugin is ideal if you want to have a solid "virtual filesystem" in a new
-project and you are also willing to improve and fix it while coding as well as
-optimizing the api for usability. That's what agile devopement is meant to
-be ;););).
-
-There are a few concrete features that i have in mind for the near future:
-
-* Improving unit and functional tests
-* Bug tracking and fixing
-* Better symfony-integration
-
- * Integration in sfForms as an alternative to sfValidatorFile, or perhaps a
- combination of both
- * Image processing: There are two adapters, one for imagick extension (no
- system calls like in sfThumbnailPlugin, but i simply don't know what is the
- better way doing it) and GD. This is redundant, because sfThumbnailPlugin
- also provides 2 adapters. Perhaps integrate it as a plugin-dependancy?
- * More, More, More! Image processing capabilities (experimental rotation is
- built in, perhaps a web2.0 mirror effect or something like this)
-
-Test
-----
-
-I began to write some unit-tests on it, but they do not fit in every aspect. So
-if you want to report a bug, i would appreciate if you'd pass unit or
functional
-tests that reproduce the issue.
-
-Please note that sfFilebasePlugin was developed on a linux machine running
-ubuntu and php5.2.6 and symfony 1.2. It should run on similar platforms, too,
-but i did not test it.
-
-Tests should also consider other operating systems like (what was its name?
-ahhh, got it:) windows and rich man's MacOS.
-
-Ok, i hope that this plugin is useful, i'd love to receive your comments and
-critiques.
-
-Have fun ;)
\ No newline at end of file
Modified: plugins/sfFilebasePlugin/lib/sfFilebasePlugin.php
===================================================================
--- plugins/sfFilebasePlugin/lib/sfFilebasePlugin.php 2009-05-12 14:39:17 UTC
(rev 18171)
+++ plugins/sfFilebasePlugin/lib/sfFilebasePlugin.php 2009-05-12 14:49:10 UTC
(rev 18172)
@@ -346,9 +346,18 @@
*
* @return array sfFilebasePluginUploadedFile $files
*/
- public function getUploadedFiles()
+ public function getUploadedFiles($index = null, $default = null)
{
- return $this->uploadedFilesManager->getUploadedFiles();
+ $files = $this->uploadedFilesManager->getUploadedFiles();
+ if($index !== null)
+ {
+ if(is_array($files) && array_key_exists($index, $files))
+ {
+ return $files[$index];
+ }
+ return $default;
+ }
+ return $files;
}
/**
Modified: plugins/sfFilebasePlugin/lib/sfFilebasePluginUploadedFile.php
===================================================================
--- plugins/sfFilebasePlugin/lib/sfFilebasePluginUploadedFile.php
2009-05-12 14:39:17 UTC (rev 18171)
+++ plugins/sfFilebasePlugin/lib/sfFilebasePluginUploadedFile.php
2009-05-12 14:49:10 UTC (rev 18172)
@@ -69,8 +69,22 @@
*/
function __construct($name, $tmp_name, $type, $error, $size,
sfFilebasePlugin $filebase)
{
+ if (!$name)
+ $name = '';
+
+ if (!$error)
+ $error = self::UPLOAD_ERR_OK;
+
+ $this->tmp_name = $filebase->getFilebaseFile($tmp_name);
+
+ if (!$size)
+ $size = $this->tmp_name->getSize();
+
+ if (!$type)
+ $type = $this->tmp_name->getMimeType() ? $this->tmp_name->getMimeType()
: 'application/octet-stream';
+
+
$this->name = $name;
- $this->tmp_name = $filebase->getFilebaseFile($tmp_name);
$this->type = $type;
$this->error = $error;
$this->size = $size;
@@ -131,15 +145,27 @@
}
/**
- * Returns true if an upload
- * error occured
+ * Returns true if there are file upload errors.
+ * If the argument $errcode is given, state is
+ * checked by this specific errcode.
+ * @example $file->isError()
+ * @example $file->isError(sfFilebaseUploadedFile::UPLOAD_ERR_NO_FILE)
* @return boolean
*/
- public function isError()
+ public function isError($errcode = null)
{
- return $this->error !== self::UPLOAD_ERR_OK;
+ if($errcode === null || $errcode === self::UPLOAD_ERR_OK)
+ {
+ return $this->hasError();
+ }
+ return $this->getError() === $errcode;
}
+ public function hasError()
+ {
+ return $this->getError() !== self::UPLOAD_ERR_OK;
+ }
+
/**
* Returns the error code of
* the uploaded file
Modified: plugins/sfFilebasePlugin/makedoc
===================================================================
--- plugins/sfFilebasePlugin/makedoc 2009-05-12 14:39:17 UTC (rev 18171)
+++ plugins/sfFilebasePlugin/makedoc 2009-05-12 14:49:10 UTC (rev 18172)
@@ -1,2 +1 @@
-cp ./README ./lib
phpdoc -s -pp -o HTML:frames:DOM/phphtmllib -d ./config,./lib -t ./doc -ric
README, LICENSE
Modified: plugins/sfFilebasePlugin/package.xml
===================================================================
--- plugins/sfFilebasePlugin/package.xml 2009-05-12 14:39:17 UTC (rev
18171)
+++ plugins/sfFilebasePlugin/package.xml 2009-05-12 14:49:10 UTC (rev
18172)
@@ -13,8 +13,8 @@
<date>2009-05-12</date>
<time>23:59:59</time>
<version>
- <release>0.0.10</release>
- <api>0.0.8</api>
+ <release>0.5.0</release>
+ <api>0.5.0</api>
</version>
<stability>
<release>stable</release>
@@ -30,6 +30,9 @@
<file role="php" name="config.php" />
</dir>
<dir name="lib">
+ <dir name="Validator">
+ <file role="php" name="sfFilebasePluginValidatorFile.php" />
+ </dir>
<file role="php" name="sfFilebasePlugin.php" />
<file role="php" name="sfFilebasePluginDirectory.php" />
<file role="php" name="sfFilebasePluginException.php" />
@@ -73,6 +76,22 @@
<changelog>
<release>
<version>
+ <release>0.5.0</release>
+ <api>0.5.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license>MIT license</license>
+ <date>2009-05-12</date>
+ <notes>
+ * Added sfFilebasePluginValidatorFile for native File upload
+ validation.
+ </notes>
+ </release>
+ <release>
+ <version>
<release>0.0.10</release>
<api>0.0.8</api>
</version>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en
-~----------~----~----~----~------~----~------~--~---