[Typo3-dev] TYPO3 and XHTML

Christopher tombedlam at yahoo.com
Wed May 11 04:01:07 CEST 2005


Hi,

--- Sebastian Roth <sebastian.roth at gmail.com> wrote:
> Hi,
> 
> What about creating some kind of TagManager class?
> 
> $e = new html::Element( 'img' );
> $e->addAttribute('height',$height);
> $e->print( );
> 
> Meaning that there is a static array containing
>  - all possible html elements
>  - all possible attributes to them
>  - some kind of callback functions to run when a element gets updated
> (useful with img, e.g. when the src attribute will be set, the
> callback function gets a reference to the tag-object & adds
> appropriate height/width attributes)
>  

I hate seeing markup in program code, so I've done some preliminary work on
a class like this - almost exactly as you describe it in fact. The code
basically revolves around an array of the html elements each of which
contains an array of attributes and properties (such as whether or not
there is a closing tag needed for the given element). In addition, there
are a few basic functions for opening tags, closing tags, quoting
attributes etc that get re-used throughout the class. It also checks the
current doctype to determine how to correctly output the tags (question
about this: I'd like to have the script parse the appropriate dtds; can
anyone direct me to a reference that would describe how to do this?)

So far, I've implemented just a sample set of elements that cover all the
usuall markup situations, but it's not suitable for viewing without a
re-write or at least a cleanup, but I have managed to output correct markup
in all the major situations I could think of (which does *not* include
complex nesting arrangements - though it might work, I'm not sure).

You basically call the functions like this:


$testOutput = $this->buildDouble("comment","","Script output:")
  .$this->buildSingle("img",$imgAttributes,0)
  .$this->buildSingle("br","",3)
  .$this->buildSingle("mEta",$metaAttributes,2)
  .$this->buildDouble("comment","",$commentContent)
  .$this->buildDouble("P","",$pContent)
  .$this->buildDouble("comment","","Script output: END");


...and you can probably guess what the output would look like ;-)

This was discussed (very briefly) on the list once before [1]. Kasper
thought it was a good idea in principle, but maybe risky from a performance
point of view.

If the performance hit could be shown not to be too severe, I think
something like this could solve a number of small but aggravating
problems...


-Christopher

[1] (The -oops!- broken thread I'm referring to):
http://typo3.org/documentation/mailing-lists/dev-list-archive/thread/110116741/
[2] (The original thread):
http://typo3.org/documentation/mailing-lists/dev-list-archive/thread/110116734/



		
__________________________________ 
Do you Yahoo!? 
Make Yahoo! your home page 
http://www.yahoo.com/r/hs




More information about the TYPO3-dev mailing list