From 7f508e187e4539a16cdbb1dd6a4b1133c53cf24d Mon Sep 17 00:00:00 2001
From: xue <>
Date: Mon, 29 May 2006 16:50:33 +0000
Subject: Blog now allows dynamically changing theme.
---
demos/blog/protected/Common/BlogPage.php | 6 ++++
demos/blog/protected/Common/schema.sql | 2 +-
demos/blog/protected/Data/Options.xml | 8 -----
demos/blog/protected/Data/Settings.xml | 11 +++++++
demos/blog/protected/Pages/Admin/ConfigMan.page | 9 +++---
demos/blog/protected/Pages/Admin/ConfigMan.php | 41 +++++++++++++++++++++++++
demos/blog/protected/application.xml | 2 +-
7 files changed, 65 insertions(+), 14 deletions(-)
delete mode 100644 demos/blog/protected/Data/Options.xml
create mode 100644 demos/blog/protected/Data/Settings.xml
(limited to 'demos/blog/protected')
diff --git a/demos/blog/protected/Common/BlogPage.php b/demos/blog/protected/Common/BlogPage.php
index f1634a80..f69e4c48 100644
--- a/demos/blog/protected/Common/BlogPage.php
+++ b/demos/blog/protected/Common/BlogPage.php
@@ -2,6 +2,12 @@
class BlogPage extends TPage
{
+ public function onPreInit($param)
+ {
+ parent::onPreInit($param);
+ $this->Theme=$this->Application->Parameters['ThemeName'];
+ }
+
public function getDataAccess()
{
return $this->getApplication()->getModule('data');
diff --git a/demos/blog/protected/Common/schema.sql b/demos/blog/protected/Common/schema.sql
index 49f6f429..a93512df 100644
--- a/demos/blog/protected/Common/schema.sql
+++ b/demos/blog/protected/Common/schema.sql
@@ -61,7 +61,7 @@ INSERT INTO tblUsers (id,name,full_name,role,status,passwd,email,reg_time,websit
VALUES (1,'admin','Prado User',1,0,'4d688da592969d0a56b5accec3ce8554','admin@example.com',1148819681,'http://www.pradosoft.com');
INSERT INTO tblPosts (id,author_id,create_time,title,content,status)
- VALUES (1,1,1148819691,'Welcome to Prado Weblog','Congratulations! You have successfully installed Prado Weblog. An administrator account has been created. Please login with admin/prado and update your password as soon as possible.',0);
+ VALUES (1,1,1148819691,'Welcome to Prado Weblog','Congratulations! You have successfully installed Prado Blog -- a PRADO-driven weblog system. A default administrator account has been created. Please login with admin/prado and update your password as soon as possible.',0);
INSERT INTO tblCategories (name,description,post_count)
VALUES ('Miscellaneous','This category holds posts on any topic.',1);
diff --git a/demos/blog/protected/Data/Options.xml b/demos/blog/protected/Data/Options.xml
deleted file mode 100644
index 02e51a98..00000000
--- a/demos/blog/protected/Data/Options.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demos/blog/protected/Data/Settings.xml b/demos/blog/protected/Data/Settings.xml
new file mode 100644
index 00000000..7e89789b
--- /dev/null
+++ b/demos/blog/protected/Data/Settings.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
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 @@
-
+
Title
-
+
Subtitle
-
+
Owner name
@@ -28,7 +28,7 @@
Site theme
-
+
@@ -52,5 +52,6 @@
+IsPostBack && $this->IsValid %> Text="Your changes have been saved." />
\ 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;
}
}
diff --git a/demos/blog/protected/application.xml b/demos/blog/protected/application.xml
index 9bca115c..39c66431 100644
--- a/demos/blog/protected/application.xml
+++ b/demos/blog/protected/application.xml
@@ -19,7 +19,7 @@
-->
-
+
--
cgit v1.2.3