%%document-view-anonymous-html%%
2002-07-21 14:26

%%preprocess%%
 // format the object for display
$this->beryliumToHtml(); 
$this->getRuntimeVars();

if ($this->id=="") {
	header("HTTP/1.0 404 Not Found");
	}

// convert generic flavor to objtype:
if ($this->flavor=="Generic") $this->flavor= "Document";

// headline fix if only title, and vice-versa
if ($this->title=="" && $this->headline=="") $this->title= "Untitled ($this->name)";
elseif ($this->title=="") $this->title= $this->headline;
elseif ($this->headline=="") $this->headline= $this->title;

// edit tag for document owner
if ($sitemember->id!=0 && $sitemember->id==$this->sitememberid) {
	if ($this->rank > 100) $this->editTag= "";
	else $this->editTag= "| <a href='$this->baseUrl?method=edit$session->cgi'><img src='/bicons/edit.png' alt='edit' title='edit this object' align=absmiddle border=0></a>
			<a href='$this->baseUrl?method=edit$session->cgi'>edit</a> &nbsp;";
	}

// only show body if body is there!
if (trim($this->body)) {
	//$this->body= bparsebml($this->body);
	$this->bodyContent= "
<table border=0>
	<tr>
		<td width='1%'><img src='/bicons/spacer.png' border=0 alt=document width=20 height=1></td>
		<td width='98%'>&nbsp;</td>
		<td width='1%'><img src='/bicons/spacer.png' border=0 alt=document width=20 height=1></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td class='objBody'>$this->body</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width='1%'>&nbsp;</td>
		<td width='98%'>&nbsp;</td>
		<td width='1%'>&nbsp;</td>
	</tr>
</table>
<table cellspacing=5 cellpadding=5>
	<tr>
		<td align='right' class='info'>
				<a href='document-$this->name.txt'><img src='/bicons/print.png' border=0 alt='text version' title='text version' align=absmiddle></a>
				<a href='document-$this->name.txt'>text</a> |
				<a href='$folder->baseUrl'><img src='/bicons/folder-open.png' border=0 alt='parent folder' title='parent folder' align=middle></a>
				<a href='$folder->baseUrl'>$folder->title</a> |
				<a href='#top'>jump to top</a>&nbsp;
				$this->editTag
				<br>&nbsp;
		</td>
	</tr>
</table>";
	}

// subscriptionTag
if ($sitemember->id>0 && $this->p_subscriptionList!="") {
    // if sitemember is on subscription list, say so and link to unsubscribe
    $subscriptionArray= explode(",",$this->p_subscriptionList);
    $found= 0;
    foreach ($subscriptionArray AS $key=>$value) {
	if ($value==$sitemember->id) {
	    $found= 1;
	    berror("document-view: found sitemember->id in subscriptionList array at $key.",1);
	    }
	}

    if ($found) {
	$this->subscribeTag= "<br>You will recieve a copy of all new comments at $member->email. 
		<a href='$this->baseUrl?method=toggleSubscribed$session->cgi'>Click to unsubscribe.</a>";
	}
    else {
	// else, link to subscribe
	$this->subscribeTag= "<br><a href='$this->baseUrl?method=toggleSubscribed$session->cgi'>Subscribe to this discussion</a> via email.";
	}
    }
elseif ($sitemember->id>0) {
    // link to subscribe
    $this->subscribeTag= "<br><a href='$this->baseUrl?method=toggleSubscribed$session->cgi'>Subscribe to this discussion</a> via email.";
    }

// how many comments?
$query= "SELECT COUNT(obj.id) FROM comment AS obj WHERE obj.parentobjtype='$this->objtype' AND obj.parentid='$this->id' $session->statuswhere $session->publicwhere";
if ($result=@mysql_query($query)) {
	$commentTotal= mysql_fetch_row($result);
	$this->commentTotal= $commentTotal[0];
	}
else $this->commentTotal= "0";



%%header%%

%%css%%


%%template%%
<table class='objTable' cellspacing=5 cellpadding=5>
	<tr>
		<td>
			<table class='objHeader'>
				<tr>
					<td width='1' valign='middle'>$this->iconTag</td>
					<td>
						<span class='objFlavor'>$this->flavor:<br></span>
						<span class='objTitle'><a href="$this->baseUrl">$this->title</a></span>
						<span class='objByline'> <br> 
							By $this->authorTag on $this->dateTag.</span>
					</td>
				</tr>
			</table>
			<blockquote class='objDescription'>$this->description<br>&nbsp;</blockquote>
			<p align="right" class='info'>$this->moreTag 
				<a href='#comments'><img src='/bicons/comment.png' alt='' title='view/add comments' align=absmiddle border=0></a> 
				<a href='#comments'>$this->commentTotal comments</a> | 
				<a href='document-$this->name.txt'><img src='/bicons/print.png' border=0 alt='text version' title='text version' align=absmiddle></a>
				<a href='document-$this->name.txt'>text</a><!-- |
				 <a href='$folder->baseUrl'><img src='/bicons/folder-open.png' border=0 alt='parent folder' title='parent folder' align=middle></a>
				<a href='$folder->baseUrl'>$folder->title</a> -->&nbsp;
				$this->editTag
			</p>
		</td>
	</tr>
</table>
$this->bodyContent
<table class="commentTable">
	<tr>
		<td valign=top><a name='comments'>&nbsp;</a></td>
		<td><span class='objTitle'>Discussion of <i>$this->title</i>:</span>
			$this->subscribeTag
			{list:SELECT obj.* FROM comment AS obj WHERE obj.siteid='$site->id' AND obj.parentobjtype='document' AND obj.parentid='$this->id' $session->statuswhere $session->publicwhere ORDER BY obj.created ASC;list}</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width='1%'><img src='/bicons/spacer.png' border=0 alt=document width=10 height=1></td>
		<td width='98%'>&nbsp;</td>
		<td width='1%'><img src='/bicons/spacer.png' border=0 alt=document width=10 height=1></td>
	</tr>
</table>

%%listrow%%

%%nullobject%%
<p><img src='/bicons/warning.png' alt='Warning' align=left><br>
	<b>The document you requested was not found.</b></p>
<p><a href='$session->scriptname$folder->name/document-.html?method=listall$session->cgi'>Here is a list</a> of all the documents in this folder.</p> 

%%footer%%

%%postprocess%%

%%end of context%%
