BlueShoes Application Framework made with PHP http://www.blueshoes.org/


Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: C:/usr/local/lib/php/blueshoes-4.2/core/html/Bs_HtmlTag.class.php
BlueShoes Application Framework - html

Bs_HtmlTag

Bs_Object
   |
  +-- Bs_HtmlTag

Html Tag Class.

 

public class Bs_HtmlTag extends Bs_Object

Html Tag Class.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!this class is untested, 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 somemethods for your tag. the methods depend on the work of eachother. if i wouldn't have coded it that way, the methods wouldhave 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".

Authors
Version4.0.$id$
Copyrightblueshoes.org

 

Methods inherited from Bs_Object

isex, isexception, tostring, tohtml, persist, unpersist, bs_object, bbsetoutput, bbawake, bbisawake, bbxmsg, bbxfunctionstart, bbxfunctionend, bbxecho, bbxvar, bbxvardump, bbforcetrace, bbbufferstart, bbbufferget, bbbufferendflush, bbbufferendclean

Public Method Summary

void

Bs_HtmlTag([ string $tag ])

Constructor.
void

setTag(string $tag)

the object may be init with a tag by using this method or directly
string

getTag()

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

getTagType()

returns the tag type. eg 'table'.
void

setTagType(string $tagType)

sets the tag type, eg 'table'.
mixed

getToken(string $key, [ string $ignoreCaseFolding ])

returns the token value for the given token.
void

setToken(string $key, mixed $value)

sets (overwrites) the token with the given key.
bool

deleteToken(string $key)

deletes the token with the given key.
bool

hasToken(string $key, [ string $ignoreCaseFolding ])

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

__parseTag(string $tag, [ string $debug ])

takes a tag (something like <bs_form name="name" what="element"/>) and
array

__parseProperties(string $propertyString, [ string $debug ])

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

Private Method Summary

void

_reset()

resets this object so we can reuse it.
void

_cleanTag()

cleans the tag. removes extra spaces and newlines.
void

_parseXmlStop()

checks if the given tag uses xml style.
void

_parseCommentStyle()

checks if the given tag uses comment chars.
void

_parseTagType()

parses and sets the name of the tag.
void

_parseTagTokens()

parses the tag tokens into $this->_tagTokens.

Public Field Summary

string

$valueDelimiter

the character to use to delimit the values.
unknown

$useXmlStop

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

$useCommentStyle

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

$caseFolding

should we do case folding? (make all tags and attributes upper/lower case)

Private Field Summary

object [unknown]

$htmlUtil

reference to the global pseudostatic object
string

$_tagString

the whole tag as a string, not sure yet if it should be
array

$_tagTokens

hash with the tokens. may be empty.
string

$_tagType

stores the type of the tag.
unknown

$this

Private Constant Summary

BS_HTMLTAG_VERSION >>4.0.$x$<< Warning: documentation is missing.

Public Method Details

Bs_HtmlTag

public void Bs_HtmlTag( [ string $tag ] )

  Constructor.

Parameter
string $tag = >>FALSE<<
(default is FALSE).
Returns void


setTag

public 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/settingsyou made/set before.

Parameter
string $tag
Returns void


getTag

public string getTag( )

  returns the whole tag as one string. with all the tokens.
also takes care about comment chars and xml style.

Returns string


getTagType

public string getTagType( )

  returns the tag type. eg 'table'.

Returns string


setTagType

public void setTagType( string $tagType )

  sets the tag type, eg 'table'.
makes use of the caseFolding setting.

Parameter
string $tagType
Returns void


getToken

public mixed getToken( string $key, [ string $ignoreCaseFolding ] )

  returns the token value for the given token.
note: if caseFolding is used, your given $key will be converted accordingto the setting. see param $ignoreCaseFolding.

Parameter
string $key
string $ignoreCaseFolding = >>FALSE<<
(default is FALSE)
Returns mixed

(a string for all values, bool TRUE for no-value tokens.)

Throws null if the token is not defined.

setToken

public void setToken( string $key, mixed $value )

  sets (overwrites) the token with the given key.
makes use of the caseFolding setting.

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


deleteToken

public bool deleteToken( string $key )

  deletes the token with the given key.
makes use of the caseFolding setting.

Parameter
string $key
Returns bool

TRUE if the token existed, bool FALSE otherwise.


hasToken

public bool hasToken( string $key, [ string $ignoreCaseFolding ] )

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

Parameter
string $key
string $ignoreCaseFolding = >>FALSE<<
(default is FALSE)
Returns bool


__parseTag

public array __parseTag( string $tag, [ string $debug ] )

  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 singlequotes, 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 likeNULL. 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 theirhtml 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' wouldbe 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.

Parameter
string $tag
string $debug = >>FALSE<<
(default is FALSE). prints out debug information
Returns array

(hash)


__parseProperties

public array __parseProperties( string $propertyString, [ string $debug ] )

  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>"

Parameter
string $propertyString
string $debug = >>FALSE<<
(default is FALSE). prints out debug information.
Returns array

(hash)


Private Method Details

_reset

private void _reset( )

  resets this object so we can reuse it.

Returns void


_cleanTag

private void _cleanTag( )

  cleans the tag. removes extra spaces and newlines.
something like:< tag param = "value" anotherParam='anotherValue'>makes it hard(er) to parse things.this method should help a bit.

Returns void


_parseXmlStop

private void _parseXmlStop( )

  checks if the given tag uses xml style.
sets $this->useXmlStop and modifies $this->_tagString.

Returns void

See Also $this

_parseCommentStyle

private void _parseCommentStyle( )

  checks if the given tag uses comment chars.

Returns void

See Also $this

_parseTagType

private void _parseTagType( )

  parses and sets the name of the tag.
examples:TAG RETURN COMMENTS------------------------------------------------------------------------------------<tag param="name"/> 'tag'<!tag param="name"/> 'tag' the ! is a short hack to comment out a tag.<!--tag--> 'tag' tag is commented out, but name stays the same.<!--tag--/> 'tag' tag is commented out, but name stays the same.<> '' empty string<param="value"> '' empty string<tag/> 'tag' xml style

Returns void


_parseTagTokens

private void _parseTagTokens( )

  parses the tag tokens into $this->_tagTokens.

Returns void


Public Field Details

$valueDelimiter

public string $valueDelimiter

>>'"'<<

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.


$useXmlStop

public unknown $useXmlStop

>><<

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 returnthe same way as the tag was received (with or without).examples:set to FALSE: <tag param="value">set to TRUE: <tag param="value"/>


$useCommentStyle

public integer $useCommentStyle

>><<

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).


$caseFolding

public unknown $caseFolding

>><<

should we do case folding? (make all tags and attributes upper/lower case)
default is "never mind".note I: you cannot set this in the middle of the work. it won't be used. oronly for new stuff. so if you really want that, set it right afterfeeding 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. onlythe first such token will be used.


Private Field Details

$htmlUtil

private object [unknown] $htmlUtil

>><<

reference to the global pseudostatic object


$_tagString

private string $_tagString

>><<

the whole tag as a string, not sure yet if it should be
the original one we got or the last concardinated one.


$_tagTokens

private array $_tagTokens

>><<

hash with the tokens. may be empty.
the key of the hash is always a string. the value is a string, evenif it is numeric. if the tag token is a single thing like 'ismap' here:<img src="foo.gif" usemap="#myMap" ismap>then the value of that hash record is bool TRUE.


$_tagType

private string $_tagType

>><<

stores the type of the tag.
example:<table border="0"> => 'table'


$this

private unknown $this

>><<



Private Constant Details

BS_HTMLTAG_VERSION

define( BS_HTMLTAG_VERSION, >>4.0.$x$<< )
Case: default: case sensitive




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta