Tuesday
24
March
2009

Zend_Validate_Hostname

In the past week I took over all issues for Zend_Validate and it’s subcomponents.
Most of them have not been touched or done since several months, so I am taking care of them in the future.

The first validator I’ve reviewed and reworked is Zend_Validate_Hostname.

New features for this newly reworked validator within trunk are:

* Supports additionally 76 IDN’s
* Supports now Multi-IDN TLDs like ORG or PL… these are TLDs which support multiple scripts
* Supports now length check for IDN’s as many IDN’s define a different limit than 64 characters.

Even if I added 76 new IDN’s to the existing 8 IDN’s there still not all actual possible TLD’s have been added.
The most common are COM and NET, but also countryIDN’s like CN or JP have to be added in future.

But, with the actual change 4 existing feature requests weere already be integrated.
I will keep you informed about new features as always, when you’ve registered to my blog. ;-)

Greetings
Thomas Weidner
I18N Team Leader, Zend Framework

Zend Framework Advisory Board Member
Zend Certified Engineer for Zend Framework

Back to top
Tuesday
3
March
2009

File uploads and upload progress

Sometimes it is necessary to show the progress for files which a user actually uploads to a site.
With the next release 1.8 the Zend Framework supports a very easy and simple way to provide the user with all wished data.

There are some prerequisits:
You must have installed and activated eighter the APC or UploadProgress extension.
You should use Zend_Form_File_Element, otherwise the needed hidden fields will not be attached.

So let’s expect you have already created the form and the controller to handle the upload itself.

To show your user the progress of his file upload you need to have an iframe or another different process beside the upload itself which shows it’s result to the user. The server part looks like this:

$adapter = new Zend_ProgressBar_Adapter_Console();
$upload  = Zend_File_Transfer_Adapter_Http::getProgress($adapter);
	
while (!$upload['done']) {
    $upload = Zend_File_Transfer_Adapter_Http:getProgress($upload);
}

There is only one thing you have to do:
* Create the wished ProgressBar adapter and give it to Zend_File_Transfer_Adapter_Http::getProgress()

All other things are done in background by this static method. You don’t need to create the form, or a file adapter. Simply call this static method.

In return your ProgressBar adapter will be updated and will show you the new progress for this upload.
However you realize your view, there are different methods to do so, you have to give the output of Zend_File_Transfer_Adapter_Http::getProgress() as input to the next call of this method.

It was never simpler to get the upload progress and show it to a user.

Greetings
Thomas Weidner
I18N Team Leader, Zend Framework

Zend Framework Advisory Board Member
Zend Certified Engineer for Zend Framework

Back to top