<?php
class entryComponents extends sfComponents {

  /**
   * create comment
   *
   */
  public function executeCreatecomment() {
  }

  /**
   * List comment of this entry
   *
   */
  public function executeListcomment() {
    if (!$this->entry_id) $this->entry_id = $this->getRequestParameter('entry_id');
    if (!$this->cm_id) $this->cm_id = $this->getRequestParameter('cm_id');
    ////////////////////////////////////////////////////////////////
    // Comment
    $c = new Criteria();
    $c->add(TblblogentrycommentPeer::CM_ENTRY,$this->entry_id);
    $this->page = $this->getRequestParameter('page', 1);

    if ($this->cm_id != null) {
      $this->tblblogentrycomment = TblblogentrycommentPeer::retrieveByPK($this->cm_id);
      if ($this->tblblogentrycomment) {
        $cc = clone $c;
        $dateCurrent = $this->tblblogentrycomment->getCmDate();
        $cc->add(TblblogentrycommentPeer::CM_DATE, $dateCurrent, Criteria::LESS_EQUAL);
        $this->cmLink = '&cm_id='.$this->cm_id;
        $num = TblblogentrycommentPeer::doCount($cc);
      	$this->page = (int)(($num-1)/10) + 1;
      }
    }
    $c->addAscendingOrderByColumn(TblblogentrycommentPeer::CM_DATE);

    $this->pager = new PropelPager($c, 'TblblogentrycommentPeer', 'doSelect', $this->page, 10);
  }

  public function executeShowlike() {
    $this->entry_id = $this->tblblogentry->getEntryId();
    $this->likeNum = $this->tblblogentry->getEntryLike();
    $this->liked = $this->getUser()->isAuthenticated() && $this->tblblogentry->getLikeUser(blogStore::$userId);
  }

  /**
   * Enter description here...
   *
   */
  public function executeSelectfolder() {
      $this->ajax = $this->getRequestParameter('ajax');
      if (null===$this->cat_id) $this->cat_id = $this->getRequestParameter('cat_id');
      if (preg_match('/tr([0-9]+)/', $this->cat_id, $value)) {
        $this->cat_id = $value[1];
      }
      $this->catItem = @blogStore::$catTree->getCatItem($this->cat_id);
  }

  public function executeListtabs() {
    $this->catItem = blogStore::$catTree->getCatItem($this->cat_id);
    $this->baseLink = '/'.$this->catItem->mod.'/list?cat_id='.$this->cat_id;
    $this->listType = $this->catItem->config['listtype'];
  }

  public function executeUploadhelp() {
  }

  public function executeApprove() {
  }
}
?>