Wednesday, August 6, 2008
By thomasw at 20:39:39
Hy interested ones,
I have good and bad news for you.
The bad news are that due to minor BC changes and the lack of time from the dev-team, which has to review the changes in the API, all new features from the I18N core are delayed until release 1.7.
This is also the case for the application wide locale which I described a chapter before. But, and this is more bad, most fixed issues will also be delayed until 1.7.
The good news are that the new release is scheduled for end September. But you can use all new features already when you are using the trunk.
What has been changed until now for the I18N core:
* I integrated an application wide locale… all I18N components can reuse an instance of Zend_Locale when registered in Zend_Registry.
* I integrated the new CLDR 1.6.1… it add’s not only several more complete informations for different languages, but also new data which will be added soon… for example, telephone data, character fall back rules, unit names just to mention some of them
* A new measurement class for time duration has been added
More things will come soon.
Another good thing is that Zend_File_Transfer was cored yesterday. It is officially available for release 1.6. Also here new features will be available soon, but not until 1.6.
I will keep you informed.
Greetings
Thomas, I18N Team Leader, Zend Framework
Monday, July 28, 2008
By thomasw at 00:08:38
Hy interested ones,
a new feature has been added within Zend Framework. it now supports the usage of an application wide locale. Anyone who is using I18N classes in his application will love this feature.
So what’s all about this new feature…. let’s look into details. Until Zend Framework 1.5 when you wanted to use several I18N aware classes you had to set the locale you wanted to use within all classes. This looked like this:
$locale = new Zend_Locale('en_US');
$date1 = new Zend_Date($locale);
$date2 = new Zend_Date($locale);
$currency = new Zend_Currency($locale);
When you use only one or two instances there is not much difference. But the more instances you use the more work you would have with the syntax. Looking at this in detail I thought why not simply set the locale once within your bootstrap and let the framework do the rest.
The solution was the usage of the registry. So let’s look at the same example and the difference in the usage:
$locale = new Zend_Locale('en_US');
Zend_Registry::set('Zend_Locale', $locale);
...
$date1 = new Zend_Date();
$date2 = new Zend_Date();
$currency = new Zend_Currency();
As you can notice now, you can forget about the locale as it’s automatically taken from the registry. This is a small and simple solution but it will solve you several headache. You can use this feature within the actual trunk or you have to wait until 1.6GA is released.
Have fun with it, anyway.
Greetings,
Thomas Weidner, I18N Team Leader, Zend Framework
Sunday, July 20, 2008
By thomasw at 22:56:00
Hy interested ones,
the new Zend_File_Transfer component is growing day for day.
As incredible new feature this component allows to use file validators.
These are necessary to increase security and allow to define rules for file uploads (and also downloads in future). So let’s see some examples to get a feeling:
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->addValidators('Size', '50kB)
->setDestination('C:/uploads')
->receive();
What we’ve done so far is to limit all sent files to 50kB filesize. Any file which is uploaded and exceeds the size of 50kB will throw an exception we can catch.
The more rules we define the more secure our upload will be.
So which other validators are supported until now:
- Size: We already know this validator. He checks the filesize of single file. You can set a minimum and a maximum filesize.
- Count: You should set this validator to represent exactly the amount of files you expect. He has also a mimimum and a maximum filecount. If this validator throws an error you are probably having an attack. But you can also limit the number of files to receive with this validator.
- Extension: This validator checks for the extension of files. You can set multiple extensions to be checked. But remember that an evil user can manually change the extension so you should not rely only on the extension.
- FilesSize: This validator also checks for the size of files. But different to the Size validator it checks for the size of ALL files. You could for example define that a single file must not exceed 50kB. But all files in sum must not exceed 200kB.
- ImageSize: The ImageSize validator checks the size of given files when they are images. You can define a mimimum and a maximum image size for width and height.
So let’s see a full example of validators and a more secure upload:
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->addValidators('Size', '250kB')
->addValidators('Count', 5)
->addValidators('FilesSize', '1MB')
->addValidators('Extension', 'gif, jpg, png')
->addValidators('ImageSize', array(10, 10, 1024, 768))
->setDestination('C:/uploads');
if (!$upload->isValid()) {
print_r($upload->getMessages());
die();
}
try {
$upload->receive();
} catch (Zend_File_Transfer_Exception $e) {
$e->getMessage();
}
So what we’ve created now is a fileupload for images.
Each imagefile can have 250kB maximum filesize. We allow in sum 5 images but all images im sum are not allowed to exceed 1MB. Additionally we allow gif, jpg and png files and define a imagesize of 10×10 up to 1024×768. All files are uploaded to ‘C:\uploads’.
As you see it’s not complicated to define a more secure upload then just using php’s move_uploaded_file.
Feel free to play around with this example.
If future there will be additional validators like MimeType and FileName.
Also filter will be added which allow you to change uploaded files on the fly before they are stored.
Filters could contain the automatic change of imagesize or changing textfiles to have a proper lineending and much more.
Greetings
Thomas, I18N Team Leader, Zend Framework
Friday, July 18, 2008
By thomasw at 22:55:15
Hy fellows,
a new version of Zend Framework will be released on Monday 21.July.2008.
It\’s the release canidate for 1.6. Even if it\’s until now not finished for public release, a release canidate can contain minor problems, it contains some new components and, of course, a huge amount of bugfixes and improvements.
My additions to this release are:
Zend_Transfer_Adapter_Ini: A adapter for using ini files for translations
Zend_File_Transfer: A component which handles file uploads and downloads for multiple transfer protocols.
Of course also a number of bugs and other small improvments to existing I18N components have been integrated.
Zend_File_Transfer is far away from being finished. But the ZF-devteam has decided that it should be integrated with 1.6. Actually it will support only the HTTP POST protocol. But it’s easy to use and it comes also with some validators especially created for file validation. As this component is not completly ready for now, it will additionally get an Zend_Form_Element_File which consumes this component, the decission has been made to delay it’s integration until RC2.
Yes, this are the bad news… we will have a RC2 anyway.
But the good news are, that we have some additionally days to fix some other issues.
Greetings
Thomas, I18N Team Leader, Zend Framework
Sunday, July 13, 2008
By thomasw at 20:01:36
Hy interested ones,
the Zend Framework has since today a new file transfer component ready for playing around.
Zend_File_Transfer allows file uploads and downloads when it’s finished.
For now, there is only HTTP POST upload available and it looks like it will be released with 1.6.
The component comes with several validators specially written for validating files with this component.
Below is an example of usage:
The example form looks like this:
<form enctype="multipart/form-data" action="index2.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
Choose a file to upload: <input name="uploadedfiles[]" type="file" /><br />
Choose a file to upload: <input name="uploadedfiles[]" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
The target looks like this:
<?php
require_once "Zend/File/Transfer/Adapter/Http.php";
require_once "Zend/File/Transfer/Exception.php";
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setValidators('size', '2000');
if ($adapter->isValid() === false) {
print_r($adapter->getMessages());
}
try {
$adapter->setDestination('C:\temp')
->receive();
} catch (Zend_File_Transfer_Exception $e) {
print $e->getMessage();
}
print "DOWNLOAD FINISHED!!";
As you see the usage is quite simple.
The seperated isValid() call is not necessary but will show you which failures occured while validation.
Any failure while uploading will also be returned as validation error even when you do not set any validator.
For now there are these validators available:
Zend_Validate_File_Count - validates the file count
Zend_Validate_File_DiskSpace - validates the disk usage of ALL files
Zend_Validate_File_Extension - validates the real file extension
Zend_Validate_File_Size - validates the size of single files
The Zend_Validate_File_Upload validator is the internal validator which checks for upload failures. There is no need to use it as it is automatically used by Zend_File_Transfer itself.
In future the component will be extended with other adapters and also with download capabilities.
I hope you enjoy testing and playing around.
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
Saturday, June 21, 2008
By thomasw at 11:41:33
Short notice:
I finished the implementation of a new adapter for Zend_Translate.
It allows you to use *.ini files as translation source within your applications.
Tuesday, June 10, 2008
By thomasw at 15:25:19
Hy interested ones,
I just added a new reference table to the documentation where people can see which ZF component depends on which other ZF component.
So if anyone is in need of just one component like Zend_Log he can just look into this table and see which other components he has also to provide that all works properly.
I hope this comes handy to people, especially to the one which declare not to have much space. :D
Related to the reference tables in general.
It would be great if anyone could update the tables (extensions) and/or test the actual content. I think the extensions section is outdated as several new components have been added and existing ones provide new features.
Maybe add a testbed for this case ? I don’t know…
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
Monday, June 2, 2008
By thomasw at 15:57:57
Hy interested ones,
I was told that within PHP 5.2.6 the directory scanning was not working any more.
After a little research and the help from a community member we found out that within PHP 5.2.6 the return values from the SPL have been changed without any response in the documentation.
The error can only be found within the Windows release of PHP 5.2.6. When you are using a older version or a non windows version you will not see any problems.
A workaround for this PHP bug has been integrated into the trunk. So within the next release it will be fixed anyway.
Greetings
Thomas
I18N Team Leader, Zend Framework
By thomasw at 15:50:47
Hy interested ones,
it was a long journey but after almost one year two of my proposals to the ZF were accepted by the dev team.
Proposal 1:
http://framework.zend.com/wiki/display/ZFPROP/Zend_Translate_Ini+-+Thomas+Weidner
This is a new adapter for Zend_Translate.
In future you will be able to have simple INI files to be used as translation source.
Not that I think that many people will use it, but from time to time it may be comfortable to have it. And INI files can be edited by customers very easy which makes them handy.
Proposal 2:
http://framework.zend.com/wiki/display/ZFPROP/Zend_File_Transfer+-+Thomas+Weidner
For this proposal the community waited about one year.
It integrates a standard way to handle file up and downloads supports many protocols and integrate several other benefits like filtering, processing and many more.
The INI adapter is almost finished and will be available in a few days when I have time.
The file transfer component will get my complete time after the coding standard has been finished. But it will not be available until the next release because it should stay a few weeks in the incubator for problem checking, bug fixing and possible improvements.
I’ll keep you informed as soon as I have new informations.
Greetings
Thomas
I18N Team Leader, Zend Framework
Friday, April 25, 2008
By thomasw at 20:22:28
Since the last few weeks I have been working hard on finishing a first draft of the ZF Coding Standard.
It’s almost finished and aims to force a equal codequality for the complete framework.
If you are interested you can already try it out.
* Download the actual trunk
* Install PHP_CodeSniffer from PEAR
* Look into Zend/incubator/tools/codingstandard for details
Actually it finds more than 160.000 errors, but you have to keep in mind that the coding standard I’ve created is really VERY strict.
It mocks about false whitespaces, about false parameter types, about missing brackets and much much more.
Until now I’ve adopted and created more than 80 different tests.
As the standard itself is for now not completly fixed and confirmed, this testbed is only a draft.
Feel free to give response to me over the I18N mailing list.
Greetings
Thomas
I18N Team Leader, Zend Framework