Apostila Joomla PHP PDF

You might also like

You are on page 1of 9

06.

06
International
PHP PHPMagazine I
n
t
e
r
n
a
t
i
o
n
a
l
P
H
P
P
H
P
M
a
g
a
z
i
n
e
Cutting-Edge Technologies for Web Professionals

Knocking at Your Door
Getting a Grip on the Next Release
Joomla! 1.5 Joomla! 1.5
Joomla! 1.5 Knocking At Your Door Cover Story
I n t e r n a t i o n a l P H P M a g a z i n e 0 6 . 2 0 0 6
2
Introduction
Last time I wrote for the International PHP Magazine (IPM),
we (IPM) were still in print, and we (Joomla!) were still called
Mambo. How things have changed! Even more change is afoot,
with the impending release of Joomla! 1.5, and several new
and exciting initiatives set to come from the IPM stable. This
article will outline and demonstrate some of the most important
improvements in Joomla!, from a developer perspective.
First, an Update
Back in August there were some events that triggered the
split, which of course we like to refer to as the rebranding
of Mambo to Joomla!. It is beyond the scope of this article to
outline the events that lead to this happening, but it is important
for everyone to know who Joomla! is, and what happened to
Mambo.
The entire Mambo teams developers, documentation writers,
forum moderators, system administrators, PR and advocacy
teams, and language translators decided in unison that this
switch was required to protect the relationship between the
developers and the community, and ensure that there would
be no more commercial attempts to manipulate the project. So
most folks are not aware of the totality of that agreement, or
that it was in complete unanimity that we decided to rebrand.
It was the most peaceful option for us, and the entire crew agreed
with the plan. So when you look at the low version numbers of
Joomla!, please remember that this is the same award winning
team that made Mambo so special. Joomla! 1.0.0 was essentially
the next maintenance release of the Mambo 4.5.2 series, with
some goodies added for measure.
I am not familiar with the team that presently works on Mambo,
and do not track their progress. But it is safe to say that you
have two completely independent projects, run by completely
independent teams, and with decidedly different roadmaps and
philosophies. With the 1.5 release, all compatibility attempts
with Joomla! and Mambo come to an end, as not only have we
made signifcant changes in our evolution, but the new Mambo
team has also progressed on their own path.
If you were wondering when it was no longer possible to mix
and match components written for Mambo/Joomla!, wonder no
more now is that time.
The International Community Speaks
Back at the Joomla! Core Developer Summit in October, it
was brought to our attention, in a rather painful fashion, that
international support in Joomla! was a critical shortcoming;
and if we wanted our software to be internationally viable
we needed to focus all our efforts to supporting a more multi-
lingual audience. We shelved our grand plans (more on that later)
for the next release, and focused instead on meeting the
communitys needs.
The frst step was to implement UTF-8 characterset support
throughout the core. UTF-8 is also known as unicode, and
Joomla! 1.5 Knocking At Your Door
by Mitchell Pirtle
Let Joomla! core developer Mitch Pirtle take you through a quick
tour of the advancements in the latest update to the award winning
content management system. You will see the new front end editing
interface, as well as the much-needed changes to the back end
administrator interface.
Getting a Grip on the Next Release
Cover Story Joomla! 1.5 Knocking At Your Door
3
I n t e r n a t i o n a l P H P M a g a z i n e 0 6 . 2 0 0 6
supports multibyte charactersets, right-to-left languages, and
others. With an aggressive schedule, we set out to implement
UTF-8 support as quickly as possible. Our expected delivery
date was within a few weeks, in November.
This effort was frustrating when we learned that not only was
the UTF-8 support going to require a lot of refactoring of the
existing core, but that there were two major issues: supporting
both PHP4 and PHP5 required totally different approaches, and
the reliance on third-party libraries that Joomla! depended on
were also unable to support UTF-8. Some libraries had to be
completely removed, and we recreated them from scratch, just
so we could support this requirement; and other libraries were
replaced with still other libraries as well.
Once the groundwork for this effort was underway, there was
a period where the localization teams were winding through
the different translations to make sure that new API calls were
supported with their language fles. While this was happening,
the developers decided to refactor some areas that badly needed
it as the UTF-8 requirement forced them to refactor the
core anyway, it was logical to take care of some architectural
shortcomings of the existing core.
The Tipping Point
It was at this moment that some very important decisions were
made that ultimately affected the delivery of 1.5 which back then
was just called 1.1, as it was not considered a major effort. The frst
big decision was to refactor the colossal and bloated joomla.php.
This bloated fle was one monolithic pile of procedural PHP that
was parsed for each and every single page that was delivered to the
browser. This exercise started out innocently enough, with signifcant
time spent just breaking out the code into separate classes, and using
many OO patterns to simplify the rendering process of content. The
intent was to make it easier on developers, but the added bonus was
performance enhancements. The effect was due to Joomla! no longer
parsing all that code for each request, and only loading classes that
were needed for that particular view.
The second big decision was to rationalize the API, as there were clear
issues with the existing one that had evolved over time. By coming
up with a solid, common philosophy we were able to refactor the
API with a much more logical approach, further simplifying efforts
for developers.
The third, and most signifcant decision was to approach Joomla!
as more than a content management system, and focus on bringing
a more framework-oriented approach to the architecture. This had
a really profound impact on Joomla! in general, and also further
necessitated core refactoring to break out the classes so that
developers had the fexibility to do just what they wanted, instead
of banging on a bunch of procedural code to make one site behave
the way they wanted, in a very manual and error-prone fashion that
made upgrades nearly impossible.
It is completely true that you could say the Joomla! content
management system was created with the Joomla! Framework. But
enough history lessons already! Lets get to the new Joomla!
First Impressions
The new template is called rhuk_milkyway, and is brought to you
by the same developer that produced the default for the 1.0.x series
as well as the 4.5.x series when we were Mambo, Andy Miller. See
Figure 1.
Fig 1: Screenshot of Default Front End Interface
Gone is the venerable SolarFlare II template, replaced with a much
more manageable layout that has more fexibility with module
positions. There are other changes, but the most interesting I will
save for the last.
Life on the Backside
So how does the administrator interface look? This is one of the
most visible changes to the end user, as the entire administrator
interface has been completely revamped. Immediately apparent is
the new template colorscheme, as evidenced by the login screen.
See Figure 2.
The new look is driven from a totally new admin template, which
also showcases the ability of Joomla! to allow for distinctly
different looks on the administrator interface, not just the front end.
Perhaps most telling is the main page, also called the Control Panel.
See Figure 3.
Joomla! 1.5 Knocking At Your Door Cover Story
I n t e r n a t i o n a l P H P M a g a z i n e 0 6 . 2 0 0 6
4
Fig 2: Screenshot of the Login Screen
Fig 3: Screenshot of the Login Screen
We have brought out an entirely new set of icons as well, which
is a welcome change of pace after looking at the previous icons
for several years. We have also consolidated both the Control Panel
choices, as well as the menu items. Gone are the multiple-nested
menus, replaced with simple, logical menus that are typically only
one level deep. The lone exception is for components, which is
necessary for complex components otherwise you would have a
simple menu that required many clicks to get where you needed for
more sophisticated applications.
We consolidated Content Items and Static Content Items to
just one, which in this article are referred to as Articles. This is a
test for now, however the fnal release may include this change in
terminology. At the time of writing the debate was still in full swing,
but for clarity I will continue to refer to them as Content Items in
this article, until the change is made permanent. See Figure 4.
The biggest change to the content editor is the consolidation of the
content areas, also known as WYSIWYG (What You See Is What
You Get) areas. In 1.0.x there were two, one for the introductory
text and another for the main body.
As this was quite confusing for a lot of newcomers to Joomla!, we
decided to simplify the whole content creation process by having
one editor area and providing a button to create the Read More...
link that signifes a separate page for lengthy text.
You can see in the screenshot the text {readmore} that tells Joomla!
you want to make that separation between introductory text and
main text. For aggregate listings such as blog lists, this inserts a
Read More... link at the end of the introductory text.
We have also changed the code for insertion of images, from
{mosimage} to just {image} for clarity, as well as getting away
from the deprecated mos terminology which originally stood for
Mambo Open Source.
Also of note is the new styling of the images tab and related tabs,
which are not layered anymore as tabs but rendered much more
cleanly with expanding divs. This is a lot easier on slower machines
and also is more cross platform to support a wider array of browsers
and browser versions. See Figure 5.
Fig 4: Screenshot of the Content Manager Fig 5: Screenshot of the Content Detail Page
Get your
International PHP Magazine
in just 4 Steps for as low as 3.50 per copy!
warm up...
choose
Step 1: Login with your Username and Password
at http://www.entwickler.com/ssl/pdf/
Step 2: Choose a subscription type:
Single Issue/Annual
confirm
content
Step 3: Confirm your payment details Step 4: Download your Issue
International PHP Magazines new download center facility ensures you have access to the
International PHP Magazine at all times. Please visit our subscription service to order your
copy of the magazine for as low as 3.50 per copy. Whats more, you can use your access
details to log into our download center any time, from anywhere, to access and download all
issues you have subscribed to.
Cover Story Joomla! 1.5 Knocking At Your Door
6
I n t e r n a t i o n a l P H P M a g a z i n e 0 6 . 2 0 0 6
Fig 6: Screenshot of the Global Conguration
Fig 7: Screenshot of the Media Manager
Fig 8: Screenshot of Front End Editor
The Global Confguration screen also gets some revamping, with the
different confguration directives consolidated to just four tabs. This
makes things a lot easier as well as quicker as we learned that having
a confguration screen with ten or more tabs was just unmanageable.
Also the top-level tabs are much more logical and intuitive,
making it more likely for the newcomers to Joomla! to jump to the
intended screen to make the changes that they desire. See Figure 6.
The new Media Manager interface is a much-needed
improvement over the old one; and is also a source of pride and
joy of the happy parent (that would be developer Louis Landry).
The tree on the left makes it so much more convenient
to jump from folder to folder, which was a common
interface complaint from the 1.0.x userbase. See Figure 7.
And now, for something completely different. Lets go back to the
front end interface, login, and try to edit a content item. See Figure 8.
Finally, some AJAX magic makes its way to the Joomla!
Interface. Perhaps this is just a frst step, but also paves the way
for the front end content editor interface to be a lot more useful.
Here is some dirty laundry from the old days: back in the Mambo
universe, we were constantly hearing about how much everyone
hated the front-end content editor interface. The problem is, none of
us ever used it. The pain we felt to fx that just wasnt there. We never
understood why it was such a big deal, or why everyone wanted us
to spend so much time on the front-end when you had so much
more power and capability available from the back end interface.
Well, quite a few of us started taking jobs developing and
customizing sites that used Mambo. For every single one
of us, the very frst project we worked on was an absolute
horror from the front end content editor perspective, that is
and we all vowed that the interface needed some serious work.
The 1.5 development team put that need into action, and provided
a fantastic interface to the front end that provides virtually the
same power and capability as the one provided by the back end,
but without giving back end access to your content writers. This
is signifcant, as it takes an early, critical step in the process of
us really rethinking how the front end interface should be used.
Finally, folks that are restricted to the front end can rejoice!
Developer Resources Everywhere
Speaking of developers, you can get a full reference of the new
API at http://api.joomla.org/, and there is a developer portal at
http://dev.joomla.org/. The portal is a great resource, as you can
Joomla! 1.5 Knocking At Your Door Cover Story
I n t e r n a t i o n a l P H P M a g a z i n e 0 6 . 2 0 0 6
7
read developer blogs, articles about the technology from a developer
perspective, and fnd links to other resources to help you be as
productive as you can be.
Additionally, you can have free hosting of your open source Joomla!
extension at forge.joomla.org, where you have access to a tracker,
subversion repository, fle release system, and more. This topic
deserves some more detail, which I hope explains how fantastic a
resource this is to you.
The JoomlaForge happens to be the biggest instance of SourceForge
Enterprise Edition (SFEE), in the world. We have over 25,000
registered developers working on more than 1,000 projects, spanning
a huge variety of applications including document management,
discussion forums, photo galleries, additional WYSIWYG editors,
you name it! Not only is there a veritable cornucopia of applications
to choose from, you can also set up your own project for free.
If you are itching to develop a Joomla! extension and release it
under an open source license, you can use all the formidable features
provided by SFEE. As well you will have your project hosted in
a Joomla!-centric environment, where you will always have the
communitys interest.
However, SFEE is not targeted at the non-technical end user
that is looking for a photo gallery, it is targeted squarely at the
developer who needs tools to collaborate with other developers
working on a software project. So what can the non-developers do?
We created our new software directory at http://extensions.joomla.
org, where you can fnd a categorized list of available applications
complete with reviews, links to the softwares home page, and
more. This is where we like to send the users of the software
to fnd additional functionality, in a non-techie presentation.
This means that the SFEE interface remains focused solely on
the needs of the developer, which is what SFEE is so good at.
Unlike the old forge (which I was the sole maintainer of for over a
year), the new JoomlaForge is a feature rich, robust environment
that really facilitates collaborative development.
But Wait, Theres More
There is one more screenshot that needs to be shown, which is the
administrator interface for managing plugins, formerly known as
mambots. See Figure 9.
Plugins have had a complete and dramatic redesign that
provides a real wealth of capabilities. You will see in this list of
default plugins a new type of plugin for authentication. We have
provided three authentication plugins for reference: the standard
Joomla! authentication plugin that uses the stock Joomla! tables,
a native LDAP plugin to authenticate from remote directory
sources such as OpenLDAP, Netware or Microsofts Active
Directory, and a little proof of concept authentication plugin
that lets you login with your Google Mail accounts credentials.
We have also included a stub for use with the XStandard WYSIWYG
editor, which has an interesting implementation. Basically you
install the editor locally on your machine (sorry, Windows is
required at this point, were working on it); and when you wish
to edit content, you dont have to wait for all that JavaScript to
download to your browser locally before rendering the editor
area. This makes editing content feel much more responsible, like
a desktop application instead of a web-based content editor. Nice!
Also you will see another new class of plugins, focused on
functionality provided by XML-RPC capabilities. There is
one plugin that lets you use a fat client blogging application (in
this case, w.bloggar) to post content to your Joomla! web site.
Not to leave it at that, we have also provided our own Joomla!
XML-RPC interface, which will provide the means for fat client
applications to interact with your web site like a web service. There
is already a Java-based client called J!Explorer that is more than
just a working prototype, to be found at www.joomlatools.org.
The plugin installer has really gone through the upgrade
process, where you no longer have to use a component
installer, module installer and so on you can now just use
the installer. Another much-needed addition is the capability
to install from a URL, instead of constantly downloading to
your client machine, and then uploading to the web server.
Speaking the International Language
One important topic not covered yet is the concept of language
packs. This allows third-party developers to provide different
language packs for their applications, not just at the Joomla! level
but also at an application level. Fig 9: Screenshot of Plugin Manager Interface
Cover Story Joomla! 1.5 Knocking At Your Door
8
I n t e r n a t i o n a l P H P M a g a z i n e 0 6 . 2 0 0 6
Listing 1
<jdoc:tmpl name=isRTL varscope=document
type=condition conditionvar=LANG_ISRTL>
<jdoc:sub condition=1>
<link href=templates/{TEMPLATE}/css/
template_rtl.css rel=stylesheet type=text/css />
</jdoc:sub>
</jdoc:tmpl>
Template Conditional Example 1
This code tells Joomla! to check and see if the language in use is a
right-to-left language; and if so, to load an additional stylesheet for
the template.
There are also ways to test to see if there are modules published in a
particular position. So for example if you wanted to render HTML
for the left module position, but only if there are published modules
there, you can use the code shown in Listing 2.
Listing 2
<jdoc:exists type=modules condition=left >
<jdoc:include type=modules name=left style=-3 />
</jdoc:exists>
Template Conditional Example 2
Most importantly, there are tutorials on templates on the developer
portal and of course the default template provided with the 1.5
distribution has all of these examples and more. By studying this
template and how it is done, you can easily get started with the new
syntax.
Its All in the Packaging
Another important point about the refactoring of Joomla! is that
this has resulted in a much more framework-oriented package. It is
actually correct to say that the Joomla! CMS was created with the
Joomla! Framework.
For example, the JApplication class allows you to create a
standalone script that does not require the CMS, but has access to
all the facilities as if the script was being rendered, and as if it was
being delivered by the CMS.
If you look in the distribution, you will see the libraries folder. This
is actually the framework, and what we used to create the CMS.
We are investigating what it would take to release the framework
as a standalone package, and hopefully under the LGPL license to
promote inclusion in other applications.
Planning for the Future
I saved my favorite part for last. In the libraries folder, you will
see the joomla folder containing the database folder. Here you see
the foundation for making Joomla! capable of using a variety of
different database platforms, allowing you to use not only MySQL
but PostgreSQL, but some commercial database platforms as well.
The frst step is already done, and you can create your own database
driver by using the existing mysql and mysqli ones as a reference
point. But what about all that SQL littering the codebase?
For example, say you wrote a component that provided a calendar
for events, like GigCalendar at www.gigcalendar.net. What happens
if someone downloads your application and they are speaking
Spanish? Your component is still rendering the language you
provided, which (in the case of GigCalendar) is English.
By being able to provide a language pack for your component, it
is now possible for someone using Joomla! in Spanish to also have
GigCalendar, also in Spanish. It sounds much easier than it really is,
and it is a wonderful capability for the international, multilingual
community.
Sometimes Looks ARE Everything
So what happens to templates, you ask? We have changed the way
templates are done, with a strict focus on making the template
fles as easy to edit as possible. One change is the move from PHP
snippets in the HTML which frustrated and confounded many
editors and proved a common source of syntax errors with a more
XML-friendly format.
For example, to include a module position in your template for the
1.0.x series, you would use:
<?php mosLoadModules ( user3, -1 ); ?>
With 1.5 you would instead use:
<jdoc:include type=modules name=user3 style=-1 />
The frst format makes great sense to a PHP developer, but is
problematic for HTML editors, to say the least. First off, your
document will not validate and of course it is very diffcult to
know while you are working on your template if it validates or not,
without actually viewing (and validating) your output as rendered
by Joomla! There are many reasons that this is undesirable.
Another template feature is conditional logic, without the need for
PHP. See the example in Listing 1.
Joomla! 1.5 Knocking At Your Door Cover Story
I n t e r n a t i o n a l P H P M a g a z i n e 0 6 . 2 0 0 6
9
That is the next step. We are participating in the Google Summer of
Code program, and hope that one of the projects will be researching
and implementing a layer for Joomla! to generate SQL based on
the driver, as opposed to hardcoding SQL statements everywhere
in your code.
There are already existing implementations for us to look at like
ADOdb and Propel, and there is also plenty to learn from other
languages such as java and python. It is my hopes that this layer is
implemented in the next point release of Joomla!, so that you can
choose the database platform that is right for you.
We All Could Use A Little Change
And now a little bit for those of you that have already written
applications to the 1.0.x API, and are worrying about the time you
are going to spend moving to the 1.5 API.
This was a very hot topic, and the lead developer on the 1.5 effort,
Johan Janssens, has made a blog post
[1]
about migrating a very
popular application called FacileForms that makes it easy to create
forms and process the posted results.
In a nutshell, Johan spent about an hour playing around with
FacileForms to get what he wanted working in 1.5. That doesnt
mean that it was fully ported, nor does it mean that all applications
will be as easy, but it should be a great reference to those of you that
are preparing for the migration of existing applications.
Mitch Pirtle is a core developer on the
Joomla! content management team and focuses
on database technologies and evangelism of the
platform for application development, as well
as being a champion of open source software.
He is also a founder of JamboWorks, providing
business and enterprise services and products
based on the Joomla! application platform. There he works on training
and client relationships, as well as business development. Mitch is
also an active member of New York PHP, vocal booster of PHP and
PostgreSQL. He can be found with his wife and children loitering
somewhere in the parks of Manhattan with his PowerBook and a cigar.
Questions & Comments
PHP Magazine Forum
Conclusion
The 1.5 release of Joomla! includes some signifcant changes, as well
as some welcome additions to functionality to ease the lives of third
party developers for product development and custom work. Not
only has the interface been simplifed for the end user, the API has
been rationalized for the developer.
More importantly, this version is a lot more suited for complex
applications and sophisticated requirements. This is an excellent
platform for integrating systems, for example, and taking on other
enterprise-scale challenges.
With Joomla! 1.5 available, life as a web developer couldnt be any
better!
Dive into the World of PHP Dive into the World of PHP
www.phpmag.net
Daily News Online Articles Opinion Polls Book Club Selections

You might also like