Re: [Phphtmllib-devel] I patched widgets/TextCSSNav.inc for clarity
Status: Beta
Brought to you by:
hemna
From: Walter A. B. I. <wab...@3g...> - 2004-02-18 18:14:03
|
Hi Erich, Can you send me a diff -u patch as an attachment. I can't seem to get= this patch to apply. It always fails for me. Also, what version of phphtmlli= b did you create the patch from? 2.4.0 is the latest. Walt Quoting Erich Enke <twi...@fa...>: > I was reading the code, and was having a hard time understanding exactl= y > what was going on in this bit of code, so I rearranged some stuff (stil= l > equivalent function), and now IMHO it's a bit more readable. In > particular: >=20 > * I fixed broken indentation > * I made an is_first variable to explicitly say what we're doing the > first time around (and that it is the first time that we are actually > concerned with) > * I collected some of the repeated conditions into an assignment into a > well-named variable > * I collected only what really changed in those different conditions, > namely the arguments to the function set_class, therefore making us abl= e > to call set_class only once. >=20 > See what you think; here's the patch: >=20 > --- TextCSSNav.inc.orig 2004-02-17 12:14:45.000000000 -0700 > +++ TextCSSNav.inc 2004-02-17 12:39:57.000000000 -0700 > @@ -165,7 +165,7 @@ > $container =3D container(); > $container->set_collapse(); > =20 > - $class =3D "first"; > + $is_first =3D TRUE; > $cnt =3D 1; > foreach( $this->data as $nav ) { > switch ($nav["type"]) { > @@ -178,19 +178,16 @@ > $url .=3D > =20 > "&".$this->_query_prefix."textcssnavselected=3D".$cnt; > } > $obj =3D html_a(htmlentities($url), > $nav["text"], "normal", $nav["target"], > $nav["title"]); > - if ($class !=3D NULL) { > - if ($this->_highlight_selected = && > ($this->_selected =3D=3D $cnt || > - =20 > $nav["selected"])) { > - $class =3D > "selected".$class; > - } > + > + $is_selected =3D $this->_highlight_sele= cted > && ($this->_selected =3D=3D $cnt || $nav["selected"]); > + $class =3D $is_selected ? "selected" : = ""; > + if ($is_first) { > + $class .=3D "first"; > + } > + if ($is_selected || $is_first) { > $obj->set_class( $class ); > - $class =3D NULL; > - } else { > - if ($this->_highlight_selected = && > ($this->_selected =3D=3D $cnt || > - =20 > $nav["selected"])) { > - $obj->set_class( > "selected" ); > - } > } > + $is_first =3D FALSE; > $cnt++; > break; > case "blank": >=20 > /// End patch /// >=20 > Hope that helps someone, > -- epte >=20 > --=20 > http://www.fastmail.fm - Accessible with your email software > or over the web >=20 >=20 > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=3D1356&alloc_id=3D3438&op=3Dclick > _______________________________________________ > Phphtmllib-devel mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phphtmllib-devel >=20 |