<?php
/**
* synType CMS Setup
* Module: Wizard Page Locale Settings
*
* 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 wizPageLocales extends wizardPage
{
static $aData = array(
'timezone' => 'Etc/UTC',
'deflang' => 'en',
'languages' => 'en',
'country' => '',
'currency' => ''
);
private $_aData = array(
'timezone' => 'Etc/UTC',
'deflang' => 'en',
'languages' => 'en',
'country' => '',
'currency' => ''
);
public function __construct($oWizard, &$in)
{
parent::__construct($oWizard, $in);
$this->_aData = self::$aData;
$aIni = parse_ini_file('./setup.ini', true);
if(isset($aIni['LANGUAGES']['languages']))
$this->_aData['languages'] = trim($aIni['LANGUAGES']['languages']);
if(isset($aIni['LANGUAGES']['default_lang']))
$this->_aData['deflang'] = trim($aIni['LANGUAGES']['default_lang']);
}
public function __destruct()
{
parent::__destruct();
}
protected function onPrepare()
{
if(($aData = $this->_oWizard->getProperty('locale')) === null)
$aData = self::$aData;
$this->_oWizard->setProperty('locale', $aData);
return 0;
}
protected function onAfterSubmit($nGoto)
{
if($nGoto != wizWizard::PAGE_SELF && isset($this->_in['locale'])){
if(($aData = $this->_oWizard->getProperty('locale')) === null)
$aData = $this->_aData;
$aData = array_merge($aData, $this->_in['locale']);
$aData['languages'] = implode(',', $aData['languages']);
$this->_oWizard->setProperty('locale', $aData);
}
return 0;
}
protected function onPage($nErr)
{
if($nErr)
return $this->getContents();
$this->setTextTop("International Settings");
if(($aData = $this->_oWizard->getProperty('locale')) === null)
throw new wizException("Persistent data not found!");
include(LIBDIR .'/libLocale/libLocale.php');
$oLocale = new libLocale();
// Timezone setting
$this->formAddText("All date/time information will be stored in UTC.<br />User input/output will be mapped to this time zones or their own setting.");
$aTmp = $oLocale->getTimezones();
$aOpts = array();
foreach($aTmp as $k => $v){
$aOpts[] = array($k, $k, true);
foreach($v as $k2 => $v2){
$aOpts[] = array($k2, $v2);
}
$aOpts[] = array($k, $v, false);
}
$this->formAddDropdown('Default Timezone', 'locale[timezone]', $aData['timezone'], $aOpts);
$this->formAddSeparator();
// Language packs
$this->formAddText("The following, selected language packs will be installed.");
$aTmp = $oLocale->getLanguages($this->_aData['languages']);
$aOpts = array();
foreach($aTmp as $k => $v){
$aOpts[] = array($k, $v);
}
$sAttr = "\" onchange=\"changeLangs(this)";
$this->formAddListbox('Install languages', 'locale[languages][]'.$sAttr, $aData['languages'], $aOpts, 8, true);
$this->formAddText("Press and hold the CTRL-Key to add/remove single entries<br />or the SHIFT-Key to (de)select a range of entries.");
$this->formAddSeparator();
// Default Language
$this->formAddText("The selected language is the default, if users don't pick another.");
$aCurLangs = array();
$aLangs = explode(',', $aData['languages']);
foreach($aOpts as $nIdx => $aLn){
if(in_array($aLn[0], $aLangs))
$aCurLangs[] = $aLn;
}
$this->formAddDropdown('Default language', 'locale[deflang]', $aData['deflang'], $aCurLangs);
$this->formAddSeparator();
// Country setting
$this->formAddText("The selected country is the default wherever a country must be chosen.");
$aTmp = $oLocale->getCountries();
$aOpts = array();
foreach($aTmp as $k => $v){
$aOpts[] = array($k, $v);
}
$sAttr = "\" onchange=\"changeCountry(this)";
$this->formAddDropdown('Country', 'locale[country]'.$sAttr, $aData['country'], $aOpts);
$this->formAddSeparator();
// Currency setting
$this->formAddText("The selected currency is the default wherever currencies are used.");
$aTmp = $oLocale->getCurrencies();
$aOpts = array();
foreach($aTmp as $k => $v){
$aOpts[] = array($k, $v);
}
$this->formAddDropdown('Currency', 'locale[currency]', $aData['currency'], $aOpts);
return $this->getContents();
}
}
?>