Location: PHPKode > scripts > ezSqliteAdmin > ezsqliteadmin/IndexView.php
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
//
// +----------------------------------------------------------------------+
// | ezSqliteAdmin V0.1                                                   |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004, Wenlong Wu <hide@address.com>                 |
// | Homepage      http://www.phpsalon.com                                |
// | License       GNU Lesser General Public License (LGPL)               | 
// +----------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or        |
// | modify it under the terms of the GNU Lesser General Public           |
// | License as published by the Free Software Foundation; either         |
// | version 2.1 of the License, or (at your option) any later version.   |
// +----------------------------------------------------------------------+
// | Authors: Wenlong Wu <hide@address.com>                            |
// +----------------------------------------------------------------------+
//
// $Id: IndexView.php,v 1.5 2004/09/18 11:47:57 wenlong Exp $
//

/**
* IndexView - default View
*
* @package		ezSqliteAdmin
* @version		$Revision: 1.5 $
* @author		Wenlong Wu <hide@address.com>
* @homepage		http://www.phpsalon.com
* @copyright	Copyright (c) 2004, Wenlong Wu
* @license		http://opensource.org/licenses/lgpl-license.php
* @access		public
*/
class IndexView extends AView implements IView {
	/**
	* Constructor
	*
	* @access	public
	*/
	function __construct() {
		//parent::__construct();
	}

	/**
	* Prepare XUL for output
	*
	* @access	public
	* @return	string		XUL
	*/
	public function render() {
		$sqlite_version = sqlite_libversion();
		$sqlite_encoding = sqlite_libencoding();
		$ezsqlite_fullname = EZSQLITE_FULLNAME;
		$xul = <<<EOD
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window
	id="MainWindow"
	name="MainWindow"
	title="$ezsqlite_fullname"
	orient="vertical"
	width="640"
	height="480"
	persist="screenX screenY width height"
	xmlns:html="http://www.w3.org/1999/xhtml"
	xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script>
<![CDATA[
function showSidebar(id) {
	var obj = document.getElementById(id);
	obj.setAttribute('hidden', false);
}
function hideSidebar(id) {
	var obj = document.getElementById(id);
	obj.setAttribute('hidden', true);
}
function changeSidebar(menuId, barId) {
	var menuObj = document.getElementById(menuId);
	if (menuObj.getAttribute('checked') == true) {
		showSidebar(barId);
	} else {
		hideSidebar(barId);
	}
	//menuObj.setAttribute('checked', !menuObj.getAttribute('checked'));
}
function changeFrame(src) {
	var obj = document.getElementById("mainFrame");
	obj.setAttribute('src', src);
}
function addLogMessage(text) {
	var obj = document.getElementById("logMessages");
	obj.setAttribute('value', (obj.getAttribute('value') + text));
}
]]>
</script>
<keyset>
	<!-- view menu -->
	<key id="viewDatabasesKey" modifiers="accel shift" key="1" />
	<key id="viewMessagesKey" modifiers="accel shift" key="2" oncommand="changeSidebar('viewMessages', 'Messages');" />
</keyset>

<toolbox>
	<menubar id="MainMenu" chromeclass="menubar">
		<menu id="FileMenu" label="File">
			<menupopup id="FilePopup">
				<menuitem label="Add Database..." />
				<menuitem label="Database Manager" onclick="window.open('./?Action=DbtreeManageView', 'DbtreeManageDialog', 'centerscreen,modal,dialog,chrome,width=400,height=220');" />
				<menuseparator/>
				<menuitem label="Import" />
				<menuitem label="Export" />
				<menuseparator/>
				<menuitem label="Quit" onclick="window.close();"/>
			</menupopup>
		</menu>
		<menu id="ViewMenu" label="View">
			<menupopup id="ViewPopup">
				<menuitem label="Databases" id="viewDatabases" key="viewDatabasesKey" type="checkbox" checked="true" onclick="changeSidebar('viewDatabases', 'Databases');" />
				<menuitem label="Messages" id="viewMessages" key="viewMessagesKey" type="checkbox" checked="true" />
				<menuseparator/>
				<menuitem label="Refresh All" onclick="window.location.reload();"/>
			</menupopup>
		</menu>
		<menu id="HelpMenu" label="Help">
			<menupopup id="HelpPopup">
				<menuitem label="Help Topics" key="helpKey"/>
				<menuseparator/>
				<menuitem label="About ezSqliteAdmin ..." oncommand="window.open('./?Action=AboutView', 'AboutDialog', 'centerscreen,modal,dialog,chrome,width=400,height=220');"/>
			</menupopup>
		</menu>
	</menubar>
</toolbox>

<hbox flex="1">
	<vbox width="200" id="Databases">
		<iframe flex="1" id="treeFrame" name="treeFrame" src="./?Action=DbtreeView"/>
	</vbox>
	<splitter />
	<iframe flex="1" id="mainFrame" name="mainFrame"  src="./?Action=MainView" />
</hbox>
<splitter />
<hbox flex="1" id="Messages">
	<textbox id="logMessages" flex="1" rows="10" multiline="true" value="not yet implemented!"/>
	<vbox>
		<vbox flex="1">
		<toolbarbutton image="images/close.png" onclick="hideSidebar('Messages');" style="align:right"/>
		</vbox>
	</vbox>
</hbox>
<statusbar>
	<statusbarpanel crop="end" flex="1">
		<progressmeter id="normal" mode="normal" flex="1"/>
	</statusbarpanel>
	<statusbarpanel label="$sqlite_version" />
	<statusbarpanel label="$sqlite_encoding" />
	<statusbarpanel>
		<stack>
			<description value="$ezsqlite_fullname" style="color: gray; padding-left: 1px; padding-top: 1px;"/>
			<description value="$ezsqlite_fullname" style="color: blue;"/>
		</stack>
	</statusbarpanel>
</statusbar>

<script>
<![CDATA[
window.opener.close();
]]>
</script>
</window>

EOD;
		return $xul;
	}
}
?>
Return current item: ezSqliteAdmin