%%document-view-writer-scene%%
hiphopclown.org 
2002-12-21 23:41

%%preprocess%%
// SCENE CONTROLLER
// get info on number of scenes here (sceneTotal)
$this->sceneQuery= "SELECT obj.* FROM document AS obj WHERE obj.folderid='$this->folderid' AND obj.flavor='Scene' $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->total= $firstscene->listsize;

// which scene is being displayed? (sceneOffset)
$this->sceneArrayKey= -1;
foreach ($sceneArray AS $key=>$myScene) {
	berror("SceneControl looking at sceneArray[$key], named $myScene[name]. ($object->name)",1);
	if ($myScene['id']==$this->id) {
		berror("SceneControl <b>MATCH</b> on $key.",1);
		$this->sceneArrayKey= "$key";
		break;
		}
	}

// find last, first, previous and next scene names
$this->offset= $this->sceneArrayKey + 1;

// OBJECT FORMATTING
// format the object for display
$this->beryliumToHtml();
$this->getRuntimeVars();
$this->applyPolicy();

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

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


// ROOM SETTINGS
berror("Getting imagesize on $folder->p_background now...",1);
if ($background= getimagesize($folder->p_background)) {
	berror("Got it.",1);
	$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 CONTROL PART II
// first is 0
$previous= $this->sceneArrayKey - 1;
$next= $this->sceneArrayKey + 1;
$last= $this->total - 1;

// prevtag / nexttag logic
if ($this->offset!=1) {
	$this->prevtag= "<a href='".$folder->baseUrl."document-".$sceneArray[$previous]['name'].".html' target='_top'>&laquo; Prev</a>&nbsp;&nbsp;";
	}
if ($this->offset==1) {
	// not showing jump-to-last
	//$this->prevtag= "<a href='".$folder->baseUrl."document-".$sceneArray[$last]['name'].".html' target='_top'>Last &raquo</a>&nbsp;&nbsp;";
	$this->prevtag= "";
	}
if ($this->offset<$this->total) {
	$this->nexttag= "&nbsp;&nbsp;<a href='".$folder->baseUrl."document-".$sceneArray[$next]['name'].".html' target='_top'>Next &raquo;</a>";
	}
if ($this->offset==$this->total) {
	$this->nexttag= "&nbsp;&nbsp;<a href='".$folder->baseUrl."document-".$sceneArray[0]['name'].".html' target='_top'>&laquo; Restart &raquo;</a>";
	}

// SCENEINFO COLOR
if ($folder->p_infoColor!="") $this->infoColor= $folder->p_infoColor;
else $this->infoColor= "white";

// INFO POSITION
$bgcenter= $this->bgnumericwidth / 2;
$this->infoLeft= ($bgcenter - 90)."px";
$this->infoTop= ($this->bgnumericheight-20)."px";


// WHICH FRAME TO DISPLAY?
if (0 && $_GET['frameid']=="") {
	$firstframe= new Comment;
	$framequery= "SELECT obj.* FROM comment AS obj WHERE obj.parentobjtype='$this->objtype' AND obj.parentid='$this->id' AND obj.flavor='Frame' $session->statuswhere $session->publicwhere ORDER BY rank DESC, created ASC";
	$firstframe->selectObject($framequery);
	$this->frameid= $firstframe->id;
	berror("Found first frame at comment:$firstframe->id.",1);
	}
elseif ($_GET['frameid']=="") {
	$this->showNull=1;
	}
else $this->frameid= $_GET['frameid'];
	
berror("<b>Scene Render: FINISHED</b>.",1);
//if ($this->itemEditor || $this->itemOwner) $this->showNull= 1;

%%header%%


%%css%%
.boothtable	{ background-color: #f9f9fb;
			border: 3px; border-color: #0e47b2; border-style: solid;
			color: #223344;
			font-family: Tahoma, Geneva, sans-serif; font-size: 12px; line-height: 18px;
			width: $this->backgroundwidth;
			}
.boothtable A { color: #135b9f; }
.frameInfo { font-family: Arial, Helvetica, sans-serif; font-size: 10px; line-height: 14px; color: $this->infoColor; text-align: center; }
.frameInfo A { color: $this->infoColor; font-weight: bold; }


%%template%%
<a name="top"> </a>
<img src="/bicons/spacer.gif" width="$this->bgnumericwidth" height="$this->bgnumericheight" border=0>
<div id='background' style='position: absolute; left: 0px; top: 0px; width: $this->backgroundwidth; height: $this->backgroundheight; z-index:1; background-color: #333333; background-image: url($folder->p_background); background-position: center center;' onDblClick="window.location='#controls';">
</div>
{list:SELECT obj.* FROM comment AS obj WHERE obj.id='$this->frameid' $session->statuswhere $session->publicwhere;view}
<br />

%%listrow%%


%%nullobject%%
<a name="top"> </a>
<img src="/bicons/spacer.gif" width="$this->bgnumericwidth" height="$this->bgnumericheight" border=0>
<div id='background' style='position: absolute; left: 0px; top: 0px; width: $this->backgroundwidth; height: $this->backgroundheight; z-index:1; background-color: #333333; background-image: url($folder->p_background); background-position: center center;' onDblClick="window.location='#controls';">
</div>
{list:SELECT obj.* FROM comment AS obj WHERE obj.flavor='Frame' AND obj.parentobjtype='document' AND obj.parentid='$this->id' $session->statuswhere $session->publicwhere ORDER BY obj.rank DESC, obj.created ASC;list}
<br />

%%footer%%


%%postprocess%%


%%end of context%%
