Location: PHPKode > projects > PSlash > pslash-0.70/html/themes/template/theme.php
<?

###############################################################################
# Copyright (C) 2000  Derek Leung
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# You may modify your copy or copies of this Program or any portion of it,
# but you must cause the modified files to carry prominent notices stating 
# that you changed the files and the date of any change.  And you are required 
# to keep a copy of this License along with this Program.
#
# You are not required to accept this License, since you have not signed it. 
# However, nothing else grants you permission to modify or distribute this 
# Program or its derivative works. These actions are prohibited by law if 
# you do not accept this License. Therefore, by modifying or distributing 
# this Program (or any work based on this Program), you indicate your 
# acceptance of this License to do so, and all its terms and conditions 
# for copying, distributing or modifying this Program or works based on it.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# See the GNU General Public License for more details.
# http://www.opensource.org/licenses/gpl-license.html
###############################################################################

global $config;

function themeindex ($aid,$time, $title, $topic, $thetext, $comments, $morelink,$icon) {

	global $config,$myTopic;
	
	
	if ( $morelink != "" && strlen($thetext) >= $config[abstractlen]) {
		$thetext = substr($thetext,0,$config[abstractlen]);
	} 
	
	$db_uname = fixquotes($aid);
	$result = mysql_query("select status,newsPostNum,userTitle from ps_users where uname='$db_uname'");
	list($status,$postNum,$dbTitle) = mysql_fetch_row($result);
	mysql_free_result($result);

	if ($dbTitle == "") {
		$titleList = FILE("$config[root_path]/usertitles");
		foreach ($titleList as $userTitle) {
			list($num,$myTitle) = split("\t",$userTitle);
			if ($postNum =="") {
				$postNum = 0;
			}
			
			if ($postNum >= $num) {
				$newTitle = $myTitle;
				
			}
		}
		if ($newTitle == "") {
			$newTitle = translate("Anonymous");
			$postNum = "null";
		}
	} else {
		$newTitle = $dbTitle;
	}
	
	if ($status == "Admin") {
		$nameColor = "red";
	
	} else if ($status == "Moderator") {
		$nameColor="green";
	} else {
		$nameColor="#5F4CB4";
	}
	
	?>


	
	<TABLE  cellSpacing=4 cellPadding=4 width="99%" align=center border=0 >
		<TBODY>
			<TR >
				<td class=indexboxup ><font size=+1><b><?=$title?></b></font></td>
			</tr>
			<tr>
				<td class=indexboxmid >
				<? if ($icon != "") { ?>
					
					<a href="index.php?myTopic=<?php echo urlencode($topic); ?>">[<?=$icon?>]</a> 
				<? }
				?>
				<? echo translate("Posted by") . "<a href=\"user.php?op=userinfo&uname=$aid\"><font color=$nameColor> <b>$aid ($newTitle)</b></font></a>" . " "; ?><font size=-2 ><? echo translate("on"); ?> <?php echo"$time ($config[timezone])"; ?></font></b></td>
			</tr>
			<tr vAlign=top>
                <TD class=outline width="100%"><br>
					<? if ($icon != "") { ?>
				
						<img src="topic-icon.php?topic=<? echo rawurlencode($icon) ?>" align="right" hspace="10" vspace="10">
					<? }
					?>
					<? echo auto_link($thetext) . "<br><br>"; ?>
					<? echo $morelink ?>
                </TD>
			    
			</TR>
		</TBODY>
	</TABLE><BR>

<? 
	unset($title,$topic,$icon,$aid,$newTitle,$time,$thetext,$morelink,$postNum,$num,$status,$dbTitle,$titleList,$userTitle,$myTitle,$nameColor);

}




function themearticle ($aid,  $datetime, $title, $thetext, $myName="", $mode="",$ip="") {
	global $myTopic,$config;


	$userArray = getCookie($config[user_cookie_name]);

	$db_uname = fixquotes($aid);
	$result = mysql_query("select status,commentPostNum,userTitle from ps_users where uname='$db_uname'");
	list($status,$postNum,$dbTitle) = mysql_fetch_row($result);
	if ($result) {
		mysql_free_result($result);
	}

	if ($status == "Admin") {
		$authorColor="red";
	} else if ($status == "Moderator") {
		$authorColor="green";
	} else {
		$authorColor="#5F4CB4";
	}
	if ($mode == "nested") {

		echo "<table cellpadding=0 cellspacing=0  border=1 bordercolordark=#FFFFFF bordercolorlight=#000000 class=articlebox><tr><td width=20% rowspan=2 valign=top class=articleleft><font color=$authorColor><b>".translate("$aid")."</b></font><br>";
	} else {
		echo "<table cellpadding=0 cellspacing=0  width=100% border=1 bordercolordark=#FFFFFF bordercolorlight=#000000 class=articlebox><tr><td width=20% rowspan=2 valign=top class=articleleft><font color=$authorColor><b>".translate("$aid")."</b></font><br>";
	}
	if ($dbTitle == "") {
		$titleList = FILE("$config[root_path]/usertitles");
		foreach ($titleList as $userTitle) {
			list($num,$myTitle) = split("\t",$userTitle);
			if ($postNum >= $num) {
				$newTitle = $myTitle;
			}
		}
		if ($newTitle == "") {
			$newTitle = translate("Anonymous");
			$postNum = "null";
		}
	} else {
		$newTitle = $dbTitle;
	}
	echo "<font size=-1>($newTitle)<br>$datetime<br><br>Posts: $postNum</font>";
	if ($ip != "" && ($userArray[status] == "Admin" || $userArray[status] == "Moderator")) {
		echo "<br>IP: $ip";
	}
	echo"</td><td width=65% class=articlebox ><b>$title</b></td><td align=right width=15% class=articleright>&nbsp;";
	if ($myName != "") {
		
		if ($userArray[status] == "Admin" || $userArray[status] == "Moderator" || strcasecmp($userArray[username],$aid) == 0) {

			echo "<a href=\"comments.php?op=editComment&pid=$myName&myTopic=$myTopic\" >[Edit]</a>";
		}
		if ($userArray[status] == "Admin" || $userArray[status] == "Moderator") {
			echo "<a href=\"comments.php?op=delComment&pid=$myName&myTopic=$myTopic\" onclick=\"return confirmDelete()\">[Delete]</a>";
		}
	}
	echo "</td></tr>";
	echo "<tr><td colspan=2  class=outline>" .auto_link($thetext)."</td></tr>";
	echo "</table>";
	unset($title,$topic,$icon,$aid,$newTitle,$time,$thetext,$morelink,$postNum,$num,$status,$dbTitle,$titleList,$userTitle,$myTitle,$authorColor,$mode,$myName,$userArray);

	
}

function themesidebox($title, $content) {
	global $myTopic;

	?>
	<table border=0 cellspacing=0 cellpadding=0 width=170 class="sidebox">
		<tr>
			<td class=sideboxtop valign="middle" width="6"><img src="imgs/spacer.gif" width="5" height="24" alt=""></td>
			<td class=sideboxtop valign="middle" width=100%>
				<b><?echo $title; ?></b>
			</td>
		</tr>

		<tr>
			<td class="sidebox">&nbsp;</td><td valign=top width="100%" class="sidebox">
				<?
					echo  auto_link($content); 
					unset($content,$tilte);
				?>
			</td>
		</tr>
	</table>
	<br>
<?php
}

function themedynamicsidebox($title, $url, $bid) {
	global $myTopic,$config;
	
	
	$rdf = grapHeadLines($url,$bid);
	// can't grap the headline, return false
	if ($rdf == false) {
		return false;
	}

?>
	<table border=0 width="170" cellspacing=0 cellpadding=0 class="sidebox"><tr>
	<td class=sideboxtop valign="middle" width="6"><img src="imgs/spacer.gif" width="6" height="24" alt=""></td>
	<td class=sideboxtop valign="middle" width=100%>
<?	
	echo "<b>$title</b>";
?>
	</td></tr>
	</td></tr>
	<tr><td class="sidebox">&nbsp;</td><td valign=top width="100%" class="sidebox" >
<?php 
		while (list(,$item) = each($rdf->items)) {
			echo "<li><a href=\"".$item[link]."\" target=\"_blank\">";
			echo $item["title"]. "</a></li>\n";
		}

		unset($rdf);
?>
	</td></tr>
	</table><br>
<?php
}



?>
Return current item: PSlash