1. Trang chủ
  2. » Công Nghệ Thông Tin

Pro Zend Framework Techniques: Build A Full CMS Project potx

266 263 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 266
Dung lượng 10,42 MB

Nội dung

Zend Framework Techniques Companion eBook Available Pro Lyman this print for content only—size & color not accurate   CYAN   MAGENTA   YELLOW   BLACK )3".        BOOKs fOr prOfEssiONALs BY prOfEssiONALs ® Pro Zend Framework Techniques: Build a Full CMS Project Dear Reader, Zend Framework is a powerful platform for rapidly creating PHP applications. This book takes you step-by-step through the process of building a simple content management system with Zend Framework and MySQL. You start by installing Zend Server and the framework. Then you learn to leverage the framework’s components, which manage the system’s design, content, users, and navigation, among many other things. With the base system up and run- ning, you move on to advanced topics such as performance tuning and creating an API for your CMS. Each topic adds to your CMS, building a flexible, stable, and powerful platform on which you can base your real-world projects This book is born from my experience of developing sites using many of the current open source CMS systems. These were adequate for the sort of projects that the CMS developers originally had in mind. Working with cre- ative people, though, I found that even the simplest projects inevitably need some customization. Developing pure custom systems is an obvious solution, but it has a down- side. There are many moving parts in a secure web publishing system, and developing them all from scratch takes far too long, as well as distracting you from writing key business logic. Zend Framework gives you the best of both worlds, letting you build exactly the software you want without ever having to reinvent the wheel. Forrest Lyman THE APRESS ROADMAP Pro Zend Framework CMS Beginning Zend Framework Beginning PHP and MySQL US $46.99 Shelve in Programming / PHP User level: Intermediate–Advanced www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version )3".        trim = 7.5" x 9.25" spine = 0.59375" 264 page count Pro Zend Framework Techniques Build a Full CMS Project Forrest Lyman Preface by Wil Sinclair Project Lead, Zend Framework Guides you through the entire process of building a customized Content Management System using the many different aspects that Zend Framework offers ThE ExpErT’s VOiCE ®  iN php  The Zend Press Series Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Download at WoweBook.Com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com i Pro Zend Framework Techniques Build a Full CMS Project ■ ■ ■ Forrest Lyman The Zend Press Series Download at WoweBook.Com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com ii Pro Zend Framework Techniques: Build a Full CMS Project Copyright © 2009 by Forrest Lyman All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-1879-1 ISBN-13 (electronic): 978-1-4302-1880-7 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Tom Welsh Technical Reviewer: Adam DeFields Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Managers: Beth Christmas and Debra Kelly Copy Editor: Kim Wimpsett Compositor: v-prompt e-Services Indexer: BIM Indexing & Proofreading Services Artist: April Milne Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders- ny@springer-sbm.com, or visit http://www.springeronline.com. For information on translations, please e-mail info@apress.com, or visit http://www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at http://www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com. Download at WoweBook.Com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com iii I would like to dedicate this book to Johnny, who first introduced me to the magic that can lie within the covers of a book. Download at WoweBook.Com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com iv Contents at a Glance ■Foreword viii ■About the Authors ix ■Acknowledgments x ■Introduction xi ■Chapter 1: Getting Started 1 ■Chapter 2: Designing Your Site 17 ■Chapter 3: Building and Processing Web Forms with Zend_Form 37 ■Chapter 4: Managing Data with Zend Framework 53 ■Chapter 5: Working with CMS Data 77 ■Chapter 6: Managing Content 95 ■Chapter 7: Creating the Site Navigation 113 ■Chapter 8: Handling Security in a Zend Framework Project 145 ■Chapter 9: Searching and Sharing Content 171 ■Chapter 10: Extending Your CMS 189 ■Chapter 11: Advanced Topics 203 ■Chapter 12: Installing and Managing a Site with Your CMS 221 ■Index 231 Download at WoweBook.Com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com v Contents ■Foreword xvii ■About the Authors xviii ■Acknowledgments xix ■Introduction xx ■Chapter 1: Getting Started 1 Introducing Zend Framework MVC Implementation 1 The Controller: Zend_Controller_Front 2 The Model: Zend_Db 2 The View: Zend_View 3 Setting Up Your Development Environment 3 Installing Zend Server CE 3 Doing Rapid Application Development with the Zend Command-Line Tool 5 Creating Your Project 6 Building a Project with the Zend Tool Framework 6 Testing Your New Project 7 Exploring the Anatomy of Your Project 8 The public Folder 9 Redirecting the Request with .htaccess 9 The Index File 9 Additional Public Folders 10 The library Folder 10 The application Folder 10 Zend_Application 10 The Bootstrap Class 11 Application Configuration 11 Action Controllers 12 Views 12 Error Handling 13 Summary 16 Download at WoweBook.Com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com ■ CONTENTS vi ■Chapter 2: Designing Your Site 17 Rendering the Presentation Layer with Zend_View 17 View Scripts 17 View Helpers 17 Rendering the Presentation Layer with Zend_Layout 18 Using Zend_Layout on Its Own 18 Zend_Layout MVC 18 Three-Step Views 18 Designing the Interface 19 Organizing the Interface Components 19 Mocking It Up 21 Creating the Base HTML Page 22 Testing Your Design 25 Creating the Layout 26 Creating the Layout 26 Adding the Dynamic Head with Zend_View’s Placeholders 27 Adding the Dynamic Content to Your Layout 28 Rendering the Controller Response with Zend_Layout 28 Configuring Your Application to Use the Layout 29 Testing Your New Layout 29 Implementing the Skin 30 What Goes in a Skin? 30 Creating the Blues Skin 31 The skin.xml File 31 The Style Sheets 31 Building a View Helper to Render the Skin 33 Using the loadSkin Helper 34 Testing the Skin 35 Summary 36 ■Chapter 3: Building and Processing Web Forms with Zend_Form 37 The Anatomy of a Zend Framework Form 37 Rendering Forms 38 Processing a Form 38 Form Elements 38 Initial Elements 38 Zend_Form_Element_Button 38 Zend_Form_Element_Captcha 39 Download at WoweBook.Com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com ■ CONTENTS vii Zend_Form_Element_Checkbox 39 Zend_Form_Element_File 39 Zend_Form_Element_Hidden 39 Zend_Form_Element_Hash 39 Zend_Form_Element_Image 39 Zend_Form_Element_MultiCheckbox 39 Zend_Form_Element_Multiselect 39 Zend_Form_Element_Password 39 Zend_Form_Element_Radio 40 Zend_Form_Element_Reset 40 Zend_Form_Element_Select 40 Zend_Form_Element_Submit 40 Zend_Form_Element_Text 40 Zend_Form_Element_Textarea 40 Custom Form Elements 40 Creating a Page Form 40 Getting Started 41 Creating the Form 41 Adding Controls to the Form 42 The Author Text Control 43 The E-mail Text Control 43 The Date Text Control 44 The URL Text Control 44 The Description Text Area Control 44 The Priority Select Control 45 The Status Select Control 45 The Submit Button 46 Rendering the Form 46 Processing the Form 48 Styling the Form 49 Summary 52 ■Chapter 4: Managing Data with Zend Framework 53 Setting Up the Database 53 Creating the CMS Database 53 Configuring the Database Connection 53 Creating the bugs Table 54 Exploring the Zend Framework Models 55 Download at WoweBook.Com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com ■ CONTENTS viii Learning About the Models 56 Creating the Bug Model 57 Working with Bugs 57 Submitting a New Bug 57 Creating the createBug() Method 57 Updating the Bug Controller’s Submit Action 58 Viewing All the Current Bugs 59 Creating the fetchBugs() Method 59 Adding the List Action to the Bug Controller 60 Creating the List View 60 Filtering and Sorting the Bug Reports 62 Updating the fetchBugs() Method 63 Creating the Form to Filter and Sort the Bugs 63 Loading and Rendering the Filter Form 64 Processing the Filters and Sort Criteria 65 Limiting and Paginating Bug Reports Using Zend_Paginator 66 Updating the fetchBugs() Method to Return a Zend_Paginator Adapter 66 Refactoring the Bug Controller listAction() to Load the Paginator 67 Rendering the Bug Reports Using the Paginator 68 Updating a Bug 71 Updating the Bug Report Form 71 Creating the Edit Action 71 Creating the Edit View 72 Updating the Bug Record 72 Deleting a Bug 73 Adding the Delete Method to the Bug Model 74 Creating the Bug Controller Delete Action 74 Summary 75 ■Chapter 5: Working with CMS Data 77 Exploring the Data Structure 77 Traditional CMS Data Structures 77 Abstract Data Structures 77 Designing a Database That Can Grow with Your System 78 Implementing the Data Management System 79 Managing Content Nodes 80 Creating the content_nodes Table 80 Creating the ContentNode Model Class 80 Download at WoweBook.Com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com [...]... collecting and returning the responses from the controller actions The Model: Zend_ Db A web application can serve data from many sources, but the most common source is a database Zend_ Db provides a SQL database interface for ZF A number of adapters for different database systems are available that provide an abstraction layer to these databases This abstraction layer enables you to use a common set... for a range of different database systems Zend_ Db_Table, which is the class that you will use to create your models, provides an objectoriented interface to these database tables It implements the Table Data Gateway pattern This pattern manages all the SQL for common database functions This is a more generic approach to database abstraction, as opposed to other ORM systems that map data objects and... fun — as possible while promoting best practices and providing an extensible framework for complex applications Content management systems are a particularly important class of applications — after all, serving content is what the web does best As the project lead of the Digitalus CMS project, a commercial CMS built on Zend Framework, Forrest Lyman is particularly well-qualified to guide the reader... default Zend Server installation, this will be ~/Apache2/htdocs You create a new project using the create project command Follow this command with the name of your project, which in this case will be zf _cms Run this command, and the Zend Tool Framework will build the base project, as in Figure 1-3 Figure 1-3 Creating a project with the Zend Tool Framework 6 Download at WoweBook.Com Simpo PDF Merge and... their relationships to a relational database It also includes an implementation of the Row Data Gateway pattern, which creates data objects that provide access to all the underlying information in a database row 2 Download at WoweBook.Com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com CHAPTER 1 ■ GETTING STARTED The View: Zend_ View Zend_ View is a lightweight class that provides... application • Data: The model handles managing the application data • Presentation: The view handles rendering the dynamic pages ■ Note There are a number of differing opinions regarding the structure of an MVC application The approach I just described is referred to as the fat controller approach This pattern is rapidly becoming the standard for web application development, because this clean separation... application/controllers path as the path to the controllers As you build your CMS, you will add many more resources to the Bootstrap class, such as the database connection, but for now this is a very simple class that leverages the base Zend_ Application_Bootstrap_Bootstrap functionality Listing 1-6 The Bootstrap Class in application/Bootstrap.php .  BOOKs fOr prOfEssiONALs BY prOfEssiONALs ® Pro Zend Framework Techniques: Build a Full CMS Project Dear Reader, Zend Framework is a powerful platform for rapidly creating PHP applications. This. 264 page count Pro Zend Framework Techniques Build a Full CMS Project Forrest Lyman Preface by Wil Sinclair Project Lead, Zend Framework Guides you through the entire process of building a customized. Managing Data with Zend Framework 53 ■Chapter 5: Working with CMS Data 77 ■Chapter 6: Managing Content 95 ■Chapter 7: Creating the Site Navigation 113 ■Chapter 8: Handling Security in a Zend Framework

Ngày đăng: 27/06/2014, 00:20