コード例 #1
0
 /** Edit a content article
  */
 public function editAction()
 {
     if ($this->_getParam('id', false)) {
         $form = new ContentForm();
         $form->submit->setLabel('Submit changes');
         $form->author->setValue($this->getIdentityForForms());
         $this->view->form = $form;
         if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
             if ($form->isValid($form->getValues())) {
                 $updateData = $form->getValues();
                 $where = array();
                 $where[] = $this->_content->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
                 $this->_content->update($updateData, $where);
                 $this->_helper->solrUpdater->update('beocontent', $this->_getParam('id'));
                 $oldData = $this->_content->fetchRow('id=' . (int) $id)->toArray();
                 $this->_helper->audit($updateData, $oldData, 'ContentAudit', $this->_getParam('id'), $this->_getParam('id'));
                 $cache = Zend_Registry::get('rulercache');
                 $tag = 'content' . md5($updateData['slug']);
                 $tag2 = 'frontcontent' . $form->getValue('section');
                 $cache->remove($tag2);
                 $cache->remove($tag);
                 $this->_flashMessenger->addMessage('You updated: <em>' . $form->getValue('title') . '</em> successfully. It is now available for use.');
                 $this->_redirect('admin/content/');
             } else {
                 $form->populate($form->getValues());
             }
         } else {
             // find id is expected in $params['id']
             $id = (int) $this->_request->getParam('id', 0);
             if ($id > 0) {
                 $content = $this->_content->fetchRow('id=' . (int) $id)->toArray();
                 if ($content) {
                     $form->populate($content);
                 } else {
                     throw new Pas_Exception_Param($this->_nothingFound);
                 }
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter);
     }
 }
コード例 #2
0
 /** Edit a content article
  * @access public
  * @return void
  * @throws Pas_Exception_Param
  */
 public function editAction()
 {
     if ($this->getParam('id', false)) {
         $form = new ContentForm();
         $form->submit->setLabel('Submit changes');
         $form->author->setValue($this->getIdentityForForms());
         $this->view->form = $form;
         if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
             if ($form->isValid($form->getValues())) {
                 $updateData = $form->getValues();
                 $where = array();
                 $where[] = $this->_content->getAdapter()->quoteInto('id = ?', $this->getParam('id'));
                 $oldData = $this->_content->fetchRow($this->_content->select()->where('id= ?', (int) $this->getParam('id')))->toArray();
                 $this->_helper->audit($updateData, $oldData, 'ContentAudit', $this->getParam('id'), $this->getParam('id'));
                 $this->_content->update($updateData, $where);
                 $this->_helper->solrUpdater->update('content', $this->getParam('id'));
                 $this->getFlash()->addMessage('You updated successfully. It is now available for use.');
                 $this->getCache()->clean(Zend_Cache::CLEANING_MODE_ALL);
                 $this->redirect('admin/content/');
             } else {
                 $form->populate($this->_request->getPost());
             }
         } else {
             // find id is expected in $params['id']
             $id = (int) $this->_request->getParam('id', 0);
             if ($id > 0) {
                 $content = $this->_content->fetchRow('id=' . (int) $id)->toArray();
                 if ($content) {
                     $form->populate($content);
                 } else {
                     throw new Pas_Exception_Param($this->_nothingFound);
                 }
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter, 500);
     }
 }