You are here: Porting a themes engine to OO « PHP Programming Language « IT news, forums, messages
Porting a themes engine to OO

Posted by Full Decent on 01/04/06 00:16

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 =
$preferences['theme']
* The page you are viewing (if it is interactive, and needs themes),
has: include("common.php");
include("themes/$theme/theme.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
Information');
* 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:
$themeengine->html_section(...)

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,
FD

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация