diff options
author | xue <> | 2006-05-29 16:50:33 +0000 |
---|---|---|
committer | xue <> | 2006-05-29 16:50:33 +0000 |
commit | 7f508e187e4539a16cdbb1dd6a4b1133c53cf24d (patch) | |
tree | f3c47d2b436113407abaa99b2b70426c7a37a083 /demos/blog/protected/Pages/Admin | |
parent | 05869f23f798c9393e2bc6d310d56a97a11d1acd (diff) |
Blog now allows dynamically changing theme.
Diffstat (limited to 'demos/blog/protected/Pages/Admin')
-rw-r--r-- | demos/blog/protected/Pages/Admin/ConfigMan.page | 9 | ||||
-rw-r--r-- | demos/blog/protected/Pages/Admin/ConfigMan.php | 41 |
2 files changed, 46 insertions, 4 deletions
diff --git a/demos/blog/protected/Pages/Admin/ConfigMan.page b/demos/blog/protected/Pages/Admin/ConfigMan.page index ad728284..0f5ef03d 100644 --- a/demos/blog/protected/Pages/Admin/ConfigMan.page +++ b/demos/blog/protected/Pages/Admin/ConfigMan.page @@ -4,16 +4,16 @@ <com:Application.Pages.Admin.AdminMenu />
-<com:TPanel GroupingText="Site settings">
+<com:TPanel GroupingText="General settings">
<span class="input-label">Title</span>
<br/>
-<com:TTextBox ID="SiteTitle" />
+<com:TTextBox ID="SiteTitle" Columns="50"/>
<br/>
<span class="input-label">Subtitle</span>
<br/>
-<com:TTextBox ID="SiteSubtitle" />
+<com:TTextBox ID="SiteSubtitle" Columns="50"/>
<br/>
<span class="input-label">Owner name</span>
@@ -28,7 +28,7 @@ <span class="input-label">Site theme</span>
<br/>
-<com:TDropDownList ID="ThemeList" />
+<com:TDropDownList ID="ThemeName" />
<br/>
</com:TPanel>
@@ -52,5 +52,6 @@ </com:TPanel>
<com:TLinkButton Text="Save" OnClick="saveButtonClicked" />
+<com:TLabel ID="Result" Visible=<%= $this->IsPostBack && $this->IsValid %> Text="Your changes have been saved." />
</com:TContent>
\ No newline at end of file diff --git a/demos/blog/protected/Pages/Admin/ConfigMan.php b/demos/blog/protected/Pages/Admin/ConfigMan.php index dcbe1537..fc652bb3 100644 --- a/demos/blog/protected/Pages/Admin/ConfigMan.php +++ b/demos/blog/protected/Pages/Admin/ConfigMan.php @@ -2,13 +2,54 @@ class ConfigMan extends BlogPage
{
+ const CONFIG_FILE='Application.Data.Settings';
+
public function onLoad($param)
{
parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $parameters=$this->Application->Parameters;
+ $this->SiteTitle->Text=$parameters['SiteTitle'];
+ $this->SiteSubtitle->Text=$parameters['SiteSubtitle'];
+ $this->SiteOwner->Text=$parameters['SiteOwner'];
+ $this->AdminEmail->Text=$parameters['AdminEmail'];
+ $this->MultipleUser->Checked=TPropertyValue::ensureBoolean($parameters['MultipleUser']);
+ $this->AccountApproval->Checked=TPropertyValue::ensureBoolean($parameters['AccountApproval']);
+ $this->PostApproval->Checked=TPropertyValue::ensureBoolean($parameters['PostApproval']);
+ $themes=$this->Service->ThemeManager->AvailableThemes;
+ $this->ThemeName->DataSource=$themes;
+ $this->ThemeName->dataBind();
+ $this->ThemeName->SelectedValue=array_search($parameters['ThemeName'],$themes);
+ }
}
public function saveButtonClicked($sender,$param)
{
+ $dom=new TXmlDocument;
+ $dom->Encoding='utf-8';
+ $dom->TagName='parameters';
+ $elements=$dom->Elements;
+ $elements[]=$this->createParameter('SiteTitle',$this->SiteTitle->Text);
+ $elements[]=$this->createParameter('SiteSubtitle',$this->SiteSubtitle->Text);
+ $elements[]=$this->createParameter('SiteOwner',$this->SiteOwner->Text);
+ $elements[]=$this->createParameter('AdminEmail',$this->AdminEmail->Text);
+ $elements[]=$this->createParameter('MultipleUser',$this->MultipleUser->Checked);
+ $elements[]=$this->createParameter('AccountApproval',$this->AccountApproval->Checked);
+ $elements[]=$this->createParameter('PostApproval',$this->PostApproval->Checked);
+ $themeName=$this->ThemeName->SelectedItem->Text;
+ $elements[]=$this->createParameter('ThemeName',$themeName);
+ $dom->saveToFile(Prado::getPathOfNamespace(self::CONFIG_FILE,'.xml'));
+ if($themeName!==$this->Theme->Name)
+ $this->Response->reload();
+ }
+
+ private function createParameter($id,$value)
+ {
+ $element=new TXmlElement('parameter');
+ $element->Attributes['id']=$id;
+ $element->Attributes['value']=TPropertyValue::ensureString($value);
+ return $element;
}
}
|