Location: PHPKode > projects > synType CMS > setup/wizards/cmssetup/page.dbcore.php
<?php
/**
 *  synType CMS Setup
 *  Module: Wizard Page Core DB
 *
 *  Copyright © 2004-2009 V. Puttrich, MindArray
 *
 *  http://www.mindarray.eu
 *
 *  Author: V. Puttrich, MindArray
 * ----------------------------------------------------------------------------
 *  $Id$
 * ----------------------------------------------------------------------------
 *
 *  This file is part of synType CMS.
 *
 *  synType CMS 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 3 of the License, or
 *  (at your option) any later version.
 *
 *  synType CMS 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 libMail. If not, see <http://www.gnu.org/licenses/>.
 *
 * ----------------------------------------------------------------------------
 **/


class wizPageDbcore extends wizardPage
{

	public function __construct($oWizard, &$in)
	{
		parent::__construct($oWizard, $in);
	}

	public function __destruct()
	{
		parent::__destruct();
	}

	protected function onPrepare()
	{
		if(($aData = $this->_oWizard->getProperty('cmsdb')) === null)
			throw new wizException("Persistent data not found!");

		// Get suported management features of driver from ini file
		/* Obsolete
		$aIni = parse_ini_file('./setup.ini', true);

		if(!isset($aIni['DBMS DriverCaps']))
			throw new wizException("Section [DBMS DriverCaps] not found in 'setup.ini'!");

		if(!isset($aIni['DBMS DriverCaps'][$aData['coredb']['dbdrv']]))
			throw new wizException("Selected driver '{$aData['coredb']['dbdrv']}' not found under section [DBMS DriverCaps] in 'setup.ini'!");

		$aCaps = explode(',', $aIni['DBMS DriverCaps'][$aData['coredb']['dbdrv']]);
		$aData['coredb']['create_db'] = (stripos($aCaps[0], 'true') !== false);
		$aData['coredb']['create_schema'] = (stripos($aCaps[1], 'true') !== false);
		$aData['coredb']['create_users'] = (stripos($aCaps[2], 'true') !== false);
		*/

		$this->_oWizard->setProperty('cmsdb', $aData);

		return 0;
	}

	protected function onAfterSubmit($nGoto)
	{
		if($nGoto != wizWizard::PAGE_SELF && isset($this->_in['coredb'])){
			if(($aData = $this->_oWizard->getProperty('cmsdb')) === null)
				throw new wizException("Persistent data not found!");

			$aData['coredb'] = array_merge($aData['coredb'], $this->_in['coredb']);
			$aData['coredb']['create_db'] = (isset($this->_in['coredb']['create_db']))? true: false;
			$aData['coredb']['create_users'] = (isset($this->_in['coredb']['create_users']))? true: false;

			$this->_oWizard->setProperty('cmsdb', $aData);
		}

		return 0;
	}

	protected function onPage($nErr)
	{
		if($nErr)
			return $this->getContents();

		$this->setTextTop("Core Database Settings");

		if(($aData = $this->_oWizard->getProperty('cmsdb')) === null)
			throw new wizException("Persistent data not found!");

//		$this->addText("Please enter data required to connect to the database server.");

		$this->formAddText("Please enter data required to connect to the database server.");
		$this->formAddInput('Host name or IP address', 'coredb[dbhost]', $aData['coredb']['dbhost'], 30);
		$this->formAddInput('Port (leave empty for default)', 'coredb[dbport]', $aData['coredb']['dbport'], 5, 5);

		$this->formAddSeparator();

		$this->formAddText("Please enter the name of the database on the server.");
		$this->formAddInput('Database name', 'coredb[dbname]', $aData['coredb']['dbname'], 30);
		$this->formAddCheckbox('Create database?', 'coredb[create_db]" onchange="swap_sysdba(this)', '1', $aData['coredb']['create_db']);

		$this->formAddSeparator();

		$this->formAddText("Please enter a prefix for table names or leave the default.");
		$this->formAddInput('Table prefix', 'coredb[dbprefix]', $aData['coredb']['dbprefix'], 30);

		$this->formAddSeparator();

		$this->formAddText("This is the standard database user.");
		$this->formAddInput('Database Username', 'coredb[dbcmsuser]', $aData['coredb']['dbcmsuser'], 30);
		$this->formAddPassword('Password', 'coredb[dbcmsuserpwd]', $aData['coredb']['dbcmsuserpwd'], 30);
		$this->formAddCheckbox('Create user?', 'coredb[create_users]" onchange="swap_sysdba(this)', '1', $aData['coredb']['create_users']);

		$this->formAddSeparator();

		$this->formAddText("Please enter the user name and password required for full access to the database server.<br />This is only used by Setup and will not be stored.");
		$this->formAddInput('DBMS Administrator (SYSDBA)', 'coredb[dbsysadm]', $aData['coredb']['dbsysadm'], 30);
		$this->formAddPassword('Password', 'coredb[dbsysadmpwd]', $aData['coredb']['dbsysadmpwd'], 30);

		return $this->getContents();
	}

}

?>
Return current item: synType CMS