[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/demos/blog/protected/Pages/Posts/ -> NewPost.php (source)

   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 &copy; 2006 PradoSoft
   8   * @license http://www.pradosoft.com/license/
   9   * @version $Id: NewPost.php 1397 2006-09-07 07:55:53Z wei $
  10   */
  11  
  12  /**
  13   * NewPost class
  14   *
  15   * @author Qiang Xue <qiang.xue@gmail.com>
  16   * @link http://www.pradosoft.com/
  17   * @copyright Copyright &copy; 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  ?>


Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7