CHAPTER 1 Application Planning and Design
What Is Web 2.0?
Database Connectivity
Web Site Templates
Web Site Features
Main Home Page and User Home Page
User Registration
Account Login and Management
User Blogs
Web Site Search
Application Management
Other Aspects of Development
Search-Engine Optimization
PHPDoc-Style Commenting
Security
Application Logging
Maintainability and Extensibility
Version Control and Unit Testing
Summary
CHAPTER 2 Setting Up the Application Framework
Web Server Setup
Operating System
Installing the Apache HTTP Server
Installing MySQL 5
Installing PHP 5.2.3
Application Filesystem Structure
Web Root Directory
Data Storage Directory
PHP Classes Directory
Templates Directory
Full Directory Structure
Installing the Zend Framework
Configuring the Web Server
Creating a Virtual Host in Linux
Creating a Virtual Host in Windows
Restarting Your Web Server
Setting Up theDatabase
Using the Model-View-Controller Pattern
Separating Application Logic from Presentation Logic
Directing All Requests to index.php
Introduction to the Zend_Controller Class
How Requests Work with Zend_Controller
Creating the IndexController
Defining Application Settings
Connecting to the Database
Testing the Database Connection
The Smarty Template Engine
Why Not Use a Different Template Engine?
Downloading and Installing Smarty
Automatic View Rendering with Zend_Controller
Integrating Smarty with the Web Site Controllers
Adding Logging Capabilities
Writing to the Log File
Summary
CHAPTER 3 User Authentication, Authorization, and Management
Creating the User Database Table
Timestamps
User Profiles
Introduction to Zend_Auth
Instantiating Zend_Auth
Authenticating with Zend_Auth
Introduction to Zend_Acl
A Zend_Acl Example
Combining Zend_Auth, Zend_Acl, and Zend_Controller_Front
Managing User Records with DatabaseObject
The DatabaseObject_User Class
Using DatabaseObject_User
Managing User Profiles
Using Profile_User
Integrating Profile_User with DatabaseObject_User
Summary
CHAPTER 4 User Registration, Login, and Logout
Adding User Registration to the Application
Creating the Form Processor for User Registration
Displaying the Registration Form and Processing Registrations .
Adding CAPTCHA to the User Registration Form
Adding E-mail Functionality
Implementing Account Login and Logout
Creating the Login Template
Adding the Account Controller Login Action
Logging Successful and Failed Login Attempts
Logging Users Out of Their Accounts
Dealing with Forgotten Passwords
Resetting a User’s Password
Functions for Resetting Passwords
Implementing Account Management
Creating the Account Home Page
Updating the Web Site Navigation
Allowing Users to Update Their Details
Summary
CHAPTER 5 Introduction to Prototype and Scriptaculous
Downloading and Installing Prototype
Prototype Documentation
Selecting Objects in the Document Object Model
The $() Function
The getElementsByClassName() Function
The $$() Function
The getElementsBySelector() Function
Prototype’s Hash Object
Other Element Extensions
Showing and Hiding Elements
Retrieving Dimensions of Elements
Managing Classes of Elements
Manipulating Strings with Prototype
Ajax Operations in Prototype
Ajax Request Options
Ajax Callback Functions
JavaScript Object Notation (JSON)
An Ajax.Request Example
Event Handling in Prototype
Observing an Event
Finding Out Which Element an Event Occurred On
Canceling an Event
Creating JavaScript Classes in Prototype
Creating a Class
Binding Function Calls to Objects
From Prototype to Scriptaculous
Prebuilt Controls
Drag and Drop
Visual Effects
DOM Element Builder
JavaScript Unit Testing
Downloading and Installing Scriptaculous
Combining Prototype, Scriptaculous, Ajax, and PHP in a Useful Example
Creating the Main HTML Page: index.php
Styling the Application: styles.css
Creating and Populating the Database: schema.sql
Managing the List Items on the Server Side: items.php
Processing Ajax Requests on the Server Side: processor.php
Summary
CHAPTER 6 Styling the Web Application
Adding Page Titles and Breadcrumbs
The Breadcrumbs Class
Generating URLs
Setting the Title and Trail for Each Controller Action
Creating a Smarty Plug-In to Output Breadcrumbs
Displaying the Page Title
Integrating the Design into the Application
Creating the Static HTML
Moving the HTML Markup into Smarty Templates
Constructing the CSS
Specifying Media Types and Loading the CSS File
Creating the Application CSS
Creating a Print-Only Style Sheet
The Full Application Style Sheet
Styling the Application Web Forms
Loading Prototype and Scriptaculous
Implementing Client-Side Form Validation
Adding JSON Support to CustomControllerAction
Modifying the Form Processor
Modifying the Registration Controller Action
Creating the JavaScript Form Validator
Loading the UserRegistrationForm Class
Summary
CHAPTER 7 Building the Blogging System
Creating the Database Tables
Setting Up DatabaseObject and Profile Classes
Creating the DatabaseObject_BlogPost Class
Creating the Profile_BlogPost Class
Creating a Controller for Managing Blog Posts
Extending the Application Permissions
The BlogmanagerController Actions
Linking to Blog Manager
Creating and Editing Blog Posts
Creating the Blog Post Submission Form Template
Instantiating FormProcessor_BlogPost in editAction()
Implementing the FormProcessor_BlogPost Class
Generating a Permanent Link to a Blog Post
Filtering Submitted HTML
Creating a New Blog Post
Previewing Blog Posts
Creating the Preview Action
Implementing the Preview Template
Requesting Confirmation for User Actions Post
Updating the Status of a Blog Post
Completing setstatusAction()
Notifying the User
Summary
CHAPTER 8 Extending the Blog Manager
Listing Blog Posts on the Blog Manager Index
Fetching Blog Posts from the Database
Assigning Recent Posts and the Monthly Summary to the Template
Displaying Recent Posts in the Template
Displaying the Monthly Summary
Ajaxing the Blog Monthly Summary
Creating the Ajax Request Output
The BlogMonthlySummary JavaScript Class
Installing the BlogMonthlySummary Class
Notifying the User About the Content Update
Integrating a WYSIWYG Editor
Downloading and Installing FCKeditor
Configuring FCKeditor
Loading FCKeditor in the Blog Editing Page
Summary
CHAPTER 9 Personalized User Areas
Controlling User Settings
Presenting Customizable Settings to Users
Processing Changes to User Settings
Creating Default User Settings
The UserController Class
Routing Requests to UserController
Handling Requests to UserController
Displaying the User’s Blog
Displaying the Blog Index Page
Displaying Individual Blog Posts
Generating Blog Archive Links
Displaying the Monthly Archive
Populating the Application Home Page
Loading Recent Public Posts
Implementing the Application Home Page
Summary
CHAPTER 10 Implementing Web 2.0 Features
Tags
Implementing Tagging
Managing Blog Post Tags
Displaying a User’s Tags on Their Blog
Displaying a Tag Space
Displaying Tags on Each Post
Web Feeds
Data Formats for Web Feeds
Creating an Atom Feed with Zend_Feed
Adding the Feed to UserController
Linking to Your Feed
Other Feed Options
Microformats
An Example of Using Microformats
Why Use Microformats?
Microformatting Your Tags
Allowing Users to Create a Public Profile
Allowing Users to Create a Public Profile
Displaying a User’s Profile
Summary
CHAPTER 11 A Dynamic Image Gallery
Storing Uploaded Files
Creating the Database Table for Image Data
Controlling Uploaded Images with DatabaseObject
Uploading Files
Setting the Form Encoding
Adding the Form
Specifying the File Input Type
Setting the Maximum File Size
Handling Uploaded Files
SendingImages
Resizing Images
Creating Thumbnails
Linking the Thumbnailer to the Image Action Handler
Managing Blog Post Images
Automatically Loading Blog Post Images
Displaying Images on the Post Preview
Deleting Blog Post Images
Using Scriptaculous and Ajax to Delete Images
Deleting Images when Posts Are Deleted
Reordering Blog Post Images
Displaying Images on User Blogs
Extending the GetPosts() Function
Displaying Thumbnail Images on Blog Index
Displaying Images on the Blog Details Page
Displaying Larger Images with Lightbox
Summary
CHAPTER 12 Implementing Site Search
Introduction to Zend_Search_Lucene
Comparison to MySQL Full-Text Indexing
Zend_Search_Lucene Field Types
Field Naming
Indexing Application Content
Indexing Multiple Types of Data
Creating a New Zend_Search_Lucene_Document
Retrieving the Index Location
Building the Entire Index
Indexing and Unindexing a Single Blog Post
Triggering Search Index Updates
Creating the Search Tool
Adding the Search Form
Handling Search Requests
Querying the Search Index
Displaying Search Results
Types of Searches
Adding Autocompletion to the Search Tool
Providing Search Suggestions
Creating an Action Handler to Return Search Results
Retrieving Search Suggestions
Loading the SearchSuggestor Class
Displaying Search Suggestions
Adding Mouse Navigation to Results
Adding Keyboard Navigation to Results
Summary
CHAPTER 13 Integrating Google Maps
Google Maps Features
Geocoding
Displaying Maps
Controlling Maps
Planning Integration
Limitations of Google Maps
Browser Compatibility
Documentation and Resources
Creating a Google Maps API Key
Adding Location Storage Capabilities
Creating the Database Table
Creating the DatabaseObject_BlogPostLocation Class
Modifying Blog Posts to Load Locations
Creating Our First Map
Creating a New Blog Manager Controller Action
Displaying Your First Google Map
Managing Locations on the Map
Handling Location Management Ajax Requests
Creating the Address Lookup Form
Extending the BlogLocationManager JavaScript Class
Using BlogLocationManager
Displaying the Map on Users’ Public Blogs
Outputting Locations Using the Geo Microformat
Creating the BlogLocations Class
Updating the Blog Post Display Template
Summary
CHAPTER 14 Deployment and Maintenance
Application Logging
E-mailing Critical Errors to an Administrator
Using Application Logs
Site Error Handling
Objectives of Error Handling
Handling Predispatch Errors
Application Runtime Errors
Web Site Administration
Administrator Section Features
Implementing Administration
Application Deployment
Different Configurations for Different Servers
Deploying Application Files with Rsync
Backup and Restore
Exporting a Database
Importing a Database
Summary
Index