%%context-backup-editor-html%%
progmin : / (context #160)
2002-06-14 15:09:53

%%preprocess%%
$this->backedup= "Backed up contexts:";
$this->contextdir= $GLOBALS['beryliumroot']."/code/contexts".$folder->name;
if ($folder->name!="/") $this->contextdir .= "/";

$this->query= "SELECT obj.* FROM context AS obj WHERE siteid='$site->id' AND status='posted' AND folderid='$folder->id'";
$this->contextarray= $this->selectObject($this->query);

foreach($this->contextarray AS $key=>$mycontext) {
	$filepath= "$this->contextdir$mycontext[name]";
	// SECURITY make sure folder exists first...
	$fileout= "%%$mycontext[classname]-$mycontext[method]-$mycontext[role]-$mycontext[format]%%
$site->name : $folder->name (context #$mycontext[id])
$mycontext[updated]

%%preprocess%%
$mycontext[preprocess]

%%header%%
$mycontext[header]

%%css%%
$mycontext[css]

%%template%%
$mycontext[template]

%%listrow%%
$mycontext[listrow]

%%nullobject%%
$mycontext[nullobject]

%%footer%%
$mycontext[footer]

%%postprocess%%
$mycontext[postprocess]

%%end of context%%
";

	$this->backedup .= "<br>$mycontext[name]";
	
	// if file exists, overwrite it
	// SECURITY we should backup contexts before overwriting them.
	$fp= @fopen($filepath, "w");
	if (@fwrite($fp,$fileout)) {
		berror("updateContext(): wrote file successfully.",1);
		$this->backedup .= " written!";
	        fclose($fp);
		}
	else {
		berror("updateContext(): unable to save context file to disk. Check permissions on the berylium/code/contexts folder.",1);
		$this->backedup .= " <b>Not written!</b>";
		}	
	}





%%header%%



%%css%%



%%template%%
This should back up all the contexts found with $this->query to ($this->contextdir).



%%listrow%%
 



%%nullobject%%
This should back up all the contexts found with $this->query to ($this->contextdir), except it didn't find any contexts here in folder: $folder->name.
<hr>
$this->backedup 



%%footer%%



%%postprocess%%



%%end of context%%
