While playing with strings one should be VERY VERY VERY cautious when trying to check for a “null” value
PHP has the bad habit of considering empty strings to be “null” and “false” , for instance
1 2 3 4 | $foo = ''; if( $foo == null && $foo == false ){ echo "So PHP actually considers empty strings to be null and false"; } |
Accessing the first element in a php array can be done as easy as this
$myArray[0] = 'foo';
and you can also use “list” to access more than one index in one call
list( $first, $second, $third ) = $myArray;
This approach , however, doesn’t work with associative arrays or arrays that have non-standard integer index like
$stringIndexedArray = array('first' => 'data','second' => 'data'); $nonStandardIntegerIndexedArray = array(5 => 'foo', 7=>'bar');
I have found two methods to access the first element in such arrays, one using “reset” and the other using “array_values”
$stringIndexedArray= array( 'first' => 'Data 1', 'second' => 'Data 2', 'third' => 'Data 3', 'forth' => 'Data 4', 'fifth' => 'Data 5' ); //reset method //Average execution time : 2.8123000000003E-6 $firstElement = reset($stringIndexedArray); //array_values method //Average execution time : 3.8123000000001E-6 list($firstElement) = array_values( $stringIndexedArray );
I’ve done some profiling and turns out that “reset” method is slightly faster than “array_values” ( as seen in code comments )
My project for GSoC 2008 was to create a WYSIWYG forms component (Web form editor) that runs on Joomla! 1.5 , This video shows a simple usage scenario ( including an encounter with a bug! )
Links:
Development trunk(SVN): http://joomlacode.org/svn/gsoc2008/JForms/trunk/
JForms blog on J! Developer website
P.S : I used CamStudio to create this video.
A few days ago I decided to suppress my “conservative” stance towards massive Javascript usage and started working on a WYSIWYG editor for HTML Forms, The application resembles drag-and-drop GUI editors, I’ve spent lot of time in building the codebase to make it as Object oriented as possible.
The codebase is simply composed of two parts, Core and pluginis “Elements”
Each draggable element is handled by a 2 files
Adding a new element would just require writing two files and the core handles the rest.
I’m using Prototype, script.aculo.us and Webtoolkit context menu, No true AJAX has been used so far, everything is done on the client side.
Now the question is , what does the end user see?
I’ve tested this on FF2 and IE6.
What I really need to implement right now is the “Resize” function
Why don’t you check A demo of the code in action
I plan to turn this into a Joomla! forms component soon Insh’Allah.
Update: My Proposal to Google Summer of Code has been accepted and I’ll be working on implementing this form editor as a Joomla! 1.5 component, You can find more information about my progress on my GSoC blog
The long waited Joomla! 1.5 has finally hit stable status
Update August 2nd, 2007: I will be releasing this hack in the following few days Insha’Allah.
Update September 4th, 2007: I’ve released the code on SourceForge you can access it by checking out the CVS there.
The project url: http://sourceforge.net/projects/arabic-tcpdf
CVS Checkout command
It is a known fact that Joomla! 1.0.x can export content into pdf format, however, this feature doesn’t seem to be working well when used to export Arabic content to pdf format, either windows-1256 or UTF-8 encoded.
To address this issue, The guys at the Joomla! core has moved to TCPDF library to export pdf files, this library has support for images and more importantly UTF-8 which means it can -theoritaclly speaking- be used to handle pretty much ANY langauge, This is true for many Left-To-Right languages, however, For a Right-To-Left language like Arabic the situation is quite different I’ll try to brief the problem here.
(more…)