summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/comments
diff options
context:
space:
mode:
authorxue <>2006-07-02 18:05:42 +0000
committerxue <>2006-07-02 18:05:42 +0000
commit7e002c23edc5fb5db70935591aa6adeda25fc7fb (patch)
tree846feb337405448cc1559c2e7b4ed6f85798e0c7 /demos/quickstart/protected/comments
parent618293517861b69334cd470068199394120cd20a (diff)
Merge from 3.0 branch till 1224.
Diffstat (limited to 'demos/quickstart/protected/comments')
-rw-r--r--demos/quickstart/protected/comments/CommentList.php58
-rw-r--r--demos/quickstart/protected/comments/CommentList.tpl105
-rw-r--r--demos/quickstart/protected/comments/QuickStartComments.php175
-rw-r--r--demos/quickstart/protected/comments/comments.dbbin6144 -> 0 bytes
4 files changed, 0 insertions, 338 deletions
diff --git a/demos/quickstart/protected/comments/CommentList.php b/demos/quickstart/protected/comments/CommentList.php
deleted file mode 100644
index 3bfb7239..00000000
--- a/demos/quickstart/protected/comments/CommentList.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-Prado::using('System.I18N.*');
-
-/**
- * CommentList class.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version : $ Sat May 27 17:53:15 AZOST 2006 $
- * @package Demo.Quickstart.comments
- * @since 3.0
- */
-class CommentList extends TTemplateControl
-{
- private $_exclude = array(
- 'Comments',
- 'Markdown',
- 'Search',
- 'GettingStarted.Introduction');
-
- private $_quickstart;
-
- public function onLoad($param)
- {
- parent::onLoad($param);
-
- $this->_quickstart = new QuickStartComments();
-
- $page = $this->getService()->getRequestedPagePath();
-
- $this->listComments($page);
- }
-
- protected function listComments($page)
- {
- $this->comments->setDataSource($this->_quickstart->getComments($page));
- $this->comments->dataBind();
- }
-
- public function addComment_Clicked($sender, $param)
- {
- $page = $this->getService()->getRequestedPagePath();
- $this->_quickstart->addNewComment($page,
- $this->email->getText(), $this->content->getText());
- $this->multiView1->setActiveViewIndex(1);
- }
-
- public function setVisible($value)
- {
- $page = $this->getService()->getRequestedPagePath();
- if(in_array($page, $this->_exclude))
- parent::setVisible(false);
- else
- parent::setVisible($value);
- }
-}
-
-?> \ No newline at end of file
diff --git a/demos/quickstart/protected/comments/CommentList.tpl b/demos/quickstart/protected/comments/CommentList.tpl
deleted file mode 100644
index 06cddd1e..00000000
--- a/demos/quickstart/protected/comments/CommentList.tpl
+++ /dev/null
@@ -1,105 +0,0 @@
-<div id="comments">
-
-<com:TRepeater ID="comments">
- <prop:HeaderTemplate>
- <h2 class="comment_header">Comments
- <com:TPlaceHolder Visible=<%$ enableNewComment %> >
- <span style="font-size:0.8em">( <a href="#add_comments">Add your comments</a> )</span>
- </com:TPlaceHolder>
- </h2>
- </prop:HeaderTemplate>
- <prop:ItemTemplate>
- <div class="comment_item comment_item<%# $this->ItemIndex%2 %>">
- <span class="number" id="comment_<%# $this->ItemIndex+1 %>"><%# $this->ItemIndex+1 %></span>
- <span class="email">
- <%# str_replace(array('@','.'),array(' at ',' dot '), strtoupper($this->DataItem['email'])) %>
- </span>
- <span class="date">
- <com:TDateFormat Value=<%# intval($this->DataItem['date_added']) %> />
- </span>
- <div class="comment">
- <com:TSafeHtml>
- <com:TMarkdown CssClass="source">
- <%# $this->DataItem['comment'] %>
- </com:TMarkdown>
- </com:TSafeHtml>
- </div>
- </div>
- </prop:ItemTemplate>
-</com:TRepeater>
-
-<com:TMultiView ID="multiView1" ActiveViewIndex="0" Visible=<%$ enableNewComment %> >
- <com:TView ID="view1">
- <div id="add_comments" class="add_comments">
- <h3>Post a comment</h3>
- <p><strong>Note:</strong>
- Please only use the comments in relation to this page for
- <ul>
- <li>questions/critcisms/suggestions on the documentation,</li>
- <li>small notes that can solve or clarify a particular problem or task.</li>
- </ul>
- If you experience errors please <a href="http://trac.pradosoft.com/newticket">file a ticket</a>
- or <a href="http://www.pradosoft.com/forum/">ask at the forum</a>.
- Please use the <a href="http://pradosoft.com/wiki/index.php/Main_Page">Prado wiki</a> for longer pieces and detailed solutions</a>.
- </p>
- <p>Comments will be periodically reviewed, integrated into the documentation and removed.
- You may use <a href="?page=Markdown">markdown syntax</a> in your comment. </p>
-
- <div class="comment_email">
- <com:TLabel ID="email_label" Text="Email:" ForControl="email"/>
- <com:TTextBox ID="email" />
- <com:TRequiredFieldValidator
- ControlToValidate="email"
- Display="Dynamic"
- ErrorMessage="An email address is required." />
- <com:TEmailAddressValidator
- ControlToValidate="email"
- CheckMXRecord="false"
- Display="Dynamic"
- ErrorMessage="Please provide your email address."/>
- </div>
- <div class="comment_content">
- <com:TLabel ID="content_label" Text="Comment:" ForControl="content"/>
- <com:TTextBox ID="content" TextMode="MultiLine"/>
- <div class="please_add">
- <com:TRequiredFieldValidator
- ControlToValidate="content"
- Display="Dynamic"
- ErrorMessage="Please add your comment." />
- </div>
- </div>
- <com:TPlaceHolder Visible=<%= strlen($this->content->Text) %> >
- <div class="comment_preview">
- <h3 style="margin:0">Preview comment</h3>
- <div class="comment">
- <com:TSafeHtml>
- <com:TMarkdown CssClass="source">
- <%= $this->content->Text %>
- </com:TMarkdown>
- </com:TSafeHtml>
- </div>
- </div>
- </com:TPlaceHolder>
- <div class="add_comment">
- <com:TButton ID="previewComment" Text="Preview Comment" />
- <com:TButton ID="addComment" Text="Add Comment" OnClick="addComment_Clicked"/>
- </div>
- </div>
- </com:TView>
- <com:TView ID="view2">
- <div class="comment_added">
- <div class="thank">Thank you, your comment is quequed for moderation.</div>
- <div class="comment_preview">
- <h3 style="margin:0">Preview comment</h3>
- <div class="comment">
- <com:TSafeHtml>
- <com:TMarkdown CssClass="source">
- <%= $this->content->Text %>
- </com:TMarkdown>
- </com:TSafeHtml>
- </div>
- </div>
- </div>
- </com:TView>
-</com:TMultiView>
-</div> \ No newline at end of file
diff --git a/demos/quickstart/protected/comments/QuickStartComments.php b/demos/quickstart/protected/comments/QuickStartComments.php
deleted file mode 100644
index 7b504caf..00000000
--- a/demos/quickstart/protected/comments/QuickStartComments.php
+++ /dev/null
@@ -1,175 +0,0 @@
-<?php
-
-/**
- * QuickStartComments class.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version : $ Sat May 27 16:49:19 AZOST 2006 $
- * @package Demos.QuickStart.comments
- * @since 3.0
- */
-class QuickStartComments
-{
- /**
- * @var string sqlite database source.
- */
- private $_database;
- /**
- * @var sqlite connection.
- */
- private $_connection;
-
- /**
- * Sets the sqlite comment database file.
- */
- public function __construct()
- {
- $this->_database = realpath(dirname(__FILE__).'/comments.db');
- }
-
- /**
- * Closed the database connection.
- */
- public function __destruct()
- {
- if(!is_null($this->_connection))
- sqlite_close($this->_connection);
- }
-
- /**
- * @return resource sqlite database connection.
- */
- protected function getConnection()
- {
- if(is_null($this->_connection))
- $this->_connection = sqlite_open($this->_database);
- return $this->_connection;
- }
-
- /**
- * Quote database input data.
- */
- protected function quote($value)
- {
- return sqlite_escape_string($value);
- }
-
- /**
- * Executes an sqlite query.
- * @param string SQL
- * @return mixed query results.
- */
- protected function query($sql)
- {
- return sqlite_query($this->getConnection(), $sql);
- }
-
- /**
- * Returns a row from the sqlite result.
- * @param resource sqlite result
- * @return array database record.
- */
- protected function fetch($resource)
- {
- if($resource !== false)
- return sqlite_fetch_array($resource);
- else
- return false;
- }
-
- /**
- * Fetch all the records for given SQL query.
- * @param string SQL query.
- * @return array result set.
- */
- protected function fetchAll($sql)
- {
- $rs = $this->query($sql);
- $rows = array();
- while($row = $this->fetch($rs))
- $rows[] = $row;
- return $rows;
- }
-
- /**
- * Returns all the comments for a given page.
- * @param string specific page comments
- * @return array list of comments
- */
- public function getComments($pageID)
- {
- $page = $this->quote($pageID);
- $sql = "SELECT * FROM comments WHERE page='$page' AND approved = 1 ORDER BY date_added ASC";
- return $this->fetchAll($sql);
- }
-
- /**
- * Adds a new comment for moderation.
- * @param string ID of the page to comment belongs
- * @param string email address of the commenter
- * @param string comment contents
- */
- public function addNewComment($pageID, $email, $comment)
- {
- $page = $this->quote($pageID);
- $email = $this->quote($email);
- $comment = $this->quote($comment);
- $date_added = time();
- $sql = <<<EOD
- INSERT INTO comments(page, email, comment, date_added)
- VALUES ('$page', '$email', '$comment', '$date_added')
-EOD;
- return $this->query($sql);
- }
-
- /**
- * Update an existing comment.
- * @param string comment ID
- * @param string page ID
- * @param string email address
- * @param string updated comment.
- */
- public function updateComment($commentID, $page, $email, $content)
- {
- $ID = intval($commentID);
- $email = $this->quote($email);
- $comment = $this->quote($content);
- $page = $this->quote($page);
- $sql = <<<EOD
- UPDATE comments SET
- email = '$email', comment = '$comment', page = '$page'
- WHERE id = $ID;
-EOD;
- $this->query($sql);
- }
-
- /**
- * Delete a comment.
- * @param string comment ID
- */
- public function deleteComment($commentID)
- {
- $ID = intval($commentID);
- $this->query("DELETE FROM comments WHERE id=$ID");
- }
-
- /**
- * @return array all the quequed comments.
- */
- public function getQuequedComments()
- {
- return $this->fetchAll("SELECT * FROM comments WHERE approved != 1");
- }
-
- /**
- * Approve a quequed comment.
- * @param string comment ID.
- */
- public function approveComment($commentID)
- {
- $ID = intval($commentID);
- $this->query("UPDATE comments SET approved = 1 WHERE id=$ID");
- }
-}
-
-?> \ No newline at end of file
diff --git a/demos/quickstart/protected/comments/comments.db b/demos/quickstart/protected/comments/comments.db
deleted file mode 100644
index b81d7123..00000000
--- a/demos/quickstart/protected/comments/comments.db
+++ /dev/null
Binary files differ