Re: [PHP] Template style question

2005-11-08 Thread Richard Lynch
On Sat, November 5, 2005 1:10 pm, Leonard Burton wrote:
 Greetings,

 HI All, I hope all is well.

 I have set up a template parser.  Basically, it parses the template
 and finds tags with tag_name.dat file and then includes the
 tag_name.dat file.  I have considered a few other options but as of
 now I think I like what I have come up with.

 The only problem that I have in my design is that I have to hard code
 tables in the dat file mixing php and html.  I would prefer to be able
 to do something like:

 [[tag with db query]]
 table
 trtdcolname/tdtdcolname/tdtdcolname/td/tr
 trtd%var1%/tdTd%var2%/tdtd%var3%/td/tr

Perhaps this:
%%repeat%%trtd%var1%/tdtd%var2%/tdtd%var3%/td/tr%%repeat%%

 /table
 [[/tag with db query]]

 I would like it to be able to parse the line with the %var1% (which is
 the column name with % or some other indicator on each side) in it and
 then have it generate how many ever rows as nessecary.

 Currently, my parsing engine loads the template, preg_splits() it so
 each template tag is on a new line, and then passes through the
 resulting array and executes the code for whatever tag is chosen.

 There are a couple ideas that I have thought of but have not thought
 of any real good way so I am turning to the list.

[waving hands wildly]
Then you could maybe use some kind of callback / back-reference
thingie in that preg_ thingie...  yeah, okay, so that part I'm not
real clear on. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Template style question

2005-11-08 Thread Richard Lynch
On Sat, November 5, 2005 5:03 pm, Leonard Burton wrote:
 On 11/5/05, Robert Cummings [EMAIL PROTECTED] wrote:
 On Sat, 2005-11-05 at 14:55, James Benson wrote:
  Give smarty a try rather than re-inventing the wheel
 
  http://smarty.php.net

 Reinventing the wheel is much better than either the LGPL or GPL.
 Writing GPL or LGPL code on PHP is just wrong.  Either keep the code
 for your own use or use the PHP license.  Most of the stuff I see that
 is distributed under the [L]*GPL isn't worth much.  If PHP can be
 written under the PHP license why can't small little apps that is
 written in PHP?  I release my code snippets (from time to time) under
 either the PHP or BSD license.

Ooooh, if I fan the flames a little, can we turn this into another
flame war for BOTH CMSes *and* licensing?!  Pretty please???

And let's work in the Nazis somehow, okay?

[that was sarcasm, folks]

Every template engine I've used, I felt like I was being forced to
write code while my hands and arms were wrapped in Taffy.

I don't see any need for another one to be built, but I never saw a
need for the first one either, so there ya go.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Template style question

2005-11-08 Thread Robert Cummings
On Tue, 2005-11-08 at 19:04, Richard Lynch wrote:
 On Sat, November 5, 2005 5:03 pm, Leonard Burton wrote:
  On 11/5/05, Robert Cummings [EMAIL PROTECTED] wrote:
  On Sat, 2005-11-05 at 14:55, James Benson wrote:
   Give smarty a try rather than re-inventing the wheel
  
   http://smarty.php.net
 
  Reinventing the wheel is much better than either the LGPL or GPL.
  Writing GPL or LGPL code on PHP is just wrong.  Either keep the code
  for your own use or use the PHP license.  Most of the stuff I see that
  is distributed under the [L]*GPL isn't worth much.  If PHP can be
  written under the PHP license why can't small little apps that is
  written in PHP?  I release my code snippets (from time to time) under
  either the PHP or BSD license.
 
 Ooooh, if I fan the flames a little, can we turn this into another
 flame war for BOTH CMSes *and* licensing?!  Pretty please???
 
 And let's work in the Nazis somehow, okay?
 
 [that was sarcasm, folks]
 
 Every template engine I've used, I felt like I was being forced to
 write code while my hands and arms were wrapped in Taffy.
 
 I don't see any need for another one to be built, but I never saw a
 need for the first one either, so there ya go.

I don;t think your the target audience, you don't see the need for OOP
either :/

*lol*

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Template style question

2005-11-08 Thread Richard Lynch
On Tue, November 8, 2005 6:23 pm, Robert Cummings wrote:
 On Tue, 2005-11-08 at 19:04, Richard Lynch wrote:
 On Sat, November 5, 2005 5:03 pm, Leonard Burton wrote:
  On 11/5/05, Robert Cummings [EMAIL PROTECTED] wrote:
  On Sat, 2005-11-05 at 14:55, James Benson wrote:
   Give smarty a try rather than re-inventing the wheel
  
   http://smarty.php.net
 
  Reinventing the wheel is much better than either the LGPL or GPL.
  Writing GPL or LGPL code on PHP is just wrong.  Either keep the
 code
  for your own use or use the PHP license.  Most of the stuff I see
 that
  is distributed under the [L]*GPL isn't worth much.  If PHP can be
  written under the PHP license why can't small little apps that is
  written in PHP?  I release my code snippets (from time to time)
 under
  either the PHP or BSD license.

 Ooooh, if I fan the flames a little, can we turn this into another
 flame war for BOTH CMSes *and* licensing?!  Pretty please???

 And let's work in the Nazis somehow, okay?

 [that was sarcasm, folks]

 Every template engine I've used, I felt like I was being forced to
 write code while my hands and arms were wrapped in Taffy.

 I don't see any need for another one to be built, but I never saw a
 need for the first one either, so there ya go.

 I don;t think your the target audience, you don't see the need for OOP
 either :/

au contraire!

I see [have seen] many needs for OOP.

The largest group of those needs is nowhere near a web-server.  I
spent most of a decade writing Lisp code for AI research.  You can't
get much more OOP than Common Lisp.  Makes PHP's OOP look wimpy. :-)
:-) :-)

I also see a HUGE need for OOP in large-scale coding projects in PHP
with multiple developers, particularly with one (or very very very
few) Software Design Architects, and a whole bunch of less-experienced
programmers.

What I abhor is the current practice of conveting the simplest
stupidest one-man or small-team site into this monstrous OOP mess,
usually by somebody who actually knows NOTHING about OOP when you get
right down to it.  He copied his coding style from another script who
doesn't really get OOP, who copied HIS coding style... and so on.

Here's how I know that OOP is probably not the right solution:
1. None, or very few, classes actually inherit from anything.
At that point, OOP is most likely being abused as a namespace
solution.  Which is fine in PHP, as there is no other reasonable
alternative.  Unfortunately, instead of coding it like a namespace
solution, it's this weird set of coding practices that would, in
theory, be good in OOP, if there were share behaviours and
properties among the classes... Which there aren't since there is no
inheritence.

2. Too many class, all the same
This is best explained by example:
I cannot count the number of times I've seen somebody decide to have a
single class for each and every table in their DB.
If you think this is a Good Idea, please spare me the long explanation
of Why it's a Good Idea.  I heard it.  It makes no sense if you
analyze it deeply-enough and understand what all the concepts of OOP
actually mean.

3. Performance suckage
OOP has overhead, by definition.  A *really* good Software Design
Architect, with no less-experienced developers to worry about,
99.% of the time, could write a more efficient non-OOP equivalent
solution for any OOP solution.  And they'd write it faster, with less
code, and it would better fufill all the promises of OOP in the first
place.  This is all a HUGE *if* because large software packages are
seldom written, in whole, by a single Software Design Architect.
The point being this:  There is a price you pay for the benefits of
OOP.  Performance.  This is an acceptable price when the benefits (and
they are legion) are real and achievable.  Unfortunately, for 99% of
the scripters out there, pounding out OOP scripts in PHP, they
benefits are not real, and not even achievable, for the
resources/needs they have.
Sometimes the OOP systems I see are *so* over-engineered, the
performance loss is significant.

For anybody still reading this missive.

Please, just stop and think about the classes you are creating.

Do they inherit any behaviour?

If not, can you re-write them in better code as procedural while
maintaining good solid modularity?

Because you really don't gain the much-vaunted code-reuse of OOP
just by copy and pasting the class from here to there.  You can do
that with functions or .inc files for Pete's sake.

If you find two classes that are very similar, and you abstract out a
common super-class, THAT is OOP code re-use at work.  Re-using a class
on another project is a chimera of code re-use.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Template style question

2005-11-08 Thread Leonard Burton
HI All,

Here is what I have done for now.

template file snippet
html
head
titletitle/title
[[header]]

[[sql sql=select user, level, ts from users order by user]]
table border=1
thead
trtdUser/tdtdClearance/tdtdTimestamp/td/tr
/thead
tbody
trtd@[EMAIL PROTECTED]/tdtd@[EMAIL PROTECTED]/tdtd@[EMAIL 
PROTECTED]/td/tr
/tbody
/table
[[footer]]
/html

/template file snippet

Fist I preg_split the template on each tag designed for the template
(i.e. [[tagname attribute=value]]).

Second, I loop through the array and if the element is pure html it
prints the line.  The lines of [[tagname]] I put the tag through a
preg_match_all() and get all of the attributes and set
$ATTRIBUTES['name']=value.

Each tag has a corresponding tag.dat file which can access the
$ATTRIBUTES array.  In the .dat file I set $TAG as an array to hold
various information about the tag that the parsing class will need to
know.

The tag.dat file will pass back any information, such as results of
SQL queries to $PASSBACK.

Once the code has been included it sees that in this instance there is
a tag with data to be imprinted so then it searches for a line with
trtd@[EMAIL PROTECTED]/tdtd@[EMAIL PROTECTED]/td/tr and then it 
loops through
the SQL results and replaces each @[EMAIL PROTECTED] with its appropriate data.

Then it prints the result and then the HTML is displayed.

It stops going through the template array when it finds another tag
starting with [[sql.  This way I can have more than one table
imprinted onto a page.

The only problem with what I have is that it only works for data being
imprinted into a table unless it is a single item being imprinted, for
which I have a seperate tag, and then it will.

This does the trick for what I have going on now but what might be
nice is to modify this so I can list the data delimited with br / or
put in a li.  I will work on this later.  For the project I am
working on I have done all that is required as far as the template
goes.  I will be able to use the template class in a number of other
apps so I will be extending it.

The biggest reason I am comming up with my own is because I want to be
able to use it under any circumstance with no regard to any term or
condition of any license and that my class is farily small with only a
very very little chance of something breaking because I couldn't find
some obscure documentation.

I wanted to avoid

What do you think?

I may rethink what I  have going on and put [[imprint]] and
[[/imprint]] tags around the data itself and then everything will get
parsed.  I am trying to avoid that as it adds a few more key strokes.

I am going to review the pear template classes some more and get some
more ideas.

Thanks and 73,


--
Leonard Burton, N9URK
[EMAIL PROTECTED]


The prolonged evacuation would have dramatically affected the
survivability of the occupants.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Template style question

2005-11-08 Thread Robert Cummings
On Tue, 2005-11-08 at 20:21, Richard Lynch wrote:
 On Tue, November 8, 2005 6:23 pm, Robert Cummings wrote:
 
  I don;t think your the target audience, you don't see the need for OOP
  either :/
 
 au contraire!
 
 I see [have seen] many needs for OOP.
 
 The largest group of those needs is nowhere near a web-server.  I
 spent most of a decade writing Lisp code for AI research.  You can't
 get much more OOP than Common Lisp.  Makes PHP's OOP look wimpy. :-)
 :-) :-)
 
 [-- SNIP --]

Ok, that was a good qualification of your stance on web oriented OOP. I
must say I generally agree with what you wrote. My biggest peeve with
OOP'ers are the ones that think it's ok to retrieve 100 results from a
database table, turn those 100 rows into objects, then recursively
retrieve the subdata for each of those objects from the database. One
site I took over on generated 18000 queries on the home page *shudder*.
Fortunately database transfers are pretty zippy when the database is on
the same machine, but as we all know, that's not scaleable :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Template style question

2005-11-06 Thread Stephen Leaf
One idea that you might try. is XSL.
instead of doing %var1% and doing a replace. you can do things like
xsl:value-of select=var1/
Doing this also completely separates presentation logic from the code.
you can do other fun things like loops also.
I will warn you by saying that XSL in the beginning is a real headache to 
figure out. but after you get things down, it's very nice.
I currently have things in my sites setup to init an Object that when echo'd 
will do the XSL translation for me.
After that all I do is gather the data into an XML document and stylize it.
Simplifies websites considerably. Gather the data you need... stylize it how 
you want it.. and if you want to swap out the entire layout on the fly.

On Saturday 05 November 2005 01:10 pm, Leonard Burton wrote:
 Greetings,

 HI All, I hope all is well.

 I have set up a template parser.  Basically, it parses the template
 and finds tags with tag_name.dat file and then includes the
 tag_name.dat file.  I have considered a few other options but as of
 now I think I like what I have come up with.

 The only problem that I have in my design is that I have to hard code
 tables in the dat file mixing php and html.  I would prefer to be able
 to do something like:

 [[tag with db query]]
 table
 trtdcolname/tdtdcolname/tdtdcolname/td/tr
 trtd%var1%/tdTd%var2%/tdtd%var3%/td/tr
 /table
 [[/tag with db query]]

 I would like it to be able to parse the line with the %var1% (which is
 the column name with % or some other indicator on each side) in it and
 then have it generate how many ever rows as nessecary.

 Currently, my parsing engine loads the template, preg_splits() it so
 each template tag is on a new line, and then passes through the
 resulting array and executes the code for whatever tag is chosen.

 There are a couple ideas that I have thought of but have not thought
 of any real good way so I am turning to the list.

 Thanks for all of your help on this list!

 --
 Leonard Burton, N9URK
 [EMAIL PROTECTED]


 The prolonged evacuation would have dramatically affected the
 survivability of the occupants.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Template style question

2005-11-05 Thread Leonard Burton
Greetings,

HI All, I hope all is well.

I have set up a template parser.  Basically, it parses the template
and finds tags with tag_name.dat file and then includes the
tag_name.dat file.  I have considered a few other options but as of
now I think I like what I have come up with.

The only problem that I have in my design is that I have to hard code
tables in the dat file mixing php and html.  I would prefer to be able
to do something like:

[[tag with db query]]
table
trtdcolname/tdtdcolname/tdtdcolname/td/tr
trtd%var1%/tdTd%var2%/tdtd%var3%/td/tr
/table
[[/tag with db query]]

I would like it to be able to parse the line with the %var1% (which is
the column name with % or some other indicator on each side) in it and
then have it generate how many ever rows as nessecary.

Currently, my parsing engine loads the template, preg_splits() it so
each template tag is on a new line, and then passes through the
resulting array and executes the code for whatever tag is chosen.

There are a couple ideas that I have thought of but have not thought
of any real good way so I am turning to the list.

Thanks for all of your help on this list!

--
Leonard Burton, N9URK
[EMAIL PROTECTED]


The prolonged evacuation would have dramatically affected the
survivability of the occupants.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Template style question

2005-11-05 Thread Florent Monnier

Perhaps you could get inspirations and tips from:
http://pear.php.net/search.php?q=templatein=packages

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Template style question

2005-11-05 Thread Leonard Burton
Hi All,

On 11/5/05, Robert Cummings [EMAIL PROTECTED] wrote:
 On Sat, 2005-11-05 at 14:55, James Benson wrote:
  Give smarty a try rather than re-inventing the wheel
 
  http://smarty.php.net

Reinventing the wheel is much better than either the LGPL or GPL.
Writing GPL or LGPL code on PHP is just wrong.  Either keep the code
for your own use or use the PHP license.  Most of the stuff I see that
is distributed under the [L]*GPL isn't worth much.  If PHP can be
written under the PHP license why can't small little apps that is
written in PHP?  I release my code snippets (from time to time) under
either the PHP or BSD license.

Thanks for you answers.  I will look through the pear classes and see
what kind of things it is doing.


--
Leonard Burton, N9URK
[EMAIL PROTECTED]


The prolonged evacuation would have dramatically affected the
survivability of the occupants.


--
Leonard Burton, N9URK
[EMAIL PROTECTED]


The prolonged evacuation would have dramatically affected the
survivability of the occupants.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php