public function createNewExhibitPage($exhibit, $parentPage = null, $title, $slug = '', $order = 1, $layout = 'text')
 {
     $exhibitPage = new ExhibitPage();
     $exhibitPage->exhibit_id = $exhibit->id;
     if ($parentPage) {
         $exhibitPage->parent_id = $parentPage->id;
     }
     $exhibitPage->title = $title;
     $exhibitPage->layout = $layout;
     $exhibitPage->order = $order;
     if ($slug != '') {
         $exhibitPage->slug = $slug;
     }
     $exhibitPage->save();
     return $exhibitPage;
 }
 /**
  * Handle the POST for the page add and edit actions.
  *
  * @param ExhibitPage $exhibitPage
  * @param string $actionName
  * @param Exhibit $exhibit
  */
 protected function processPageForm($exhibitPage, $actionName, $exhibit = null)
 {
     $this->view->assign(compact('exhibit', 'actionName'));
     $this->view->exhibit_page = $exhibitPage;
     if ($this->getRequest()->isPost()) {
         $exhibitPage->setPostData($_POST);
         try {
             $success = $exhibitPage->save();
             return true;
         } catch (Exception $e) {
             $this->_helper->flashMessenger($e->getMessage(), 'error');
             return false;
         }
     }
 }
 /**
  * Create an exhibit page.
  *
  * @param Exhibit $exhibit The parent exhibit.
  * @param string $title The page title.
  * @param string $slug The page slug.
  * @param string $layout The layout template.
  * @param integer $order The page order.
  * @return ExhibitPage
  */
 protected function _exhibitPage($exhibit = null, $title = 'Test Title', $slug = 'test-slug', $layout = 'text', $order = 1)
 {
     // Create a parent exhibit if none is passed.
     if (is_null($exhibit)) {
         $exhibit = $this->_exhibit();
     }
     $page = new ExhibitPage();
     $page->exhibit_id = $exhibit->id;
     $page->slug = $slug;
     $page->layout = $layout;
     $page->title = $title;
     $page->order = $order;
     $page->save();
     return $page;
 }
 /**
  * Handle the POST for the page add and edit actions.
  *
  * @param ExhibitPage $exhibitPage
  * @param string $actionName
  * @param Exhibit $exhibit
  */
 protected function processPageForm($exhibitPage, $actionName, $exhibit = null)
 {
     if (class_exists('Omeka_Form_SessionCsrf')) {
         $csrf = new Omeka_Form_SessionCsrf();
     } else {
         $csrf = '';
     }
     $this->view->assign(compact('exhibit', 'actionName'));
     $this->view->exhibit_page = $exhibitPage;
     $this->view->csrf = $csrf;
     if ($this->getRequest()->isPost()) {
         if (!($csrf === '' || $csrf->isValid($_POST))) {
             $this->_helper->_flashMessenger(__('There was an error on the form. Please try again.'), 'error');
             return;
         }
         $exhibitPage->setPostData($_POST);
         try {
             $success = $exhibitPage->save();
             return true;
         } catch (Exception $e) {
             $this->_helper->flashMessenger($e->getMessage(), 'error');
             return false;
         }
     }
 }
 /**
  * Tests to make sure the exhibits controller will return a 404 error for a bad exhibit page slug
  *
  **/
 public function testNoError404WithGoodExhibitPageSlug()
 {
     $exhibits = get_records('Exhibit');
     $this->assertEquals(1, count($exhibits));
     $exhibit = $exhibits[0];
     $exhibit->slug = 'goodexhibitslug';
     $exhibit->save();
     $this->assertEquals('goodexhibitslug', $exhibit->slug, 'Bad exhibit slug.');
     $exhibitPage = new ExhibitPage();
     $exhibitPage->title = 'Test Page';
     $exhibitPage->order = 1;
     $exhibitPage->layout = 'image-list-left-thumbs';
     $exhibitPage->slug = 'goodexhibitpageslug';
     $exhibitPage->exhibit_id = $exhibit->id;
     $exhibitPage->save();
     $this->assertTrue($exhibitPage->exists());
     try {
         $this->dispatch('exhibits/show/goodexhibitslug/goodexhibitpageslug');
     } catch (Exception $e) {
         $this->fail('Should not have thrown a 404 error for a good exhibit page slug.');
     }
 }