function __autoload($classname)
{
// put the path to your class files here
$my_path = "/var/www/mydomain.com/lib";
// tell PHP to scan the default include paht AND your include path
set_include_path(get_include_path() . PATH_SEPARATOR . $my_path);
// name your classes and filenames with underscores, i.e., Net_Whois stored in Net_Whois.php
$classfile = str_replace("_", "/", $classname) . ".php";
include_once($classfile);
}
/**
* EXAMPLE:
* create one of your objects, saved in /var/www/mydomain.com/lib/Project/Database.php
*/
$db = new Project_Database();
/**
* EXAMPLE:
* create a PEAR object, saved in /usr/local/lib/php/File.php
*/
$f = new File();
/**
* Themeing function to render a form as a table.
*
* The $form array should contain the following:
* - $form['heading'], a form item of the default (markup) type (thus with
* only #value set), containing an (optional) heading.
* - $form['header'], an array of form items of the default (markup) type
* (thus with only #value set), containing the header fields
* - $form['rows'], an array of form items containing the rows. Each row is
* again an array of form items.
* - $form['empty'], if this is set, then no table will be rendered. You may
* want to put an "empty message" in here.
*
* When $form['empty'] is not set, a table will be rendered first. After that,
* all other form items will get rendered.
* If $form['empty'] is set, $form['header'] and $form['rows] will be deleted,
* and then all other form items will get rendered.
*/
function theme_mymodule_table_form($form) {
$output = '';
$header = array();
$rows = array();
// We always want the heading to be rendered first.
$output .= drupal_render($form['heading']);
if (!$form['empty']) {
// Render $form['header'] as the header of the table.
foreach ($form['header'] as $field) {
$header[]['data'] = $field['#value'];
}
unset($form['header']);
// Render $form['rows'] as the rows of the table.
foreach (element_children($form['rows']) as $i) {
$row = array();
foreach (element_children($form['rows'][$i]) as $key) {
$row[]['data'] = drupal_render($form['rows'][$i][$key]);
}
$rows[] = $row;
}
// Render the table.
$output .= theme('table', $header, $rows, array('width' => '100%'));
}
else {
// Delete the header and rows, just to be sure.
unset($form['header']);
unset($form['rows']);
// Render the empty message.
$output .= drupal_render($form['empty']);
}
// Render the remaining form items.
$output .= drupal_render($form);
return $output;
}
<?php
// TODO: Enter some task that needs to be done.
// FIXME: Enter some bug that needs to be fixed.
// FIXME(BugNumber): Reference a bug number for FIXME.
// CHANGED: Once finished with TODO, replacement with CHANGED is recommended.
// NOTE: Enter a simple note.
// OPTIMIZE: A TODO specifically for optimization notes.
// IMPROVE: A TODO specifically for improvement notes.
// Examples:
// TODO: Add in a update script.
// FIXME: Bug in update script (cannot download new file).
// FIXME(81239): Bug in update script (cannot download new file).
// CHANGED: Added update script.
// NOTE: The update script is still a bit buggy.
// OPTIMIZE: Update download speed.
// IMPROVE: Make the UI a bit better for update script.
?>
// home.php?act=index
<?php
if (isset($_GET['act'])) $PAGEACTION = $_GET['act'];
else $PAGEACTION = 'index';
switch ($PAGEACTION) {
// index page
case 'index':
include ('index.php');
break;
// an about page
case 'about':
include ('about.php');
break;
// $PAGEACTION doesn't exist
default:
// or just forward to home.php?act=index
echo "page does not exist";
break;
}
?>