Book Image

Mastering Joomla! 1.5 Extension and Framework Development Second Edition

Book Image

Mastering Joomla! 1.5 Extension and Framework Development Second Edition

Overview of this book

Joomla! is one of the world’s top open source content management systems, which enables you to build websites and powerful online applications. Out of the box, Joomla! does a great job of managing the content needed to enhance the functionality of your website. But for many people, the true power of Joomla! lies in its application framework that makes it possible for thousands of developers around the world to create powerful add-ons and extensions. This book will guide you through the complexities of implementing add-ons, components, modules, and plugins in Joomla! 1.5. If you feel that you’ve mastered the basics of creating Joomla! extensions, then this book will take you to the next level. Packed with expert advice on all aspects of programming with Joomla!, this book is an invaluable reference guide you will turn to again and again for your Joomla! development tasks. The book starts by explaining the structure and design of the Joomla! Framework. Then we move on to extending and storing data in standard fields and dealing with multilingual requirements. Further, you will discover best practices, design, and coding methods for Joomla! components, modules, plugins, and other extensions. Along the way, you will actually design and create a component, module, and plugin that work together to add functionality to the Joomla! framework. You will also learn about customizing the page output using JavaScript effects, making use of Web Services from within Joomla! and ensuring that your code is secure and error-free. You will discover how to easily create sophisticated extensions that are robust, user-friendly, and professional by taking advantage of the many libraries and utilities provided by the Joomla! framework. A comprehensive, up-to-date reference to the Joomla! Framework API is also included in the book. Finally, we will discuss advanced methods for rendering your extensions more robust, secure, and professional.
Table of Contents (18 chapters)
Mastering Joomla! 1.5 Extension and Framework Development
Credits
About the Author
About the Reviewer
Preface

JObject


abstract, located in / joomla/base/object.php

JObject is a common base class. It provides constructor compatibility between PHP4 and PHP5 and provides some common methods.For more information about using the JObject refer to Chapter 2, Getting Started.

Direct descendents

JApplication

Base class for a Joomla! application

JArchiveBzip2

Bzip2 format adapter for the JArchive class

JArchiveGzip

Gzip format adapter for the JArchive class

JArchiveTar

Tar format adapter for the JArchive class

JArchiveZip

AIP format adapter for the JArchive class

JAuthenticationResponse

Provides an object for storing user and error details

JBrowser

Provides information about the current web client

JButton

Button base class

JCache

Cache base class

JCacheStorage

Abstract cache storage handler

JController

Base controller class

JDatabase

Database connector class

JDate

Class that stores a date

JDocument

Provides an interface to parse and display a document

JDocumentRenderer

Abstract class for a renderer

JElement

Parameter base class

JException

Provides the Joomla! exception object

JFeedEnclosure

Internal class that stores feed enclosure information

JFeedImage

Internal class that stores feed image information

JFeedItem

Internal class that stores feed item information

JFilterInput

Class for filtering input from any data source

JFTP

FTP client class

JInstaller

Base installer class

JInstallerComponent

Component installer

JInstallerLanguage

Language installer

JInstallerPlugin

Plugin installer

JInstallerTemplate

Template installer

JIntallerModule

Module installer

JLanguage

Languages/translation handler class

JLDAP

LDAP client class

JLog

Logging class

JMenu

Class handles menus and menu items

JModel

Base class for models that use the MVC

JNode

Tree node class

JObservable

Abstract class to implement the observer design pattern

JObserver

Abstract class to implement the observer design pattern

JPagination

Provides a common interface for content pagination

JPaginationObject

Represents a particular item in the pagination lists

JPane

Abstract class that provides tabs and sliders

JPathway

Class that maintains the pathway (breadcrumbs)

JProfiler

Utility class to assist in the process of benchmarking

JRegistry

Handles configuration details in a hierarchical namespace

JRegistryFormat

Abstract format for the registry

JRouter

Class to create and parse routes

JSession

Class for managing HTTP sessions

JSessionStorage

Custom session storage handler for PHP

JSimpleCrypt

Simple algorithm for encrypting or decrypting strings

JSimpleXML

SimpleXML implementation

JSimpleXMLElement

SimpleXML element

JTable

Abstract Table class

JToolbar

Toolbar handling class

JTree

Hierarchichal tree class

JURI

Class to handle URIs

JUser

Class that handles all application interaction with a user

JView

Base class for view classes that use the MVC

Properties

array $_errors

An array of error messages or JException objects

Deprecated methods

The following methods have been deprecated as of version 1.5; their use is not recommended. Use the recommended alternative instead.

Deprecated Method

Recommended Alternative

getPublicProperties()

getProperties()

Methods

Constructor __construct

This constructor is designed to be overridden in subclasses. Overriding methods should always call parent::__construct(). This is the PHP 5 constructor format. This class provides two constructors to support PHP 5 and PHP 4 (see the next method description) constructor methods.

JObject __construct()

  • object: Returns a new JObject object

Constructor JObject

This constructor is a hack to support the PHP 5 constructor __construct() on PHP 4. This constructor removes the need for subclasses to use the className() style constructor. Subclasses need only define the __construct() constructor, which if PHP 5 is not being used, is call by this method. Although this constructor does not define any parameters, this does not restrict subclasses from doing so. Multiple parameters can still be used, all of which will be passed to the highest level __construct() method. Redefined in all direct descendants.

JObject JObject()

  • object: Returns a new JObject object

get

This method returns the value of the requested property. If the property is not set, then the optional default value will be returned. This method will not return a reference; in subclasses it can be beneficial to add specific methods where a reference to a property is more suitable. Private properties, identified by an underscore at the start of the name, can be returned using this method. Redefined in descendants as:

  • JParameter::get(): get a value

  • JSession::get(): get data from the session store

  • JCache::get(): get cached data by id and group

  • JCacheView::get(): get cached view data

  • JCachePage::get(): get cached page data

  • JCacheCallback::get(): executes callback or returns cached output

  • JCacheStorage::get(): get data by id and group

  • JCacheStorageApc::get(): get APC data by id and group

  • JCacheStorageMemcache::get(): get memcache data by id and group

  • JCacheStorageXCache::get(): get cached data by id and group

  • JCacheStorageFile::get(): get file data by id and group

  • JCacheStorageEaccelerator::get(): get cached data by id and group

  • JView::get(): get data from model or view property

  • JLanguage::get(): get a metadata language property

  • JFTP::get(): get file from FTP server

mixed get($property, [$default = null])

  • string $property: The name of the property

  • mixed $default: The default value if the property has not been initialized

  • mixed: Returns the value of the property

getError

This method returns the most recent error that occurred during the execution of one of the object's methods. The error can be an object or a string. See JError for more information about errors. If the error number $i is specified but does not exists the method returns false.

mixed getError([$i = null], [$toString = true])

  • integer $i: Optional; the error number; by default the last error is retrieved

  • boolean $toString: If true directs JError objects to return error message

  • mixed: Returns an error message string, JError object or false

getErrors

This method returns a copy of the $_errors property.

array getErrors()

  • array: Returns an array of errors associated with the object

getProperties

This method returns an associative array of all the properties of an object; this includes run-time properties not just class properties. If $public is true (default) only public properties will be returned; if false all properties, public and private (properties identified by an underscore at the start of the name) will be returned.

array getProperties([$public = true])

  • boolean $public: If true returns only public properties

  • array: Returns an an associative array of object properties

set

This is a mutator method that sets the value of the requested property of the object. If the property does not exist it creates it. Redefined in descendants as:

  • JParameter::set(): sets a value

  • JSession::set(): sets data into the session store

mixed set($property, [$value = null])

  • string $property: The name of the property

  • mixed $value: The value of the property to set

  • mixed: Returns the previous value of the property

setError

This method adds an error to the object's error history. Redefined in descendants as:

  • JDocumentError::setError(): sets error object.

void setError($error)

  • string $error: The error message.

  • void: No return type

setProperties

This method sets the object properties obtained from either an associative array or another object.

boolean setProperties($properties)

  • mixed $properties: Either an associative array or another object

  • boolean: Returns true upon success

toString

method gets the class name of the object and returns it as a string. Redefined in descendants as:

  • JRegistry::toString(): gets a namespace in a given string format

  • JException::toString(): returns an error message

  • JURI::toString(): returns full URI string

  • JSimpleXMLElement::toString(): gets a well-formed XML string

string toString()

  • string: Returns the object's class name as a string