Category: P4A

P4A 3 commit digest (4th feb 2008): the big one »

This is one on the biggest commit ever done in the world :-) There are a lot of changes “under the hood”, please read the changelog because it’s really important for you to know what is changed.

I’m really in hurry thus this digest is not as beautiful as I would but…

One of the most important thing is the new field validation infrastructure, you can simply do a $field->addValidator(new P4A_Validate_GreaterThan(5)) and you’ll know that your field won’t be valid until its value won’t be greater than 5. We’ve a lot of validators ’cause we subclass every Zend_Validate class (we need to subclass because Zend_Validate doesn’t support translatable error messages). P4A_Mask::saveRow() now automatically validates every field highlights the errors on the mask.

Another important point is that I rewrote the popup management, now we don’t have 2 masks opened at the same time (this has a few engineering problems) and opening a popup will cause a complete redesign of the mask (solving some other jquery related bugs we had). Wait, popup management is not complete, we already have new ideas to bring the ajax experience to a new level but I need time to write code…

oh how I would need time…

Here’s the changelog:

- PEAR::Net_Useragent_Detect was updated to 2.4.0
- P4A_Object, P4A_Widget and P4A_Data_Source are now declared as abstract
- the “eval” call within P4A_Object::actionHandler() method was changed to a call_user_func_array which seems to be faster
- all “function &function_name” declarations were changed to “function function_name”, removing the & symbol
- many ‘&’ symbols were removed cause of the new PHP5 reference management
- P4A_Table and P4A_DB_Navigator were php5ized
- P4A_Table_Col::setFormatted() and unsetFormatted() methods were removed, use isFormatted(null/true/false) instead
- P4A_Table_Col::setFormat() and unsetFormat() methods were removed
- P4A_Table_Col now has the “onformat” event that can be triggered to do custom format operations (same as P4A_Field)
- P4A_DB_Source::getFieldName() method was removed
- P4A_Data_Field::getSchemaTableField() method was added, it will return “schema.table.field”
- P4A_Data_Field::setReadOnly() method was removed, use isReadOnly(null/true/false)
- P4A_Quote_SQL_Value() global function was added
- a bug with P4A_DB was fixed to allow sqlite to work the right way with sequences
- PEAR repository was removed
- PEAR::validate module was renamed to pear_validate.php and moved to p4a/libraries/ directory
- PEAR::Net_Useragent_Detect module was renamed to pear_net_useragent_detect.php and moved to p4a/libraries/ directory
- P4A_Mkdir_Recursive() global function was added to P4A standard library
- All System::mkdir calls were changed to use the new P4A_Mkdir_Recursive() function
- a bunch of unuseful referenced were removed from core helpers
- GetId3 library was updated to 2.0.0b4 (which is php5 only), helper apps for windows servers were removed, they’ve to be installed in the system path thus we cannot ship them with p4a package ’cause they would be unuseful
- P4A_Field::setType(’image’) now causes a fatal error, image is not a recognized type anymore, always use file, it will render images/video/audio preview if it’s possible
- P4A_DEFAULT_ERROR_REPORTING, P4A_EXTENDED_ERROR_REPORTING, P4A_MINIMAL_ERROR_REPORTING constants were added
- P4A now sets error_reporting to P4A_MINIMAL_ERROR_REPORTING before using getid3() and then restore the error_reporting to the previous value
- P4A_Validate and PEAR::Validate classes were removed
- P4A_Field::addValidator() method was added, you can pass it Zend_Validate_* obejects
- P4A_Field::isValid() method was added to check if the validators chain is respected or not
- P4A_Base_Mask::setRequiredField() method now relies on Zend_Validator_NotEmpty
- P4A_Base_Mask::checkRequiredFields() method was renamed to validateFields() and now checks all validators chains for all fields and not only required fields
- all javascripts were refactored
- javascript/css popup management was reworked
- P4A_Base_Mask::setRequiredField(), validateFields(), warning(), error() and info() methods were moved to P4A_Mask
- P4A_Validate_Alnum, P4A_Validate_Alpha, P4A_Validate_Between, P4A_Validate_Ccnum, P4A_Validate_Date, P4A_Validate_Digits, P4A_Validate_EmailAddress, P4A_Validate_Float, P4A_Validate_GreaterThan, P4A_Validate_Hex,
P4A_Validate_Hostname, P4A_Validate_InArray, P4A_Validate_Int, P4A_Validate_Ip, P4A_Validate_LessThan, P4A_Validate_NotEmpty, P4A_Validate_Regex and P4A_Validate_StringLength classes were added.
These classes rely on Zend_Validate_* classes but we need them to allow translation of error messages
- P4A::isPopupOpened() and getFocusedObjectId() methods are now marked as deprecated
- popup system was completely rewritten
- when generating image thumbnails now we pass by the application’s index file instead of directly linking phpthumb
- phpThumb was updated to 1.7.8
- jQuery::form was updated to 2.0.3
- ajax upload was enabled again
- a bug with getID3 was solved, now we catch the exception triggered when file is not recognized and simply go on
- YAHOO YUI CSS reset was added
- P4A_Mask::validateFields() method is now automatically called by P4A_Mask::saveRow()
- P4A_Table::setTitle() and getTitle() methods were removed, use setLabel() and getLabel() instead

P4A 3 commit digest »

Hi to all and welcome to the P4A 3 commit digest of this week :-)

Let’s start saying that I worked a lot porting to PHP5 all P4A core objects and widgets (the only one left behind is the db_navigator, I’ll work on it soon) so now we finally have a full PHP5 code, I still need to work on strict validation but most of the work is done. Having a full PHP5 code raised some bugs, cause we sometimes used to access to private variables from outside an object and this is not possible anymore, so I’ve added a few methods and patched some code, now everything is a lot more clean. I also fixed some small graphical issues with P4A_Buttons within toolbars. I also worked a bit on making P4A work with oracle, we’re almost there :) Then I added a new and improved version of P4A_Base_Mask (which uses system messages instead of P4A_Messages) to the core and ported the products_catalogue application to it, doing that made me remove a lot of code, all now is clean and much more readable. I also put a definitive fix to the addslashes issue, we add some getSQLvalue() methods within P4A, now they use the “double single quote” instead of addslashes, this is the right SQL behaviour and anyway addslashes has been marked deprecated within PHP.

These were a few things I wanted to point out, now let’s take a look at the changelog:

- P4A::init() method was removed
- helpers, P4A_Box, P4A_Object, P4A_Button, P4A_Collection, P4A_Field, P4A_Array_Source, P4A_DB_Source, P4A_Widget, P4A_Mask, P4A, P4A_Frame, P4A_Fieldset, P4A_Label, P4A_Line, P4A_Link, P4A_Menu, P4A_Menu_Item and P4A_Canvas were php5ized
- P4A_Widget::composeStringClassStyle() was rewritten and renamed to composeStringClass()
- P4A_Toolbar default size is now 32
- P4A_Button now inherits height from toolbar (just done via CSS)
- P4A_Mask::setIcon() now supports a path to an image instead of the icon name
- P4A_Fieldset::setTitle() and getTitle() methods were removed cause deprecated, use setLabel() and getLabel() instead
- P4A::getPopupMask() and getPopupMaskName() methods were added
- P4A_Mask::getFocusedObjectId() method was added
- P4A_Link::setLabel() method was removed ’cause inherited from P4A_Widget
- P4A_Menu_Item::setAccessKey() and getAccessKey() methods were removed ’cause inherited from P4A_Widget
- P4A_Table::addToolbar() and newToolbar() methods were removed ’cause not implemented
- P4A_Table::addNavigationBar() method was removed
- P4A_Menu_Item::setIcon() now supports a path to an image instead of the icon name
- P4A_Sheet was removed ’cause had too many performance issues and it should be rewritten
- FCKEditor was updated to 2.5.1
- “oracle” was renamed to “oci” within P4A_DB to reflect PDO naming
- P4A_DB_Source::setSchema() and getSchema() methods were added
- some minor bugfixes to P4A_DB_Source were applied in order to make oracle work
- P4A_Generate_Default_Label() global function now turns the original label lowercase before applying the default rules, this is due for databases which returns uppercase field names
- a new version of P4A_Base_Mask was added to the core
- “products catalogue” sample app was ported to P4A_Base_Mask
- sample_en, sample_it and sample_i18n applications were removed
- some minor enhancements were made to products_catalogue sample
- P4A_Widget::intercept() and implementMethod() methods now automatically call the addAction() method when the event is recognized as a browser event
- P4A_Data_Field::getSQLValue() and getSQLNewValue() now returns data quoted with “double single quote” instead using addslashes (which is deprecated and not working for oracle)
- P4A_Object::dropIntercept() method was removed
- P4A_Object::dropMethod() method was added
- P4A_Object::destroy() method now does not unset the variable from parent but sets it to null
- a bug with P4A_Object::destroy() was solved, it happened when destroying an object directly stored in the $p4a object

Now, my TODO is getting thinner and, if I’ll have time, we could have a sort of preview release in a few weeks, anyway:

- implement application level translations
- port products_catalogue to the new translation system
- change p4a_table_col image handling, we’ve to pass by index.php and not phpthumb.php
- implement p4a_table::addCheckboxCol
- p4a_table action col should also support html (for images)
- implement errors with exceptions
- redo the css
- check if p4a_validate can be ported to ZF, maybe drop p4a_validate, add a valitator to p4a_field, user could add a ZF validator object to the field
- php5ize db_navigator

as you can see, some things are new features, some others are tasks for the sample applications… this means we’ve almost completed our work also if I know I got to check other few things within the P4A 3 core programming. Anyway see you next week with a new digest :-)

P4A 3 commit digest »

First technical post on the new blog, as usual 10% of the code take 90% of work, for this commit I spent a lot of time trying to get a final solution for a cross browser message rendering issue (we wanted an icon with a text on the right, both vertically centered). I also unified the generated HTML code for buttons, P4A_Message and system messages. Then I moved my attention on a better pngfix routine for explorer 6, port some P4A elements to PHP 5 and clean up the API a bit (removing some methods with really weird names)

Here you have a screenshot of the new button with a long label (note that the accesskey is underlined):
P4A 3 new button layout

and here you can see the new system message, with icons and long descriptions (you can’t see it but it has a nice fade-in fade-out effect):
P4A 3 system messages

Time for the raw changelog:

- P4A_DB_Source::setQuery() was rewritten and now it’s works again
- jQuery was updated to 1.2.2
- javascript code for P4A system messages was rewritten from scratch
- P4A_Message and P4A_Tab_Pane were php5ized
- P4A_Tab_Pane::setActivePage() method now returns the active page
- P4A_Tab_Pane::nextPage() method now returns the active page
- P4A_Message::setIcon() now supports a path to an image instead of the icon name
- P4A_Message and p4a->message HTML/CSS was unified
- jQuery UI datepicker CSS was reworked
- P4A_Generate_Widget_Layout_Table() global function was added to P4A’s standard library, this creates an HTML table (1row, 2cols) useful when you’ve to output an image on a col and a text on the other col
- HTML output for P4A_Message, P4A system messages and P4A_Button was rewritten using HTML tables because we need users to have the same browsing experience on all browsers
- P4A’s javascript PNG fix routine was dropped
- jQuery::iFixPng 1.7 was introduced
- P4A_THEMES_PATH and P4A_THEMES_DIR constants were dropped
- P4A_Field::noAllowNull() method was removed
- P4A_Field::allowNull() method now supports passing the “false” value to disable the feature
- P4A_Field::unsetUploadSubpath() method was removed, use setUploadSubpath(null) to disable the feature
- P4A_Field::unsetMaxThumbnailSize() method was removed, use setMaxThumbnailSize(null) to disable the feature
- P4A_Field::setRichTextareaToolbar(), getRichTextareaToolbar() and getRichTextareaToolbars() were removed because unsupported by fckeditor
- P4A_Field was php5ized

See you at the next digest :-)

P4A 3 massive commit, cleaning is started »

Let’s start highlighting the most important parts of this huge commit:

  • P4A system messages were introduced, now from everywhere in your application you can simply do p4a::singleton()->message(”this is a message”) and your text will be printed to the user with a nice floating panel that will disappear after a few seconds. Now you won’t have to instance P4A_Message anymore and you won’t have the scrolling effect hat P4A_Message has, your mask will remain in the same exact position and the messages will scroll down and disappear. This new feature allows you to output multiple messages, not only one, they’re managed as a queue and they also work during an ajax call.
  • numbers/date formatting issue is finally over. Using P4A < 3 was very hard to create a custom formatter for numers and dates, now when P4A_Field is going to execute a format (or normalize) operation, the onFormat (or onNormalize) event is fired. When you want to do custom formatting/normalization simply intercept the new events and, within your interceptor method, return the formatted or normalized values.
  • P4A now autodetecs the number of decimals from database and uses it within the formatting/normalizing routines by default
  • cleaning is started, some methods/classes/files were dropped or renamed, we need to provide the best API possible, thus we’ve to clean out some old things are give anything the right name to let coders understand everything the easy way

And now the complete changelog for this commit:

- P4A_DB::setSelect() was removed
- P4A_DB_Source and P4A_Data_Source were php5ized
- P4A_DB_Source::__sleep() was turned into __wakeup()
- P4A_Data_Field::setSchema() and getSchema() methods were added
- P4A_DB_Source::getFieldName() now returns “schema.table.field” and can accept “schema.table.field” as a param
- P4A_DB::getLikeOperator() and setLikeOperator() methods were dropped, they were not flexible enough to handle all DB insensitive “like” syntax
- P4A_DB::getCaseInsensitiveLikeSQL() method was added
- P4A_Field::setFormat(), unsetFormat(), cleanNewValue() methods were removed
- P4A_Object::actionHandler() methods now supports unlimited params instead of only one
- P4A_Field now triggers onFormat and onNormalize events you can intercept to do custom format/normalize (your method must return the formatted/normalized value)
- P4A_Field::unformat() method was renamed to normalize()
- P4A_Field::getUnformattedNewValue() was renamed to getNormalizedNewValue()
- P4A_Data_Field::setNumOfDecimals() and getNumOfDecimals() methods were added
- P4A_Field::createDataField() methods now automatically calls P4A_Data_Field::setNumOfDecimals() setting the number of decimals detected from the DB structure
- P4A_I18N::format() method now has a third param “num_of_decimals”, used only if type is float or decimal
- P4A_Field::format() method now uses the P4A_Data_Field->getNumOfDecimals() to automatically format numbers the most coherent way
- P4A::message() method was added, you can use it to print out messages to users without having to instance any P4A_Message
- P4A::getMessages() method was added to read and clean the messages queue
- P4A::getMessages() method is now used to print out messages to users in a nice way
- P4A_Field::setFormatted() and unsetFormatted() methods were removed, now you can use only isFormatted(true/false)
- P4A_Field::getStringValue() method was removed
- P4A_Standard_Toolbar strange behaviour that automatically disables some buttons one certain conditions was removed
- P4A_Standard_Toolbar was renamed to P4A_Full_Toolbar
- P4A_AUTO_MAXLENGTH constant was removed because its feauture was troubleful
- P4A_Field::getAutoMaxLength() method was removed
- include.php file content was moved to p4a.php and include.php file was removed
- config.php file was renamed to constants.php, config makes users think they can change it but it should never be modified

My TODO list is changing so fast that I’m not goin’ to post it now, anyway we all know the most important tasks… :)
See you very soon!

P4A 2.2.3 is out, third maintenance release for 2.2 branch »

The changelog for this release is really short:

- a bug with P4A_Label was fixed (”for” property was erroneous with radio and file P4A_Field)
- ajax file upload was disabled due to a strange bug we hope to solve with future releases of jQuery and its “form” module

but the file upload bug was really tricky.
Download P4A 2.2.3

P4A 3 translations opening and waiting for you »

Now that the new P4A 3 translation system is finished, I finally took some time to import all P4A 2.2 translations into our new and shining community localization system.

You can have a complete look at the translation status, fix possible translation errors for your language as well as adding your language here:
https://translations.launchpad.net/p4a/trunk/+pots/p4a

Now, we really want P4A to have the best translations possible but we need your help, translating is very easy and won’t take more than a few minutes. Thank you to everyone will help us delivering the most wonderful translations for your next generation web applications!

P4A 3 christmas update »

I want to wish you a marry Christmas with a small update on P4A 3 development status. Here you have the changelog since last update:

- P4A_Image was removed
- P4A_Icon was renamed to P4A_Image
- P4A_Button::composeStringProperties() method was removed
- P4A_Image::setIcon() now supports a path to an image instead of the icon name
- P4A_Toolbar::enable() and disable() methods params were removed
- P4A_Toolbar::addLabel() method was renamed to addBox()
- P4A_Toolbar::setOrientation() method was removed because it was not implemented
- jQuery::dimensions plugin was updated to 1.2
- DHTMLCalendar by dynarch was dropped and replaced by jQuery::UI::datepicker 3.2
- P4A_Field::getAsDate() now it’s fully working with the jQuery::UI::datepicker with an additional ajax call to reformat the date
- P4A_DB::getLikeOperator() and setLikeOperator() methods were added, like operator (LIKE/ILIKE) is autodetected and it’s useful when you’re generating a query
- P4A_Field’s autocomplete was ported to P4A_DB::getLikeOperator() thus now it should work better with different databases (eg: postgreSQL)
- P4A_Widget::raise() method was removed
- P4A_I18N::getLocaleEngine() method was added to retrieve a copy of the Zend_Locale object
- standard.php library file was cleaned removing PHP4 functions
- P4A::getP4AJavascript() method was added, it will return a bunch of javascript code needed for P4A initialization
- jQuery::UI::datepicker was localized using Zend Framework data, no need to sync with datepicked localization files

and the updated TODO:

- check p4a_button sizes when we have a toolbar with buttons with icons and without icons
- implement application level translations
- port sample_i18n to the new translation system
- spread about the new translation system so users start translate
- check db_source for aliases
- try to detect the decimal format and use it during formatting
- check p4a_table ordering
- custom formatter for date/time/etc
- change p4a_table_col image handling, we’ve to pass by index.php and not phpthumb.php
- integrate p4a_base_mask in core and port samples to it
- auto addaction on intercept and implementmethod when the action is a browser action
- implement db_source::setquery, maybe separate db_sources?
- implement db_source::setZendSelect or something like that, maybe separate db_sources?
- implement p4a_table::addCheckboxCol
- p4a_table action col should also support html (for images)
- remove P4A_Toolbar::getAsString() method with its strange behaviour?
- generate datepicker “firstDay” telling which is the first day of the week (we’ve to wait for ZF fix about that)

Now let’s rest for a couple of days :) marry Christmas to everyone!

P4A 3 continues growing »

Following the previous post, here you have the new things I’ve coded:

- POT file for the new translation system was prepared and committed to p4a/i18n/templates/p4a.pot
- P4A_Generate_Default_Label() global function was added, it takes a string such as “this_is_field” and returns “This is a field”, useful to generate labels from field names and other things
- P4A_Button and P4A_Widget were ported to P4A_Generate_Default_Label() to generate default labels
- default labels are now generated with ucfirst function instead of ucwords
- P4A toolbars and P4A_Table were ported to the new translation system
- translations are now applied at rendering time, not at build time
- P4A_Highlight_AccessKey() global function was added
- P4A_Widget::setLabel() does not automatically create accesskey now, it would cause problems with translations
- P4A_Object::intercept() and P4A_Object::actionHandler() now turn action name to lower before processing
- P4A_Menu now uses P4A_Highlight_AccessKey()
- P4A_Widget::setValue() and getValue() methods were removed because they’ve not all widgets have a value
- P4A_Button::setValue() and getValue() methods were removed, use setLabel() and getLabel() which are logically correct
- README file was updated, dropping some old browsers support and removing PHP4
- P4A_Button are now rendered as HTML buttons
- P4A_Button::setVisible() method now has a second parameter “visible”, check the reference
- all constructors were converted to PHP5 naming (public function __construct)
- P4A_Button::setIcon() now supports a path to an image instead of the icon name
- “currency” format/normalize was removed, it was never used and should not be handled in an application contest (you won’t print € only because your application is running with an european locale)
- P4A_Href widget was removed
- P4A_DB::limitQuery(), selectLimit() getError(), getNativeError(), query() and close() methods were removed because they can’t work with Zend_DB
- P4A_DB::rollback() and select() methods were added
- P4A_DB::fetchOne(), fetchCol(), fetchRow() and fetchAll() methods were added for Zend_Db naming convention compatibility
- P4A_Fieldset now uses getLabel() instead of getTitle() to render its legend, setTitle() and getTile() are now deprecated
- P4A_DB::get*() and query*() methods are now deprecated

and my updated TODO:

- check p4a_button sizes when we have a toolbar with buttons with icons and without icons
- implement application level translations
- port sample_i18n to the new translation system
- spread about the new translation system so users start translate
- check db_source for aliases
- try to detect the decimal format and use it during formatting
- check p4a_table ordering
- custom formatter for date/time/etc
- make ui.datepicker.js work with our new date format definitions (maybe call p4a by ajax to reformat)
- change p4a_table_col image handling, we’ve to pass by index.php and not phpthumb.php
- integrate p4a_base_mask in core and port samples to it
- remove p4a_icon and port its funcionalities inside p4a_image
- auto addaction on intercept and implementmethod when the action is a browser action
- implement db_source::setquery, maybe separate db_sources
- implement p4a_table::addCheckboxCol

P4A 3 starts roaring »

Back from the weekend in Dublin it’s time to write an update on my nightly coding sessions on P4A 3.

Well, a bunch of things were already done, porting to Zend Framework seems to be easier than what I expected, I’m working hard (you know time is always low) and I still have many many things to do but things start working and this is really exciting.

Here you have a changelog of what I did in the past weeks:

- Zend Framework 1.0.3 was added
- Database connection now relies on Zend_DB PDO adapters
- check_configuration.php was ported to Zend_DB to check the database connection
- P4A_DB_Source was ported to Zend_DB (not completely done and tested, check the TODO list)
- P4A_DB_Source::setFields() syntax was changed, now you must provide only fields from the main table and not from joines ones
- P4A_DB_Source::addJoin() syntax was changed, join type param was dropped and now you have a third param to pass the columns you want to extract from the joined table (default extracts all columns)
- P4A_DB_Source now has many methods to add joins: addJoinCross(), addJoinFull(), addJoinInner(), addJoinLeft(), addJoinNatural(), addJoinRight()
- P4A_I18N does not manage charset anymore, only UTF-8 will be supported from now on
- P4A_I18N numbers format/normalization now relies on Zend_Locale
- P4A_I18N dates format/normalization now relies on Zend_Date and Zend_Locale
- P4A_I18N::getCountry() was renamed to getRegion()
- P4A_I18N::autoFormat() was renamed to format()
- P4A_I18N::autoUnFormat() was renamed to format()
- P4A_Number format/normalization class was removed
- P4A_Date format/normalization class was removed
- all P4A i18n format definition files were removed
- translation messages files were reorganized and renamed
- days and months translations were removed from translation messages files (now they’re provided by Zend_Locale)
- yes/no translations were removed from translation messages files (now they’re provided by Zend_Locale)
- boolean normalization works much better now (eg for italian language: it detects “sì” or “si” or “s” without case difference and the same engine works for every language)

and a TODO list of what I need to keep in my mind:

- “time” format/normalize
- “currency” format/normalize
- move translations to Zend_Translate (in progress)
- check db_source with multivalues
- check db_source for aliases
- make ui.datepicker.js work with our date format definitions
- rename constructors to __construct

Many of you would like to know what we’ll do with the graphic layer… actually we’ve decided to stop experiments on extjs and other javascript frameworks, they’ve been too time-consuming and we found bugs and limitations thus, at the moment, we’re keeping the old rendering layer. Being real, I think that P4A 3 will still generate the HTML markup but we’ll rewrite the CSS from scratch without relying on javascript frameworks that seem to not fit our needs.

Stay tuned! ;-)

P4A 2.2.2, hot fix for a db_source bug »

Changelog:

- Major bugfix on P4A_DB_Source::saveRow(), the patch from Edr (introduced in 2.2.0) was removed and a few checks were added to prevent inconsistency
- some little bugs on P4A_DB_Source were fixed

Download P4A 2.2.2