コード例 #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
ファイル: index.php プロジェクト: taviroquai/bootwiki
    $app->response()->body((string) $layout);
});
/*
 * Save content edition
 */
$app->post('/edit/:alias', function ($alias) use($app) {
    // redirect if not logged
    if (BootWiki::getLoggedAccount() == null) {
        $app->redirect(BASEURL);
    }
    // load content to edit
    $content = new Content();
    $content->load($alias, TRUE);
    $content->savePost($_POST['content'], $_FILES['upload_image']);
    // Load form
    $form = new ContentForm();
    $form->edit($content);
    // Load layout
    $layout = new Layout($form);
    $layout->loadRecent();
    $layout->loadPopular();
    $layout->loadUnpublished();
    // Print layout
    $app->response()->body((string) $layout);
});
/*
 * Display login form
 */
$app->get('/mod/auth', function () use($app) {
    // Load authentication form
    $main = new Block('auth_form');
コード例 #3
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);
     }
 }
コード例 #4
0
ファイル: NewsForm.php プロジェクト: alexyandy/monc-php
 public function save()
 {
     $this->cateid = Cate::getNewsCate();
     return parent::save();
 }