2001-03-10 11:07:52 +00:00
< ? php
2000-10-10 10:52:19 +00:00
2001-02-18 15:14:56 +00:00
function theme_init () {
2001-01-21 19:41:11 +00:00
global $user , $themes ;
if ( $user -> theme && file_exists ( $themes [ $user -> theme ][ 0 ])) {
2001-01-26 13:38:46 +00:00
include_once $themes [ $user -> theme ][ 0 ];
2001-01-21 19:41:11 +00:00
}
else {
2001-05-06 17:19:58 +00:00
include_once $themes [ variable_get ( " theme_default " , key ( $themes ))][ 0 ];
2001-01-21 19:41:11 +00:00
}
return new Theme ();
}
2001-03-24 17:50:08 +00:00
function theme_link ( $separator = " | " ) {
2001-04-29 10:03:21 +00:00
$links [] = " <A HREF= \" index.php \" > " . t ( " home " ) . " </A> " ;
$links [] = " <A HREF= \" search.php \" > " . t ( " search " ) . " </A> " ;
$links [] = " <A HREF= \" submit.php \" > " . t ( " submit " ) . " </A> " ;
2001-04-23 11:06:18 +00:00
$links [] = " <A HREF= \" account.php \" > " . t ( " account " ) . " </A> " ;
2001-05-12 21:06:13 +00:00
foreach ( module_list () as $name ) {
if ( module_hook ( $name , " page " )) $links [] = " <A HREF= \" module.php?mod= $name\ " > " .t( $name ) . " </ A > " ;
}
// if (module_exist("forum")) $links[] = "<A HREF=\"module.php?mod=forum\">".t("forum") ."</A>";
// if (module_exist("diary")) $links[] = "<A HREF=\"module.php?mod=diary\">". t("diary") ."</A>";
// if (module_exist("book")) $links[] = "<A HREF=\"module.php?mod=book\">". t("handbook") ."</A>";
2001-04-29 10:03:21 +00:00
2001-03-24 17:50:08 +00:00
return implode ( $separator , $links );
}
2001-03-24 17:04:11 +00:00
2000-12-23 23:25:28 +00:00
function theme_account ( $theme ) {
2001-05-05 13:57:29 +00:00
global $user ;
2001-01-26 13:38:46 +00:00
if ( $user -> id ) {
2000-12-30 11:58:14 +00:00
// Display account settings:
2001-02-12 20:40:43 +00:00
$content .= " <LI><A HREF= \" account.php?op=track&topic=comments \" > " . t ( " track your comments " ) . " </A></LI> \n " ;
2001-03-24 17:04:11 +00:00
$content .= " <LI><A HREF= \" account.php?op=track&topic=nodes \" > " . t ( " track your nodes " ) . " </A></LI> \n " ;
2001-05-06 17:19:58 +00:00
$content .= " <LI><A HREF= \" account.php?op=track&topic=site \" > " . strtr ( t ( " track %a " ), array ( " %a " => variable_get ( " site_name " , " drupal " ))) . " </A></LI> \n " ;
2000-12-23 23:25:28 +00:00
$content .= " <P> \n " ;
2001-02-12 20:40:43 +00:00
$content .= " <LI><A HREF= \" account.php?op=edit&topic=user \" > " . t ( " edit your information " ) . " </A></LI> \n " ;
$content .= " <LI><A HREF= \" account.php?op=edit&topic=site \" > " . t ( " edit your preferences " ) . " </A></LI> \n " ;
$content .= " <LI><A HREF= \" account.php?op=edit&topic=content \" > " . t ( " edit your content " ) . " </A></LI> \n " ;
2000-12-23 23:25:28 +00:00
$content .= " <P> \n " ;
2001-01-06 11:39:43 +00:00
2001-02-18 15:14:56 +00:00
if ( user_access ( $user )) {
2001-05-06 17:19:58 +00:00
$content .= " <LI><A HREF= \" admin.php \" >administer " . variable_get ( " site_name " , " drupal " ) . " </A></LI> \n " ;
2001-01-06 11:39:43 +00:00
$content .= " <P> \n " ;
}
2001-05-05 13:57:29 +00:00
foreach ( module_list () as $name ) {
if ( $links = module_invoke ( $name , " menu " )) {
foreach ( $links as $link ) $content .= " <LI> $link </LI> \n " ;
}
2001-01-04 21:09:40 +00:00
}
2001-05-05 13:57:29 +00:00
if ( $link ) $content .= " <P> \n " ;
2001-01-06 11:39:43 +00:00
2001-02-12 20:40:43 +00:00
$content .= " <LI><A HREF= \" account.php?op=logout \" > " . t ( " logout " ) . " </A></LI> \n " ;
2000-12-23 23:25:28 +00:00
2001-02-17 12:59:24 +00:00
$theme -> box ( strtr ( t ( " %a's configuration " ), array ( " %a " => $user -> userid )), " $content " );
2000-12-23 23:25:28 +00:00
}
else {
2001-04-02 21:18:17 +00:00
$output .= " <DIV ALIGN= \" center \" > \n " ;
2001-02-17 12:59:24 +00:00
$output .= " <FORM ACTION= \" account.php?op=login \" METHOD= \" post \" > \n " ;
$output .= " <B> " . t ( " Username " ) . " :</B><BR><INPUT NAME= \" userid \" SIZE= \" 15 \" ><P> \n " ;
$output .= " <B> " . t ( " Password " ) . " :</B><BR><INPUT NAME= \" passwd \" SIZE= \" 15 \" TYPE= \" password \" ><BR> \n " ;
$output .= " <INPUT TYPE= \" submit \" VALUE= \" " . t ( " Login " ) . " \" ><BR> \n " ;
$output .= " <A HREF= \" account.php \" > " . t ( " REGISTER " ) . " </A> \n " ;
2000-12-23 23:25:28 +00:00
$output .= " </FORM> \n " ;
2001-04-02 21:18:17 +00:00
$output .= " </DIV> \n " ;
2000-12-23 23:25:28 +00:00
2001-02-12 20:40:43 +00:00
$theme -> box ( t ( " Login " ), $output );
2000-12-23 23:25:28 +00:00
}
}
2001-01-13 16:33:19 +00:00
function theme_blocks ( $region , $theme ) {
2001-03-25 10:57:01 +00:00
global $id , $PHP_SELF , $status , $user ;
2001-01-26 13:38:46 +00:00
2001-01-24 08:24:37 +00:00
switch ( strrchr ( $PHP_SELF , " / " )) {
2001-03-24 17:04:11 +00:00
case " /node.php " :
2001-03-08 21:00:28 +00:00
if ( $region != " left " ) {
2001-03-29 19:50:31 +00:00
if ( $user -> id ) $node = db_fetch_object ( db_query ( " SELECT * FROM node WHERE nid = ' $id ' " ));
2001-03-25 10:57:01 +00:00
if ( $node -> status == $status [ queued ]) theme_moderation_results ( $theme , $node );
2001-03-24 17:04:11 +00:00
// else theme_new_headlines($theme);
2001-03-08 21:00:28 +00:00
}
2000-12-23 23:25:28 +00:00
break ;
2001-01-24 08:24:37 +00:00
case " /index.php " :
2001-03-08 10:49:26 +00:00
if ( $user -> id ) $result = db_query ( " SELECT * FROM blocks b LEFT JOIN layout l ON b.name = l.block WHERE (b.status = 2 OR (b.status = 1 AND l.user = ' $user->id ')) " . (( $region == " left " || $region == " right " ) ? ( $region == " left " ? " AND b.region = 0 " : " AND b.region = 1 " ) : " " ) . " ORDER BY weight " );
2001-02-27 20:58:51 +00:00
else $result = db_query ( " SELECT * FROM blocks WHERE status = 2 " . (( $region == " left " || $region == " right " ) ? ( $region == " left " ? " AND region = 0 " : " AND region = 1 " ) : " " ) . " ORDER BY weight " );
2000-12-29 11:00:56 +00:00
while ( $block = db_fetch_object ( $result )) {
2001-05-05 13:57:29 +00:00
$blocks = module_invoke ( $block -> module , " block " );
2001-02-12 20:40:43 +00:00
$theme -> box ( t ( $blocks [ $block -> offset ][ " subject " ]), $blocks [ $block -> offset ][ " content " ]);
2000-12-29 11:00:56 +00:00
}
break ;
2000-12-23 23:25:28 +00:00
}
}
2001-03-24 17:04:11 +00:00
function theme_morelink ( $theme , $node ) {
2001-04-16 11:38:12 +00:00
return ( $node -> body ) ? " [ <A HREF= \" node.php?id= $node->nid\ " >< FONT COLOR = \ " $theme->link\ " > " . t( " read more " ) . " </ FONT ></ A > | " . sizeof(explode( " " , $node->body )) . " " . t( " words " ) . " | < A HREF = \ " node.php?id= $node->nid\ " >< FONT COLOR = \ " $theme->link\ " > " . format_plural(node_get_comments( $node->nid ), " comment " , " comments " ) . " </ FONT ></ A > ] " : " [ < A HREF = \ " node.php?id= $node->nid\ " >< FONT COLOR = \ " $theme->link\ " > " . format_plural(node_get_comments( $node->nid ), " comment " , " comments " ) . " </ FONT ></ A > ] " ;
2000-12-23 23:25:28 +00:00
}
2001-03-24 17:04:11 +00:00
function theme_moderation_results ( $theme , $node ) {
2001-05-16 20:54:37 +00:00
foreach ( explode ( " ; " , $node -> users ) as $vote ) {
if ( $vote ) {
$data = explode ( " : " , $vote );
$output .= format_username ( $data [ 0 ]) . " voted ' $data[1] '.<BR> " ;
2000-12-23 23:25:28 +00:00
}
}
2001-05-16 20:54:37 +00:00
$theme -> box ( t ( " Moderation results " ), ( $output ? $output : t ( " This node has not been moderated yet. " )));
2000-12-23 23:25:28 +00:00
}
2001-03-25 10:57:01 +00:00
/*
//
// depricated -> new block strategy
//
2000-12-23 23:25:28 +00:00
function theme_new_headlines ( $theme , $num = 10 ) {
2001-03-29 19:50:31 +00:00
$result = db_query ( " SELECT nid, title FROM node WHERE status = 2 AND type = 'story' ORDER BY nid DESC LIMIT $num " );
2001-03-24 17:04:11 +00:00
while ( $node = db_fetch_object ( $result )) $content .= " <LI><A HREF= \" node.php?id= $node->nid\ " > " . check_output( $node->title ) . " </ A ></ LI > \n " ;
2001-03-01 21:34:09 +00:00
$theme -> box ( t ( " Latest headlines " ), $content );
2000-12-23 23:25:28 +00:00
}
2000-10-10 10:52:19 +00:00
2000-12-30 11:58:14 +00:00
function theme_old_headlines ( $theme , $num = 10 ) {
global $user ;
2001-01-26 13:38:46 +00:00
2001-03-24 17:04:11 +00:00
$result = db_query ( " SELECT id, subject, timestamp FROM story WHERE status = 2 ORDER BY timestamp DESC LIMIT " . ( $user -> nodes ? $user -> nodes : $num ) . " , $num " );
while ( $node = db_fetch_object ( $result )) {
if ( $time != date ( " F jS " , $node -> timestamp )) {
$content .= " <P><B> " . date ( " l, M jS " , $node -> timestamp ) . " </B></P> \n " ;
$time = date ( " F jS " , $node -> timestamp );
2000-12-30 11:58:14 +00:00
}
2001-03-24 17:04:11 +00:00
$content .= " <LI><A HREF= \" node.php?id= $node->nid\ " > " . check_output( $node->title ) . " </ A ></ LI > \n " ;
2000-12-30 11:58:14 +00:00
}
2001-03-01 21:34:09 +00:00
$theme -> box ( t ( " Older headlines " ), $content );
2000-12-30 11:58:14 +00:00
}
2001-03-25 10:57:01 +00:00
*/
2000-12-30 11:58:14 +00:00
2000-11-07 08:58:36 +00:00
?>