%%folder-view-anonymous-html%%
2002-07-21 14:40

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

global $debug;
// folder only-- force http or https depending on role and method.
if ($session->request->connection!="http" && ( $session->request->method!="login" && $session->request->method!="createmember" && $session->request->method!="logout")) {
	 $newlocation= "http://$site->name$session->refreshURL";
	 if ($debug) berror("In rooms, everyone connects via HTTP unless logging in or something. Trying to redirect to <a href='$newlocation'>$newlocation</a> because you are a $sitemember->role looking at a ".$session->request->method." page.",0);
	 header("Location: $newlocation");
	 exit;
	 }
elseif ($session->request->connection!="https" && ( $session->request->method=="login" || $session->request->method=="createmember" || $session->request->method=="logout")) {
	 $newlocation= "https://$site->name$session->refreshURL";
	 if ($debug) berror("Logins and Members connect via HTTPS. Trying to redirect to <a href='$newlocation'>$newlocation</a> because you are a $sitemember->role looking at a ".$session->request->method." page.",0);
	 header("Location: $newlocation");
	 exit;
	 }
 
// format the object for display
$this->beryliumToHtml();
$this->getRuntimeVars();
$this->applyPolicy();

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

// 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;


//
// Folder-Only stuff follows...
//


//
// User Control Bar
$rrole= "r$sitemember->role";
$this->{$rrole}= "selected";
switch ($sitemember->truerole) {
    case "admin":
        $roleoptions= "<option value='admin' $this->radmin>admin</option>
              <option value='editor' $this->reditor>editor</option>
              <option value='writer' $this->rwriter>writer</option>
              <option value='member' $this->rmember>member</option>
              <option value='anonymous' $this->ranonymous>anonymous</option>";
        break;
        
    case "editor":
        $roleoptions= "<option value='editor' $this->reditor>editor</option>
              <option value='writer' $this->rwriter>writer</option>
              <option value='member' $this->rmember>member</option>
              <option value='anonymous' $this->ranonymous>anonymous</option>";
        break;
        
    case "writer":
        $roleoptions= "<option value='writer' $this->rwriter>writer</option>
              <option value='member' $this->rmember>member</option>
              <option value='anonymous' $this->ranonymous>anonymous</option>";
        break;
        
    case "member":
        $this->loginheader= "Prepared for $sitemember->truerole <a href='$sitemember->idUrl'>$sitemember->name</a>.<br>
            <a href='$sitemember->idUrl?method=edit'>preferences</a> | <a href='$refreshURL?method=logout'>logout</a>";
        $this->loginfooter= "Prepared for $sitemember->truerole <a href='$sitemember->idUrl'>$sitemember->name</a>.<br>
            <a href='$sitemember->idUrl?method=edit'>preferences</a> | <a href='$refreshURL?method=logout'>logout</a>&nbsp;";
        break;
        
    default:
        $this->loginheader= "<form action='$object->baseSSLUrl?method=login' name='userLogin' method='POST'>
                You are being anonymous.&nbsp;&nbsp;&nbsp;<br>
                <input type='text' name='email' value='email' onFocus=\"document.userLogin.email.value=''\" size='10' class='permaform'>
                <input type='password' name='password' value='***' onFocus=\"document.userLogin.password.value=''\" size='6' class='permaform'>
		<input type='submit' name='login' value='login' class='permaformbutton'><br><br>
                <a href='$object->baseUrl?method=login'>Login</a> above or
                <a href='$object->baseURL?method=createmember'>register here</a>.
            </form>";
        $this->loginfooter= "You are being anonymous. Please <a href='$object->baseUrl?method=login'>login or register here</a>.";
        break;
    }
if ($sitemember->truerole!="anonymous" && $sitemember->truerole!="member") {
    $this->loginheader= "
        <form action='$session->refreshUrl' name='userControl' method='GET'>
            Prepared for $sitemember->truerole <a href='$sitemember->idUrl'>$sitemember->name</a>.<br>
            <a href='$sitemember->idUrl?method=edit'>preferences</a> | <a href='$refreshURL?method=logout'>logout</a>
            <br>
            <img src='/bicons/spacer.gif' width='1' height='24'>
            View as 
            <select name='role' onChange='document.userControl.submit()' align='absmiddle'>
              $roleoptions
            </select>
            <input type='submit' name='go' value='&raquo;' class='buttonstyle'>
        </form>";
    $this->loginfooter= "Prepared for $sitemember->truerole <a href='$sitemember->idUrl'>$sitemember->name</a>.<br>
        <a href='$sitemember->idUrl?method=edit'>preferences</a> | <a href='$refreshURL?method=logout'>logout</a>&nbsp;";
    }

if ($sitemember->truerole!=$sitemember->role) {
    $this->loginfooter= "Rendered as if you were an $sitemember->role. (<a href='$session->refreshUrl?role=0'>off</a>)<br>".$this->loginfooter;
    }

//
// Session Inventory	
// create inventory list from session->p_inventory
if (trim($session->p_inventory)) {
	$inventoryList= "
			<hr>
			<table class='inventoryTable'>
				<tr>
					<td><img src='/bicons/pickup.gif' border=0 alt='' title='your inventory' align=middle> You are holding:</td>
				</tr>";
	$inventoryArray= explode(" ", trim($session->p_inventory));
	foreach ( $inventoryArray AS $key=>$value ) {
		$valuearray= explode(":", $value);
		$classname= $valuearray[0];
		$inventoryList= $inventoryList."
				<tr>
					<td align='center'>
						<img src='/bicons/$classname.gif' border=0 alt='' title='$value' align=right vspace=5>
						 [$value]<br><a href='$this->baseUrl?method=drop&key=$key'>drop</a> | <a href='$this->baseUrl?method=discard&key=$key'>discard</a>
					</td>
				</tr>";
		}
	$inventoryList= $inventoryList."
				<tr>
					<td>Location is $this->title.<br>
						<img src='/bicons/spacer.gif' border=0 alt='' title='' width=1 height=20>
						<a href='$this->baseUrl?method=dropall'><img src='/bicons/drop.gif' border=0 alt='' title='move all items into the current folder' align=middle></a> <a href='$this->baseUrl?method=dropall'>drop all items</a></td>
				</tr>
			</table>";
	$this->inventoryList= bparsebml($inventoryList);
	}

// SUBSCRIPTIONS
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 FOLDER 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 room</a>
			-- get new comments and updates via email.
			To find out who is subscribed,
			<a href='$this->baseUrl?method=viewSubscriptionList'>click here</a>.</p>";
		}
	}
elseif ($sitemember->id>0 && $sitemember->role!="anonymous") {
	// link to subscribe
	$this->subscribeTag= "<p><a href='$this->baseUrl?method=toggleSubscribed$session->cgi'>Subscribe to this room</a>
		-- get new comments and updates via email.</p>";
	}

// BODY DISPLAY
if (trim($this->body)!="") {
	if (trim($this->headline)!="" && $this->headline!=$this->title) {
		$headline= "<p class='objHeadline'>$this->headline</p>";
		}
	$this->bodyTag= "$headline<blockquote class='objBody'>$this->body</blockquote>";
	}
	
	
// EDITOR/OWNER CONTROLS
if ($this->itemEditor) {
	$this->editorControls= " | <b>Room Controls:</b>
			<a href='$this->baseUrl?method=toggleRank'><img src='/bicons/bulbsgif/$this->glow.gif' alt='$this->publishStatus' title='folder:$this->id is $this->publishStatus' align=absmiddle border=0></a> |
			<a href='$this->baseUrl?method=edit'><img src='/bicons/edit.gif' alt='edit' title='edit this object' align=absmiddle border=0></a>
			<a href='$this->baseUrl?method=edit'>edit</a> |
			<a href='$this->baseUrl?method=pickup'><img src='/bicons/pickup.gif' alt='pick up' title='pick up this object' align=absmiddle border=0></a>
			<a href='$this->baseUrl?method=pickup'>pick up</a>";
	}

// ROOM SETTINGS
if ($background= @getimagesize($this->p_background)) {
	$width= $background[0];
	$height= $background[1];

	$targetwidth= 630;
	$targetheight= 430;

	if ($width>$targetwidth) {
		//$height= $height * ($targetwidth/$width);
		$width= $targetwidth;
		}
	if ($height>$targetheight) {
		//$width= $width * ($targetheight/$height);
		$height= $targetheight;
		}

	$this->backgroundwidth= $width."px";
	$this->bgnumericwidth= $width;
	$this->backgroundheight= $height."px";
	$this->bgnumericheight= $height;
	}
	
// SCENE CONTROLLER
// get info on number of scenes here (sceneTotal)
/* if ($object->objtype=="document") $notcurrent= " AND obj.id!='$object->id' ";
else $this->sceneQueryOffset= "1,"; 
*/
$this->sceneQuery= "SELECT obj.* FROM document AS obj WHERE obj.folderid='$this->id' AND obj.flavor='Scene' AND obj.rank>=100 $notcurrent $session->statuswhere $session->publicwhere ORDER BY rank DESC, created ASC ";
$firstscene= new Document;
berror("SceneControl: <b>looking up scene list here</b>",1);
$sceneArray= $firstscene->selectObject($this->sceneQuery);
berror("SceneControl: <b>found $firstscene->listsize scenes</b>.",1);
$this->sceneTotal= $firstscene->listsize;

// which scene is being displayed? (sceneOffset)
if ($object->objtype=="document" && $object->flavor=="Scene" && $session->request->method=="view") {
	// scene is indicated in URL
	if ($_GET['editMode']==1) $modeTag= "&editMode=1";
	$scene= $this->baseUrl."document-$object->name.scene?method=view$modeTag$session->cgi";

	// but it would help everyone to know which scene it is
	$this->sceneOffset= 0;
	foreach ($sceneArray AS $key=>$myScene) {
		berror("SceneControl looking at sceneArray[$key], named $myScene[id]. ($object->id)",1);
		if ($myScene['id']==$object->id) {
			berror("SceneControl <b>MATCH</b> on $key.",1);
			$this->sceneOffset= "$key";
			break;
			}
		}

	// display scrollbars for editing?
	if ($object->itemOwner || $object->itemEditor) {
		$scrolling="auto";
		if ($this->bgnumericwidth<460) {
			$this->bgnumericwidth=460;
			}
		$this->bgnumericwidth+=16;
		$this->bgnumericheight+=16;
		}
	else $scrolling="no";
	$this->currentScene= "<b>$object->title</b> by $object->authorTag";
	}
elseif ($object->objtype=="folder" && $session->request->method=="view") {
	$this->sceneOffset=0;
	$scene= $this->baseUrl."document-$firstscene->name.scene";
	$scrolling="no";
	$firstscene->beryliumToHtml();
	$firstscene->getRuntimeVars();
	$this->currentScene= "<b>$firstscene->title</b> by $firstscene->authorTag";
	}

// create iframe tag in which to render scene
if ($scene!="") {
	berror("SceneControl rendering scene $scene.",1);
	$this->showScene= "<IFRAME name=\"scene\" src=\"$scene\" width=\"$this->bgnumericwidth\" height=\"$this->bgnumericheight\"
		scrolling=\"$scrolling\" frameborder=\"0\">
	[Your user agent does not support frames or is currently configured
	not to display frames. This means your browser is probably unable to render this site, but you may visit
	<A href=\"http://galactron/berylium/document-char-3df6caf96bf1e.scene\">the related scene</A> and see what happens.]
	</IFRAME>";
	}

if ($sitemember->role=="anonymous" || $sitemember->role=="member") $this->showNull= 1;

%%header%%
<!-- <table width='100%' border=0 padding=0 spacing=0>
	<tr>
		<td align='center' valign='top'>
			<table class='bodytable' cellpadding="5">
				<tr>
					<td align='center' valign='top'>
						 end of site header -->
$this->showScene
<div class="sceneList">
	Now playing $this->currentScene. <br/>Featured scenes: {list:$this->sceneQuery LIMIT $this->sceneQueryOffset 3 ;scenelist}
</div>
<!--<img src="/bicons/spacer.gif" height=5 width=5 border=0>-->
<table class='siteHeader'>
    <tr>
	<td width="60%" valign='top' class='objDescription'>
		You are in:<br />
		<span class='objTitle'><a href='$this->baseUrl'>$this->title</a></span>
		<br />$this->description
		<div class="exitList">
			{list:SELECT obj.* FROM folder AS obj WHERE ( obj.id='$this->folderid' OR obj.folderid='$this->id' ) AND obj.id!='$this->id' AND obj.rank>50 $session->statuswhere $session->publicwhere ORDER BY obj.rank DESC, obj.created ASC;exitlist}
		</div>
	</td>
	<td width="35%" class="info" align='right' rowspan="2">
		$this->loginheader
	</td>
    </tr>
    <!-- <tr>
	<td colspan="2" class="info">
			<form name='search' action='$site->baseUrl/document-.html?method=listall' method='post'>
			<input type='hidden' name='listrank' value='50'>
			$this->showDelTag
			<a href='#bottom'>bottom of page</a> | keyword:
			<input type='text' name='keyword' value='$session->keyword' size=12 class='permaform'>
			<input type='submit' name='submit' value='search' class='permaformbutton'>
			</form>
	</td>
    </tr> -->
</table>
					</td>
				</tr>
				<tr>
					<td align='center' valign='top'>
						<table>
							<tr>
								<td valign='top' width='78%' class='contentcell'>
									<!-- begin object content -->

%%css%%


%%template%%
<table class='siteHeader'>
	<tr>
		<td>
			$this->bodyTag
			<p align='right' class='info'><a href="#scenes">Scene List</a> | <a href="#comments">Comments</a>&nbsp; $this->editorControls &nbsp;</p>
			<br />
			<a name="scenes"> </a>
				<span class='objTitle'>
					<img src='/bicons/spacer.gif' width='1' height='20' border=0>
					Scenes in this Room:
				</span>
				( <a href="$this->baseUrl/document-.html?method=create">create a new Scene here</a> )
				{list:$this->sceneQuery;index}
			<br />
			<a name="exits"> </a>
				<span class='objTitle'>
					<img src='/bicons/spacer.gif' width='1' height='20' border=0>
					Exits from this Room:
				</span>
				( <a href="$this->baseUrl/folder-.html?method=create">create a new Room/Folder here</a> )
				( <a href="$this->baseUrl/folder-.html?method=createLink">add a Link as an Exit</a> )
				{list:SELECT obj.* FROM folder AS obj WHERE ( obj.id='$this->folderid' OR obj.folderid='$this->id' ) AND obj.id!='$this->id' $session->statuswhere $session->publicwhere ORDER BY obj.rank DESC, obj.created ASC;index}
		</td>
	</tr>
</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<br>
			<table class='bodytable' width="$this->bgnumericwidth">
				<tr>
					<td align='center' valign='top'>
						<table>
							<tr>
								<td valign='top' width='78%' class='contentcell'>
									<!-- begin comments -->
<table class="commentTable">
	<tr>
		<td colspan=2>
			<a name='comments'> </a>
			<span class='objTitle'>Discussion of $this->title</span>:
			$this->subscribeTag
		</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td valign=top>&nbsp;</td>
		<td>
		{list:SELECT obj.* FROM comment AS obj WHERE obj.siteid='$site->id' AND obj.parentobjtype='folder' AND obj.parentid='$this->id' $session->statuswhere $session->publicwhere ORDER BY obj.created ASC;roomlist}
		</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width='1%'><img src='/bicons/spacer.gif' border=0 alt=document width=10 height=1></td>
		<td width='98%'>&nbsp;</td>
		<td width='1%'><img src='/bicons/spacer.gif' border=0 alt=document width=10 height=1></td>
	</tr>
</table>



%%listrow%%


%%nullobject%%
<table class='siteHeader'>
	<tr>
		<td>
			$this->bodyTag
			<br />
			<a name="scenes"> </a>
			<span class='objTitle'>
				Scenes in this Room:
			</span> ( <a href="#top">Back to current scene</a> | <a href="#comments">Add or Read Comments</a>&nbsp; $this->editorControls )

			{list:$this->sceneQuery;index}
		</td>
	</tr>
</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<br>
			<table class='bodytable' width="$this->bgnumericwidth">
				<tr>
					<td align='center' valign='top'>
						<table>
							<tr>
								<td valign='top' width='78%' class='contentcell'>
									<!-- begin comments -->
<table class="commentTable">
	<tr>
		<td colspan=2>
			<a name='comments'> </a>
			<span class='objTitle'>Discussion of <a href="#top">$this->title</a>:</span>  ( <a href="#top">Back to current scene</a> | <a href="#scenes">Scene List</a> )
			$this->subscribeTag
		</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td valign=top>&nbsp;</td>
		<td>
		{list:SELECT obj.* FROM comment AS obj WHERE obj.siteid='$site->id' AND obj.parentobjtype='folder' AND obj.parentid='$this->id' $session->statuswhere $session->publicwhere ORDER BY obj.created ASC;roomlist}
		</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width='1%'><img src='/bicons/spacer.gif' border=0 alt=document width=10 height=1></td>
		<td width='98%'>&nbsp;</td>
		<td width='1%'><img src='/bicons/spacer.gif' border=0 alt=document width=10 height=1></td>
	</tr>
</table>

%%footer%%
									<!-- end object/comments -->
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<a name='bottom'></a>
			<br>
			<table class='bodytable' width="$this->bgnumericwidth">
				<tr>
					<td align='center' valign='top'>
						<table class='siteHeader'>
							<tr>
								<td width='20%'><img src='/bicons/spacer.gif' border=0 alt='controls:' title=''></td>
								<td width='80%' class='info' align='right'>
									<form name='search' action='$site->baseUrl/document-.html?method=listall' method='post'>
									<input type='hidden' name='listrank' value='50'>
									<!-- session controls
									<img src="/bicons/spacer.gif" width=1 height=20>
									<a href='$session->refreshURL'><img src='/bicons/refresh.gif' border=0 alt='' title='refresh page' align=middle></a>&nbsp;<a href='$session->refreshURL'>refresh</a> |
									$this->cancelTag | -->
									$this->debugTag
									$this->contextTag
									$this->showDelTag
									<a href='#top'>top of page</a> | keyword:
									<input type='text' name='keyword' value='$session->keyword' size=12 class='permaform'>
									<input type='submit' name='submit' value='search' class='permaformbutton'>
									<br><br>$this->loginfooter
									</form>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

%%postprocess%%


%%end of context%%

