Upload
pool-pg
View
76
Download
15
Embed Size (px)
Citation preview
Zend FrameworkManual en Espaol
Traduccin al 38.7% - Actualizado el 14 de Noviembre del 2009 - Revisin Nro.471
Para obtener la versin ms actual del manual ir a http://manual.zfdes.com
Algunos de los documentos publicados an no han sido revisados y esposible que contenga errores. Si deseas puedes enviarnos un mensaje a
[email protected] con sugerencias y/o para informarnos de algn error.
ColaboradoresPedro Boda
Kattia NinahuancaJavier Martinez
Benjamn GonzalesActualmente presentamos a los colaboradores ms activos en la portada del manual. Esto no
quiere decir que no existan ms colaboradores que tambin trabajan en el manual o que hayanayudado de manera activa en un pasado. Existen tambin muchas personas que ayudan con sus
observaciones a los cuales le estamos infinitamente agradecidos. Si deseas unirte al grupo de traductorespuedes enviarnos un mail a [email protected] solicitando tu inclusin
Compilado porBenjamn Gonzales
(http://www.codigolinea.com)
Grupo de Traduccin porWeb (http://zfdes.com)
Lista de Discucin (http://groups.google.com.pe/group/zendframeworkspanish?hl=es)SVN (http://code.google.com/p/zendframework-hispano/)
Gua de Referencia del Programador: Zend FrameworkPublished 2009-11-15Copyright 2005-2009 Zend Technologies Inc. (http://www.zend.com)
iii
ndice de Contenidos1. Introduccin a Zend Framework ........................................................................................................ 1
Descripcin general .................................................................................................................... 1Instalacin ................................................................................................................................ 1
2. Zend_Acl ...................................................................................................................................... 3Introduccin .............................................................................................................................. 3
Acerca de los Recursos ....................................................................................................... 3Acerca de las Reglas ........................................................................................................... 3Creando las Listas de Control de Acceso (ACL) ...................................................................... 4Registrando Roles ............................................................................................................... 5Definiendo Controles de Acceso ........................................................................................... 6Consultando la ACL ........................................................................................................... 7
Perfeccionamiento de los controles de acceso .................................................................................. 7Definir mejor los controles de acceso ..................................................................................... 7Eliminar los controles de acceso ........................................................................................... 9
Uso Avanzado .......................................................................................................................... 10Almacenamiento Permanente de los Datos ACL ..................................................................... 10Escribiendo reglas condicionales ACL con aserciones ........................................................... 10
3. Zend_Amf ................................................................................................................................... 13Introduccin ............................................................................................................................. 13Zend_Amf_Server ..................................................................................................................... 13
Conectndose al Servidor desde Flex .................................................................................... 15Manejo de errores ............................................................................................................. 16Respuestas de AMF .......................................................................................................... 17Objetos tipados ................................................................................................................. 17Recursos .......................................................................................................................... 19Conectndose al Servidor desde Flash .................................................................................. 19Authentication .................................................................................................................. 21
4. Zend_Application .......................................................................................................................... 23Introduccin ............................................................................................................................. 23Inicio rpido con Zend_Application ............................................................................................. 23
Usando Zend_Tool ............................................................................................................ 23Aadir Zend_Application a su aplicacin .............................................................................. 25Agregando y Creando Recursos ........................................................................................... 27Prximos pasos con Zend_Application ................................................................................. 28
Teora de Operacin .................................................................................................................. 28Bootstrapping ................................................................................................................... 29Plugins de Recursos .......................................................................................................... 34
Ejemplos ................................................................................................................................. 36Funcionalidad Bsica ................................................................................................................. 39
Zend_Application .............................................................................................................. 39Zend_Application_Bootstrap_Bootstrapper ............................................................................ 42Zend_Application_Bootstrap_ResourceBootstrapper ................................................................ 43Zend_Application_Bootstrap_BootstrapAbstract ..................................................................... 44Zend_Application_Bootstrap_Bootstrap ................................................................................ 47Zend_Application_Resource_Resource .................................................................................. 47Zend_Application_Resource_ResourceAbstract ...................................................................... 47
Plugins de Recursos Disponibles ................................................................................................. 49Zend_Application_Resource_Db .......................................................................................... 49Zend_Application_Resource_Frontcontroller .......................................................................... 50Zend_Application_Resource_Layout ..................................................................................... 51Zend_Application_Resource_Modules .................................................................................. 52
Gua de Referencia del Programador
iv
Zend_Application_Resource_Navigation ............................................................................... 53Zend_Application_Resource_Router ..................................................................................... 54Zend_Application_Resource_Session .................................................................................... 54Zend_Application_Resource_View ....................................................................................... 55
5. Zend_Auth ................................................................................................................................... 57Introduccin ............................................................................................................................. 57
Adaptadores ..................................................................................................................... 57Resultados ....................................................................................................................... 58Persistencia de Identidad .................................................................................................... 59Uso ................................................................................................................................ 61
Tabla de base de datos de autenticacin ........................................................................................ 63Introduccin ..................................................................................................................... 63Advanced Usage: Manteniendo el resultado del Objeto DbTable ................................................ 65Ejemplo de Uso Avanzado ................................................................................................. 66
Autenticacin "Digest" ............................................................................................................... 67Introduccin ..................................................................................................................... 67Detalles Especficos .......................................................................................................... 68Identidad ......................................................................................................................... 68
Adaptador de Autenticacin HTTP .............................................................................................. 68Introduccin ..................................................................................................................... 68Descripcin del diseo ....................................................................................................... 69Opciones de Configuracin ................................................................................................. 69Resolvers ......................................................................................................................... 70Uso Bsico ...................................................................................................................... 70
LDAP Authentication ................................................................................................................ 71Introduction ..................................................................................................................... 71Usage ............................................................................................................................. 72The API .......................................................................................................................... 73Server Options ................................................................................................................. 75Collecting Debugging Messages .......................................................................................... 77Common Options for Specific Servers .................................................................................. 78
Autenticacin con Open ID ....................................................................................................... 79Introduccin ..................................................................................................................... 79Caractersticas .................................................................................................................. 80
6. Zend_Cache ................................................................................................................................. 83Introduccin ............................................................................................................................. 83The Theory of Caching .............................................................................................................. 85
The Zend_Cache Factory Method ........................................................................................ 85Tagging Records ............................................................................................................... 86Cleaning the Cache ........................................................................................................... 86
Zend_Cache Frontends ............................................................................................................... 87Zend_Cache_Core ............................................................................................................. 87Zend_Cache_Frontend_Output ............................................................................................ 90Zend_Cache_Frontend_Function .......................................................................................... 91Zend_Cache_Frontend_Class .............................................................................................. 91Zend_Cache_Frontend_File ................................................................................................ 93Zend_Cache_Frontend_Page ............................................................................................... 94
Zend_Cache Backends ............................................................................................................... 98Zend_Cache_Backend_File ................................................................................................. 98Zend_Cache_Backend_Sqlite .............................................................................................. 99Zend_Cache_Backend_Memcached .................................................................................... 100Zend_Cache_Backend_Apc ............................................................................................... 101Zend_Cache_Backend_Xcache .......................................................................................... 101Zend_Cache_Backend_ZendPlatform .................................................................................. 101
Gua de Referencia del Programador
v
Zend_Cache_Backend_TwoLevels ..................................................................................... 101Zend_Cache_Backend_ZendServer_Disk and Zend_Cache_Backend_ZendServer_ShMem ........... 103
7. Zend_Captcha ............................................................................................................................. 105Introduccin ........................................................................................................................... 105Captcha Operation ................................................................................................................... 105CAPTCHA Adapters ............................................................................................................... 106
Zend_Captcha_Word ....................................................................................................... 106Zend_Captcha_Dumb ....................................................................................................... 107Zend_Captcha_Figlet ....................................................................................................... 107Zend_Captcha_Image ....................................................................................................... 107Zend_Captcha_ReCaptcha ................................................................................................ 108
8. Zend_CodeGenerator .................................................................................................................... 109Introduccin ........................................................................................................................... 109
Teora de Operacin ........................................................................................................ 109Ejemplos de Zend_CodeGenerator ............................................................................................. 111Referencias de Zend_CodeGenerator .......................................................................................... 118
Clases Abstractas e Interfaces ............................................................................................ 118Clases Concretas de CodeGenerator ................................................................................... 119
9. Zend_Config ............................................................................................................................... 125Introduccin ........................................................................................................................... 125Aspectos Tericos ................................................................................................................... 126Zend_Config_Ini ..................................................................................................................... 127Zend_Config_Xml ................................................................................................................... 129
10. Zend_Config_Writer ................................................................................................................... 133Zend_Config_Writer ................................................................................................................ 133
11. Zend_Console_Getopt ................................................................................................................. 135Introduction ............................................................................................................................ 135Declaring Getopt Rules ............................................................................................................ 136
Declaring Options with the Short Syntax ............................................................................. 136Declaring Options with the Long Syntax ............................................................................. 136
Fetching Options and Arguments ............................................................................................... 137Handling Getopt Exceptions .............................................................................................. 137Fetching Options by Name ............................................................................................... 137Reporting Options ........................................................................................................... 138Fetching Non-option Arguments ........................................................................................ 138
Configuring Zend_Console_Getopt ............................................................................................. 139Adding Option Rules ....................................................................................................... 139Adding Help Messages .................................................................................................... 139Adding Option Aliases ..................................................................................................... 139Adding Argument Lists .................................................................................................... 140Adding Configuration ...................................................................................................... 140
12. Zend_Controller ......................................................................................................................... 143Inicio rpido a Zend_Controller ................................................................................................. 143
Introduccin ................................................................................................................... 143Quick Start .................................................................................................................... 143
Conceptos Bsicos de Zend_Controller ....................................................................................... 146El Front Controller .................................................................................................................. 149
Introduccin ................................................................................................................... 149Mtodos Bsicos ............................................................................................................. 150Mtodos Accessor Ambientales ......................................................................................... 151Parmetros de Front Controller .......................................................................................... 152Extendiendo el Front Controller ......................................................................................... 153
La solicitud del Objeto ............................................................................................................. 154Introduccin ................................................................................................................... 154
Gua de Referencia del Programador
vi
Solicitud HTTP ............................................................................................................... 154Subclassing the Request Object ......................................................................................... 157
El Router Standard .................................................................................................................. 158Introduccin ................................................................................................................... 158Usando un Router ........................................................................................................... 160Operacin Bsica del Rewrite Router .................................................................................. 160Routes por Defecto .......................................................................................................... 161URL Base y Subdirectorios ............................................................................................... 163Parmetros Globales ........................................................................................................ 163Tipos de Route ............................................................................................................... 163Usando Zend_Config con RewriteRouter ......................................................................... 174Subclassing del Router ..................................................................................................... 175
El Despachador ....................................................................................................................... 176Introduccin ................................................................................................................... 176Subclaseando el Despachador ............................................................................................ 177
Controladores de Accin .......................................................................................................... 180Introduccin ................................................................................................................... 180Inicializacin de Objectos ................................................................................................. 182Ganchos de Pre- and Post-Despacho ................................................................................... 182Accessors (Accededores) .................................................................................................. 182Integracin de Vistas ....................................................................................................... 183Mtodos Utilitarios .......................................................................................................... 185Controladores de Accin y haciendo Subclases ..................................................................... 185
Action Helpers ....................................................................................................................... 187Introduction .................................................................................................................... 187Helper Initialization ......................................................................................................... 187The Helper Broker .......................................................................................................... 188Built-in Action Helpers .................................................................................................... 189Writing Your Own Helpers ............................................................................................... 217
The Response Object ............................................................................................................... 217Usage ............................................................................................................................ 217Manipulating Headers ...................................................................................................... 219Named Segments ............................................................................................................ 220Testing for Exceptions in the Response Object ..................................................................... 221Subclassing the Response Object ....................................................................................... 222
Plugins .................................................................................................................................. 222Introduction .................................................................................................................... 222Writing Plugins ............................................................................................................... 222Using Plugins ................................................................................................................. 223Retrieving and Manipulating Plugins .................................................................................. 224Plugins Included in the Standard Distribution ....................................................................... 224
Using a Conventional Modular Directory Structure ....................................................................... 229Introduction .................................................................................................................... 229Specifying Module Controller Directories ............................................................................ 230Routing to Modules ......................................................................................................... 231Module or Global Default Controller .................................................................................. 231
Excepciones MVC ................................................................................................................... 232Introduccin ................................................................................................................... 232Manejando las Excepciones .............................................................................................. 232Excepciones MVC que Usted Pueda Encontrar ..................................................................... 233
13. Zend_Currency .......................................................................................................................... 237Introduction to Zend_Currency .................................................................................................. 237
Why use Zend_Currency? ................................................................................................. 237How to Work with Currencies ................................................................................................... 237
Gua de Referencia del Programador
vii
Creating and Output String from a Currency ........................................................................ 239Changing the Format of a Currency .................................................................................... 239Reference Methods for Zend_Currency ............................................................................... 241Settings new default values ............................................................................................... 242Zend_Currency Performance Optimization ........................................................................... 242
14. Zend_Date ................................................................................................................................ 245Introduccin ........................................................................................................................... 245
Asigne Siempre una Zona Horaria por Defecto ..................................................................... 245Por Qu Usar Zend_Date? ............................................................................................... 245
Theory of Operation ................................................................................................................ 246Internals ........................................................................................................................ 246
Basic Methods ........................................................................................................................ 247Current Date .................................................................................................................. 247Zend_Date by Ejemplo .................................................................................................... 247
Zend_Date API Overview ......................................................................................................... 249Opciones Zend_Date ........................................................................................................ 249Working with Date Values ................................................................................................ 250Basic Zend_Date Operations Common to Many Date Parts ..................................................... 251Comparing Dates ............................................................................................................ 254Getting Dates and Date Parts ............................................................................................ 255Working with Fractions of Seconds .................................................................................... 256Sunrise / Sunset .............................................................................................................. 256
Creation of Dates .................................................................................................................... 257Create the Actual Date ..................................................................................................... 257Create a Date from Database ............................................................................................. 257Create Dates from an Array .............................................................................................. 258
Constants for General Date Functions ......................................................................................... 258Using Constants .............................................................................................................. 259List of All Constants ....................................................................................................... 259Self-Defined OUTPUT Formats with ISO ............................................................................ 263Self-Defined OUTPUT Formats Using PHP's date() Format Specifiers ...................................... 266
Working Ejemplos ................................................................................................................... 268Checking Dates ............................................................................................................... 268Sunrise and Sunset .......................................................................................................... 269Time Zones .................................................................................................................... 271
15. Zend_Db .................................................................................................................................. 273Zend_Db_Adapter ................................................................................................................... 273
Conexin a una Base de Datos utilizando un Adaptador ....................................................... 273La base de datos de ejemplo ............................................................................................. 278Reading Query Results ..................................................................................................... 279Writing Changes to the Database ....................................................................................... 282Quoting Values and Identifiers .......................................................................................... 285Controlling Database Transactions ..................................................................................... 288Listing and Describing Tables ........................................................................................... 289Closing a Connection ....................................................................................................... 290Running Other Database Statements ................................................................................... 291Retrieving Server Version ................................................................................................. 291Notes on Specific Adapters ............................................................................................... 291
Zend_Db_Statement ................................................................................................................. 294Creando una Declaracin .................................................................................................. 294Ejecutando la declaracin ................................................................................................. 295Extrayendo Resultados de una declaracin SELECT .............................................................. 295
Zend_Db_Profiler .................................................................................................................... 298Introduccin ................................................................................................................... 298
Gua de Referencia del Programador
viii
Usando el Perfilador ........................................................................................................ 299Uso avanzado del Perfilador .............................................................................................. 300Perfiladores Especializados ............................................................................................... 302
Zend_Db_Select ...................................................................................................................... 303Descripcin del Objeto Select ............................................................................................ 303Creando un Objeto Select ................................................................................................. 303Construyendo consultas Select ........................................................................................... 304Ejecutando consultas Select .............................................................................................. 316Otros Mtodos ................................................................................................................ 317
Zend_Db_Table ...................................................................................................................... 319Introduction .................................................................................................................... 319Defining a Table Class ..................................................................................................... 319Creating an Instance of a Table ......................................................................................... 322Inserting Rows to a Table ................................................................................................. 323Updating Rows in a Table ................................................................................................ 325Deleting Rows from a Table ............................................................................................. 326Finding Rows by Primary Key .......................................................................................... 326Querying for a Set of Rows .............................................................................................. 327Querying for a Single Row ............................................................................................... 331Retrieving Table Metadata Information ............................................................................... 331Caching Table Metadata ................................................................................................... 332Customizing and Extending a Table Class ........................................................................... 334
Zend_Db_Table_Row .............................................................................................................. 337Introduction .................................................................................................................... 337Fetching a Row .............................................................................................................. 337Writing rows to the database ............................................................................................. 339Serializing and unserializing rows ...................................................................................... 341Extending the Row class .................................................................................................. 342
Zend_Db_Table_Rowset ........................................................................................................... 345Introduction .................................................................................................................... 345Fetching a Rowset ........................................................................................................... 345Retrieving Rows from a Rowset ........................................................................................ 346Retrieving a Rowset as an Array ........................................................................................ 348Serializing and Unserializing a Rowset ............................................................................... 348Extending the Rowset class ............................................................................................... 349
Zend_Db_Table Relationships ................................................................................................... 350Introduction .................................................................................................................... 350Defining Relationships ..................................................................................................... 351Fetching a Dependent Rowset ........................................................................................... 353Fetching a Parent Row ..................................................................................................... 354Fetching a Rowset via a Many-to-many Relationship ............................................................. 356Cascading Write Operations .............................................................................................. 358
Zend_Db_Table_Definition ....................................................................................................... 360Introduction .................................................................................................................... 360Basic Usage ................................................................................................................... 360Advanced Usage ............................................................................................................. 361
16. Zend_Debug ............................................................................................................................. 363Mostrar informacin de variables(Dumping Variables) ................................................................... 363
17. Zend_Dojo ................................................................................................................................ 365Introduccin ........................................................................................................................... 365Zend_Dojo_Data: Envolturas de dojo.data ................................................................................... 365
Uso de Zend_Dojo_Data .................................................................................................. 365Agregando metadatos a sus contenedores ............................................................................ 367Casos Avanzados de Uso .................................................................................................. 367
Gua de Referencia del Programador
ix
Ayudantes de Dojo View ......................................................................................................... 369dojo() Ayudante de Vista .................................................................................................. 369Ayudantes de Vistas Especficos de Dijit ............................................................................. 374
Elementos y Decoradores de Dojo Form ..................................................................................... 387Decoradores de Forms Especficos de Dijit .......................................................................... 388Elementos de Formularios Dijit-Specific ............................................................................. 389Ejemplos de Dojo Form ................................................................................................... 405
Zend_Dojo build layer support .................................................................................................. 412Introduction .................................................................................................................... 412Generating Custom Module Layers with Zend_Dojo_BuildLayer ............................................. 413Generating Build Profiles with Zend_Dojo_BuildLayer .......................................................... 416
18. Zend_Dom ................................................................................................................................ 419Introduccin ........................................................................................................................... 419Zend_Dom_Query ................................................................................................................... 419
Theory of Operation ........................................................................................................ 419Methods Available .......................................................................................................... 420
19. Zend_Exception ......................................................................................................................... 423Using Exceptions .................................................................................................................... 423
20. Zend_Feed ................................................................................................................................ 425Introduction ............................................................................................................................ 425Importing Feeds ...................................................................................................................... 426
Custom feeds .................................................................................................................. 426Retrieving Feeds from Web Pages ............................................................................................. 431Consuming an RSS Feed .......................................................................................................... 431Consuming an Atom Feed ........................................................................................................ 432Consuming a Single Atom Entry ............................................................................................... 433Modifying Feed and Entry structures .......................................................................................... 434Custom Feed and Entry Classes ................................................................................................. 435Zend_Feed_Reader .................................................................................................................. 436
Introduction .................................................................................................................... 436Importing Feeds .............................................................................................................. 437Retrieving Underlying Feed and Entry Sources ..................................................................... 438Cache Support and Intelligent Requests ............................................................................... 439Locating Feed URIs from Websites .................................................................................... 440Retrieving Feed Information .............................................................................................. 441Retrieving Entry/Item Information ...................................................................................... 443Extending Feed and Entry APIs ......................................................................................... 445
21. Zend_File ................................................................................................................................. 451Zend_File_Transfer ................................................................................................................. 451
Supported Adapters for Zend_File_Transfer ......................................................................... 452Options for Zend_File_Transfer ......................................................................................... 452Checking Files ................................................................................................................ 452Additional File Informations ............................................................................................. 453Progress for file uploads ................................................................................................... 454
Validators for Zend_File_Transfer .............................................................................................. 456Using Validators with Zend_File_Transfer ........................................................................... 457Count Validator .............................................................................................................. 459Crc32 Validator .............................................................................................................. 460ExcludeExtension Validator .............................................................................................. 460ExcludeMimeType Validator ............................................................................................. 461Exists Validator .............................................................................................................. 461Extension Validator ......................................................................................................... 462FilesSize Validator .......................................................................................................... 463ImageSize Validator ........................................................................................................ 463
Gua de Referencia del Programador
x
IsCompressed Validator .................................................................................................... 464IsImage Validator ............................................................................................................ 465Hash Validator ................................................................................................................ 465Md5 Validator ................................................................................................................ 466MimeType Validator ........................................................................................................ 466NotExists Validator ......................................................................................................... 467Sha1 Validator ................................................................................................................ 468Size Validator ................................................................................................................. 468WordCount Validator ....................................................................................................... 469
Filters for Zend_File_Transfer ................................................................................................... 469Using filters with Zend_File_Transfer ................................................................................. 470Decrypt filter .................................................................................................................. 471Encrypt filter .................................................................................................................. 472LowerCase filter ............................................................................................................. 472Rename filter .................................................................................................................. 473UpperCase filter .............................................................................................................. 474
22. Zend_Filter ............................................................................................................................... 475Introduccin ........................................................................................................................... 475
Qu es un filtro? ........................................................................................................... 475Uso bsico de los filtros ................................................................................................... 475Usando el mtodo esttico staticFilter() .............................................................................. 476
Standard Filter Classes ............................................................................................................. 477Alnum ........................................................................................................................... 477Alpha ............................................................................................................................ 477BaseName ...................................................................................................................... 477Callback ........................................................................................................................ 477Compress and Decompress ............................................................................................... 478Decrypt ......................................................................................................................... 483Digits ............................................................................................................................ 485Dir ................................................................................................................................ 485Encrypt .......................................................................................................................... 485HtmlEntities ................................................................................................................... 488Int ................................................................................................................................ 488LocalizedToNormalized .................................................................................................... 488NormalizedToLocalized .................................................................................................... 490Null .............................................................................................................................. 492StripNewlines ................................................................................................................. 493RealPath ........................................................................................................................ 493StringToLower ................................................................................................................ 494StringToUpper ................................................................................................................ 494StringTrim ..................................................................................................................... 494StripTags ....................................................................................................................... 495
Filter Chains .......................................................................................................................... 495Writing Filters ........................................................................................................................ 495Zend_Filter_Input .................................................................................................................... 496
Declaring Filter and Validator Rules ................................................................................... 496Creating the Filter and Validator Processor .......................................................................... 497Retrieving Validated Fields and other Reports ...................................................................... 498Using Metacommands to Control Filter or Validator Rules ..................................................... 501Adding Filter Class Namespaces ........................................................................................ 506
Zend_Filter_Inflector ............................................................................................................... 507Operation ....................................................................................................................... 507Setting Paths To Alternate Filters ....................................................................................... 508Setting the Inflector Target ............................................................................................... 508
Gua de Referencia del Programador
xi
Inflection Rules .............................................................................................................. 509Utility Methods ............................................................................................................... 511Using Zend_Config with Zend_Filter_Inflector ..................................................................... 512
23. Zend_Form ............................................................................................................................... 513Zend_Form ............................................................................................................................ 513Inicio rpido a Zend_Form ....................................................................................................... 513
Creando un objeto formulario ............................................................................................ 513Aadir elementos al formulario ......................................................................................... 513Generar un formulario ...................................................................................................... 516Comprobar si un formulario es vlido ................................................................................. 517Obteniendo el estado de error ............................................................................................ 517Poniendo todo junto ........................................................................................................ 518Usando un objeto Zend_Config ......................................................................................... 519Conclusin ..................................................................................................................... 520
Creando elementos de formulario usando Zend_Form_Element ....................................................... 520Cargadores de Plugin ....................................................................................................... 521Filters ............................................................................................................................ 522Validadores .................................................................................................................... 524Decoradores ................................................................................................................... 528Metadatos y atributos ....................................................................................................... 531Elementos Estndar ......................................................................................................... 532Mtodos de Zend_Form_Element ....................................................................................... 532Configuracin ................................................................................................................. 535Elementos personalizados ................................................................................................. 536
Creando formularios usando Zend_Form ..................................................................................... 537Cargadores de Plugin ....................................................................................................... 538Elementos ...................................................................................................................... 538Grupos de visualizacin (display groups) ............................................................................. 542Subformularios ............................................................................................................... 546Metadatos y Atributos ...................................................................................................... 547Decoradores ................................................................................................................... 549Validacin ..................................................................................................................... 551Mtodos ........................................................................................................................ 552Configuracin ................................................................................................................. 555Formularios personalizados ............................................................................................... 557
Creando un personalizado marcado de formulario usando Zend_Form_Decorator ................................ 558Operacin ...................................................................................................................... 559Decoradores estndar ....................................................................................................... 559Decoradores personalizados .............................................................................................. 559Generando decoradores individuales ................................................................................... 562
Elementos Enviados en el Formulario Estandard de Zend Framework ............................................... 563Zend_Form_Element_Button ............................................................................................. 563Zend_Form_Element_Captcha ........................................................................................... 563Zend_Form_Element_Checkbox ......................................................................................... 564Zend_Form_Element_File ................................................................................................. 565Zend_Form_Element_Hidden ............................................................................................ 568Zend_Form_Element_Hash ............................................................................................... 568Zend_Form_Element_Image .............................................................................................. 568Zend_Form_Element_MultiCheckbox ................................................................................. 568Zend_Form_Element_Multiselect ....................................................................................... 569Zend_Form_Element_Password ......................................................................................... 570Zend_Form_Element_Radio .............................................................................................. 570Zend_Form_Element_Reset ............................................................................................... 570Zend_Form_Element_Select .............................................................................................. 570
Gua de Referencia del Programador
xii
Zend_Form_Element_Submit ............................................................................................ 571Zend_Form_Element_Text ................................................................................................ 571Zend_Form_Element_Textarea .......................................................................................... 571
Decoradores de Formulario (Form Decorartors) estndar contenidos en Zend Framework ...................... 571Zend_Form_Decorator_Callback ........................................................................................ 572Zend_Form_Decorator_Captcha ......................................................................................... 572Zend_Form_Decorator_Description .................................................................................... 572Zend_Form_Decorator_DtDdWrapper ................................................................................. 572Zend_Form_Decorator_Errors ............................................................................................ 573Zend_Form_Decorator_Fieldset ......................................................................................... 573Zend_Form_Decorator_File ............................................................................................... 573Zend_Form_Decorator_Form ............................................................................................. 573Zend_Form_Decorator_FormElements ................................................................................ 573Zend_Form_Decorator_FormErrors .................................................................................... 573Zend_Form_Decorator_HtmlTag ........................................................................................ 574Zend_Form_Decorator_Image ............................................................................................ 574Zend_Form_Decorator_Label ............................................................................................ 574Zend_Form_Decorator_PrepareElements ............................................................................. 575Zend_Form_Decorator_ViewHelper .................................................................................... 575Zend_Form_Decorator_ViewScript ..................................................................................... 575
Internacionalizacin de Zend_Form ............................................................................................ 577Inicializando I18n en formularios ....................................................................................... 577Objetivos estndar I18n .................................................................................................... 578
Uso avanzado de Zend_Form .................................................................................................... 578Notacin de array ............................................................................................................ 578Formularios Multi-Pgina ................................................................................................. 581
24. Zend_Gdata .............................................................................................................................. 591Introduction ............................................................................................................................ 591
Structure of Zend_Gdata .................................................................................................. 591Interacting with Google Services ....................................................................................... 592Obtaining instances of Zend_Gdata classes .......................................................................... 592Google Data Client Authentication ..................................................................................... 593Dependencies ................................................................................................................. 593Creating a new Gdata client .............................................................................................. 593Common Query Parameters .............................................................................................. 594Fetching a Feed .............................................................................................................. 595Working with Multi-page Feeds ......................................................................................... 595Working with Data in Feeds and Entries ............................................................................. 596Updating Entries ............................................................................................................. 596Posting Entries to Google Servers ...................................................................................... 596Deleting Entries on Google Servers .................................................................................... 597
Authenticating with AuthSub .................................................................................................... 597Creating an AuthSub authenticated Http Client ..................................................................... 598Revoking AuthSub authentication ...................................................................................... 599
Using the Book Search Data API ............................................................................................... 599Authenticating to the Book Search service ........................................................................... 599Searching for books ......................................................................................................... 599Using community features ................................................................................................ 601Book collections and My Library ....................................................................................... 603
Authenticating with ClientLogin ................................................................................................ 604Creating a ClientLogin authenticated Http Client .................................................................. 605Terminating a ClientLogin authenticated Http Client ............................................................. 605
Using Google Calendar ............................................................................................................ 605Connecting To The Calendar Service .................................................................................. 606
Gua de Referencia del Programador
xiii
Retrieving A Calendar List ............................................................................................... 608Retrieving Events ............................................................................................................ 609Creating Events .............................................................................................................. 611Modifying Events ............................................................................................................ 614Deleting Events .............................................................................................................. 615Accessing Event Comments .............................................................................................. 615
Using Google Documents List Data API ..................................................................................... 616Get a List of Documents .................................................................................................. 616Upload a Document ......................................................................................................... 616Searching the documents feed ........................................................................................... 617
Using Google Health ............................................................................................................... 618Connect To The Health Service ......................................................................................... 618Profile Feed ................................................................................................................... 621Profile List Feed ............................................................................................................. 622Sending Notices to the Register Feed .................................................................................. 623
Using Google Spreadsheets ....................................................................................................... 624Create a Spreadsheet ........................................................................................................ 624Get a List of Spreadsheets ................................................................................................ 624Get a List of Worksheets .................................................................................................. 624Interacting With List-based Feeds ...................................................................................... 625Interacting With Cell-based Feeds ...................................................................................... 627
Using Google Apps Provisioning ............................................................................................... 628Setting the current domain ................................................................................................ 628Interacting with users ....................................................................................................... 629Interacting with nicknames ............................................................................................... 632Interacting with email lists ................................................................................................ 634Interacting with email list recipients ................................................................................... 635Handling errors ............................................................................................................... 636
Using Google Base .................................................................................................................. 637Connect To The Base Service ........................................................................................... 637Retrieve Items ................................................................................................................ 640Insert, Update, and Delete Customer Items .......................................................................... 641
Using Picasa Web Albums ....................................................................................................... 643Connecting To The Service ............................................................................................... 643Understanding and Constructing Queries ............................................................................. 646Retrieving Feeds And Entries ............................................................................................ 647Creating Entries .............................................................................................................. 651Deleting Entries .............................................................................................................. 652
Using the YouTube Data API ................................................................................................... 654Authentication ................................................................................................................ 655Developer Keys and Client ID ........................................................................................... 655Retrieving public video feeds ............................................................................................ 655Retrieving video comments ............................................................................................... 657Retrieving playlist feeds ................................................................................................... 658Retrieving a list of a user's subscriptions ............................................................................. 658Retrieving a user's profile ................................................................................................. 659Uploading Videos to YouTube .......................................................................................... 659Browser-based upload ...................................................................................................... 661Checking upload status .................................................................................................... 662Other Functions .............................................................................................................. 662
Catching Gdata Exceptions ....................................................................................................... 66225. Zend_Http ................................................................................................................................ 665
Introduction ............................................................................................................................ 665Using Zend_Http_Client ................................................................................................... 665
Gua de Referencia del Programador
xiv
Configuration Parameters .................................................................................................. 665Performing Basic HTTP Requests ...................................................................................... 666Adding GET and POST parameters ................................................................................... 667Accessing Last Request and Response ................................................................................ 668
Zend_Http_Client - Advanced Usage .......................................................................................... 668HTTP Redirections .......................................................................................................... 668Adding Cookies and Using Cookie Persistence ..................................................................... 668Setting Custom Request Headers ....................................................................................... 669File Uploads ................................................................................................................... 670Sending Raw POST Data ................................................................................................. 671HTTP Authentication ....................................................................................................... 671Sending Multiple Requests With the Same Client ................................................................. 671
Zend_Http_Client - Connection Adapters .................................................................................... 673Overview ....................................................................................................................... 673The Socket Adapter ......................................................................................................... 673The Proxy Adapter .......................................................................................................... 675The cURL Adapter .......................................................................................................... 677The Test Adapter ............................................................................................................ 677Creating your own connection adapters ............................................................................... 680
Zend_Http_Cookie and Zend_Http_CookieJar .............................................................................. 681Introduction .................................................................................................................... 681Instantiating Zend_Http_Cookie Objects .............................................................................. 681Zend_Http_Cookie getter methods ..................................................................................... 683Zend_Http_Cookie: Matching against a scenario ................................................................... 684The Zend_Http_CookieJar Class: Instantiation ...................................................................... 685Adding Cookies to a Zend_Http_CookieJar object ................................................................. 685Retrieving Cookies From a Zend_Http_CookieJar object ........................................................ 686
Zend_Http_Response ............................................................................................................... 687Introduction .................................................................................................................... 687Boolean Tester Methods ................................................................................................... 687Accessor Methods ........................................................................................................... 688Static HTTP Response Parsers ........................................................................................... 689
26. Zend_InfoCard .......................................................................................................................... 691Introduction ............................................................................................................................ 691
Basic Theory of Usage ..................................................................................................... 691Using as part of Zend_Auth .............................................................................................. 691Using the Zend_InfoCard component standalone ................................................................... 693Working with a Claims object ........................................................................................... 694Attaching Information Cards to existing accounts .................................................................. 694Creating Zend_InfoCard Adapters ...................................................................................... 695
27. Zend_Json ................................................................................................................................ 697Introduccin ........................................................................................................................... 697Uso Bsico ............................................................................................................................ 697Uso Avanzado de Zend_Json .................................................................................................... 697
Objetos JSON ................................................................................................................. 697Codificando Objetos PHP ................................................................................................. 698Codificador/Decodificador Interno ...................................................................................... 698Expresiones JSON ........................................................................................................... 698
Conversin de XML a JSON .................................................................................................... 699Zend_Json_Server - servidor JSON-RPC ..................................................................................... 700
Detalles Avanzados ......................................................................................................... 70328. Zend_Layout ............................................................................................................................. 709
Introduccin ........................................................................................................................... 709Zend_Layout Quick Start .......................................................................................................... 709
Gua de Referencia del Programador
xv
Layout scripts ................................................................................................................. 709Using Zend_Layout with the Zend Framework MVC ............................................................. 710Using Zend_Layout as a Standalone Component ................................................................... 712Sample Layout ................................................................................................................ 712
Zend_Layout Configuration Options ........................................................................................... 714Ejemplos ....................................................................................................................... 714
Zend_Layout Advanced Usage .................................................................................................. 716Custom View Objects ...................................................................................................... 716Custom Front Controller Plugins ........................................................................................ 716Custom Action Helpers .................................................................................................... 717Custom Layout Script Path Resolution: Using the Inflector ..................................................... 717
29. Zend_Ldap ............................................................................................................................... 719Introduction ............................................................................................................................ 719
Theory of operation ......................................................................................................... 719API overview ......................................................................................................................... 722
Configuration / options ..................................................................................................... 722API Reference ................................................................................................................ 724
Usage Scenarios ...................................................................................................................... 746Authentication scenarios ................................................................................................... 746Basic CRUD operations ................................................................................................... 746Extended operations ......................................................................................................... 748
Tools .................................................................................................................................... 748Creation and modification of DN strings ............................................................................. 748Using the filter API to create search filters .......................................................................... 748Modify LDAP entries using the Attribute API ...................................................................... 749
Object oriented access to the LDAP tree using Zend_Ldap_Node .................................................... 749Basic CRUD operations ................................................................................................... 749Extended operations ......................................................................................................... 749Tree traversal ................................................................................................................. 74