Location: PHPKode > scripts > ezSqliteAdmin > ezsqliteadmin/MainModel.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: MainModel.php,v 1.2 2004/09/18 09:30:03 wenlong Exp $
//

/**
* MainModel
*
* @package		ezSqliteAdmin
* @version		$Revision: 1.2 $
* @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 MainModel extends AModel {
	/**
	* the singleton instance of MainModel
	*
	* @access	private
	* @var		object
	*/
	static private $instance = null;
	
	/**
	* contains the tab labels
	*
	* @access	public
	* @var		array
	*/
	public $tabs = array();

	/**
	* contains the tab panels
	*
	* @access	public
	* @var		array
	*/
	public $tabpanels = array();

	/**
	* Constructor
	*/
	public function __construct() {
		parent::__construct();
	}

	/**
	* Get the (singleton) instance of the MainModel
	*
	* @access	public
	* @return	object		the MainModel singleton
	*/
	static public function getInstance() {
		if (self::$instance == null) {
			self::$instance = new MainModel();
		}
		return self::$instance;
    }
	
	/**
	* Add an element to tabbox
	*
	* @access	public
	* @param	string		[$classname] the class name
	* @param	string		[$label] tab label
	* @param	mixed		[$icon] tab icon
	* @return	void
	*/
	public function add($classname, $label, $icon = null) {
		$this->tabs[] = array('label' => $label, 'icon' => $icon);

		$file = $classname . '.php';
		if (!file_exists($file)) {
			throw new Exception("Cannot find $file");
		}
		require_once($file);
		if (!class_exists($classname)) {
			throw new Exception("class $classname does not exist");
		}

		$class = new ReflectionClass($classname);
		if (!$class->isSubclassOf(new ReflectionClass('AView'))) {
			throw new Exception("$classname is not a valid caller, must be extends from AView");
		}
		$view = $class->newInstance();
		$this->tabpanels[$classname] = $view;
	}
}
?>
Return current item: ezSqliteAdmin