Location: PHPKode > projects > synType CMS > setup/wizards/cmssetup/page.cmsadmin.php
<?php
/**
 *  synType CMS Setup
 *  Module: Wizard Page CMS Admin
 *
 *  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 wizPageCmsadmin extends wizardPage
{
	static $aData = array(
		'auth'		=> array(
			'username'		=> 'Admin',
			'pwd'			=> ''
		),
		'person'	=> array(
			'salutation'	=> '',
			'name'			=> '',
			'email'			=> '',
			'phone'			=> '',
			'address'		=> array(
				'addr1'		=> '',
				'addr2'		=> '',
				'street'	=> '',
				'zip'		=> '',
				'city'		=> '',
				'country'	=> ''
			)
		)
	);


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

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

	protected function onPrepare()
	{
		if(($aData = $this->_oWizard->getProperty('admin')) === null)
			$aData = self::$aData;

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

		return 0;
	}

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

				$aData['auth'] = $this->_in['auth'];
				$aData['person'] = $this->_in['person'];

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

		return 0;
	}

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

		$this->setTextTop("Administrator Setup");

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

		include(LIBDIR .'/libLocale/libLocale.php');
		$oLocale = new libLocale();

		$this->formAddInput('Username', 'auth[username]', $aData['auth']['username'], 30, 32);
		$this->formAddInput('Password', 'auth[pwd]', $aData['auth']['pwd'], 30, 32);

		$this->formAddSeparator();

		$aOpts = array(
			array('mr', 'Mr.'),
			array('mrs', 'Mrs.')
		);
		$this->formAddInput('Full name', 'person[name]', $aData['person']['name'], 30, 100);
		$this->formAddInput('Email address', 'person[email]', $aData['person']['email'], 30, 100);
		$this->formAddInput('Phone no.', 'person[phone]', $aData['person']['phone'], 30, 100);

		$this->formAddSeparator();

		$this->formAddText('<strong>Address</strong>');
		$this->formAddDropdown('Salutation', 'person[salutation]', $aData['person']['salutation'], $aOpts);
		$this->formAddInput('Name', 'person[address][addr1]', $aData['person']['address']['addr1'], 30, 150);
		$this->formAddInput('C/o etc.', 'person[address][addr2]', $aData['person']['address']['addr2'], 30, 150);
		$this->formAddInput('Street', 'person[address][street]', $aData['person']['address']['street'], 30, 150);
		$this->formAddInput('Zip', 'person[address][zip]', $aData['person']['address']['zip'], 8, 8);
		$this->formAddInput('City', 'person[address][city]', $aData['person']['address']['city'], 30, 150);
		// Country setting
		$aTmp = $oLocale->getCountries();
		$aOpts = array();
		foreach($aTmp as $k => $v){
			$aOpts[] = array($k, $v);
		}
		if(empty($aData['person']['address']['country'])){
			if(($aLocale = $this->_oWizard->getProperty('locale')) === null)
				throw new wizException("Persistent data not found!");

			$aData['person']['address']['country'] = $aLocale['country'];
		}
		$this->formAddDropdown('Country', 'person[address][country]', $aData['person']['address']['country'], $aOpts);

		return $this->getContents();
	}

}

?>
Return current item: synType CMS