示例#1
0
 public function editAction()
 {
     if ($this->tplVars['lvals']['canEdit'] && $this->_hasParam('id')) {
         array_push($this->tplVars['page_js'], 'jquery-1.8.3.js');
         array_push($this->tplVars['page_js'], 'select2.min.js');
         array_push($this->tplVars['page_css'], 'comments.css');
         array_push($this->tplVars['page_css'], 'select2.css');
         array_push($this->tplVars['header']['actions']['names'], array('name' => 'edit', 'menu_name' => 'Edit Comment'));
         array_push($this->tplVars['header']['actions']['names'], array('name' => 'add', 'menu_name' => 'Add Comment'));
         $this->tplVars['lvals']['isNewRecord'] = false;
         array_push($this->viewIncludes, 'comments/commentsEdit.tpl');
         $id = $this->_getParam('id');
         $this->tplVars['lvals']['postRes'] = 2;
         $comments = new CommentsModel();
         $this->tplVars['products'] = $comments->getProducts(true);
         $this->tplVars['pages'] = $comments->getPages(true, $this->getSiteId());
         if ($this->_request->getPost('ispost')) {
             $this->to_log();
             $this->tplVars['comment'] = $this->_request->getPost();
             $this->tplVars['pages']['select'] = $this->_request->getPost('comment_pages');
             $this->tplVars['products']['select'] = $this->_request->getPost('comment_product_id');
             $this->tplVars['lvals']['postRes'] = $comments->setCommentById($id, $this->tplVars['comment']);
             if ((bool) $this->_request->getPost('toitem')) {
                 $this->_redirect('/comments/list/#comment' . $id . '');
             }
         } else {
             $this->tplVars['comment'] = $comments->getCommentById($id);
             $this->tplVars['products']['select'] = array($this->tplVars['comment']['comment_product_id']);
             $this->tplVars['pages']['select'] = explode(',', $this->tplVars['comment']['comment_pages']);
         }
     }
 }