Not good. Only a third of the way through chapter 2, yes, chapter TWO and I'm seriously considering retiring this book. Things had not been working as they ought to (as he said they would) until I got my hands DIRTY. Dirty as in "retro-fitting" my server to use an OLD version of the Zend framework. Only then did things "start" to work. This author simply moves TOO FAST even for an intermediate programmer. Also, there are NO "workarounds" for common problems a user may run into. It's not good for difficult subjects like ZEND.
Author(s): Quentin Zervaas
Series: The expert's voice in Web development
Edition: 1st ed. 2008. Corr 2nd printing
Publisher: Apress; Distributed by Springer-Verlag New York
Year: 2008
Language: English
Pages: 592
City: Berkeley, CA :, New York, NY
Practical Web 2.0 Applications with PHP......Page 1
Contents at a Glance......Page 5
Contents......Page 7
About the Author......Page 17
About the Technical Reviewer......Page 18
Who This Book Is For......Page 19
How This Book Is Structured......Page 20
Contacting the Author......Page 22
Application Planning and Design......Page 23
Database Connectivity......Page 24
Main Home Page and User Home Page......Page 25
Web Site Search......Page 26
PHPDoc-Style Commenting......Page 27
Maintainability and Extensibility......Page 29
Summary......Page 30
Web Server Setup......Page 31
Installing the Apache HTTP Server......Page 32
Installing PHP 5.2.3......Page 33
Data Storage Directory......Page 34
Full Directory Structure......Page 35
Installing the Zend Framework......Page 36
Creating a Virtual Host in Linux......Page 37
Setting Up the Database......Page 39
Using the Model-View-Controller Pattern......Page 40
Separating Application Logic from Presentation Logic......Page 41
Directing All Requests to index.php......Page 43
Introduction to the Zend_Controller Class......Page 44
How Requests Work with Zend_Controller......Page 45
Creating the IndexController......Page 47
Defining Application Settings......Page 49
Connecting to the Database......Page 51
The Smarty Template Engine......Page 52
Using a Metalanguage for Templates......Page 55
Downloading and Installing Smarty......Page 56
Automatic View Rendering with Zend_Controller......Page 58
Integrating Smarty with the Web Site Controllers......Page 61
Adding Logging Capabilities......Page 63
Writing to the Log File......Page 65
Summary......Page 66
Creating the User Database Table......Page 67
Timestamps......Page 69
User Profiles......Page 70
Introduction to Zend_Auth......Page 71
Instantiating Zend_Auth......Page 72
Authenticating with Zend_Auth......Page 74
Introduction to Zend_Acl......Page 76
A Zend_Acl Example......Page 77
Combining Zend_Auth, Zend_Acl, and Zend_ Controller_Front......Page 79
Managing User Records with DatabaseObject......Page 83
The DatabaseObject_User Class......Page 84
Using DatabaseObject_User......Page 86
Managing User Profiles......Page 88
Using Profile_User......Page 89
Integrating Profile_User with DatabaseObject_User......Page 91
Summary......Page 94
Adding User Registration to the Application......Page 95
The Initial FormProcessor_UserRegistration Class......Page 96
Adding Username Validation to FormProcessor_UserRegistration......Page 99
Validating the User’s Name......Page 100
Validating the User’s E-mail Address......Page 101
The Complete FormProcessor_UserRegistration Class......Page 102
The Initial AccountController Class......Page 103
Developing the Templates......Page 104
Handling the Form Submission......Page 108
Adding CAPTCHA to the User Registration Form......Page 110
CAPTCHA and Accessibility......Page 111
Generating a CAPTCHA Image......Page 112
Adding the CAPTCHA Image to the Registration Form......Page 115
Adding E-mail Functionality......Page 117
Implementing Account Login and Logout......Page 122
Creating the Login Template......Page 123
Adding the Account Controller Login Action......Page 124
Logging Successful and Failed Login Attempts......Page 127
Logging Users Out of Their Accounts......Page 129
Dealing with Forgotten Passwords......Page 130
Resetting a User’s Password......Page 131
Functions for Resetting Passwords......Page 134
Creating the Account Home Page......Page 138
Updating the Web Site Navigation......Page 140
Allowing Users to Update Their Details......Page 142
Summary......Page 143
Downloading and Installing Prototype......Page 145
The $() Function......Page 146
The getElementsByClassName() Function......Page 147
The $$() Function......Page 150
Prototype’s Hash Object......Page 151
Other Element Extensions......Page 152
Managing Classes of Elements......Page 153
Manipulating Strings with Prototype......Page 155
Ajax Request Options......Page 156
Ajax Callback Functions......Page 157
JavaScript Object Notation (JSON)......Page 160
An Ajax.Request Example......Page 162
Handling XML Data from an Ajax Request......Page 163
Handling XML That Isn’t Well Formed......Page 164
The Complete Ajax.Request Example......Page 165
Observing an Event......Page 167
Finding Out Which Element an Event Occurred On......Page 168
Creating a Class......Page 169
Binding Function Calls to Objects......Page 170
Prebuilt Controls......Page 173
Visual Effects......Page 174
JavaScript Unit Testing......Page 175
Combining Prototype, Scriptaculous, Ajax, and PHP in a Useful Example......Page 176
Creating the Main HTML Page: index.php......Page 178
Styling the Application: styles.css......Page 179
Creating and Populating the Database: schema.sql......Page 180
Connecting to the Database......Page 181
Processing and Saving the List Order......Page 182
Processing Ajax Requests on the Server Side: processor.php......Page 183
Handling the Load Action......Page 184
Initializing the Application with init()......Page 185
Updating the Status Container with setStatus()......Page 186
Loading the List of Items with loadItems()......Page 187
Handling the Response from the Ajax Request in loadItems()......Page 188
Handling a Change to the List Order with saveItemOrder()......Page 189
Handling the Response from the Ajax Request in saveItemOrder()......Page 190
Summary......Page 191
Adding Page Titles and Breadcrumbs......Page 193
The Breadcrumbs Class......Page 194
Generating URLs......Page 196
Generating URLs in Controller Actions......Page 197
Generating URLs in Smarty Templates......Page 198
Setting the Title and Trail for Each Controller Action......Page 200
Creating a Smarty Plug-In to Output Breadcrumbs......Page 202
Displaying the Page Title......Page 204
Integrating the Design into the Application......Page 205
Creating the Static HTML......Page 206
Moving the HTML Markup into Smarty Templates......Page 210
Modifying header.tpl......Page 211
Modifying footer.tpl......Page 212
Highlighting the Active Navigation Section......Page 213
Specifying Media Types and Loading the CSS File......Page 214
Creating the Three-Column Layout......Page 215
Styling the Tabbed Navigation Bar......Page 217
Styling the Page Content......Page 219
Creating a Print-Only Style Sheet......Page 220
Modifying the Screen Style Sheet......Page 221
The Full Application Style Sheet......Page 223
Styling the Application Web Forms......Page 226
Loading Prototype and Scriptaculous......Page 229
Implementing Client-Side Form Validation......Page 230
Modifying the Form Processor......Page 231
Modifying the Registration Controller Action......Page 232
Returning Form Errors Using JSON......Page 233
Creating the JavaScript Form Validator......Page 234
Hiding Form Errors......Page 235
Handling the Form Submission......Page 236
Handling the Form Validation Response......Page 237
Loading the UserRegistrationForm Class......Page 238
Summary......Page 239
Creating the Database Tables......Page 241
Creating the DatabaseObject_BlogPost Class......Page 243
Extending the Application Permissions......Page 245
The BlogmanagerController Actions......Page 247
Linking to Blog Manager......Page 248
Creating the Blog Post Submission Form Template......Page 250
Instantiating FormProcessor_BlogPost in editAction()......Page 253
Implementing the FormProcessor_BlogPost Class......Page 255
Generating a Permanent Link to a Blog Post......Page 262
Filtering Submitted HTML......Page 265
Why Filter Embedded JavaScript?......Page 266
Implementing the cleanHtml() Method......Page 267
Creating a New Blog Post......Page 269
Previewing Blog Posts......Page 270
Implementing the Preview Template......Page 271
Requesting Confirmation for User Actions......Page 274
Completing setstatusAction()......Page 276
Notifying the User......Page 278
Adding FlashMessenger to CustomControllerAction......Page 279
Writing Messages to FlashMessenger......Page 280
Outputting FlashMessenger Messages on the Web Site......Page 281
Summary......Page 284
Listing Blog Posts on the Blog Manager Index......Page 287
Creating the _GetBaseQuery() Method......Page 288
Creating the GetPosts() Function......Page 291
Retrieving a Monthly Summary of Posts......Page 294
Assigning Recent Posts and the Monthly Summary to the Template......Page 296
Displaying Recent Posts in the Template......Page 298
Displaying the Monthly Summary......Page 301
Calling the Smarty Plug-in in the Side Columns......Page 302
Ajaxing the Blog Monthly Summary......Page 305
Creating the Ajax Request Output......Page 306
The BlogMonthlySummary JavaScript Class......Page 307
Notifying the User About the Content Update......Page 309
Managing Message Containers......Page 310
Updating the Messages Container with BlogMonthlySummary......Page 311
Integrating a WYSIWYG Editor......Page 313
Downloading and Installing FCKeditor......Page 314
Configuring FCKeditor......Page 315
Loading FCKeditor in the Blog Editing Page......Page 316
Summary......Page 318
Controlling User Settings......Page 319
Presenting Customizable Settings to Users......Page 320
Processing Changes to User Settings......Page 321
Creating Default User Settings......Page 323
The UserController Class......Page 324
Creating a New Route......Page 325
Injecting the Route into the Router......Page 326
Dynamically Generating URLs for Custom Routes......Page 327
Generating Other Required Routes......Page 329
Handling Requests to UserController......Page 331
Displaying the Blog Index Page......Page 335
Implementing the indexAction() Method......Page 336
Displaying Blog Posts on the User Home Page......Page 337
Displaying Individual Blog Posts......Page 340
Implementing the viewAction() Method......Page 341
Displaying the Blog Post Details......Page 343
Generating Blog Archive Links......Page 344
Implementing the archiveAction() Method......Page 346
Loading Recent Public Posts......Page 348
Implementing the Application Home Page......Page 349
Loading Multiple User Records......Page 350
Retrieving the Latest Posts for the Home Page......Page 352
Creating the Application Home Page Template......Page 353
Summary......Page 355
Implementing Web 2.0 Features......Page 357
Implementing Tagging......Page 358
Managing Blog Post Tags......Page 362
Displaying a User’s Tags on Their Blog......Page 366
Retrieving Posts Based on a Tag......Page 369
Routing Requests to the Tag Space......Page 370
Handling Requests to the Tag Space......Page 371
Outputting the Tag Space......Page 372
Web Feeds......Page 373
Creating an Atom Feed with Zend_Feed......Page 374
Adding the Feed to UserController......Page 375
Linking to Your Feed......Page 377
Other Feed Options......Page 379
An Example of Using Microformats......Page 380
Why Use Microformats?......Page 382
The Firefox Operator Plug-In......Page 383
Microformatting Your Tags......Page 384
Allowing Users to Create a Public Profile......Page 385
Processing the User Details Form......Page 386
Displaying the User Profile Options......Page 387
Displaying a User’s Profile......Page 388
Summary......Page 391
A Dynamic Image Gallery......Page 393
Storing Uploaded Files......Page 394
Controlling Uploaded Images with DatabaseObject......Page 395
Uploading Files......Page 396
Adding the Form......Page 397
Specifying the File Input Type......Page 399
Setting the Maximum File Size......Page 400
Creating the Blog Manager Action Handler......Page 401
Creating the Image-Upload Form Processor......Page 402
Writing Files to the Filesystem......Page 406
Sending Images......Page 409
Creating Thumbnails......Page 412
Determining the Width and Height of the Thumbnail......Page 413
Determining the Input and Output Functions......Page 414
Generating the Thumbnail Filename......Page 415
Creating the Thumbnail......Page 416
Linking the Thumbnailer to the Image Action Handler......Page 417
Generating Image Filenames......Page 418
Updating imageAction() to Serve the Thumbnail......Page 420
Automatically Loading Blog Post Images......Page 421
Displaying Images on the Post Preview......Page 423
Deleting Blog Post Images......Page 425
Modifying the PHP Deletion Code......Page 428
Creating the BlogImageManager JavaScript Class......Page 429
Loading BlogImageManager in the Post Preview......Page 432
Deleting Images when Posts Are Deleted......Page 433
Saving the Order to Database......Page 434
Adding Sortable to BlogImageManager......Page 436
Extending the GetPosts() Function......Page 439
Displaying Thumbnail Images on the Blog Index......Page 440
Displaying Images on the Blog Details Page......Page 442
Displaying Larger Images with Lightbox......Page 444
Loading Lightbox on the Blog Details Page......Page 445
Linking the Blog Post Images to Lightbox......Page 446
Summary......Page 447
Introduction to Zend_Search_Lucene......Page 449
Comparison to MySQL Full-Text Indexing......Page 450
Zend_Search_Lucene Field Types......Page 451
Indexing Application Content......Page 452
Creating a New Zend_Search_Lucene_Document......Page 453
Retrieving the Index Location......Page 455
Building the Entire Index......Page 456
Indexing and Unindexing a Single Blog Post......Page 457
Adding a Single Blog Post to the Index......Page 458
Removing a Blog Post from the Index......Page 460
When a Post Is Created......Page 461
When a Post Is Deleted......Page 462
When a Post’s Tags Are Changed......Page 463
Adding the Search Form......Page 464
Handling Search Requests......Page 465
Querying the Search Index......Page 466
Displaying Search Results......Page 470
Types of Searches......Page 473
Providing Search Suggestions......Page 474
Creating an Action Handler to Return Search Results......Page 475
Retrieving Search Suggestions......Page 476
Displaying Search Suggestions......Page 479
Adding Mouse Navigation to Results......Page 482
Adding Keyboard Navigation to Results......Page 484
Summary......Page 489
Geocoding......Page 491
Map Controls......Page 492
Map Overlays......Page 493
Limitations of Google Maps......Page 495
Creating a Google Maps API Key......Page 496
Creating the DatabaseObject_BlogPostLocation Class......Page 497
Modifying Blog Posts to Load Locations......Page 499
Creating Our First Map......Page 500
Creating a New Blog Manager Controller Action......Page 501
Linking to the locationsAction() Function......Page 502
Loading the Google Maps API......Page 503
Beginning the BlogLocationManager JavaScript Class......Page 505
Loading BlogLocationManager......Page 507
Handling Location Management Ajax Requests......Page 509
The New Location Form Processor......Page 510
Creating the locationsManage Controller Action......Page 511
Creating the Address Lookup Form......Page 514
Required Methods......Page 515
Class Initialization......Page 517
The loadMap() Function......Page 518
The zoomAndCenterMap() Function......Page 519
Adding Locations with addMarkerToMap()......Page 520
Removing Markers Using removeMarkerFromMap()......Page 522
Displaying Saved Locations with loadLocationsSuccess()......Page 523
Handling the Add Location Form Submission......Page 524
Handling the Geocoder Response with createPoint()......Page 525
Saving New Coordinates for Dragged Locations......Page 527
Removing Markers from the Map......Page 528
Unloading the Map......Page 529
Using BlogLocationManager......Page 530
Outputting Locations Using the Geo Microformat......Page 531
Creating the BlogLocations Class......Page 533
Updating the Blog Post Display Template......Page 536
Summary......Page 538
Creating the Log Writer......Page 541
Adding the EmailLogger Writer to Zend_Log......Page 544
Using Application Logs......Page 545
Site Error Handling......Page 546
Notifying the User of Errors......Page 548
Catching Errors......Page 549
Application Runtime Errors......Page 553
Creating the Error Display Templates......Page 556
User Management......Page 557
Implementing Administration......Page 558
Creating the AdminController Class......Page 559
Different Configurations for Different Servers......Page 560
Telling the Bootstrap Which Configuration to Use......Page 561
Deploying Application Files with Rsync......Page 564
Exporting a Database......Page 565
Importing a Database......Page 566
Summary......Page 567
Index......Page 569