You are previewing Mastering Joomla! 1.5 Extension and Framework Development.
O'Reilly logo
Mastering Joomla! 1.5 Extension and Framework Development

Book Description

Extend the power of Joomla! by adding components, modules, plugins, and other extensions

  • In-depth guide to programming Joomla! 1.5 Framework

  • Design and build secure and robust components, modules, and plugins

  • Customize the document properties, add multilingual capabilities, and provide an interactive user experience

  • Includes a comprehensive reference to the major areas of Joomla!’s common classes, variables, and constants crucial for creating Joomla! Extensions.

  • In Detail

    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.

    The most comprehensive, up-to-date, and accurate developer’s reference for Joomla!

    Table of Contents

    1. Mastering Joomla! 1.5 Extension and Framework Development
      1. Mastering Joomla! 1.5 Extension and Framework Development
      2. Credits
      3. About the Author
      4. About the Reviewer
      5. Preface
        1. History
        2. What this book covers
        3. What you need for this book
        4. Conventions
        5. Reader feedback
        6. Customer support
        7. Errata
        8. Piracy
        9. Questions
      6. 1. Introduction to Joomla!
        1. Overview
        2. Joomla! 1.5 Framework
          1. Framework layer
            1. Libraries
            2. Framework
            3. Plugins
          2. Application layer
          3. Extension layer
        3. Extension types and their uses
          1. Components
          2. Modules
          3. Plugins
          4. Languages
          5. Templates
          6. Tools
        4. Extension Manager
        5. Requirements
        6. Joomla Extension Directory (JED)
        7. Development tools
          1. JoomlaCode.org
          2. Coding standards
          3. phpDocumentor
          4. J!Dump
        8. Summary
      7. 2. Getting Started
        1. A quick object lesson
          1. Inheriting from JObject
          2. Design Patterns
          3. Predefined constants
        2. The Joomla! process
          1. Working with JRequest
          2. From Request to Response
          3. Load Core
            1. Libraries
          4. Build application
            1. The session
          5. Initialize application
            1. Multilingual support
            2. UTF-8 string handling
          6. Route application
            1. URI structure
          7. Dispatch application
          8. Render application
          9. Send response
        3. Directory structure
        4. Summary
      8. 3. The Database
        1. The core database
          1. Database structure
        2. Database naming conventions
          1. Database Prefix
          2. Table names
          3. Column names
          4. Creating a component table
        3. Additional points to consider
          1. Dates
          2. Parsing data
          3. Dealing with multilingual requirements
        4. Using the database
          1. JDatabase::query()
            1. Writing queries
          2. JDatabase::load methods
            1. loadResult( ) : string
            2. loadResultArray( numinarray : int=0 ) : array
            3. loadRow( ) : array
            4. loadAssoc( ) : array
            5. loadObject( ) : stdClass
            6. loadRowList( key : int ) : array
            7. loadAssocList( key : string='' ) : array
            8. loadObjectList( key : string='' ) : array
          3. JDatabase::ADOdb methods
          4. JTable
            1. Creating the JTable subclass
            2. Creating a new record
            3. Reading a record
            4. Updating a record
            5. Deleting a record
            6. Checking a record in or out
            7. Ordering
            8. Publishing
            9. Hits
            10. Parameter fields
        5. Summary
      9. 4. Extension Design
        1. Supporting classes
        2. Helpers
        3. Using and building getInstance() methods
        4. Using the registry
            1. Saving and loading registry values
        5. The user
          1. User parameters
        6. The session
        7. The browser
        8. Assets
        9. Extension structure
          1. The structure of a component
            1. Component directory structure
            2. Component file structure
                1. index.html
                2. Entry point
                3. Controller
                4. Views
                5. Models
                6. Tables
            3. Component class names
                1. Backend (/administrator/components)
                2. Frontend ( /components )
            4. Setting up a component sandbox
            5. SQL install and uninstall files
            6. Install and uninstall scripts
            7. Component XML manifest file
          2. The structure of a module
            1. Module directory structure
            2. Module file structure
                1. index.html
                2. Module entry point
                3. Helper
                4. Layouts
            3. Module class names
                1. Frontend (/modules)
            4. Setting up a module sandbox
            5. Module XML manifest file
          3. The structure of a plugin
            1. Plugin directory structure
            2. Setting up a plugin sandbox
        10. Extension packaging
        11. Summary
      10. 5. Component Design
        1. Component design
          1. The MVC software design pattern
            1. Model
            2. View
            3. Controller
            4. Connecting the dots
        2. Building the MVC component
          1. Building the component frontend
            1. Building the entry point
            2. Building the controller
            3. Building the frontend model
            4. Building the frontend view
              1. Building the view layouts
                1. Default layout
                2. List layout
            5. Rendering other document types
              1. Feed
              2. PDF
              3. RAW
            6. Updating the manifest
          2. Building the component backend
            1. Building the backend entry point
            2. Building the controller
                1. Display task
                2. Edit task
                3. Add task
                4. Save task
                5. Cancel task
                6. Remove task
          3. Building the backend model
          4. Building the table
          5. Building views
            1. View #1
              1. The layout
            2. View #2
              1. The layout
            3. Updating the manifest
        3. Dealing with component configuration
        4. Help files
        5. Routing
        6. Summary
      11. 6. Module Design
        1. First steps
          1. Standalone modules
          2. Modules and components working together
          3. Frontend and backend module display positions
        2. Module settings (parameters)
        3. Helpers
        4. Layouts (templates)
          1. Media
        5. Translating
        6. Summary
      12. 7. Plugin Design
        1. Events
        2. Listeners
          1. Registering listeners
          2. Handling events
            1. Listener function
            2. Listener class
        3. Plugin groups
          1. Authentication
          2. Content
          3. Editors
          4. Editors-xtd
          5. Search
          6. System
          7. User
          8. XML-RPC
        4. Loading plugins
        5. Using plugins as libraries (in lieu of library extensions)
        6. Translating plugins
        7. Dealing with plugin settings (parameters)
          1. File naming conflicts
        8. Summary
      13. 8. Rendering Output
        1. Improving components
        2. Component backend
          1. Toolbars
          2. Submenu
          3. The joomla.html library
            1. behavior
            2. email
            3. form
            4. grid
            5. image
            6. list
            7. menu
            8. select
          4. Component layouts (templates) revisited
            1. Admin form
            2. Layout improvements
              1. Adding a WYSIWYG editor
              2. Iterative layout templates
        3. Itemized data
          1. Pagination
          2. Ordering
          3. Filtering and searching
        4. Summary
      14. 9. Customizing the Page
        1. Application message queue
        2. Redirecting the browser
          1. Component XML metadata files and menu parameters
        3. Using menu item parameters
        4. Modifying the document
          1. Page title
          2. Pathway
          3. JavaScript
          4. CSS
          5. Metadata
          6. Custom header tags
        5. Translating
          1. Translating text
          2. Defining translations
          3. Debugging translations
        6. Using JavaScript effects
          1. JPane
          2. Tooltips
          3. Fx.Slide
        7. Summary
      15. 10. APIs and Web Services
        1. XML
          1. Parsing
          2. Editing
          3. Saving
        2. AJAX
          1. Response
          2. Request
        3. LDAP
        4. Email
        5. File transfer protocol
        6. Web services
        7. Building a web service (XML-RPC plugin)
        8. Summary
      16. 11. Error Handling and Security
        1. Errors, warnings, and notices
          1. Return values
          2. Customizing error handling
        2. Dealing with CGI request data
          1. Preprocessing CGI data
          2. Escaping and encoding data
          3. Escaping and quoting database data
          4. Encode XHTML data
          5. Regular Expressions
            1. Patterns
            2. Matching
            3. Replacing
        3. Access control
          1. Menu item access control
          2. Extension access control
        4. Attacks
          1. How to avoid common attacks
            1. Using the session token
            2. Code injection
              1. PHP code injection
              2. SQL injection
            3. XSS—Cross Site Scripting
            4. File system snooping
          2. Dealing with attacks
            1. Log out and block
            2. Attack logging
            3. Notify the site administrator
        5. Summary
      17. 12. Utilities and Useful Classes
        1. Dates
          1. Date and time parameter
          2. Time zone parameter
        2. File system
          1. Paths
          2. Folders
          3. Files
          4. Archives
        3. Arrays
        4. Trees
        5. Log files
        6. Summary
      18. A. Joomla! Core Classes
        1. JApplication
            1. Properties
            2. Inherited methods
            3. Deprecated methods
            4. Methods
                  1. Constructor __construct
                  2. close
                  3. dispatch
                  4. enqueueMessage
                  5. getCfg
                  6. getClientId
                  7. getInstance
                  8. getMenu
                  9. getMessageQueue
                  10. getName
                  11. getPathway
                  12. getRouter
                  13. getTemplate
                  14. getUserState
                  15. getUserStateFromRequest
                  16. initialise
                  17. isAdmin
                  18. isSite
                  19. login
                  20. logout
                  21. redirect
                  22. registerEvent
                  23. render
                  24. route
                  25. setUserState
                  26. triggerEvent
        2. JController
            1. Properties
            2. Inherited properties
            3. Inherited methods
            4. Methods
                  1. Constructor __construct
                  2. addModelPath
                  3. addViewPath
                  4. authorize
                  5. display
                  6. execute
                  7. getModel
                  8. getName
                  9. getTask
                  10. getTasks
                  11. getView
                  12. redirect
                  13. registerDefaultTask
                  14. registerTask
                  15. setAccessControl
                  16. setMessage
                  17. setRedirect
                  18. _addPath
                  19. _createFileName
                  20. _createModel
                  21. _createView
                  22. _setPath
        3. JDatabase
            1. Direct descendents
            2. Properties
            3. Inherited properties
            4. Inherited methods
            5. Methods
                  1. Constructor __construct
                  2. Destructor __destruct
                  3. addQuoted
                  4. connected
                  5. debug
                  6. explain
                  7. getAffectedRows
                  8. getCollation
                  9. getConnectors
                  10. getErrorMsg
                  11. getErrorNum
                  12. getEscaped
                  13. getInstance
                  14. getLog
                  15. getNullDate
                  16. getNumRows
                  17. getPrefix
                  18. getQuery
                  19. getTableCreate
                  20. getTableFields
                  21. getTableList
                  22. getTicker
                  23. getUTFSupport
                  24. getVersion
                  25. hasUTF
                  26. insertid
                  27. insertObject
                  28. isQuoted
                  29. loadAssoc
                  30. loadAssocList
                  31. loadObject
                  32. loadObjectList
                  33. loadResult
                  34. loadResultArray
                  35. loadRow
                  36. loadRowList
                  37. nameQuote
                  38. query
                  39. queryBatch
                  40. Quote
                  41. replacePrefix
                  42. setQuery
                  43. setUTF
                  44. splitSql
                  45. stderr
                  46. test
                  47. updateObject
              1. ADOdb methods
                  1. BeginTrans
                  2. CommitTrans
                  3. ErrorMsg
                  4. ErrorNo
                  5. Execute
                  6. GenID
                  7. GetCol
                  8. GetOne
                  9. GetRow
                  10. PageExecute
                  11. RollbackTrans
                  12. SelectLimit
        4. JDocument
            1. Direct descendents
            2. Properties
            3. Inherited properties
            4. Inherited methods
            5. Methods
                  1. Constructor __construct
                  2. addScript
                  3. addScriptDeclaration
                  4. addStyleDeclaration
                  5. addStyleSheet
                  6. getBase
                  7. getBuffer
                  8. getCharset
                  9. getDescription
                  10. getDirection
                  11. getGenerator
                  12. getHeadData
                  13. static getInstance
                  14. getLanguage
                  15. getLink
                  16. getMetaData
                  17. getModifiedDate
                  18. getTitle
                  19. getType
                  20. loadRenderer
                  21. render
                  22. setBase
                  23. setBuffer
                  24. setCharset
                  25. setDescription
                  26. setDirection
                  27. setGenerator
                  28. setHeadData
                  29. setLanguage
                  30. setLineEnd
                  31. setLink
                  32. setMetaData
                  33. setMimeEncoding
                  34. setModifiedDate
                  35. setTab
                  36. setTitle
                  37. setType
                  38. _getLineEnd
                  39. _getTab
        5. JDocumentRenderer
            1. Direct descendents
            2. Properties
            3. Inherited properties
            4. Inherited methods
            5. Methods
                  1. Constructor __construct
                  2. getContentType
                  3. render
        6. JFactory
            1. Methods
                  1. getACL
                  2. getApplication
                  3. getCache
                  4. getConfig
                  5. getDate
                  6. getDBO
                  7. getDocument
                  8. getEditor
                  9. getLanguage
                  10. getMailer
                  11. getSession
                  12. getTemplate
                  13. getURI
                  14. getUser
                  15. getXMLParser
                  16. _createACL
                  17. _createConfig
                  18. _createDBO
                  19. _createDocument
                  20. _createLanguage
                  21. _createMailer
                  22. _createSession
                  23. _createTemplate
        7. JModel
            1. Properties
            2. Inherited properties
            3. Inherited methods
            4. Methods
                  1. Constructor __construct
                  2. addIncludePath
                  3. addTablePath
                  4. getDBO
                  5. getInstance
                  6. getName
                  7. getState
                  8. getTable
                  9. setDBO
                  10. setState
                  11. _createFileName
                  12. _createTable
                  13. _getList
                  14. _getListCount
        8. JObject
            1. Direct descendents
            2. Properties
            3. Deprecated methods
            4. Methods
                  1. Constructor __construct
                  2. Constructor JObject
                  3. get
                  4. getError
                  5. getErrors
                  6. getProperties
                  7. set
                  8. setError
                  9. setProperties
                  10. toString
        9. JPlugin
            1. Properties
            2. Inherited properties
            3. Inherited methods
            4. Methods
                  1. Constructor __construct
                  2. Constructor JPlugin
                  3. loadLanguage
        10. JTable
            1. Direct descendents
            2. Properties
            3. Inherited properties
            4. Inherited methods
            5. Methods
                  1. Constructor __construct
                  2. addIncludePath
                  3. bind
                  4. canDelete
                  5. check
                  6. checkin
                  7. checkout
                  8. delete
                  9. getDBO
                  10. getInstance
                  11. getKeyName
                  12. getNextOrder
                  13. getTableName
                  14. hit
                  15. isCheckedOut
                  16. load
                  17. move
                  18. publish
                  19. reorder
                  20. reset
                  21. save
                  22. setDBO
                  23. store
                  24. toXML
        11. JUser
            1. Properties
            2. Inherited properties
            3. Inherited methods
            4. Methods
                  1. Constructor __construct
                  2. authorize
                  3. bind
                  4. defParam
                  5. delete
                  6. getInstance
                  7. getParam
                  8. getParameters
                  9. getTable
                  10. load
                  11. save
                  12. setLastVisit
                  13. setParam
                  14. setParameters
        12. JView
            1. Properties
            2. Inherited properties
            3. Inherited methods
            4. Methods
                  1. Constructor __construct
                  2. addHelperPath
                  3. addTemplatePath
                  4. assign
                  5. assignRef
                  6. display
                  7. escape
                  8. get
                  9. getLayout
                  10. getModel
                  11. getName
                  12. loadHelper
                  13. loadTemplate
                  14. setEscape
                  15. setLayout
                  16. setLayoutExt
                  17. setModel
                  18. _addPath
                  19. _createFileName
                  20. _setPath