summaryrefslogtreecommitdiff
path: root/demos/blog/protected
diff options
context:
space:
mode:
authorxue <>2006-05-30 21:26:29 +0000
committerxue <>2006-05-30 21:26:29 +0000
commitb87fd00a62994d24a3708cec5f5613ed2e9a67ed (patch)
tree175dae5b58cdbeaf8d66898483c15974495ca3fc /demos/blog/protected
parent75f28186a995aa930f6db9f05ec7b63bbd2cd284 (diff)
merge from 3.0 branch till 1111.
Diffstat (limited to 'demos/blog/protected')
-rw-r--r--demos/blog/protected/Common/BlogDataModule.php15
-rw-r--r--demos/blog/protected/Common/schema.sql6
-rw-r--r--demos/blog/protected/Data/Settings.xml1
-rw-r--r--demos/blog/protected/Layouts/MainLayout.tpl2
-rw-r--r--demos/blog/protected/Pages/Admin/ConfigMan.page10
-rw-r--r--demos/blog/protected/Pages/Admin/ConfigMan.php2
-rw-r--r--demos/blog/protected/Pages/Posts/ListPost.page6
-rw-r--r--demos/blog/protected/Pages/Posts/ViewPost.page1
-rw-r--r--demos/blog/protected/Pages/Posts/ViewPost.php2
-rw-r--r--demos/blog/protected/Portlets/CommentPortlet.php39
-rw-r--r--demos/blog/protected/Portlets/CommentPortlet.tpl15
11 files changed, 97 insertions, 2 deletions
diff --git a/demos/blog/protected/Common/BlogDataModule.php b/demos/blog/protected/Common/BlogDataModule.php
index a15701ab..3dc71989 100644
--- a/demos/blog/protected/Common/BlogDataModule.php
+++ b/demos/blog/protected/Common/BlogDataModule.php
@@ -341,9 +341,22 @@ class BlogDataModule extends TModule
return $commentRecord;
}
+ public function queryComments($filter,$orderBy,$limit)
+ {
+ if($filter!=='')
+ $filter='WHERE '.$filter;
+ $sql="SELECT * FROM tblComments $filter $orderBy $limit";
+ $result=$this->query($sql);
+ $rows=sqlite_fetch_all($result,SQLITE_ASSOC);
+ $comments=array();
+ foreach($rows as $row)
+ $comments[]=$this->populateCommentRecord($row);
+ return $comments;
+ }
+
public function queryCommentsByPostID($id)
{
- $sql="SELECT * FROM tblComments WHERE post_id=$id";
+ $sql="SELECT * FROM tblComments WHERE post_id=$id ORDER BY create_time DESC";
$result=$this->query($sql);
$rows=sqlite_fetch_all($result,SQLITE_ASSOC);
$comments=array();
diff --git a/demos/blog/protected/Common/schema.sql b/demos/blog/protected/Common/schema.sql
index a93512df..9c111f0c 100644
--- a/demos/blog/protected/Common/schema.sql
+++ b/demos/blog/protected/Common/schema.sql
@@ -66,5 +66,11 @@ INSERT INTO tblPosts (id,author_id,create_time,title,content,status)
INSERT INTO tblCategories (name,description,post_count)
VALUES ('Miscellaneous','This category holds posts on any topic.',1);
+INSERT INTO tblCategories (name,description,post_count)
+ VALUES ('PRADO','Topics related with the PRADO framework.',0);
+
+INSERT INTO tblCategories (name,description,post_count)
+ VALUES ('PHP','Topics related with PHP.',0);
+
INSERT INTO tblPost2Category (post_id,category_id)
VALUES (1,1);
diff --git a/demos/blog/protected/Data/Settings.xml b/demos/blog/protected/Data/Settings.xml
index b097f22f..69f55370 100644
--- a/demos/blog/protected/Data/Settings.xml
+++ b/demos/blog/protected/Data/Settings.xml
@@ -7,6 +7,7 @@
<parameter id="MultipleUser" value="false" />
<parameter id="AccountApproval" value="false" />
<parameter id="PostPerPage" value="6" />
+ <parameter id="RecentComments" value="6" />
<parameter id="PostApproval" value="false" />
<parameter id="ThemeName" value="Winter" />
</parameters> \ No newline at end of file
diff --git a/demos/blog/protected/Layouts/MainLayout.tpl b/demos/blog/protected/Layouts/MainLayout.tpl
index 87313f38..f3a77adc 100644
--- a/demos/blog/protected/Layouts/MainLayout.tpl
+++ b/demos/blog/protected/Layouts/MainLayout.tpl
@@ -34,6 +34,8 @@
<com:Application.Portlets.ArchivePortlet />
+<com:Application.Portlets.CommentPortlet />
+
</div><!-- end of sidebar -->
<div id="footer">
diff --git a/demos/blog/protected/Pages/Admin/ConfigMan.page b/demos/blog/protected/Pages/Admin/ConfigMan.page
index 69ee0899..5c6cd53d 100644
--- a/demos/blog/protected/Pages/Admin/ConfigMan.page
+++ b/demos/blog/protected/Pages/Admin/ConfigMan.page
@@ -56,6 +56,16 @@
Text="Please enter a number." />
<br/>
+<span class="input-label">Number of recent comments shown</span>
+<com:TTextBox ID="RecentComments" Columns="8"/>
+<com:TRegularExpressionValidator
+ ControlToValidate="RecentComments"
+ ValidationGroup="settings"
+ Display="Dynamic"
+ RegularExpression="[1-9]\d*"
+ Text="Please enter a number." />
+<br/>
+
<com:TCheckBox ID="PostApproval" Text="New posts need approval" />
<br/>
diff --git a/demos/blog/protected/Pages/Admin/ConfigMan.php b/demos/blog/protected/Pages/Admin/ConfigMan.php
index 6443e5a0..e4b89b3c 100644
--- a/demos/blog/protected/Pages/Admin/ConfigMan.php
+++ b/demos/blog/protected/Pages/Admin/ConfigMan.php
@@ -34,6 +34,7 @@ class ConfigMan extends BlogPage
$this->MultipleUser->Checked=TPropertyValue::ensureBoolean($parameters['MultipleUser']);
$this->AccountApproval->Checked=TPropertyValue::ensureBoolean($parameters['AccountApproval']);
$this->PostPerPage->Text=$parameters['PostPerPage'];
+ $this->RecentComments->Text=$parameters['RecentComments'];
$this->PostApproval->Checked=TPropertyValue::ensureBoolean($parameters['PostApproval']);
$themes=$this->Service->ThemeManager->AvailableThemes;
$this->ThemeName->DataSource=$themes;
@@ -55,6 +56,7 @@ class ConfigMan extends BlogPage
$elements[]=$this->createParameter('MultipleUser',$this->MultipleUser->Checked);
$elements[]=$this->createParameter('AccountApproval',$this->AccountApproval->Checked);
$elements[]=$this->createParameter('PostPerPage',$this->PostPerPage->Text);
+ $elements[]=$this->createParameter('RecentComments',$this->RecentComments->Text);
$elements[]=$this->createParameter('PostApproval',$this->PostApproval->Checked);
$themeName=$this->ThemeName->SelectedItem->Text;
$elements[]=$this->createParameter('ThemeName',$themeName);
diff --git a/demos/blog/protected/Pages/Posts/ListPost.page b/demos/blog/protected/Pages/Posts/ListPost.page
index 4c96d6fb..1371a5ab 100644
--- a/demos/blog/protected/Pages/Posts/ListPost.page
+++ b/demos/blog/protected/Pages/Posts/ListPost.page
@@ -3,6 +3,12 @@
<com:TPanel ID="CategoryPanel" Visible="false" CssClass="category">
<div class="category-name">
<%= $this->Category->Name %>
+<com:THyperLink
+ Text="[#]"
+ Tooltip="Edit this category"
+ Visible=<%= $this->User->IsAdmin %>
+ NavigateUrl=<%= $this->Service->constructUrl('Posts.EditCategory',array('id'=>$this->Category->ID)) %>
+ />
<com:TLinkButton
Text="[-]"
Tooltip="Delete this category"
diff --git a/demos/blog/protected/Pages/Posts/ViewPost.page b/demos/blog/protected/Pages/Posts/ViewPost.page
index 5bd80a52..c48b8537 100644
--- a/demos/blog/protected/Pages/Posts/ViewPost.page
+++ b/demos/blog/protected/Pages/Posts/ViewPost.page
@@ -43,6 +43,7 @@ by
<prop:ItemTemplate>
<div class="comment">
<div class="comment-header">
+<a name="c<%# $this->DataItem->ID %>"></a>
<com:TLinkButton
Text="Delete"
Attributes.onclick="if(!confirm('Are you sure to delete this comment?')) return false;"
diff --git a/demos/blog/protected/Pages/Posts/ViewPost.php b/demos/blog/protected/Pages/Posts/ViewPost.php
index 84f33cff..8d0a7124 100644
--- a/demos/blog/protected/Pages/Posts/ViewPost.php
+++ b/demos/blog/protected/Pages/Posts/ViewPost.php
@@ -75,7 +75,7 @@ class ViewPost extends BlogPage
public function deleteButtonClicked($sender,$param)
{
- $this->DataAccess->deletePost($this->PostID);
+ $this->DataAccess->deletePost($this->CurrentPost->ID);
$this->gotoDefaultPage();
}
diff --git a/demos/blog/protected/Portlets/CommentPortlet.php b/demos/blog/protected/Portlets/CommentPortlet.php
new file mode 100644
index 00000000..4147d6d3
--- /dev/null
+++ b/demos/blog/protected/Portlets/CommentPortlet.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * CommentPortlet class file
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ $Date: $
+ */
+
+Prado::using('Application.Portlets.Portlet');
+
+/**
+ * CommentPortlet class
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class CommentPortlet extends Portlet
+{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $comments=$this->Application->getModule('data')->queryComments('','ORDER BY create_time DESC','LIMIT 10');
+ foreach($comments as $comment)
+ {
+ $comment->ID=$this->Service->constructUrl('Posts.ViewPost',array('id'=>$comment->PostID)).'#c'.$comment->ID;
+ if(strlen($comment->Content)>40)
+ $comment->Content=substr($comment->Content,0,40).' ...';
+ }
+ $this->CommentList->DataSource=$comments;
+ $this->CommentList->dataBind();
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/blog/protected/Portlets/CommentPortlet.tpl b/demos/blog/protected/Portlets/CommentPortlet.tpl
new file mode 100644
index 00000000..cebdabc6
--- /dev/null
+++ b/demos/blog/protected/Portlets/CommentPortlet.tpl
@@ -0,0 +1,15 @@
+<div class="portlet">
+
+<h2 class="portlet-title">Latest comments</h2>
+
+<div class="portlet-content">
+<com:TBulletedList
+ ID="CommentList"
+ DisplayMode="HyperLink"
+ DataTextField="Content"
+ DataValueField="ID"
+ EnableViewState="false"
+ />
+</div><!-- end of portlet-content -->
+
+</div><!-- end of portlet -->