Introducción a Zend Framework

 Aprendiendo Zend Framework

Apéndice

 Referencia de Zend Framework


  • Zend_Gdata
  • Zend_Http
  • Zend_InfoCard
  • Zend_Json
  • Zend_Layout
  • Zend_Ldap
  • Zend_Loader
  • Zend_Locale
  • Zend_Log
  • Zend_Mail
  • Zend_Markup
  • Zend_Measure
  • Zend_Memory
  • Zend_Mime
  • Zend_Navigation
  • Zend_Oauth
  • Zend_OpenId
  • Zend_Paginator
  • Zend_Pdf
  • Zend_ProgressBar
  • Zend_Queue
  • Zend_Reflection
  • Zend_Registry
  • Zend_Rest

  • Zend_Search_Lucene
  • Zend_Serializer
  • Zend_Server
  • Zend_Service
  • Zend_Session
  • Zend_Soap
  • Zend_Tag
  • Zend_Test
  • Zend_Text
  • Zend_TimeSync
  • Zend_Tool
  • Zend_Tool_Framework
  • Zend_Tool_Project
  • Zend_Translate
  • Zend_Uri
  • Zend_Validate
  • Zend_Version
  • Zend_View
  • Zend_Wildfire
  • Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Traducción al 26.9% - Actualizado el 2011-11-16 - Revisión 24249 - Versión ZF 1.11.x

    46.2. Getting Started With Zend_Markup

    This guide to get you started with Zend_Markup uses the BBCode parser and HTML renderer. The priciples discussed can be adapted to other parsers and renderers.

    Ejemplo 46.1. Basic Zend_Markup Usage

    We will first instantiate a Zend_Markup_Renderer_Html object using the Zend_Markup::factory() method. This will also create a Zend_Markup_Parser_Bbcode object which will be added to the renderer object.

    Afther that, we will use the render() method to convert a piece of BBCode to HTML.

    // Creates instance of Zend_Markup_Renderer_Html,
    // with Zend_Markup_Parser_BbCode as its parser
    $bbcode Zend_Markup::factory('Bbcode');

    echo 
    $bbcode->render('[b]bold text[/b] and [i]cursive text[/i]');
    // Outputs: '<strong>bold text</strong> and <em>cursive text</em>'

    Ejemplo 46.2. A more complicated example of Zend_Markup

    This time, we will do exactly the same as above, but with more complicated BBCode markup.

    $bbcode Zend_Markup::factory('Bbcode');

    $input = <<<EOT
    [list]
    [*]Zend Framework
    [*]Foobar
    [/list]
    EOT;

    echo 
    $bbcode->render($input);
    /*
    Should output something like:
    <ul>
    <li>Zend Framework</li>
    <li>Foobar</li>
    </ul>
    */

    Ejemplo 46.3. Processing incorrect input

    Besides simply parsing and rendering markup such as BBCode, Zend_Markup is also able to handle incorrect input. Most BBCode processors are not able to render all input to XHTML valid output. Zend_Markup corrects input that is nested incorrectly, and also closes tags that were not closed:

    $bbcode Zend_Markup::factory('Bbcode');

    echo 
    $bbcode->render('some [i]wrong [b]sample [/i] text');
    // Note that the '[b]' tag is never closed, and is also incorrectly
    // nested; regardless, Zend_Markup renders it correctly as:
    // some <em>wrong <strong>sample </strong></em><strong> text</strong>

    digg delicious meneame google twitter technorati facebook

    Comentarios

    Loading...