Re: [Phphtmllib-devel] TRtag::push_reference() bug
Status: Beta
Brought to you by:
hemna
From: Walter A. B. I. <wab...@bu...> - 2002-06-06 20:47:34
|
On Thu, 2002-06-06 at 07:16, David McNab wrote: > Hi again, > > When using the push_reference() method in TRtag, it sometimes wraps the > inserted thing even when it's actually a TDtag. ---push_reference() was meant to take a tag object as the reference. > > Example: > > $page = new HTMLPageClass("This page"); > $page->push_reference($font); > $font = new > FONTtag(array('size'=>'4','face'=>'arial,helvetica,sans-serif')); > $font->push_reference($table1); > $table1 = new TABLEtag(array('border'=>1)); > $table1->push_reference($row[0]); > $table1->push_reference($row[1]); > > $row[0] = new TRtag(0); > $row[0]->push_reference($col[0][0]); // forward reference > $row[0]->push_reference($col[0][1]); // ditto $col[0][0] doesn't really exist at this point, so push_reference() doesn't know what type of tag its pushing. It can't know what type of tag you might push in the future :) If you look at the push_reference() code for the TRtag, it tries to detect if the item being pushed is a TD or TH. If it is, it doesn't wrap it. If its not, it wraps it. Since what you are pushing isn't an object, it wraps it. > $col[0][0] = new TDtag(0, "Cell A"); > $col[0][1] = new TDtag(0, "Cell B"); > > $row[1] = new TRtag(0); > $col[1][0] = new TDtag(0, "Cell C"); // backward reference > $col[1][1] = new TDtag(0, "Cell D"); // ditto > $row[1]->push_reference($col[1][0]); > $row[1]->push_reference($col[1][1]); > > print $page->render(); push_reference was meant to allow you to push an object, and at some later time manipulate that object. So you could do something like ... ... $span = new SPANtag; $td->push_reference( $span ); ... ... ... $span->push("foo"); $span->set_tag_attribute("class", "green"); Walt |