summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/comments/CommentList.php
blob: 3bfb723926655c1bbd003496c8d1783ca0eef040 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?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);
	}
}

?>