7.25.2006

XForms cometh to PHP ! Throw out HTML_Quickform?

PHP Architect has an article in their June 2006 issue about using XForms within PHP5. If you don’t know what XForms is/are, you’d better look into it. It’s basically a way to describe forms on your page and all the data validation rules entirely in XML. The form presentation and validation capabilities of it are kind of like HTML_Quickform on crack. Of course, there’s always a rub. No browsers natively support XForms. The article in PHPArch uses the FormFaces JavaScript to get things to work. But I don’t like the way FormFaces comes off. They tout both a GPL license and a commercial one but then they mask the JavaScript so you can’t extend it or see how it’s actually working. That smells like a temporary GPL license to me. So, I don’t think you could do XForms on the client side just yet. It’d be nice if someone would step up and create a server-based solution for XForms in PHP. Maybe I’ll do that myself. In the meantime though, the Quickform folks are already busy planning HTML_Quickform2, a PHP5 version of their form production code. That will have to do for now I suppose.

7.22.2006

Smarty not so smarty in PHP5. Try XSLT instead.

So I’ve been working on this pretty big migration project lately, from PHP4 / MySQL 4 to PHP5 / MySQL5. It’s even larger because we’re moving from a largely procedural code base to using objects with inheritance and a lot of composition.

So what’s all that have to do with Smarty? Well, all our PHP devs are busy getting familiar with the framework I’ve built for the project. So, that leaves some HTML gurus and ASP folks sitting around under-utilized on this project. Ideally, I’d like the PHP folks to work on the backend stuff and then have an HTML or ASP dev take care of the views.

Of course, if the templates are all done in Smarty that means these folks have to possess not only a decent understanding of PHP, but also thorough experience with Smarty templating. These skills are a bit of a reach for the HTML folks… and the ASP people will mostly just protest because they’d have to learn PHP stuff AND develop on a Linux box. ;-)

Enter XSLT. Most developers in other languages use XSLT already (ASP, .NET, JSP, etc). I’ve never understood why it’s so slow to catch on with PHP. Perhaps because the XML tools in PHP4 were so poor?

So if the ASP folks already know XSLT, and the HTML folks don’t yet, but can learn a templating skill that is basically development-language-agnostic, I think it’s a win-win-win situation.

I’ve thought this way for a long time but this project has really crystallized my take on it. Developers at any level should strive to learn tools and techniques that can be universally applied to other languages. You may be a PHP programmer today, but you might be something else tomorrow.

7.17.2006

Functionality of the PHP trim command I bet you did not know

trim

(PHP 3, PHP 4 , PHP 5)trim -- Strip whitespace from the beginning and end of a string

Description

string trim ( string str [, string charlist]) You can also specify the characters you want to strip, by means of the charlist parameter. Simply list all characters that you want to be stripped. With .. you can specify a range of characters. Example:

$strComma = "item 1, item 2, item 3,"; 
echo trim($strComma, ',');

7.13.2006

Best... Typo... Ever...

From: Sysadmin Subject: Server auto logout FYI Interactive logins on all unix machines will now automatically timeout after 1 hour of inactivity. If you are running a long-running job/script, this will be unaffected if it runs past an hour. If you are just shitting at a shell prompt, and haven't typed anything in an hour, you will be logged out. Feel free to pass this on to anyone else I may have missed.

7.10.2006

Load this Firefox bookmark in the sidebar

Bookmark a page in Firefox. Right click on the bookmark and select "properties." There's an option for "Load this bookmark in the sidebar." If you check that button, every time you click on that bookmark, it will open up in your sidebar. Pretty darn handy. Can't believe I didn't know about this before. Of course, the only things I bookmark locally anymore are internal apps.

This doesn't work in SeaMonkey though.

7.06.2006

Everybody else is doing the Ajax Whois, why not me?

A buddy at work fell in love with the Ajax Whois and wanted a version on his own linux site. I've been playing around with a lot of Ajax stuff lately so I thought I'd give it a go using Ajax (javascript) and PHP. Here's the resulting code. It's just a quick and dirty solution because I had some technical difficulties working on his crappy server. I couldn't upload anything (like the brilliant prototype js library) so I had to bake most of the js from scratch except for a line borrowed here and there, most notably from this guy. Of course the other informal rule was that it had to be completed during spare time at work today. It's just two files, index.php and whois.php (rename the saved files with .php extension). Download and enjoy your own web based ajax whois. Just be careful not to get yourself blacklisted by doing tons of searches in a short time period.

7.05.2006

Zend Studio Tip of the day -- Bookmarks

Ever need to refer to 2 or more different places in a file while in Zend? You can bookmark the sections for easy manuvering through the file. Put your cursor on the line you want to bookmark, and either right click the line number on the left or hit "F2." Voila! A green bookmark has been setup.

How do you use this puppy? Easy. Take a look at the right hand side of the editor window and you'll see a green line that is clickable, right next to the scroll bar. Clicking there takes you to that bookmark. Even cooler, if you hover over the bookmark line there, it will pop-up the line of code that is bookmarked.

If you need to remove the bookmark, you do the same thing, right click on the line number of hit F2 again.

Until next time... Happy Zending!

AOL Instant Messenger – Triton, Norton, Password problems

So I thought I’d forgo using my GAIM today, even though it's totally working correctly... and even though it completely connects to all my instant message accounts... and see if the new AOL Instant Messenger called Triton did anything interesting. It turns out it does not. The thing hardly even works. Ugh. Why do I even bother?


Frustration # 1

When I installed it, it left my old AOL messenger in there instead of just upgrading that one.



Frustration # 2

I couldn’t figure out which ports to open on my Norton software firewall. Even though I explicitly gave AIM6.exe permission to access the Internet, it was trying to use some odd port that I don’t have opened. I’m afraid it’s too new for the port info to be out in the wild yet. This one’s a deal-breaker for me, but it gets worse.



Frustration # 3

I had forgotten my password so I clicked the “forgot password” link which brought me to https://my.screenname.aol.com/ where I was able to answer some pre-determined security questions and then change my password. However, while the screens there reminded me to only use letters and numbers for the password, the web form neglected to check for other characters.

So without realizing this restriction, I used a symbol in my password. Of course when you get into AIM Triton (with no firewall of course), it keeps coming back that your username/password is incorrect. Because it sees that symbol and freaks out. This one stumped me for a good few minutes. You have to go back and change your password to not use any funny characters. This is form validation 101 people. Filter input. And give appropriate error messages.

Back to GAIM I go.