blueshoes php application framework and cms            core_html
[ class tree: core_html ] [ index: core_html ] [ all elements ]

Class: Bs_HtmlTag

Source Location: /core/html/Bs_HtmlTag.class.php

Class Overview

Bs_Object
   |
   --Bs_HtmlTag

Html Tag Class.


Author(s):

Version:

  • 4.5.$Revision: 1.4 $ $Date: 2003/11/26 22:57:35 $

Copyright:

  • blueshoes.org

Variables

Methods


Inherited Variables

Inherited Methods

Class: Bs_Object

Bs_Object::Bs_Object()
Bs_Object::getErrors()
Basic error handling: Get *all* errors as string array from the global Bs_Error-error stack.
Bs_Object::getLastError()
Basic error handling: Get last error string from the global Bs_Error-error stack.
Bs_Object::getLastErrors()
Basic error handling: Get last errors string array from the global Bs_Error-error stack sinc last call of getLastErrors().
Bs_Object::persist()
Persists this object by serializing it and saving it to a file with unique name.
Bs_Object::setError()
Basic error handling: Push an error string on the global Bs_Error-error stack.
Bs_Object::toHtml()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::toString()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::unpersist()
Fetches an object that was persisted with persist()

Class Details

[line 50]
Html Tag Class.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! this class is experimental. write ecg please. --andrej !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

represents an html tag, but only the first part. eg: <tag param="value"> but not: <tag param="value"></tag>

note I: if a tag uses the same token twice, only the first value is used. eg <table border="0" border="1"> => border="0".

note II: you may not use this class [pseudo]static and only choose some methods for your tag. the methods depend on the work of each other. if i wouldn't have coded it that way, the methods would have to do the same work more than once.

naming convention: in the tag <img src="foo.gif" usemap="#myMap" ismap> the 'ismap' token is called "no-value token". this exists in html and is not compatible with xml and xhtml! in xhtml it would be ismap="true".




Tags:

pattern:  singleton: (pseudostatic)
status:  experimental
access:  public
version:  4.5.$Revision: 1.4 $ $Date: 2003/11/26 22:57:35 $
author:  andrej arn <at blueshoes dot org>
copyright:  blueshoes.org
todo:  

__parseTag() and __parseProperties() are from older code. maybe modify them a bit. i added the __ in front of the function names to make them stand out.

dependencies: Bs_HtmlUtil



[ Top ]


Class Variables

$caseFolding =

[line 150]

should we do case folding? (make all tags and attributes upper/lower case) default is "never mind". i really recommend doing this.

note I: you cannot set this in the middle of the work. it won't be used. or only for new stuff. so if you really want that, set it right after feeding the object with your tag.

note II: if your tag uses 2 tokens with the same name but different case, you face the same problem as if the case would be the same. only the first such token will be used.




Tags:

var:  ('l' for 'lower case', 'u' for 'upper case'
todo:  make use of this one.
access:  public

Type:   char


[ Top ]

$htmlUtil =

[line 57]

reference to the global pseudostatic object


Type:   object


[ Top ]

$useCommentStyle =  0

[line 131]

if set to 1 then <tag> will be written as <!--tag-->.

if set to 2 then <tag> will be written as <!tag>. if set to 0 then the tag will be returned as it was received. if set to -1 then there won't be any comment chars at all (returned).




Tags:

access:  public

Type:   mixed


[ Top ]

$useXmlStop =

[line 118]

if set to TRUE then getTag() will return with the final slash.

if set to FALSE then it won't. if not set then it will return the same way as the tag was received (with or without).

examples: set to FALSE: <tag param="value"> set to TRUE: <tag param="value"/>




Tags:

access:  public

Type:   mixed


[ Top ]

$valueDelimiter =  '"'

[line 103]

the character to use to delimit the values.

eg <tag param="value"> ^ ^ could also be a single quote ' or nothing (empty string). the default value is highly recommended.




Tags:

var:  (usually a char, default is '"')
access:  public

Type:   string


[ Top ]



Class Methods


constructor Bs_HtmlTag [line 157]

Bs_HtmlTag Bs_HtmlTag( [string $tag = FALSE])

Constructor.



Parameters:

string   $tag   (default is FALSE).

[ Top ]

method deleteToken [line 341]

bool deleteToken( string $key)

deletes the token with the given key.

makes use of the caseFolding setting.




Tags:

return:  TRUE if the token existed, bool FALSE otherwise.
access:  public


Parameters:

string   $key  

[ Top ]

method getTag [line 195]

string getTag( )

returns the whole tag as one string. with all the tokens.

also takes care about comment chars and xml style.




Tags:

access:  public


[ Top ]

method getTagType [line 228]

string getTagType( )

returns the tag type. eg 'table'.



Tags:

access:  public


[ Top ]

method getToken [line 263]

mixed getToken( string $key, [bool $ignoreCaseFolding = FALSE])

returns the token value for the given token.

note: if caseFolding is used, your given $key will be converted according to the setting. see param $ignoreCaseFolding.




Tags:

return:  (a string for all values, bool TRUE for no-value tokens.)
throws:  null if the token is not defined.
access:  public


Parameters:

string   $key  
bool   $ignoreCaseFolding   (default is FALSE)

[ Top ]

method getTokens [line 291]

array getTokens( [bool $ignoreCaseFolding = FALSE])

returns all token values.

note: if caseFolding is used, your given $key will be converted according to the setting. see param $ignoreCaseFolding.




Tags:

throws:  bool FALSE
access:  public


Parameters:

bool   $ignoreCaseFolding   (default is FALSE)

[ Top ]

method hasToken [line 364]

bool hasToken( string $key, [bool $ignoreCaseFolding = FALSE])

tells if the token with the given key exists. see getToken().



Tags:

access:  public


Parameters:

string   $key  
bool   $ignoreCaseFolding   (default is FALSE)

[ Top ]

method setTag [line 174]

void setTag( string $tag)

the object may be init with a tag by using this method or directly in the constructor.

using this method kills all old data from before. also params/settings you made/set before.




Tags:

access:  public


Parameters:

string   $tag  

[ Top ]

method setTagType [line 241]

void setTagType( string $tagType)

sets the tag type, eg 'table'.

makes use of the caseFolding setting.




Tags:

access:  public


Parameters:

string   $tagType   tagType

[ Top ]

method setToken [line 320]

void setToken( string $key, mixed $value)

sets (overwrites) the token with the given key.

makes use of the caseFolding setting.




Tags:

access:  public


Parameters:

string   $key  
mixed   $value   (bool TRUE for no-value tokens, everything else will be converted to string.)

[ Top ]

method __parseProperties [line 734]

array __parseProperties( mixed $propertyString, [bool $debug = FALSE], string &$propertyString)

same as parseTag() but takes a tag string instead of a full tag.

example: "type=\"formelement\" type='formelement' type=formelement formelement>" instead of: "<bs type=\"formelement\" type='formelement' type=formelement formelement>"




Tags:

return:  (hash)
see:  parseTag()
access:  public


Parameters:

string   &$propertyString  
bool   $debug   (default is FALSE). prints out debug information.

[ Top ]

method __parseTag [line 539]

array __parseTag( mixed $tag, [bool $debug = FALSE], string &$tag)

takes a tag (something like <bs_form name="name" what="element"/>) and parses its properties into a hash.

example: $tag = <bs type="formelement" name="name" multiple value='sam&#039;s pizzaland'/> $return = parseTag($tag); //now $return = array('type'=>'formelement', 'name'=>'name', 'multiple'=>TRUE, 'value'=>"sam's pizzaland");

tag properties may look different. as in html, the following versions are allowed: <bs type="formelement" type='formelement' type=formelement formelement> So properties can stand alone or can have a value, and the value can be in single quotes, double quotes or none at all. If a prop stands alone, it is treated like 'property=true' (bool). Cause in the hash we cannot set an undefined value like NULL. We'd have to make something up like 'bs_unset' which i don't want to.

The characters documented in Bs_HtmlUtil->filterForHtml() need to be translated to their html equivalents, not escaped. thus the following writings are *not* allowed: <bs value="my name is \"tom\"" value='sam\' pizzaland'>

Not allowed, as in html, is the writing <bs value=hello world> because 'world' would be a single property and does not belong to the value=hello.

Please be a bit careful when you write your tags. Things to avoid:

  • tags that use more than 1 line (cr/lf)
  • < tag name = hello / > <tag name = hello> (note the extra spaces)
As you can see in the example above, html special chars (&something) are converted for you.




Tags:

return:  (hash)
see:  parseProperties()
access:  public


Parameters:

string   &$tag  
bool   $debug   (default is FALSE). prints out debug information

[ Top ]


Documentation generated on Mon, 29 Dec 2003 21:11:07 +0100 by phpDocumentor 1.2.3