diff options
Diffstat (limited to 'demos/blog')
| -rw-r--r-- | demos/blog/index.php | 5 | ||||
| -rw-r--r-- | demos/blog/protected/Common/BlogDataModule.php | 15 | ||||
| -rw-r--r-- | demos/blog/protected/Common/schema.sql | 6 | ||||
| -rw-r--r-- | demos/blog/protected/Data/Settings.xml | 1 | ||||
| -rw-r--r-- | demos/blog/protected/Layouts/MainLayout.tpl | 2 | ||||
| -rw-r--r-- | demos/blog/protected/Pages/Admin/ConfigMan.page | 10 | ||||
| -rw-r--r-- | demos/blog/protected/Pages/Admin/ConfigMan.php | 2 | ||||
| -rw-r--r-- | demos/blog/protected/Pages/Posts/ListPost.page | 6 | ||||
| -rw-r--r-- | demos/blog/protected/Pages/Posts/ViewPost.page | 1 | ||||
| -rw-r--r-- | demos/blog/protected/Pages/Posts/ViewPost.php | 2 | ||||
| -rw-r--r-- | demos/blog/protected/Portlets/CommentPortlet.php | 39 | ||||
| -rw-r--r-- | demos/blog/protected/Portlets/CommentPortlet.tpl | 15 | ||||
| -rw-r--r-- | demos/blog/themes/Fall/style.css | 2 | ||||
| -rw-r--r-- | demos/blog/themes/Spring/style.css | 2 | ||||
| -rw-r--r-- | demos/blog/themes/Summer/style.css | 2 | ||||
| -rw-r--r-- | demos/blog/themes/Winter/style.css | 2 | 
16 files changed, 106 insertions, 6 deletions
diff --git a/demos/blog/index.php b/demos/blog/index.php index 43c0b436..88f798db 100644 --- a/demos/blog/index.php +++ b/demos/blog/index.php @@ -4,11 +4,16 @@ $basePath=dirname(__FILE__);  $frameworkPath=$basePath.'/../../framework/prado.php';
  $assetsPath=$basePath.'/assets';
  $runtimePath=$basePath.'/protected/runtime';
 +$dataPath=$basePath.'/protected/Data';
  if(!is_writable($assetsPath))
  	die("Please make sure that the directory $assetsPath is writable by Web server process.");
  if(!is_writable($runtimePath))
  	die("Please make sure that the directory $runtimePath is writable by Web server process.");
 +if(!is_writable($dataPath))
 +	die("Please make sure that the directory $dataPath is writable by Web server process.");
 +if(!extension_loaded("sqlite"))
 +	die("SQLite PHP extension is required.");
  require_once($frameworkPath);
 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 © 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 © 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 -->
 diff --git a/demos/blog/themes/Fall/style.css b/demos/blog/themes/Fall/style.css index 27975b05..9b18b151 100644 --- a/demos/blog/themes/Fall/style.css +++ b/demos/blog/themes/Fall/style.css @@ -132,7 +132,7 @@ a img {  .portlet-content {
  	margin: 0 0 10px 0;
 -	padding: 10px 10px 0 10px;
 +	padding: 10px 0 0 10px;
  	font-size: 10px;
  }
 diff --git a/demos/blog/themes/Spring/style.css b/demos/blog/themes/Spring/style.css index 7066669c..6a675c0f 100644 --- a/demos/blog/themes/Spring/style.css +++ b/demos/blog/themes/Spring/style.css @@ -132,7 +132,7 @@ a img {  .portlet-content {
  	margin: 0 0 10px 0;
 -	padding: 10px 10px 0 10px;
 +	padding: 10px 0 0 10px;
  	font-size: 10px;
  }
 diff --git a/demos/blog/themes/Summer/style.css b/demos/blog/themes/Summer/style.css index 068860d1..d7218f7d 100644 --- a/demos/blog/themes/Summer/style.css +++ b/demos/blog/themes/Summer/style.css @@ -132,7 +132,7 @@ a img {  .portlet-content {
  	margin: 0 0 10px 0;
 -	padding: 10px 10px 0 10px;
 +	padding: 10px 0 0 10px;
  	font-size: 10px;
  }
 diff --git a/demos/blog/themes/Winter/style.css b/demos/blog/themes/Winter/style.css index 4eadd18e..bfa488fa 100644 --- a/demos/blog/themes/Winter/style.css +++ b/demos/blog/themes/Winter/style.css @@ -133,7 +133,7 @@ a img {  .portlet-content {
  	margin: 0 0 10px 0;
  	border-top: 1px solid #cfd4d9;
 -	padding: 10px 10px 0 10px;
 +	padding: 10px 0 0 10px;
  	font-size: 10px;
  }
  | 
