note 16287 added to pear.about
| From: | codeguru at cs dot utexas dot edu | Date: | Tue, 23 Oct 2001 19:03:37 +0000 |
| Subject: | note 16287 added to pear.about | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-19339@lists.php.net to get a copy of this message | ||
My table class is similar to many other PHP table classes except one thing. It can attach call back
functions to each of the table cell so that all required contents that are to be rendered in that
cell are coded separately from the code creating table. This has a great advantage that we can
first inherit from a table class that creates the table frames that are common to a number of pages.
The contents are rendered by other virtual functions (understand I used C++ terms here. :-)), which
will later be redefined again in another class which is inherited from this class. For example,
suppose many pages have top parts, left and right pars.
+---------------------------+
| Top Part |
+---------------------------+
| | |
| | |
| Left | Right |
| Part | Part |
| | |
| | |
+---------------------------+
Then, we can define a table class(PCommonTable) for this table structure as,
class PCommonTable extends PTable
{
function PCommonTable()
{
// call parent constructor
$this->PTable();
}
// this function which creates
// rows and columns and attaches
// callback is already defined
// in the parent PTable class,
// so must use this name.
function CreateTable()
{
// create a row for Top part
$li_Row = $this->AddRow();
// create a column for this row
// and attaches the callback function
$this->AddCol($li_Row, 0, 0, "\$this->DrawTopPart");
// add another row
$li_Row = $this->AddRow();
// add 2 colums for this row
// for Left and Right Part
$this->AddColumn($li_Row, 0, 0, "\$this->DrawLeftPart");
$this->AddColumn($li_Row, 0, 0, "\$this->DrawRightPart");
}
function DrawTopPart()
{
// do nothing
}
function DrawLeftPart()
{
// do nothing
}
function DrawRightPart()
{
// do nothing
}
}
Then, you derive a new class from this PCommonTable class to create the actual page with contents in
it and here, you don't need to rewrite all table frame management codes! You can just redefine
the contents only by redefining all of the Draw{Top|Left|Right}Part() functions only!
class PIntroTableClass extends PCommonTable
{
function DrawTopPart()
{
print "Hello! I am top!";
}
function DrawLeftPart()
{
print "Hello! I am Left!";
}
function DrawRightPart()
{
print "Hello! I am Right!";
}
}
The internals of all PFC framework to make this work is a little bit complicated but this really
greatly minimized the repeating codes across the pages.
This PFC project is slowly making progress only by myself. In the future, I would like to build
1. Web Service classes in view of .NET trend
2. More Client classes involving Javascript manipulation
- I was very much impressed at th interactivity of the .NET aspx classes at the browsers and
why net PHP?
I named PFC + these additional part as PHPX, and welcome anyone who could join me or advise me or
put comments to it.
I am currently a graduate student at Computer Sciences, UT Austin so cannot think of these too much
but I think it would be great if others could join!!!
To test or see how they work, visit
http://satriani.wo.to/ or
http://www.cs.utexas.edu/users/codeguru/
I will setup download pages if anyone wants source codes for my PFC, currently I have got no time
to.
--
http://www.php.net/manual/en/pear.about.php
http://master.php.net/manage/user-notes.php?action=edit+16287
http://master.php.net/manage/user-notes.php?action=delete+16287
http://master.php.net/manage/user-notes.php?action=reject+16287