CakePHP Digest #13

Posted by Matt on Mon, May 04 2009

Prelude

This digest kind of sucks. As we'd say in high school: My B G (which translates to "My Bad, Gangsta," for those who aren't from dorky middle class America). I have something kind of cool that I hope to get out this week that should make up for it.

News

CakePHP 1.2.3.8166

There is a new bug fix release for the 1.2 branch. The biggest issue this fixes is described below in the Tickets and Commits section.

CakeFest Talks

It looks like all the slots have been assigned for talks at CakeFest.

First 1.3 Site In The Wild?

TheChaw is now running on CakePHP 1.3. I would guess this is the first real CakePHP 1.3 site out there. Although I made a joke a couple digests ago about how everyone should move to 1.3 immediately. Some people didn't realize it was a joke, so for all I know there could be a bunch of sites updated to 1.3 already.

CakePHP Meetup in Dallas

@britg setup a CakePHP meetup for the Dallas area bakers.

Tickets and Commits

I can't even get this post out and it's already fixed.
A low danger XSS vulnerability is currently open closed. The trick allows you to inject HTML into some CakePHP apps. For example here's one of my sites. This doesn't work on all sites. For example the CakePHP sites seem to be immune. I'm calling this one "low danger" because I was only able to get HTML into the page, not JavaScript. Plus, it only works when you get people to visit your hacked link.

See the comment below from Ramon on how to exploit this for JavaScript

In The Wild

www.vendoo.co.za

@johannduplessis announced his latest site: www.vendoo.co.za. It's a "classifieds site and aggregator."

In The Blogs

Pagination With Custom Find Types

Mariano Iglesias has a nice post on doing pagination with custom find types.

Ajax Form Validation

JamNite posted a rather lengthy tutorial on doing Ajax validation using jQuery.

Which teknoid Posts to Highlight?

If I linked to every new teknoid post there wouldn't be room for any other blogs. I'll pick there two: "Give all of your error messages a different layout" and "More pondering about HABTM".

In The Groups

Uhhh....

Code

jQuery Ajax Helper

loadsys.com released a replacement for the default AjaxHelper that uses jQuery. How many of you use the AjaxHelper for generating JavaScript code? I'm interested to know if most people just write their own JS - this is what I do - rather then using the helpers.

Plugin Manager

@rodrigorm pointed out a project he's been working on - a plugin manager.

My Stuff

I updated a few of my projects last week. Since I'm completely obsessed with plugins I'm converting all my code. So far I've done the LazyLoader, Custom Find Types and jQuery Validation. I plan on doing the rest as I get time.

I'm Out!

And on that note don't forget to subscribe to my feed or follow me on twitter.

As always if you think I missed something leave a comment. Or if you do something interesting and want it included in the next digest, send me an email.

Posted in CakePHP Digest

18 Comments

Joshua McNeese said on May 04, 2009
i definitely write my own js. since most the js i write is extjs, the helper doesn't really do me any good.
Robert Navarro said on May 05, 2009
I too write all my own js. Although I do use jQuery to do so, I'll take a closer look at that replacement and see if it's any good =)
Heath Nail said on May 05, 2009
I write my own javascript as well.
Javier said on May 05, 2009
I remember asking a question or IRC about the AjaxHelper. After a while, somebody replied: "I won't let you out of here until you swear with blood that you'll use jQuery". And so I did.
Gabriel Gilini said on May 06, 2009
now that's sad.
Ivan said on May 05, 2009
It was about time you posted something new, thought you bailed out on us :-)
Matt said on May 05, 2009
I'm more of quality over quantity blogger...assuming you ignore this post.
Lee (Loadsys) said on May 05, 2009
Matt, we definitely think you are right. For most scenarios we write our own JS as well. However, this helper comes in handy mostly in the following scenarios.

1) When leveraging Cake's core pagination...mostly for Admin/CMS portals or when ajax pagination is needed on front-end.

2) We take over support for a lot of CakePHP apps. A lot of these apps are leveraging the ajax helper. We prefer jQuery, so we'll convert the app to jQuery so it is easier for our team to maintain. This helper lets us do this rather quickly...if not seamlessly.

So, I guess we think there is a time and place for it. We have had this helper for a long while, but sometimes get a little busy to find time to contribute code.

Lee Forkenbrock
Loadsys
Matt said on May 05, 2009
Good point on the ajax pagination.

The main reason I was wondering if people actually use the Ajax helper is Cake's support for multiple JS libs coming in 1.3. I'm tempted to say that this will be no use to me, but maybe I'll be blown away by the awesomeness of it.
Lee (Loadsys) said on May 05, 2009
I see. I didn't realize that. That will be very nice. We'll be watching out for the release of 1.3 then.
Ramon said on May 05, 2009
Regarding the XSS issue. Yes, it is possible to execute JavaScript here is the proof.

-R
Matt said on May 07, 2009
Thanks for pointing that out. Corrected above.
Richard@Home said on May 06, 2009
I use jQuery exclusively and have never touched the AJAX helpers. jQuery is helper enough :-)
Nick said on May 07, 2009
I use the Ajax and Javascript helper all the time using the Javascript::object and Ajax::input/link/remoteFunction very frequently.

I still develop primarily in prototype+scriptaculous. I haven't drank the jQuery koolaid yet. =)
Kjell said on May 17, 2009
I write my own JS too. Using LowPro most of the time.
Javier said on May 29, 2009
Hi, Matt.

Sorry to comment here. I was trying to comment on you "GitHub Updates" article, but it seems comments are closed.

I'm a bit confused about how to use your jQuery validation plugin with custom rules. You say that we're free to use AJAX. I was wondering if you were talking about a simple AJAX request to do something unrelated to validation, or an AJAX validation.

If you're talking about AJAX validation... well, now it's when I'm confused. I wanna validate if a field is unique, so I wrote something simple to test it:

jQuery.fn.validate.isUnique = function( val, params ) {
$.get( '/validate_uniqueness', {
value: val
},
function(error) {
return error.length == 0;
})
}

And, of course, it doesn't work, for an obvious reason. It sends the value to the server, but it doesn't send the field it wants to validate. I could write tens of functions in both my server and client side to perform validation field by field, but that doesn't look funny :-).

So, is there anything I'm missing here? Is it possible to pass the input field that is validating to my custom function?

Thanks.

BTW, I've forked the project to add a few things I needed: http://github.com/javierm/js_validate
Matt said on May 30, 2009
Hey Javier,
I've been meaning to write about this very topic. Keep any eye out for something next week. You may be right that the plugin needs some changes (adding the field) to make Ajax more usable.

I'll check out your changes as well.

Thanks,
Matt
Javier said on Jun 03, 2009
Hi, Matt.

I've updated my fork so the custom functions recieve the field as well.

Feel free to insult my code, vote for banning me from GitHub, or whatever.

Regards.

Javier.

Add new comment