2001-03-10 11:07:52 +00:00
< ? php
2001-10-20 18:57:09 +00:00
// $Id$
2000-10-10 10:52:19 +00:00
2002-04-14 19:34:04 +00:00
/**
* Basic theme
*
* @ package theme system
*/
2001-06-10 13:53:44 +00:00
class BaseTheme {
2002-06-12 12:33:27 +00:00
var $background = " #ffffff " ;
var $foreground = " #000000 " ;
2001-10-20 13:35:12 +00:00
2002-04-14 19:34:04 +00:00
function system ( $field ) {
2002-06-12 12:33:27 +00:00
$system [ " name " ] = " Basic theme " ;
$system [ " author " ] = " Drupal " ;
$system [ " description " ] = " Basic theme. Lynx friendly " ;
2002-04-14 19:34:04 +00:00
return $system [ $field ];
}
2001-12-15 16:22:31 +00:00
function header ( $title = " " ) {
2002-09-11 15:17:49 +00:00
$output = " <!DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.0 Transitional//EN \" \" DTD/xhtml1-transitional.dtd \" > \n " ;
2002-11-09 16:24:46 +00:00
$output .= " <html><head><title> " . variable_get ( site_name , " drupal " ) . " </title> " ;
$output .= theme_head ( $main );
$output .= " </head><body bgcolor= \" $this->background\ " text = \ " $this->foreground\ " > " ;
2001-10-20 13:35:12 +00:00
$output .= " <table border= \" 0 \" cellspacing= \" 4 \" cellpadding= \" 4 \" ><tr><td valign= \" top \" width= \" 170 \" > " ;
print $output ;
2002-02-19 22:58:33 +00:00
$this -> box ( t ( " Navigation " ), @ implode ( " <br /> " , link_page ())); theme_blocks ( " all " , $this );
2002-01-12 21:35:13 +00:00
print " </td><td valign= \" top \" > " ;
2001-10-20 13:35:12 +00:00
}
2001-06-29 22:08:57 +00:00
function links ( $links , $delimiter = " | " ) {
2002-06-12 12:33:27 +00:00
return implode ( $delimiter , $links );
This a rather large commit that needs a lot of fine-tuning. If you
update, you'll break your site as you need switching from structure
to index.module: so this can be considered an intermediate commit.
If you upgrade, and you are welcome to, just create a collection
called "section" (for now) and assign your nodes some attributes
in the described format.
Feedback and bugreports are welcomed. Questions will be answered.
CHANGES:
- comment system:
+ when replying to a node (rather then to a comment), that
node is displayed above the reply form.
+ when replying to a comment (rather then to a node), that
comment is displayd above the reply form.
- removed structure.inc, removed structure.module.
- node.inc:
+ added 2 new node functions called 'node_attribute_edit()' and
'node_attribute_save()' used to 'hook in' any indexing system
including your home-brewed stuff if you'd want to. Currently,
index.module is the facto default index system.
See story.module for usage.
- book.module, story.module, poll.module, page.module, forum.module:
+ added preview functionality to administration section (via node
module).
+ removed all references to structure.inc (category, topic).
- moderate.module:
+ removed all references to structure.inc (category, topic).
- book.module, story.module, page.module, forum.module:
+ increased the sizes of some textareas.
- submit.php:
+ removed all references to structure.inc (category, topic).
- marvin.theme:
+ removed dead code: function story() was depricated.
- unconed.theme:
+ removed hardcoded references to drop.org.
- marvin.theme, unconed.theme, jeroen.theme, yaroon.theme, example.theme:
+ removed all references to structure.inc (category, topic).
TODO:
- file.module, trip_link.module:
+ update preview functionality:
see story.module for example.
+ remove references to 'cid' and 'tid', use 'attribute' instead:
see story.module for example.
- extend and build upon index.module as well as making it configurable
2001-06-10 15:01:20 +00:00
}
2001-07-14 12:12:41 +00:00
2001-07-14 13:36:38 +00:00
function image ( $name ) {
return " misc/ $name " ;
2001-07-14 12:12:41 +00:00
}
2001-08-11 14:54:39 +00:00
2001-10-20 13:35:12 +00:00
function node ( $node , $main ) {
2003-02-09 17:39:40 +00:00
if ( module_exist ( " taxonomy " )) {
$terms = taxonomy_link ( " taxonomy terms " , $node );
2002-05-20 18:00:59 +00:00
}
2002-05-25 06:47:47 +00:00
2002-12-31 12:34:07 +00:00
$output = " <b> $node->title </b> by " . format_name ( $node ) . " <br /> " ;
2003-02-09 17:39:40 +00:00
2002-05-20 18:00:59 +00:00
if ( count ( $terms )) {
$output .= " <small>( " . $this -> links ( $terms ) . " )</small><br /> " ;
}
2003-02-09 17:39:40 +00:00
2001-10-20 13:35:12 +00:00
if ( $main && $node -> teaser ) {
2002-12-31 12:34:07 +00:00
$output .= check_output ( $node -> teaser );
2001-10-20 13:35:12 +00:00
}
else {
2002-12-31 12:34:07 +00:00
$output .= check_output ( $node -> body );
2001-10-07 12:27:58 +00:00
}
2001-11-23 17:10:46 +00:00
if ( $links = link_node ( $node , $main )) {
$output .= " <br />[ " . $this -> links ( $links ) . " ] " ;
2001-10-20 13:35:12 +00:00
}
$output .= " <hr /> " ;
print $output ;
2001-10-07 12:27:58 +00:00
}
2001-10-20 13:35:12 +00:00
function box ( $subject , $content , $region = " main " ) {
2003-01-21 22:57:43 +00:00
$output = " <p><b> $subject </b><br /> $content </p> " ;
2001-10-20 13:35:12 +00:00
print $output ;
}
2003-02-01 19:54:19 +00:00
function block ( $subject , $content , $region = " main " ) {
global $theme ;
$theme -> box ( $subject , $content , $region );
}
2001-10-20 13:35:12 +00:00
function footer () {
2002-09-11 15:17:49 +00:00
$output = " </td></tr></table> " ;
2001-10-20 13:35:12 +00:00
$output .= " </body></html> " ;
print $output ;
}
2001-06-10 13:53:44 +00:00
}
2002-10-22 18:46:43 +00:00
function theme_mark () {
/*
** Return a marker . Used to indicate new comments or required form
** fields .
*/
return " <span style= \" color: red; \" >*</span> " ;
}
2002-11-09 20:50:50 +00:00
function theme_item_list ( $items = array (), $title = NULL ) {
2002-11-09 13:59:36 +00:00
/*
** Return a formatted array of items .
*/
2002-11-09 20:12:03 +00:00
if ( isset ( $title )) {
2002-11-09 13:59:36 +00:00
$output .= " <b> $title </b><br /> " ;
}
2002-11-09 20:12:03 +00:00
if ( isset ( $items )) {
foreach ( $items as $item ) {
$output .= " - $item <br /> " ;
}
2002-11-09 13:59:36 +00:00
}
return $output ;
}
2002-10-22 18:46:43 +00:00
function theme_error ( $message ) {
/*
** Return an error message .
*/
return " <div style= \" color: red; \" > $message </div> " ;
}
2002-04-14 19:34:04 +00:00
function theme_list () {
static $list ;
2001-01-21 19:41:11 +00:00
2002-04-14 19:34:04 +00:00
if ( ! $list ) {
$list = array ();
$result = db_query ( " SELECT * FROM system where type = 'theme' AND status = '1' ORDER BY name " );
while ( $theme = db_fetch_object ( $result )) {
2002-05-25 06:47:47 +00:00
if ( file_exists ( $theme -> filename )) {
$list [ $theme -> name ] = $theme ;
}
2002-04-14 19:34:04 +00:00
}
2001-01-21 19:41:11 +00:00
}
2002-04-14 19:34:04 +00:00
return $list ;
}
2002-11-09 16:24:46 +00:00
function theme_head ( $main = 0 ) {
$head = module_invoke_all ( " head " , $main );
2002-11-10 21:16:58 +00:00
return implode ( $head , " \n " );
2002-11-09 16:24:46 +00:00
}
2002-04-14 19:34:04 +00:00
function theme_init () {
global $user ;
$themes = theme_list ();
$name = $user -> theme ? $user -> theme : variable_get ( " theme_default " , 0 );
if ( is_object ( $themes [ $name ])) {
include_once ( $themes [ $name ] -> filename );
2002-04-15 15:10:06 +00:00
$theme_class = " Theme_ $name " ;
2002-11-17 16:32:03 +00:00
@ $obj =& new $theme_class ();
$obj -> path = dirname ( $themes [ $name ] -> filename );
2002-04-14 19:34:04 +00:00
return $obj ;
2001-01-21 19:41:11 +00:00
}
2002-02-17 13:04:50 +00:00
2002-04-14 19:34:04 +00:00
@ $obj =& new BaseTheme ;
return $obj ;
2001-01-21 19:41:11 +00:00
}
2003-02-01 19:54:19 +00:00
/**
* Render blocks available for $user and $region calling $theme -> block ( $region ) .
*
* @ param string $region main | left | right
*/
function theme_blocks ( $region ) {
2003-02-27 22:48:32 +00:00
global $user , $REQUEST_URI ;
2001-01-26 13:38:46 +00:00
2002-10-26 15:17:26 +00:00
$result = db_query ( " SELECT * FROM blocks WHERE (status = '1' OR custom = '1') " . ( $region != " all " ? " AND region = '%s' " : " " ) . " ORDER BY weight, module " , $region == " left " ? 0 : 1 );
2002-05-20 07:34:38 +00:00
2002-01-21 17:31:13 +00:00
while ( $result && ( $block = db_fetch_object ( $result ))) {
2003-02-27 22:48:32 +00:00
if ((( $block -> status && ( ! $user -> uid || ! $block -> custom )) || ( $block -> custom && $user -> block [ $block -> module ][ $block -> delta ])) && ( ! $block -> path || preg_match ( '/' . str_replace ( '/' , '\/' , $block -> path ) . '/' , request_uri ()))) {
2002-10-26 15:17:26 +00:00
$block_data = module_invoke ( $block -> module , " block " , " view " , $block -> delta );
if ( $block_data [ " content " ]) {
2003-02-11 20:01:17 +00:00
theme ( " block " , $block_data [ " subject " ], $block_data [ " content " ], $region );
2002-05-02 19:13:45 +00:00
}
2000-12-23 23:25:28 +00:00
}
}
}
2001-10-22 12:55:41 +00:00
2003-02-11 20:01:17 +00:00
function theme () {
2002-06-23 13:31:30 +00:00
global $theme ;
$args = func_get_args ();
2002-10-22 18:46:43 +00:00
2002-06-23 13:31:30 +00:00
$function = array_shift ( $args );
if ( method_exists ( $theme , $function )) {
return call_user_method_array ( $function , $theme , $args );
2002-10-22 18:46:43 +00:00
}
2002-06-23 13:31:30 +00:00
else {
return call_user_func_array ( $function , $args );
}
}
2000-11-07 08:58:36 +00:00
?>