2000-10-10 10:52:19 +00:00
< ?
2001-01-21 19:41:11 +00:00
function theme_load () {
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 {
include_once $themes [ key ( $themes )][ 0 ];
}
return new Theme ();
}
2000-12-23 23:25:28 +00:00
function theme_account ( $theme ) {
2001-01-04 21:09:40 +00:00
global $user , $site_name , $links , $menu ;
2001-01-26 13:38:46 +00:00
if ( $user -> id ) {
2000-12-23 23:25:28 +00:00
function submission_number () {
$result = db_query ( " SELECT COUNT(id) FROM stories WHERE status = 1 " );
return ( $result ) ? db_result ( $result , 0 ) : 0 ;
}
2001-01-04 21:09:40 +00:00
function menu ( $name , $module ) {
global $menu ;
2001-01-04 21:17:07 +00:00
if ( $module [ " menu " ]) $menu = ( $menu ) ? array_merge ( $menu , $module [ " menu " ]()) : $module [ " menu " ]();
2001-01-04 21:09:40 +00:00
}
module_iterate ( " menu " );
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 " ;
$content .= " <LI><A HREF= \" account.php?op=track&topic=stories \" > " . t ( " track your stories " ) . " </A></LI> \n " ;
$content .= " <LI><A HREF= \" account.php?op=track&topic=site \" > " . t ( " track " ) . " $site_name </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-04 22:09:38 +00:00
if ( user_permission ( $user )) {
2001-01-16 11:08:03 +00:00
$content .= " <LI><A HREF= \" admin.php \" >administer " . $site_name . " </A></LI> \n " ;
2001-01-06 11:39:43 +00:00
$content .= " <P> \n " ;
}
2001-02-12 20:40:43 +00:00
$content .= " <LI><A HREF= \" submission.php \" > " . t ( " submission queue " ) . " </A> (<FONT COLOR= \" red \" > " . submission_number () . " </FONT>)</LI> \n " ;
$content .= " <P> \n " ;
2001-01-06 11:39:43 +00:00
if ( $menu && ksort ( $menu )) {
2001-02-12 20:40:43 +00:00
foreach ( $menu as $link => $url ) $content .= " <LI><A HREF= \" $url\ " > " . t( $link ) . " </ A ></ LI > \n " ;
2001-01-04 21:09:40 +00:00
$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-12 20:40:43 +00:00
$theme -> box ( strtr ( t ( " %s's configuration " ), array ( " %s " => $user -> userid )), " $content " );
2000-12-23 23:25:28 +00:00
}
else {
$output .= " <CENTER> \n " ;
$output .= " <FORM ACTION= \" account.php?op=Login \" METHOD= \" post \" > \n " ;
2001-02-12 20:40:43 +00:00
$output .= " <P><B> " . t ( " Username " ) . " :</B><BR><INPUT NAME= \" userid \" SIZE= \" 15 \" ></P> \n " ;
$output .= " <P><B> " . t ( " Password " ) . " :</B><BR><INPUT NAME= \" passwd \" SIZE= \" 15 \" TYPE= \" password \" ></P> \n " ;
2000-12-23 23:25:28 +00:00
$output .= " <P><INPUT NAME= \" op \" TYPE= \" submit \" VALUE= \" Login \" ></P> \n " ;
2001-02-12 20:40:43 +00:00
$output .= " <P><A HREF= \" account.php \" > " . t ( " REGISTER " ) . " </A></P> \n " ;
2000-12-23 23:25:28 +00:00
$output .= " </FORM> \n " ;
$output .= " </CENTER> \n " ;
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 ) {
2000-12-29 11:00:56 +00:00
global $id , $PHP_SELF , $user ;
2001-01-26 13:38:46 +00:00
2001-01-24 08:24:37 +00:00
switch ( strrchr ( $PHP_SELF , " / " )) {
case " /story.php " :
2000-12-23 23:25:28 +00:00
if ( $user -> id ) $story = db_fetch_object ( db_query ( " SELECT * FROM stories WHERE id = ' $id ' " ));
if ( $story -> status == 1 ) theme_moderation_results ( $theme , $story );
else theme_new_headlines ( $theme );
break ;
2001-01-24 08:24:37 +00:00
case " /index.php " :
2001-01-13 16:33:19 +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 AND l.user = ' $user->id ')) " . (( $region == " left " || $region == " right " ) ? ( $region == " left " ? " AND b.region = 0 " : " AND b.region = 1 " ) : " " ) . " ORDER BY weight " );
else $result = db_query ( " SELECT * FROM blocks WHERE status = 2 ORDER BY weight " );
2000-12-29 11:00:56 +00:00
while ( $block = db_fetch_object ( $result )) {
$blocks = module_execute ( $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
}
}
function theme_morelink ( $theme , $story ) {
2001-02-04 22:09:38 +00:00
return ( $story -> article ) ? " [ <A HREF= \" story.php?id= $story->id\ " >< FONT COLOR = \ " $theme->link\ " >< B > read more </ B ></ FONT ></ A > | " . strlen( $story->article ) . " bytes | < A HREF = \ " story.php?id= $story->id\ " >< FONT COLOR = \ " $theme->link\ " > " . format_plural( $story->comments , " comment " , " comments " ) . " </ FONT ></ A > ] " : " [ < A HREF = \ " story.php?id= $story->id\ " >< FONT COLOR = \ " $theme->link\ " > " . format_plural( $story->comments , " comment " , " comments " ) . " </ FONT ></ A > ] " ;
2000-12-23 23:25:28 +00:00
}
function theme_moderation_results ( $theme , $story ) {
global $user ;
2001-02-04 22:09:38 +00:00
if ( $user -> id && $story -> id && ( $user -> id == $story -> author || user_get_history ( $user -> history , " s $story->id " ))) {
2001-01-13 08:29:50 +00:00
$result = db_query ( " SELECT * FROM users WHERE history LIKE '%s $story->id %' " );
2000-12-23 23:25:28 +00:00
while ( $account = db_fetch_object ( $result )) {
2001-02-04 22:09:38 +00:00
$output .= format_username ( $account -> userid ) . " voted ` " . user_get_history ( $account -> history , " s $story->id " ) . " '.<BR> " ;
2000-12-23 23:25:28 +00:00
}
2001-01-26 13:38:46 +00:00
2001-01-13 08:29:50 +00:00
$theme -> box ( " Moderation results " , ( $output ? $output : " This story has not been moderated yet. " ));
2000-12-23 23:25:28 +00:00
}
}
function theme_related_links ( $theme , $story ) {
2000-12-30 11:58:14 +00:00
// Parse story for <A HREF="">-tags:
2000-12-23 23:25:28 +00:00
$text = stripslashes ( " $story->abstract $story->updates $story->article " );
while ( $text = stristr ( $text , " <A HREF= " )) {
$link = substr ( $text , 0 , strpos ( strtolower ( $text ), " </a> " ) + 4 );
$text = stristr ( $text , " </A> " );
if ( ! stristr ( $link , " mailto: " )) $content .= " <LI> $link </LI> " ;
}
2001-01-26 13:38:46 +00:00
// Stories in the same section:
2001-01-21 19:41:11 +00:00
$content .= " <LI>More about <A HREF= \" index.php?section= " . urlencode ( $story -> section ) . " \" > $story->section </A>.</LI> " ;
2000-12-23 23:25:28 +00:00
2000-12-30 11:58:14 +00:00
// Stories from the same author:
2000-12-23 23:25:28 +00:00
if ( $story -> userid ) $content .= " <LI>Also by <A HREF= \" search.php?author= " . urlencode ( $story -> userid ) . " \" > $story->userid </A>.</LI> " ;
$theme -> box ( " Related links " , $content );
}
function theme_new_headlines ( $theme , $num = 10 ) {
global $user ;
$content = " " ;
$result = db_query ( " SELECT id, subject FROM stories WHERE status = 2 ORDER BY id DESC LIMIT $num " );
2001-01-20 12:20:31 +00:00
while ( $story = db_fetch_object ( $result )) $content .= " <LI><A HREF= \" story.php?id= $story->id\ " > " . check_output( $story->subject ) . " </ A ></ LI > \n " ;
2000-12-23 23:25:28 +00:00
$theme -> box ( " Latest headlines " , $content );
}
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
2000-12-30 11:58:14 +00:00
if ( $user -> stories ) $result = db_query ( " SELECT id, subject, timestamp FROM stories WHERE status = 2 ORDER BY timestamp DESC LIMIT $user->stories , $num " );
else $result = db_query ( " SELECT id, subject, timestamp FROM stories WHERE status = 2 ORDER BY timestamp DESC LIMIT $num , $num " );
2001-01-26 13:38:46 +00:00
while ( $story = db_fetch_object ( $result )) {
2000-12-30 11:58:14 +00:00
if ( $time != date ( " F jS " , $story -> timestamp )) {
$content .= " <P><B> " . date ( " l, M jS " , $story -> timestamp ) . " </B></P> \n " ;
$time = date ( " F jS " , $story -> timestamp );
}
2001-01-20 12:20:31 +00:00
$content .= " <LI><A HREF= \" story.php?id= $story->id\ " > " . check_output( $story->subject ) . " </ A ></ LI > \n " ;
2000-12-30 11:58:14 +00:00
}
$theme -> box ( " Older headlines " , $content );
}
2000-11-07 08:58:36 +00:00
?>