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

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

// folder only-- force http for anonymous
if ($session->request->connection!="http" && $session->request->method!="login" && $session->request->method!="createmember" && $session->request->method!="logout") {
	 $newlocation= "http://$site->name$session->refreshURL";
	 berror("Anonymous connects via HTTP. Trying to redirect to $newlocation.",1);
	 header("Location: $newlocation");
	 exit;
	 }
 
// format the object for display
$this->beryliumToHtml(); 
$this->getRuntimeVars();

// 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...
//
// kludge for different flavors of folder WRT documents...
if ($this->flavor=="weblog") {
	$this->folderOrderBy= "AND obj.rank>=500 AND obj.name!='$this->name' AND obj.folderid='$this->id' ORDER BY rank DESC";
	$this->documentOrderBy= "ORDER BY created DESC";
	$this->imageOrderBy= "ORDER BY updated DESC LIMIT 3";
	if ($this->imageid=="0") $this->iconTag= "<img src='/bicons/weblog$this->iconpvt.png' border=0 alt='folder:$this->id (weblog)' title='folder:$this->id (weblog)'><br>&nbsp;";
	}
else {
	$this->folderOrderBy= "AND obj.rank>=500 AND obj.name!='$this->name'  AND obj.folderid='$this->id' ORDER BY rank DESC";
	$this->documentOrderBy= "ORDER BY rank DESC, created ASC";
	$this->imageOrderBy= "";
	}


//
// Object Access Bar (folders, documents, etc)
// show berylium icon at top
if ($this->imageid=="0" && ($sitemember->role=="editor" || $sitemember->role=="admin")) {
    $this->topIconTag= "<img src='/bicons/blogo-label-48x48.png' border=0 alt='berylium' title='A berylium site. See http://berylium.org for info.'>";
    }
else $this->topIconTag= $this->iconTag;

// contexts are for admins only:
if ($sitemember->role=="admin") {
	$this->adminAccess= " | <a href='$folder->baseURL/context-.html?method=view'>contexts</a>"; 
	}


//
// Session Control Bar (Cancel, debug, etc...)
// cancel button
    if ($session->request->method!="view" && $session->request->method!="listall") {
	    $this->cancelTag= "<a href='$object->baseUrl'><img src='/bicons/cancel.png' border=0 alt='' title='cancel' align=middle></a>&nbsp;<a href='$object->baseUrl'>cancel</a>";
	    }
    elseif ($object->objtype!="folder" || $session->request->method=="listall") {
	    $this->cancelTag= "<a href='$this->baseUrl'><img src='/bicons/folder-open.png' border=0 alt='' title='parent folder' align=middle></a>&nbsp;<a href='$this->baseUrl'>$this->title</a>";
	    }
    elseif ($containers[1]->baseUrl!="") {
	    $this->cancelTag= "<a href='".$containers[1]->baseUrl."'><img src='/bicons/folder-open.png' border=0 alt='' title='parent folder' align=middle></a>&nbsp;<a href='".$containers[1]->baseUrl."'>".$containers[1]->title."</a>";
	    }
    else {
	    $this->cancelTag= "<a href='http://$site->name/'><img src='/bicons/folder-open.png' border=0 alt='' title='parent site' align=middle></a>&nbsp;<a href='http://$site->name/'>$site->name</a>";
	    }
// debug switch
    if ($session->p_debug) {
	$this->debugTag= "<a href='$session->refreshURL&debug=off'>no debug</a> |";
	}
    elseif ($sitemember->role=="admin") {
	$this->debugTag= "<a href='$session->refreshURL&debug=1'>debug</a> |";
	}
// standardContext switch
    if ($session->p_standardContext) {
	$this->contextTag= "<a href='$session->refreshURL&standardContext=0'>site look</a> |";
	}
    elseif ($sitemember->role=="writer" || $sitemember->role=="editor" || $sitemember->role=="admin") {
	$this->contextTag= "<a href='$session->refreshURL&standardContext=1'>berylium look</a> |";
	}
// showDeleted switch
    if ($session->p_showDeleted) {
	$this->showDelTag= "<a href='$session->refreshURL&showDeleted=0'>hide deleted</a> |";
	}
    elseif ($sitemember->role=="editor" || $sitemember->role=="admin") {
	$this->showDelTag= "<a href='$session->refreshURL&showDeleted=1'>show deleted</a> |";
	}

//
// 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->baseUrl?method=login' name='userLogin' method='POST'>
                You are being anonymous. &nbsp; <br>
                <input type='text' name='email' value='email' onFocus=\"document.userLogin.email.value=''\" size='10'>
                <input type='password' name='password' value='***' onFocus=\"document.userLogin.password.value=''\" size='8'>
                <input type='submit' name='login' value='&raquo;' class='buttonstyle'><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.png' 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.png' 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.png' 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);
	}
	

%%header%%
<table border=0>
    <tr>
	<td width="5%" align=middle valign=top>
	    <a href="/berylium">$this->topIconTag</a>
	</td>
	<td width="65%" valign='top'>
	    <span class='objTitle'><a href='$folder->baseUrl'>$folder->title</a> @ <a href='$site->baseUrl'>$site->title</a></span>
	    <span class='objDescription'><br>$folder->description</span>
	</td>
	<td width="30%" class="info" align='right' rowspan="2">
            $this->loginheader
        </td>
    </tr>
    <tr>
	<td colspan="2" class="info">
	    <!-- object access controls -->
	    <a href="$site->baseUrl/folder-.html?method=listall">folders</a> |
	    <a href="$site->baseUrl/document-.html?method=listall">documents</a> |
	    <a href="$site->baseUrl/image-.html?method=listall">images</a> |
	    <a href="$site->baseUrl/sitemember-.html?method=listall">members</a>
	    $this->adminAccess
	</td>
    </tr>
    <tr>
	<td colspan="3" class="info">
	    <!-- session controls -->
	    <img src="/bicons/spacer.gif" width=1 height=20>
	    <a href='$session->refreshURL'><img src='/bicons/refresh.png' 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='#bottom'>bottom of page</a>
	</td>
    </tr>
</table>
</td>
</tr>
</table>
<br>
<table class='bodytable'>
<tr>
<td align='center' valign='top'>
<table>
	<tr>
		<td valign='top' width='22%' class='navigationcell'>
			{list:SELECT obj.* FROM folder AS obj, folder WHERE obj.rank>=100 AND obj.siteid='$site->id' AND obj.status='posted' AND folder.id=obj.folderid AND obj.name!='/'  AND obj.folderid='$site->folderid' $session->publicwhere ORDER BY obj.rank DESC;navbar}
			$this->inventoryList
		</td>
		<td valign='top' width='78%' class='contentcell'>
<!-- begin object content -->



%%css%%


%%template%%
<p class='objHeadline'><img src='/bicons/spacer.gif' width='1' height='20' border=0>$this->headline</p>
<span class='objBody'>$this->body<br>&nbsp;</span>
{index:folder;index;$this->folderOrderBy}
{index:document;index;$this->documentOrderBy}
{index:image;index;$this->imageOrderBy}


%%listrow%%


%%nullobject%%
 <p><img src='/bicons/warning.png' alt='Warning' align=left><br>
	<b>The folder you requested was not found.</b></p>
<p>Please see the <a href='$site->baseUrl'>site homepage</a> or choose one of the folders at left. Thanks!</p>


%%footer%%
<!-- end object content -->
		</td>
	</tr>
</table>
<a name='bottom'></a>
</td>
</tr>
</table>
<br>
<table class='bodytable'>
<tr>
<td align='center' valign='top'>
<table>
	<tr>
		<td width='20%'><img src='/bicons/spacer.gif' border=0 alt='controls:' title=''></td>
		<td width='80%' class='info'>
			<!-- session controls -->
			<img src="/bicons/spacer.gif" width=1 height=20>
			<a href='$session->refreshURL'><img src='/bicons/refresh.png' 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>
			<p align='right'>$this->loginfooter</p>
		</td>
	</tr>
</table>


%%postprocess%%


%%end of context%%
