Location: PHPKode > projects > Aukyla Document Management System > plugins/Frontends/DummyFrontend.php
<?php
/*
     DummyFrontend.php, a simple example frontend
     Copyright (C) 2003-2005 Arend van Beelen, Auton Rijnsburg

     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

     For any questions, comments or whatever, you may mail me at: hide@address.com
*/

require_once('Config.php');
require_once('ConfigEditor.php');
require_once('Decoration.php');
require_once('Document.php');
require_once('Forms.php');
require_once('Frontend.php');
require_once('GUI.php');
require_once('Locale.php');
require_once('Login.php');
require_once('Menus.php');
require_once('Messages.php');
require_once('Navigation.php');
require_once('Output.php');
require_once('String.php');
require_once('Views.php');
require_once('Windows.php');

/**
 * @brief A dummy frontend
 */
class DummyFrontend implements Frontend
{
	/**
	 * Build the frontend.
	 */
	public function buildGUI()
	{
		// initialize localization module for this frontend
		Locale::init('plugins/Frontends');

		$this->windowManager = $windowManager = new WindowManager();

		// create the main window
		$mainWindow = new MainWindow(i18n('Aukyla PHP Framework'));

		// add a logo
		new Box($mainWindow, 'logo');

		// build the main menu
		$menu = new Menu($mainWindow, 'mainmenu');
		$autonEntry = new MenuEntry($menu, i18n('Auton'));
		$autonEntry->setLink('http://www.auton.nl/');
		$autonEntry->setCssClass('home');

		// build the sub menu
		$menu = new Menu($mainWindow, 'submenu');
		new MenuHead($menu, i18n('Main Menu'));

		if(String::startsWith(Login::username(), 'anonymous'))
		{
			// for anonymous users
			$loginEntry = new MenuEntry($menu, i18n('Login'));
			$loginEntry->setLink(Navigation::viewLink('view', 'Login'));
		}
		else
		{
			// and for logged in users
			if(Login::isMemberOf('admin'))
			{
				$preferencesEntry = new MenuEntry($menu, i18n('Aukyla Administration Area'));
				if(String::startsWith(Config::globals('secureBaseURL'), 'https://'))
				{
					$preferencesEntry->setLink("https://{$_SERVER['HTTP_HOST']}/admin.php");
				}
				else
				{
					$preferencesEntry->setLink("http://{$_SERVER['HTTP_HOST']}/admin.php");
				}
			}
			$preferencesEntry = new MenuEntry($menu, i18n('Preferences'));
			$preferencesEntry->setLink(Navigation::viewLink('view', 'ConfigEditor'));
			$logoutEntry = new MenuEntry($menu, i18n('Logout'));
			$logoutEntry->setLink(Config::globals('baseURL').'?action=Logout');
		}

		// create a container for the views
		$main = new Box($mainWindow, 'main');
		new MessagesWidget($main);
		$viewContainer = new ViewContainer($main);

		// don't allow anonymous users access to an editor
		if(String::startsWith(Login::username(), 'anonymous') &&
		   String::endsWith($viewContainer->view(), 'Editor'))
		{
			Config::unsetRequests();
			$viewContainer->setView('default');
			Messages::error(i18n('You do not have acces to this view.'));
		}

		// create a login view
		$view = new View($viewContainer, 'Login');
		new LoginForm($view);

		// create the view with the config editor
		$view = new View($viewContainer, 'ConfigEditor');
		$configEditor = new ConfigEditor($view);
		$configTab = new ConfigTab($configEditor, i18n('General'), 'global');
		new SelectConfigOption($configTab, 'language', Locale::language(), Locale::availableLanguages(),
		                       i18n('Language:'));
		new SelectConfigOption($configTab, 'theme', Decoration::theme(), Decoration::availableThemes(),
		                       i18n('Theme:'));

		// create a simple default view
		$view = new View($viewContainer);
		new Header($view, i18n('Welcome to the Aukyla PHP Framework!'));
		new Paragraph($view,
		              i18n('Congratulations! You have successfully installed the Aukyla PHP Framework. To be able to do something useful you will need to install an application on top of the framework.'));
		$section = new Section($view);
		new Header($section, i18n('Login information'));
		new Paragraph($section,
		              i18n('You can log in using "demo1" or "demo2" as username, the passwords are "demo1" and "demo2" as well. There is also an "admin" user with equal password.'));
	}

	/**
	 * Show the frontend.
	 */
	public function showGUI()
	{
		$this->windowManager->show();
	}

	private $windowManager;
}

?>
Return current item: Aukyla Document Management System