summaryrefslogtreecommitdiff
path: root/demos/blog/protected
diff options
context:
space:
mode:
authorxue <>2006-05-29 16:50:33 +0000
committerxue <>2006-05-29 16:50:33 +0000
commit7f508e187e4539a16cdbb1dd6a4b1133c53cf24d (patch)
treef3c47d2b436113407abaa99b2b70426c7a37a083 /demos/blog/protected
parent05869f23f798c9393e2bc6d310d56a97a11d1acd (diff)
Blog now allows dynamically changing theme.
Diffstat (limited to 'demos/blog/protected')
-rw-r--r--demos/blog/protected/Common/BlogPage.php6
-rw-r--r--demos/blog/protected/Common/schema.sql2
-rw-r--r--demos/blog/protected/Data/Options.xml8
-rw-r--r--demos/blog/protected/Data/Settings.xml11
-rw-r--r--demos/blog/protected/Pages/Admin/ConfigMan.page9
-rw-r--r--demos/blog/protected/Pages/Admin/ConfigMan.php41
-rw-r--r--demos/blog/protected/application.xml2
7 files changed, 65 insertions, 14 deletions
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 <b>admin/prado</b> 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 <b>admin/prado</b> 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 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<parameters>
- <parameter id="SiteTitle" value="Qiang's Blog" />
- <parameter id="SiteSubtitle" value="A PRADO-driven weblog" />
- <parameter id="SiteOwner" value="Qiang Xue" />
- <parameter id="AdminEmail" value="admin@example.com" />
-</parameters> \ 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<parameters>
+ <parameter id="SiteTitle" value="A wonderful day with LG and ChongChong ^_^" />
+ <parameter id="SiteSubtitle" value="The first time at dog beach :-p" />
+ <parameter id="SiteOwner" value="LP" />
+ <parameter id="AdminEmail" value="LP@LG.com" />
+ <parameter id="MultipleUser" value="false" />
+ <parameter id="AccountApproval" value="false" />
+ <parameter id="PostApproval" value="false" />
+ <parameter id="ThemeName" value="Basic" />
+</parameters> \ 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 @@
<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;
}
}
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 @@
<route class="TFileLogRoute" Categories="System" Levels="Notice,Warning,Error,Alert,Fatal" />
</module>
-->
- <module class="System.Util.TParameterModule" ParameterFile="Application.Data.Options" />
+ <module class="System.Util.TParameterModule" ParameterFile="Application.Data.Settings" />
</modules>
<services>
<!-- page service -->