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

%%preprocess%%
 // format the object for display
$this->beryliumToHtml(); 
$this->getRuntimeVars();
berror("<b>document-view</b>: applying policy:",1);
$this->applyPolicy();

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.gif' alt='edit' title='edit this object' align=absmiddle border=0></a>
			<a href='$this->baseUrl?method=edit$session->cgi'>edit</a> &nbsp;";
	}
	
// editor controls for editors
if ($this->itemEditor) {
	$this->editorControls= "<p align='right' class='info'>$this->moreTag 
				<a href='#comments'><img src='/bicons/comment.gif' 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.gif' border=0 alt='text version' title='text version' align=absmiddle></a>
				<a href='document-$this->name.txt'>text</a> |
				<a href='$this->baseUrl?method=toggleRank$session->cgi'><img src='/bicons/bulbsgif/$this->glow.gif' alt='$this->publishStatus' title='document:$this->id is $this->publishStatus' align=absmiddle border=0></a> |
				<a href='$this->baseUrl?method=edit$session->cgi'><img src='/bicons/edit.gif' alt='edit' title='edit this object' align=absmiddle border=0></a>
				<a href='$this->baseUrl?method=edit$session->cgi'>edit</a> |
				<a href='$this->baseUrl?method=pickup$session->cgi'><img src='/bicons/pickup.gif' alt='pick up' title='pick up this object' align=absmiddle border=0></a>
				<a href='$this->baseUrl?method=pickup$session->cgi'>pick up</a>&nbsp;
			</p>";
	}

// only show body if body is there!
if (trim($this->body)) {
	//$this->body= bparsebml($this->body);
	$this->bodyContent= "
<table cellspacing=5 cellpadding=5>
	<tr>
		<td valign='top' align='center'  class='objBodyTable'>
			<table>
				<tr>
					<td class='objBody' width='95%'>$this->body</td>
					<td width='5%'>&nbsp;</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<td align='right' class='info' colspan=2>
							<a href='document-$this->name.txt'><img src='/bicons/print.gif' 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.gif' 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>
		</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= "<p>You will receive a copy of all new comments at $member->email.
		<a href='$this->baseUrl?method=toggleSubscribed$session->cgi'>Click to unsubscribe.</a>
		To find out who else is subscribed, <a href='$this->baseUrl?method=viewSubscriptionList'>click here</a>.</p>";
	}
    else {
	// else, link to subscribe
	$this->subscribeTag= "<p><a href='$this->baseUrl?method=toggleSubscribed$session->cgi'>Subscribe to this discussion</a> via email.
	To find out who is subscribed, <a href='$this->baseUrl?method=viewSubscriptionList'>click here</a>.</p>";
	}
    }
elseif ($sitemember->id>0) {
    // link to subscribe
    $this->subscribeTag= "<p><a href='$this->baseUrl?method=toggleSubscribed$session->cgi'>Subscribe to this discussion</a> via email.</p>";
    }

// 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 cellspacing=5 cellpadding=5>
	<tr>
		<td class='objHeaderTable' >
			<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.gif' 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.gif' 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.gif' 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 cellspacing=5 cellpadding=5>
	<tr>
		<td valign='top' align='center'  class="commentTable">
			<table>
				<tr>
					<td valign=top><a name='comments'>&nbsp;</a>
						<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>
				</tr>
				<tr>
					<td>&nbsp;</td>
				</tr>
			</table>
		</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%%
