summaryrefslogtreecommitdiff
path: root/demos/blog
diff options
context:
space:
mode:
Diffstat (limited to 'demos/blog')
-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/ViewPost.page1
-rw-r--r--demos/blog/protected/Portlets/CommentPortlet.php39
-rw-r--r--demos/blog/protected/Portlets/CommentPortlet.tpl15
9 files changed, 90 insertions, 1 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/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/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 -->