%%folder-view-editor-html%%
2002-07-18 19:54

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

// folder only-- force https for editors
if ($session->request->connection!="https") {
	 $newlocation= "https://$site->name$session->refreshURL";
	 berror("Editors connect via SSL. 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...
//$userank="obj.rank DESC,";
if ($this->p_sortorder=="alpha") {
	// alphabetical
	$this->folderOrderBy= "AND obj.rank>=500 AND obj.name!='$this->name' AND obj.folderid='$this->id' ORDER BY $userank obj.title ASC";
	$this->documentOrderBy= "ORDER BY $userank obj.title ASC";
	$this->imageOrderBy= "ORDER BY $userank obj.title ASC LIMIT 3";
	}
elseif ($this->p_sortorder=="chrono") {
	// chrono
	$this->folderOrderBy= "AND obj.rank>=500 AND obj.name!='$this->name'  AND obj.folderid='$this->id' ORDER BY $userank obj.created ASC";
	$this->documentOrderBy= "ORDER BY $userank obj.created ASC LIMIT 16";
	$this->imageOrderBy= "ORDER BY $userank obj.created ASC LIMIT 3";
	}
else {
	// reverse chrono
	$this->folderOrderBy= "AND obj.rank>=500 AND obj.name!='$this->name' AND obj.folderid='$this->id' ORDER BY $userank obj.created DESC";
	$this->documentOrderBy= "ORDER BY $userank obj.created DESC LIMIT 16";
	$this->imageOrderBy= "ORDER BY $userank obj.created 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;";
	}


//
// Object Access Bar (folders, documents, etc)
// show berylium icon at top
if ($this->imageid=="0") {
    $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='https://$site->name$object->uri?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' class='permaform'>
              $roleoptions
            </select>
            <input type='submit' name='go' value='&raquo;' class='buttonstyle'>
        </form>";
    $safename= preg_replace("/\s/","&nbsp;",$sitemember->name);
    $this->loginfooter= "Prepared for $sitemember->truerole <a href='$sitemember->idUrl'>$safename</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 class='siteHeader'>
    <tr>
	<td width="5%" align=center valign=middle>
	    <a href="/berylium">$this->topIconTag</a>
	</td>
	<td width="60%" valign='middle'>
	    <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="35%" 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">
			<form name='search' action='$site->baseUrl/document-.html?method=listall' method='post'>
			<input type='hidden' name='listrank' value='50'>
			<img src="/bicons/spacer.gif" width=5 height=18>
			<!-- 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> | 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>
</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, obj.title ASC;navbar}
			<hr>
			<table>
				<tr>
					<td>
						<img src='/bicons/folder.png' border=0 alt='new folder' title='new folder' align=middle>&nbsp;<a href='$session->scriptname$folder->name/folder-.html?method=create'>new folder</a><br>
					</td>
				</tr>
				<tr>
					<td>
						<img src='/bicons/document.png' border=0 alt='new document' title='new document' align=middle>&nbsp;<a href='$session->scriptname$folder->name/document-.html?method=create'>new document</a><br>
					</td>
				</tr>
				<tr>
					<td>
						<img src='/bicons/image.png' border=0 alt='new image' title='new image' align=middle>&nbsp;<a href='$session->scriptname$folder->name/image-.html?method=create'>new image</a><br>
					</td>
				</tr>
				<tr>
					<td>
						<img src='/bicons/sitemember.png' border=0 alt='new site member' title='new site member' align=middle>&nbsp;<a href='$session->scriptname/sitemember-.html?method=create'>new member</a><br>
					</td>
				</tr>
			</table>
			$this->inventoryList
		</td>
		<td valign='top' width='78%' class='contentcell'>
<!-- begin object content -->



%%css%%


%%template%%
<table class=objTable cellspacing=5 cellpadding=5>
	<tr>
		<td>
                  <table class="objHeader">
                          <tr>
                                  <td>
                                          <span class='objFlavor'>$this->flavor:<br></span>
                                          <span class="objTitle"><a href="$this->baseUrl">$this->headline</a></span>
                                          <span class='objByline'> <br> 
                                                  By $this->authorTag (#$this->sitememberid) on $this->dateTag.</span>
                                  </td>
                          </tr>
                          <tr>
                                  <td><span class="info">
                                          folder:$this->id is <b>$this->publishStatus</b> as of $this->updated.
                                          <img src='/bicons/event.png' alt='updated $this->updated' title='created $this->created - updated $this->updated' align=absmiddle border=0>
                                          </span>
                                  </td>
                          </tr>
                  </table>
                </td>
        </tr>
</table>
<blockquote class="objBody">$this->body</blockquote>
<p align="right" class='info'>
	<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.png' 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.png' alt='pick up' title='pick up this object' align=absmiddle border=0></a>
	<a href="$this->baseUrl?method=pickup">pick up</a>&nbsp;
</p>
{index:folder;index;$this->folderOrderBy}
{index:document;index;$this->documentOrderBy}


%%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 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'>
			<!-- <img src="/bicons/spacer.gif" width=1 height=20> -->
			<!-- 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> | 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>


%%postprocess%%


%%end of context%%
