Monday, May 15, 2006

A simple user login and registration system

The GMTT Lite Login System is a wonderful little easily understood piece of code. There's a lot of other good stuff on the site, but it's being rebuilt so you have to navigate arounda bit from the front page to find it.

Wednesday, May 03, 2006

Programmer’s Critique of Joomla

Ten reasons Joomla!/Mambo is an outdated CMS

[From: "RipperDoc’s Clinic, Dissecting just about everything, live from Hong Kong, China"]

"Having recently been working intensely with Joomla!, and in the same time with Wordpress and some AJAX-development I have come to the following conclusion: Joomla!/Mambo is outdated. It has moved from being cool and hot to being mainstream, boring and just old…here is my list of reasons that it’s outdated…”

“The layout is based on tables.”

[Shouldn't the parts of a Content Management System be distributed as follows: content [database], presentation [template file], and control flow [program file]?]

“It is also very cluttered and when making a template, you have very little control on how system outputted data should be displayed.”

[The template tags in Movable Type and Wordpress REALLY DO separate the data and presentation layer]

The templates and style sheets tend to be large and cluttered, with heaps of different, class names, often confusingly named.

[Again template tags]

“The administrative interface is slow and not very user friendly.”

[Modules seemed easy to handle. components couldn’t figure out]

“You can still not sort tables after columns, even though they look sortable. You often get stuck by pressing back and getting the message “Do you want to resend the POSTDATA?”.

“Some simple AJAX and usability thinking would make the interface much better. “

[Usability for sure, but not really sure how making it asynchronous would make it simpler]

There is a plethora of templates and plugins, but it’s very hard to find good ones. Many plugins are badly developed, very specialized or cost money. When searching for templates you get hundreds of sites selling templates but not looking very trustworthy.

[One plug and play module with functionality (poll, login, quiz...) that you can put in any CMS block (left, top, right, center) that can be used in any CMS, Joomla, PostNuke, Wordpress…]

“Of course, the fork has caused greats problem. Plugins are being shifted from Mambo to Joomla, some deprecated, and the confusion is considerable.”

[It confuses me, but its free, how can I complain?]

“This is very different from the Wordpress community, where most plugins are of high quality, and where you quite easily can find the plugins thanks to the blogging community.”

[Wordpress looks like it has everything and the registration is in one non-OO file, I’m going to try this]

“The code base is huge and the API is complicated and often inconsequent. Just getting the right information as a developer is a challenge. To add to this, the balance between backwards compability and refactoring is a constant issue, and it seems Mambo is always somewhere in between, in the bad sense.”

[Getting right information, that’s it. Wasted a lot of time. Just going to use a debugger.]

“The whole CMS package is big and bulky, and so is the system itself. It’s often slow, either in loading or in finishing administrative tasks, due to many page loads until completion of a task.”

[Is Wordpress or any PHP system really any faster?]

“The category system is inconseqent, having sections, with categories, but no more sub levels. Add to this components with their own separate systems. This needs a real cleanup. The same problems occur in the user management system, with a rigid hiearchy of ACL that is buggy and not used everywhere… Where is the social collaboration in Mambo… “

[Make the content taggable with multiple key words, so it can role up into different semantic hierarchies]

"Development is very slow. It takes months and months to make just a slight update, which mostly consists of bug fixes. The whole mess around the forking of the code into Joomla! also made a halt in the progress. My guess is that the code base is cluttered and makes it hard for developers to quickly add features, especially when having to consider backwards compability."

"I admit, I have compared with Wordpress in many of these issues. And Wordpress is a clear role model, but it is a blog system, not a full-fledged CMS. Even though Wordpress can be a CMS, with some plugins, it’s not optimal. Where are all the modern and original CMS:es? There must be a huge user base that’s craving something new, light-weight, easily integrated and extendable?"

[Seems like Wordpress. I’ll give it a try. Don’t mean to be negative, but need something simple to understand]

Choosing a PHP Debugger II

The Eclipse IDE (Integrated Development Environment) with PHP plugin seems like the best option for stepping through CMS execution to see how control flow and variable scope works.

The combination must be widely used since there is even an acronym for it AMPLE (Apache Mysql PHP Eclipse) programming.

Confusing mix of object-oriented and imperative programming

There’s a confusing mix of imperative and object-oriented PHP in the registration module. What’s confusing is that in the object-oriented presentation layer I have to make a call back to the non-OO data layer to look up the subscriber id in a table.

I’m running it under PHP 4 also. I thought PHP 5 was object oriented? What’s up? So I guess I have to find out what PHP 4 OO programming was. Luckily there’s a little article by the authors of PHP themselves.

To understand what is happening I’ve also started to recall those old ideas from the theory of programming languages: variable scope and control flow (as well as the Scheme concepts of closures and continuations that help make sense of the most difficult aspects like non-local control flow and scope in objects).

Anyway don't mean to be negative, but I am going to make sense of this stuff, and this blog is going to record the steps I take to understand it.

Tuesday, May 02, 2006

Debugger to follow control flow and namespaces with

I can already see that I'm going to need a PHP debugger since I can print variables out to the Joomla webpage. It will also show what namespaces are defined in any given part of a program and also show me control flow.

Wikipedia has a list of PHP editors and debugger front-ends.

What debugger to choose?

I downloaded Activestate's Komodo IDE to check out first.

Modifying the registration component II

Control flows from registration.php to registration.html.php, from the data layer to the presentation layer.

registration.php just has functions, no classes.
registration.html.php has one big class in it called HTML_registration.

The main switch statement in registration.php calls registerForm below.

The data layer function registerForm calls the presentation layer function registerForm: HTML_registration::registerForm($option, $useractivation);

Control then passes to the validation if-statement that I'm modifying.

If I define the function subscriber_exists() and the constant _REGWARN_SUBSCRIBER in registration.php it should be available inside the class HTML_registration?

registration.php:


function registerForm( $option, $useractivation ) {
    global $mainframe;
    
    if (!$mainframe->getCfg( 'allowUserRegistration' )) {
        mosNotAuth();
        return;
    }
    
    $mainframe->SetPageTitle(_REGISTER_TITLE);
    
    HTML_registration::registerForm($option, $useractivation);
}



registration.html.php:


function registerForm($option, $useractivation) {
    ?>
    function submitbutton() {
        var form = document.mosForm;
        var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");
        
        // do field validation
        if (subscriber_exists(form.subscriberid.value)) {
            alert( "<?php echo html_entity_decode(_REGWARN_SUBSCRIBER);?>" );
            } else if (form.name.value == "") {
            alert( "<?php echo html_entity_decode(_REGWARN_NAME);?>" );
            } else if (form.username.value == "") {
            alert( "<?php echo html_entity_decode(_REGWARN_UNAME);?>" );
            } else if (r.exec(form.username.value) || form.username.value.length < 3) {
            alert( "<?php printf( html_entity_decode(_VALID_AZ09), html_entity_decode(_PROMPT_UNAME), 2 );?>" );
            } else if (form.email.value == "") {
            alert( "<?php echo html_entity_decode(_REGWARN_MAIL);?>" );
            } else if (form.password.value.length < 6) {
            alert( "<?php echo html_entity_decode(_REGWARN_PASS);?>" );
            } else if (form.password2.value == "") {
            alert( "<?php echo html_entity_decode(_REGWARN_VPASS1);?>" );
            } else if ((form.password.value != "") && (form.password.value != form.password2.value)){
            alert( "<?php echo html_entity_decode(_REGWARN_VPASS2);?>" );
            } else if (r.exec(form.password.value)) {
            alert( "<?php printf( html_entity_decode(_VALID_AZ09), html_entity_decode(_REGISTER_PASS), 6 );?>" );
            } else {
            form.submit();
        }
    }

Modifying the registration component (com_registration)

Today I decided to jump straight into the the registration component and modify it.

The form-validation if-statement in registration.html.php listed below was quick to modify. Now I have to decide where to define the two things I'm adding:

1. The subscriber validation function: subscriber_exists($id)
2. The error message constant: _REGWARN_SUBSCRIBER

The function does a database lookup so I guess I got to put it in the data later: registration.php, not the presentation layer: registration.html.php , but there are no obvious examples to follow. Going to have look it over and make a reasonable guess.


function submitbutton() {
    var form = document.mosForm;
    var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");
    
    // do field validation
    if (subscriber_exists(form.subscriberid.value)) {
        alert( "<?php echo html_entity_decode(_REGWARN_SUBSCRIBER);?>" );
        } else if (form.name.value == "") {
        alert( "<?php echo html_entity_decode(_REGWARN_NAME);?>" );
        } else if (form.username.value == "") {
        alert( "<?php echo html_entity_decode(_REGWARN_UNAME);?>" );
        } else if (r.exec(form.username.value) || form.username.value.length < 3) {
        alert( "<?php printf( html_entity_decode(_VALID_AZ09), html_entity_decode(_PROMPT_UNAME), 2 );?>" );
        } else if (form.email.value == "") {
        alert( "<?php echo html_entity_decode(_REGWARN_MAIL);?>" );
        } else if (form.password.value.length < 6) {
        alert( "<?php echo html_entity_decode(_REGWARN_PASS);?>" );
        } else if (form.password2.value == "") {
        alert( "<?php echo html_entity_decode(_REGWARN_VPASS1);?>" );
        } else if ((form.password.value != "") && (form.password.value != form.password2.value)){
        alert( "<?php echo html_entity_decode(_REGWARN_VPASS2);?>" );
        } else if (r.exec(form.password.value)) {
        alert( "<?php printf( html_entity_decode(_VALID_AZ09), html_entity_decode(_REGISTER_PASS), 6 );?>" );
        } else {
        form.submit();
    }
}

Monday, May 01, 2006

Reasonable people can't understand Joomla

I posted the following to OpenSourceCMS. I haven't given up on Joomla! (as if anyone cares) and when I am finished mastering it, I am going to create some documentation that describes the big picture because the details are pretty intuitive already. If they don't want it on the Joomla! site, I'll just stick in this blog, which can double as a general web publishing platform (if you pre-date entries to the very beginning of the blog and then put links to them in the right sidebar):

Two quotes from people who have been having problems with Joomla! documentation:

"I must say that if the team behind Joomla, and also the other developers that use it, want to see it beeing widely used and really apreciated by the rest of us an effort torwards clear, adequate and effective starting documentation must be in place. I would love to start using it, since there are so many good opinions about its strengths, unfortunatly good documentation not being one of them."

"I'm a programmer and ever reading through what little documentation I could find I still could not get the site configured in any sort of decent manner."

I agree. I've had a hard time customizing it without delving deeply into the code. I can actually write what I need in fairly simple PHP so I think stanadalone system is the approach I'm going to take unless I can find a simpler system to customize.

The incredibly rude replies are probably by people who've never had a job in their life or incredibly socially inept.

REALITY: Increasingly non-programmers or programmers who have a only a limited amount of time to spare from other duties are being called on to customize CMSs. CMSs that adapt themselves to these peoples' needs will survive, those that don't, won't. The documentation doesn't explain the big picture of how the whole thing operates. Once you know the big picture, everything else should be common-sense. Movable-Type is an example of a CMS like this. The presentation of content on web pages also usually violates long established principles. Take for instance, Anna's Joomla! Tips which should be in h2 or h1 and visible on this page when it displays without scrolling:

http://forum.joomla.org/index.php/topic,5503.0.html

Jon Fernquest
http://joomlafordummieslikeme.blogspot.com/
Posted by Jon Fernquest on Monday, 01 May 2006 at 1:43