| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* ConfigMan class file
|
|
|
4 |
*
|
|
|
5 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
6 |
* @link http://www.pradosoft.com/
|
|
|
7 |
* @copyright Copyright © 2006 PradoSoft
|
|
|
8 |
* @license http://www.pradosoft.com/license/
|
|
|
9 |
* @version $Id: ConfigMan.php 1398 2006-09-08 19:31:03Z xue $
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
/**
|
|
|
13 |
* ConfigMan class
|
|
|
14 |
*
|
|
|
15 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
16 |
* @link http://www.pradosoft.com/
|
|
|
17 |
* @copyright Copyright © 2006 PradoSoft
|
|
|
18 |
* @license http://www.pradosoft.com/license/
|
|
|
19 |
*/
|
|
|
20 |
class ConfigMan extends BlogPage
|
|
|
21 |
{
|
|
|
22 |
const CONFIG_FILE='Application.Data.Settings';
|
|
|
23 |
|
|
|
24 |
public function onLoad($param)
|
|
|
25 |
{
|
|
|
26 |
parent::onLoad($param);
|
|
|
27 |
if(!$this->IsPostBack)
|
|
|
28 |
{
|
|
|
29 |
$parameters=$this->Application->Parameters;
|
|
|
30 |
$this->SiteTitle->Text=$parameters['SiteTitle'];
|
|
|
31 |
$this->SiteSubtitle->Text=$parameters['SiteSubtitle'];
|
|
|
32 |
$this->SiteOwner->Text=$parameters['SiteOwner'];
|
|
|
33 |
$this->AdminEmail->Text=$parameters['AdminEmail'];
|
|
|
34 |
$this->MultipleUser->Checked=TPropertyValue::ensureBoolean($parameters['MultipleUser']);
|
|
|
35 |
$this->AccountApproval->Checked=TPropertyValue::ensureBoolean($parameters['AccountApproval']);
|
|
|
36 |
$this->PostPerPage->Text=$parameters['PostPerPage'];
|
|
|
37 |
$this->RecentComments->Text=$parameters['RecentComments'];
|
|
|
38 |
$this->PostApproval->Checked=TPropertyValue::ensureBoolean($parameters['PostApproval']);
|
|
|
39 |
$themes=$this->Service->ThemeManager->AvailableThemes;
|
|
|
40 |
$this->ThemeName->DataSource=$themes;
|
|
|
41 |
$this->ThemeName->dataBind();
|
|
|
42 |
$this->ThemeName->SelectedValue=array_search($parameters['ThemeName'],$themes);
|
|
|
43 |
}
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
public function saveButtonClicked($sender,$param)
|
|
|
47 |
{
|
|
|
48 |
$dom=new TXmlDocument;
|
|
|
49 |
$dom->Encoding='utf-8';
|
|
|
50 |
$dom->TagName='parameters';
|
|
|
51 |
$elements=$dom->Elements;
|
|
|
52 |
$elements[]=$this->createParameter('SiteTitle',$this->SiteTitle->Text);
|
|
|
53 |
$elements[]=$this->createParameter('SiteSubtitle',$this->SiteSubtitle->Text);
|
|
|
54 |
$elements[]=$this->createParameter('SiteOwner',$this->SiteOwner->Text);
|
|
|
55 |
$elements[]=$this->createParameter('AdminEmail',$this->AdminEmail->Text);
|
|
|
56 |
$elements[]=$this->createParameter('MultipleUser',$this->MultipleUser->Checked);
|
|
|
57 |
$elements[]=$this->createParameter('AccountApproval',$this->AccountApproval->Checked);
|
|
|
58 |
$elements[]=$this->createParameter('PostPerPage',$this->PostPerPage->Text);
|
|
|
59 |
$elements[]=$this->createParameter('RecentComments',$this->RecentComments->Text);
|
|
|
60 |
$elements[]=$this->createParameter('PostApproval',$this->PostApproval->Checked);
|
|
|
61 |
$themeName=$this->ThemeName->SelectedItem->Text;
|
|
|
62 |
$elements[]=$this->createParameter('ThemeName',$themeName);
|
|
|
63 |
$dom->saveToFile(Prado::getPathOfNamespace(self::CONFIG_FILE,'.xml'));
|
|
|
64 |
if($themeName!==$this->Theme->Name)
|
|
|
65 |
$this->Response->reload();
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
private function createParameter($id,$value)
|
|
|
69 |
{
|
|
|
70 |
$element=new TXmlElement('parameter');
|
|
|
71 |
$element->Attributes['id']=$id;
|
|
|
72 |
$element->Attributes['value']=TPropertyValue::ensureString($value);
|
|
|
73 |
return $element;
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
?>
|