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 | |
parent | 05869f23f798c9393e2bc6d310d56a97a11d1acd (diff) |
Blog now allows dynamically changing theme.
-rw-r--r-- | .gitattributes | 3 | ||||
-rw-r--r-- | demos/blog/protected/Common/BlogPage.php | 6 | ||||
-rw-r--r-- | demos/blog/protected/Common/schema.sql | 2 | ||||
-rw-r--r-- | demos/blog/protected/Data/Options.xml | 8 | ||||
-rw-r--r-- | demos/blog/protected/Data/Settings.xml | 11 | ||||
-rw-r--r-- | demos/blog/protected/Pages/Admin/ConfigMan.page | 9 | ||||
-rw-r--r-- | demos/blog/protected/Pages/Admin/ConfigMan.php | 41 | ||||
-rw-r--r-- | demos/blog/protected/application.xml | 2 | ||||
-rw-r--r-- | demos/blog/sitemap.txt | 106 | ||||
-rw-r--r-- | framework/Xml/TXmlDocument.php | 4 |
10 files changed, 68 insertions, 124 deletions
diff --git a/.gitattributes b/.gitattributes index 939be8a0..7a91eef7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -34,7 +34,7 @@ demos/blog/protected/Common/BlogUserManager.php -text demos/blog/protected/Common/XListMenu.php -text demos/blog/protected/Common/messages.txt -text demos/blog/protected/Common/schema.sql -text -demos/blog/protected/Data/Options.xml -text +demos/blog/protected/Data/Settings.xml -text demos/blog/protected/Layouts/MainLayout.php -text demos/blog/protected/Layouts/MainLayout.tpl -text demos/blog/protected/Pages/Admin/AdminMenu.php -text @@ -83,7 +83,6 @@ demos/blog/protected/Portlets/Portlet.php -text demos/blog/protected/Portlets/SearchPortlet.php -text demos/blog/protected/Portlets/SearchPortlet.tpl -text demos/blog/protected/application.xml -text -demos/blog/sitemap.txt -text demos/blog/themes/Basic/style.css -text demos/composer/index.php -text demos/composer/index2.php -text 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 -->
diff --git a/demos/blog/sitemap.txt b/demos/blog/sitemap.txt deleted file mode 100644 index 8326855b..00000000 --- a/demos/blog/sitemap.txt +++ /dev/null @@ -1,106 +0,0 @@ -Be careful about username case sensitivity!!
-
-Home : list of blogs filtered by a category or time range, with paging
-
-ViewBlog : read a single blog with all comments and a comment input form
-NewBlog : create a new blog, with file attachment form and THtmlArea
-EditBlog : edit an existing blog
-
-LoginUser : login page
-NewUser : create a new user
-EditUser : edit the current user
-
-Admin : whether allow multiple users, whether HTML is allowed (first user is always the admin)
-
-URL design:
-
-index.php?page=ListBlog×pan=123,456&limit=123,456 : list of latest blogs, equivalent to:
-index.php?page=NewBlog
-index.php?page=EditBlog&id=123
-index.php?page=ViewBlog&id=123
-index.php?page=NewUser
-index.php?page=EditUser
-index.php?page=ViewUser
-index.php?page=Admin
-
-
-Use Case 1: Add a post
-1. Authorization check
-2. display UI for adding post
-3. input validation
-4. add post to DB
-5. display UI for post list
-
-
-DB Logic needed:
-
-class Post extends DataObject
-{
- public $xxx;
-}
-
-class Comment extends DataObject
-{
-}
-
-class UserProfile extends DataObject
-{
-
-}
-
-class DataObject extends TComponent
-{
- protected static $mapping=array();
-
- public function __construct($db)
- {
- }
-
- protected static function generateModifier($filter,$orderBy,$limit)
- {
- $modifier='';
- if($filter!=='')
- $modifier=' WHERE '.$filter;
- if($orderBy!=='')
- $modifier.=' ORDER BY '.$orderBy;
- if($limit!=='')
- $modifier.=' LIMIT '.$limit;
- return $modifier;
- }
-
- public static function queryRow($filter='')
- {
- $modifier=self::generateModifier($filter,'','');
- }
-
- public static function query($filter='',$orderBy='',$limit='')
- {
- $modifier=self::generateModifier($filter,$orderBy,$limit);
- }
-
- public function save()
- {
- }
-
- public function delete()
- {
- }
-}
-
-public function queryUsers($filter='',$sortBy='',$limit='')
-public function queryUser($id)
-public function insertUser($user)
-public function updateUser($user)
-public function deleteUser($id)
-
-public function queryPosts($filter='',$sortBy='',$limit='')
-public function queryPost($id)
-public function insertPost($post)
-public function updatePost($post)
-public function deletePost($id)
-
-public function queryComments($filter='',$sortBy='',$limit='')
-public function queryComment($id)
-public function insertComment($comment)
-public function updateComment($comment)
-public function deleteComment($id)
diff --git a/framework/Xml/TXmlDocument.php b/framework/Xml/TXmlDocument.php index 66f2f13b..62793cf4 100644 --- a/framework/Xml/TXmlDocument.php +++ b/framework/Xml/TXmlDocument.php @@ -35,11 +35,11 @@ class TXmlElement extends TComponent /** * @var string tagname of this element */ - private $_tagName; + private $_tagName='unknown'; /** * @var string text enclosed between openning and closing tags of this element */ - private $_value; + private $_value=''; /** * @var TXmlElementList list of child elements of this element */ |