Mastering Joomla! 1.5 Extension and Framework Development - Pdf 12

www.it-ebooks.info
Mastering Joomla! 1.5
Extension and Framework
Development
The Professional Guide to Programming
Joomla!
Extend the power of Joomla! by adding components,
modules, plugins, and other extensions

Chuck Lanham
James Kennard
BIRMINGHAM - MUMBAI
www.it-ebooks.info
Mastering Joomla! 1.5 Extension and Framework
Development
The Professional Guide to Programming Joomla!
Copyright © 2010 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the authors, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
First published: November 2007
Second edition: June 2010

Project Coordinator
Ashwin Shetty
Proofreaders
Joel Johnson
Aaron Nash
Graphics
Geetanjali Sawant
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
www.it-ebooks.info
About the Author
Chuck Lanham began his career as a database software engineer with Burroughs
Corp. He later worked for Informix Corp. managing the database tools development
group while serving as repository architect. He has founded and managed two
successful software development companies, and taught college courses on database
theory, data communications, and computer technologies. He has also managed the
global development and deployment of leading CRM and CMS systems for many
Fortune 500 companies, and managed the development and deployment of some
of the largest e-commerce websites in the world.
In 2002, Chuck left the corporate world and started a new company, Blue Water
Associates. This company is located near the deep blue waters of Lake Tahoe where
he designs, develops, and maintains websites for small to medium sized businesses,
both within the U.S. and abroad.
Chuck has been developing websites using Joomla! since 2007 with the release of
version 1.5 and has developed several extensions for use in the websites he has
designed. This is Chuck's rst book as an author, although he has reviewed and
edited several books and written numerous technical articles for publication.
www.it-ebooks.info

CodeIgniter, CakePHP, jQuery, and other known open source technologies.
His desire to learn and share his knowledge has led him to be a regular reviewer of
books from Packt, such as Drupal E-commerce, Joomla! With Flash, Joomla! 1.5 SEO,
Magento Theme Design and Symfony 1.3 web application development.
Recently he has even published his own book, CodeIgniter 1.7, which can be found on
the Packt website. If you work with PHP, take a look at it!
He is currently working on a new book for Packt, this time Joomla! related, check for
it soon!
If you want to know more about him, you can check his site at
www.joseargudo.com.
www.it-ebooks.info
Suhreed Sarkar is an IT consultant, trainer, and technical writer. He studied
Marine engineering, served on board a ship for two years, and then began his
journey into the IT world with MCSE in Windows NT 4.0 track. Later he studied
business administration and earned MBA from the University of Dhaka. He has
a bunch of BrainBench certications on various topics including PHP4, Project
Management, RDBMS Concepts, E-commerce, Web Server Administration,
Internet Security, Training Development, Training Delivery and Evaluation,
and Technical Writing.
As a trainer, he taught courses on system administration, web development,
e-commerce and MIS. He has consulted several national and international
organizations including United Nations, and helped clients building and adopting
their enterprise portals, large-scale databases and management information systems.
He is a renowned technical author in Bengali – having dozens of books published on
subjects covering web development, LAMP, networking, and system administration.
He authored three books for Packt - Zen Cart: E-commerce Application
Development, Joomla! E-commerce with VirtueMart, and Joomla! with Flash. Now
he is authoring a Cookbook on Joomla!
While not busy with hacking some apps, blogging on his blog (
www.suhreedsarkar.

Joomla Extension Directory (JED) 17
Development tools 17
JoomlaCode.org 18
Coding standards 18
phpDocumentor 19
J!Dump 21
Summary 23
www.it-ebooks.info
Table of Contents
[ ii ]
Chapter 2: Getting Started 25
A quick object lesson 25
Inheriting from JObject 27
Design Patterns 29
Predefined constants 30
The Joomla! process 32
Working with JRequest 32
From Request to Response 33
Load Core 37
Libraries 37
Build application 39
The session 39
Initialize application 40
Multilingual support 41
UTF-8 string handling 41
Route application 43
URI structure 43
Dispatch application 46
Render application 47
Send response 47

JTable 67
Creating the JTable subclass 70
Creating a new record 72
Reading a record 75
Updating a record 75
Deleting a record 76
Checking a record in or out 78
Ordering 79
Publishing 80
Hits 81
Parameter fields 81
Summary 82
Chapter 4: Extension Design 83
Supporting classes 83
Helpers 84
Using and building getInstance() methods 85
Using the registry 90
Saving and loading registry values 92
The user 94
User parameters 95
The session 101
The browser 103
Assets 106
Extension structure 107
The structure of a component 108
Component directory structure 108
Component file structure 110
Component class names 112
Setting up a component sandbox 114
SQL install and uninstall files 117

Updating the manifest 162
Building the component backend 162
Building the backend entry point 163
Building the controller 164
Building the backend model 170
Building the table 176
Building views 177
View #1 177
View #2 182
Updating the manifest 188
Dealing with component configuration 189
Help files 191
Routing 192
Summary 194
Chapter 6: Module Design 195
First steps 195
Standalone modules 196
Modules and components working together 197
Frontend and backend module display positions 198
Module settings (parameters) 199
Helpers 203
Layouts (templates) 206
Media 210
www.it-ebooks.info
Table of Contents
[ v ]
Translating 211
Summary 212
Chapter 7: Plugin Design 213
Events 214

image 255
list 256
menu 257
select 257
Component layouts (templates) revisited 258
Admin form 259
Layout improvements 260
www.it-ebooks.info
Table of Contents
[ vi ]
Itemized data 270
Pagination 270
Ordering 277
Filtering and searching 281
Summary 291
Chapter 9: Customizing the Page 293
Application message queue 293
Redirecting the browser 295
Component XML metadata files and menu parameters 299
Using menu item parameters 308
Modifying the document 309
Page title 310
Pathway 310
JavaScript 312
CSS 313
Metadata 314
Custom header tags 315
Translating 315
Translating text 315
Defining translations 317

Escaping and quoting database data 377
Encode XHTML data 378
Regular Expressions 379
Patterns 379
Matching 381
Replacing 382
Access control 383
Menu item access control 385
Extension access control 385
Attacks 387
How to avoid common attacks 387
Using the session token 388
Code injection 389
XSS—Cross Site Scripting 391
File system snooping 392
Dealing with attacks 392
Log out and block 393
Attack logging 396
Notify the site administrator 397
Summary 398
Chapter 12: Utilities and Useful Classes 399
Dates 400
Date and time parameter 400
Time zone parameter 401
File system 405
Paths 405
Folders 408
Files 412
Archives 415
Arrays 416

Direct descendents 474
Properties 475
Inherited properties 475
Inherited methods 475
Methods 475
JFactory 476
JModel 483
Properties 483
Inherited properties 483
Inherited methods 483
Methods 484
JObject 488
Direct descendents 488
Properties 490
Deprecated methods 490
Methods 490
www.it-ebooks.info
Table of Contents
[ ix ]
JPlugin 494
Properties 494
Inherited properties 494
Inherited methods 494
Methods 495
JTable 496
Direct descendents 497
Properties 497
Inherited properties 497
Inherited methods 497
Methods 498

and start building new extensions. Perhaps the most important of the changes is the
reorganization and classication of les and classes. This change encourages but does
not force developers to use the Joomla! libraries consistently between extensions.
History
Rice Studios, formerly Miro, created a closed-source CMS called 'Mambo' in the
year 2000. One year later, Mambo was re-licensed under two separate licenses,
one of which was open source. The open-source version became known as
'Mambo Site Server'.
www.it-ebooks.info
Preface
[ 2 ]
In 2002 Mambo Site Server was re-branded 'Mambo Open Source' (Also referred to
as MamboOS or MOS) in an attempt to differentiate the commercial and open source
avors of Mambo. All rights to Mambo Open Source were ofcially released into the
open source community in 2003.
Mambo Open Source was extremely successful and won a large number of
prestigious open-source awards.
In 2005 the commercial version of Mambo was re-branded as 'Jango'. Rice Studios,
at that time still Miro, also chose to form the Mambo Foundation, a non-prot
organization. The intention was to create a body that would help protect the
principles of Mambo and provide a more structured working methodology.
The creation of the Mambo Foundation created a rift in the Mambo Open Source
community. The creation of the Mambo Foundation was seen by many as an attempt
by Rice Studios to gain control of the Mambo Open Source project.
Not long after the Mambo Foundation was created, a group, consisting mainly of
the Mambo Open Source core developers, publicly announced that they intended to
abandon Mambo Open Source. The group formed a non-prot organization called
'Open Source Matters'.
Open Source Matters created the Joomla! project, a guaranteed 100% open-source
GPL project. The rst release of Joomla! (Joomla! 1.0) was very similar to the then

JTable. The JTable is used to display and
edit regular two-dimensional tables of cells. The JTable has many facilities that
make it possible to customize its rendering and editing but provides defaults for
these features so that simple tables can be set up easily.
Chapter 4, Extension Design covers the basics in extension design. We begin with
helper classes, then cover building and using
getInstance() methods. We cover the
registry along with saving and loading registry values. We explain the User, Session,
Browser and Assets. We nish the chapter with a discussion on the structure of
components, modules, and plugins and explain extension packaging and developing
XML manifest les for each.
Chapter 5, Component Design is about designing components. It starts with the
structure and a basic design of a component using the MVC design pattern. Then
we learn conguring the component and its various elements and parameters.
Chapter 6, Module Design covers designing modules. It explains standalone modules,
module settings, frontend and backend modules, and modules and components
working together. Then we talk about using templates.
Chapter 7, Plugin Design deals with designing plugins. It initially deals with listeners/
observers and then the various plugin groups like authentication, content editors,
search, and others. Then comes loading, translating, and using plugins as libraries.
Finally it deals with, plugin settings.
www.it-ebooks.info
Preface
[ 4 ]
Chapter 8, Rendering Output explains ways to render output and how to maintain
consistency throughout. It starts with the joomla.html library and then continues
to describe how to build component HTML layouts. Then it discusses how to output
the backend of a component. The chapter ends with the details of itemized data
and pagination.
Chapter 9, Customizing the Page deals with customizing the page. We cover things

Appendix F, Joomla! Utility Classes covers twenty Joomla! utility classes that perform
many common tasks.
www.it-ebooks.info
Preface
[ 5 ]
Appendix G, Request and Session Handling details the Joomla! request and session
handling classes, including caching and routing.
Appendix H, XML Manifest File provides detailed information on the tags available
for use in XML Manifest les.
What you need for this book
To use this book effectively you need access to a Joomla! 1.5 installation. In order
to run Joomla! 1.5 you need the following software: PHP 4.3 or higher (4.4.3 or
greater is recommended), MySQL 3.23 or higher and Apache 1.3 or higher or an
equivalent webserver.
Conventions
In this book, you will nd a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.
Code in text is shown as follows: "We can include other contexts through the use of
the
include directive."
A block of code is set as follows:
[default]
exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)
When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
[default]

Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.
Downloading the example code for the book
Visit />files/0523_Code.zip to directly download the example code.
The downloadable les contain instructions on how to use them.
www.it-ebooks.info


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status