Location: PHPKode > projects > Community Learning Network > cln/lib/CLN/interfaces/Page/getLayoutContent.php
<?php
/*
 * Gets Layout Content
 *
 * Copyright (c) 2003-4 St. Christopher House
 *
 * Developed by The Working Group Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  
 *
 * @version $Id: getLayoutContent.php,v 1.11 2004/11/12 18:18:21 darcy Exp $
 *
 */

define('CLN_FILE_BASE', '../../../../');
$PAGETYPE = 'Admin';
include(CLN_FILE_BASE . 'index.php');

//********************************************************************

if(!class_exists("SimpleXMLParser")) {
	require_once("SimpleXMLParser.php");
}

/*
 *
 * Class:  EditLayoutParser()
 *
 * 		Extends LayoutParser
 *			- prepares layout for layout interface
 *
 *                
 */
class EditLayoutParser extends SimpleXMLParser {
	var $rowExists = FALSE;
	var $newExists = FALSE;
	
	function tag_open($parser, $tag, $attributes)
	{
		if($tag == "BLOCK") {
			$block =& new $GLOBALS['classes']['ko']['classname']($attributes['KOID']);
			$block->loadPartObject(0);	// this assumes that loadPartObject gets the right language
			
			$this->content .= "<BLOCK koId=\"".$block->koId."\" "
							  ."modId=\"".$block->modId."\" modName=\"".$block->modName."\" title=\"".$block->currentPart['title']."\">\n";
		
			//$this->content .= "<BLOCK id=\"".$attributes['KOID']." ".$block->currentPart['title']."\">";
		}
		else if($tag == "NEW") {
			$this->content .= "<ROW><COLUMN>\n";
			$this->newExists = TRUE;
		}
		// All other tags fall through
		else {
			if($tag == "ROW") {
				$this->rowExists = TRUE;
			}
			$attr = "";
			while(list($key,$value) = each($attributes)) {
				$attr .= " ".$key."=\"".$value."\"";
			}
			
			$this->content .= "<".$tag.$attr.">\n";
		}	
	}
	    
	function tag_close($parser, $tag)
    	{	
		if($tag == "NEW") {
			$this->content .= "</COLUMN></ROW></LAYOUT>\n";
		} 
		else if($tag == "LAYOUT") {
			// do nothing - this is a hack to get NEW back into the normal layout structure - dwc
		} 
		else if($tag == "PAGE") {
			if(!$this->newExists) {
				if(!$this->rowExists) {
					$this->content .= "<ROW><COLUMN></COLUMN></ROW>";
				}
				$this->content .= "</LAYOUT>";
			}
			$this->content .= "</".$tag.">\n";
		} else {
			$this->content .= "</".$tag.">\n";
		}
	}

}


//********************************************************************

$editLayoutParser = new EditLayoutParser();

header("Content-type: application/xml");

// Get the pageId
if($_SESSION['Page']->currentPart['object']->layout) {
	if($content = $editLayoutParser->parse($_SESSION['Page']->currentPart['object']->layout)) {
		print $content;
	} else {
		print "<error>LayoutParser could not process layout</error>";
	}
} else {
	print "<error>Page object does not exist.</error>";
}


?>
Return current item: Community Learning Network