| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* NewPost class file
|
|
|
4 |
*
|
|
|
5 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
6 |
* @link http://www.pradosoft.com/
|
|
|
7 |
* @copyright Copyright © 2006 PradoSoft
|
|
|
8 |
* @license http://www.pradosoft.com/license/
|
|
|
9 |
* @version $Id: NewPost.php 1398 2006-09-08 19:31:03Z xue $
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
/**
|
|
|
13 |
* NewPost class
|
|
|
14 |
*
|
|
|
15 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
16 |
* @link http://www.pradosoft.com/
|
|
|
17 |
* @copyright Copyright © 2006 PradoSoft
|
|
|
18 |
* @license http://www.pradosoft.com/license/
|
|
|
19 |
*/
|
|
|
20 |
class NewPost extends BlogPage
|
|
|
21 |
{
|
|
|
22 |
public function onLoad($param)
|
|
|
23 |
{
|
|
|
24 |
parent::onLoad($param);
|
|
|
25 |
if(!$this->IsPostBack)
|
|
|
26 |
{
|
|
|
27 |
$this->Categories->DataSource=$this->DataAccess->queryCategories();
|
|
|
28 |
$this->Categories->dataBind();
|
|
|
29 |
}
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
public function saveButtonClicked($sender,$param)
|
|
|
33 |
{
|
|
|
34 |
if($this->IsValid)
|
|
|
35 |
{
|
|
|
36 |
$postRecord=new PostRecord;
|
|
|
37 |
$postRecord->Title=$this->Title->SafeText;
|
|
|
38 |
$postRecord->Content=$this->Content->SafeText;
|
|
|
39 |
if($this->DraftMode->Checked)
|
|
|
40 |
$postRecord->Status=PostRecord::STATUS_DRAFT;
|
|
|
41 |
else if(!$this->User->IsAdmin && TPropertyValue::ensureBoolean($this->Application->Parameters['PostApproval']))
|
|
|
42 |
$postRecord->Status=PostRecord::STATUS_PENDING;
|
|
|
43 |
else
|
|
|
44 |
$postRecord->Status=PostRecord::STATUS_PUBLISHED;
|
|
|
45 |
$postRecord->CreateTime=time();
|
|
|
46 |
$postRecord->ModifyTime=$postRecord->CreateTime;
|
|
|
47 |
$postRecord->AuthorID=$this->User->ID;
|
|
|
48 |
$cats=array();
|
|
|
49 |
foreach($this->Categories->SelectedValues as $value)
|
|
|
50 |
$cats[]=TPropertyValue::ensureInteger($value);
|
|
|
51 |
$this->DataAccess->insertPost($postRecord,$cats);
|
|
|
52 |
$this->gotoPage('Posts.ViewPost',array('id'=>$postRecord->ID));
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
?>
|