Class THtmlWriter

Description

Implements interfaces:

THtmlWriter class

THtmlWriter is a writer that renders valid XHTML outputs. It provides functions to render tags, their attributes and stylesheet fields. Attribute and stylesheet values will be automatically HTML-encoded if they require so. For example, the 'value' attribute in an input tag will be encoded.

A common usage of THtmlWriter is as the following sequence:

  1. $writer->addAttribute($name1,$value1);
  2. $writer->addAttribute($name2,$value2);
  3. $writer->renderBeginTag($tagName);
  4. // ... render contents enclosed within the tag here
  5. $writer->renderEndTag();
Make sure each invocation of renderBeginTag is accompanied with a renderEndTag and they are properly nested, like nesting tags in HTML and XHTML.

  • since: 3.0
  • version: $Id: THtmlWriter.php 1398 2006-09-08 19:31:03Z xue $
  • author: Qiang Xue <qiang.xue@gmail.com>

Located in /Web/UI/THtmlWriter.php (line 39)

TComponent
   |
   --TApplicationComponent
      |
      --THtmlWriter
Method Summary
THtmlWriter __construct (ITextWriter $writer)
void addAttribute (string $name, string $value)
void addAttributes (array $attrs)
void addStyleAttribute (string $name, string $value)
void addStyleAttributes (array $attrs)
void flush ()
void getWriter ()
void removeAttribute (string $name)
void removeStyleAttribute (string $name)
void renderBeginTag (string $tagName)
void renderEndTag ()
void setWriter (mixed $writer)
void write (string $str)
void writeBreak ()
void writeLine ([string $str = ''])
Methods
Constructor __construct (line 109)

Constructor.

  • access: public
THtmlWriter __construct (ITextWriter $writer)
  • ITextWriter $writer: a writer that THtmlWriter will pass its rendering result to
addAttribute (line 138)

Adds an attribute to be rendered.

  • access: public
void addAttribute (string $name, string $value)
  • string $name: name of the attribute
  • string $value: value of the attribute
addAttributes (line 127)

Adds a list of attributes to be rendered.

  • access: public
void addAttributes (array $attrs)
  • array $attrs: list of attributes to be rendered
addStyleAttribute (line 167)

Adds a stylesheet attribute to be rendered

  • access: public
void addStyleAttribute (string $name, string $value)
  • string $name: stylesheet attribute name
  • string $value: stylesheet attribute value
addStyleAttributes (line 156)

Adds a list of stylesheet attributes to be rendered.

  • access: public
void addStyleAttributes (array $attrs)
  • array $attrs: list of stylesheet attributes to be rendered
flush (line 185)

Flushes the rendering result.

This will invoke the underlying writer's flush method.

  • access: public
void flush ()
getWriter (line 114)
  • access: public
void getWriter ()
removeAttribute (line 147)

Removes the named attribute from rendering

  • access: public
void removeAttribute (string $name)
  • string $name: name of the attribute to be removed
removeStyleAttribute (line 176)

Removes the named stylesheet attribute from rendering

  • access: public
void removeStyleAttribute (string $name)
  • string $name: name of the stylesheet attribute to be removed
renderBeginTag (line 220)

Renders the openning tag.

  • access: public
void renderBeginTag (string $tagName)
  • string $tagName: tag name
renderEndTag (line 250)

Renders the closing tag.

  • access: public
void renderEndTag ()
setWriter (line 119)
  • access: public
void setWriter (mixed $writer)
write (line 194)

Renders a string.

  • access: public
void write (string $str)
  • string $str: string to be rendered
writeBreak (line 211)

Renders an HTML break.

  • access: public
void writeBreak ()
writeLine (line 203)

Renders a string and appends a newline to it.

  • access: public
void writeLine ([string $str = ''])
  • string $str: string to be rendered

Inherited Methods

Inherited From TApplicationComponent

TApplicationComponent::getApplication()
TApplicationComponent::getRequest()
TApplicationComponent::getResponse()
TApplicationComponent::getService()
TApplicationComponent::getSession()
TApplicationComponent::getUser()
TApplicationComponent::publishAsset()
TApplicationComponent::publishFilePath()

Inherited From TComponent

TComponent::addParsedObject()
TComponent::attachEventHandler()
TComponent::canGetProperty()
TComponent::canSetProperty()
TComponent::createdOnTemplate()
TComponent::detachEventHandler()
TComponent::evaluateExpression()
TComponent::evaluateStatements()
TComponent::getEventHandlers()
TComponent::getSubProperty()
TComponent::hasEvent()
TComponent::hasEventHandler()
TComponent::hasProperty()
TComponent::raiseEvent()
TComponent::setSubProperty()
TComponent::__get()
TComponent::__set()

Documentation generated on Mon, 21 Apr 2008 11:35:08 -0400 by phpDocumentor 1.3.0RC4