470,849 Members | 1,249 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

Porting a themes engine to OO

Hey again!

In my quest to make proper use of OO PHP I would like to ask for a
critique of the current method of doing themes in the Camera Life
(http://fdcl.sf.net) software and see if an OO approach is more
appropriate. This program consists of multiple PHP pages that include a
common.php file. My motivation is to make making themes easier, so we
can get more theme contributors!

Themes consist of image files, a css file and a PHP file that generates
HTML. An example is linked from here:
http://fdcl.sourceforge.net/index.php?content=themes In order to
"install a theme," you untar the package into your "themes" folder and
select the new theme from the administrative page.

* The common.php file gets the preference: $theme =
* The page you are viewing (if it is interactive, and needs themes),
has: include("common.php");
* The first line in HEAD of the page you are viewing is: <link
rel="stylesheet" href="themes/<?= $theme ?>/theme.css">
* The page you are viewing makes some HTML calls to the theme engine
(in the golbal namespace) like this: html_section('Photo Tasks and
* Any themed images on the page go like this: <img src="themes/<?=
$theme ?>/images/small-photo" ...>, images can be in any format,
because the software explicitly requires content negotiation :-)

I am wondering if I should update this to a OO approach, and if so,
how? My first guess would be to:

* Create themes/theme_base.php with a "theme" class and stubs for all
the html functions.
* All themes/*/theme.php will be classes that extend the "theme" class
* Change common.php to something like:
foreach(glob("themes/*/theme.php" as $themefile) {include $themefile};
* Add to common.php something like "$themeengine = new
$preferences['theme']". Here $preferences['theme'] is the name of a
type that will instantiate $themeengine.
* On each page the user sees, change to calls like:

Please let me know if this is an abuse of the OO concept of PHP, or if
there are other considerations that I am overlooking. And thanks for
your quick and helpful responses to my last OO question.

Thank in advance,

Jan 3 '06 #1
0 1335

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Jan Hyde | last post: by
4 posts views Thread by Sean | last post: by
6 posts views Thread by Clinton Farleigh | last post: by
3 posts views Thread by WT | last post: by
11 posts views Thread by New Bee | last post: by
2 posts views Thread by mike | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.