Example #1
0
 /**
  * Load the configuration form for a specific theme.  
  * That configuration form will be POSTed back to this URL.
  *
  * @return void
  */
 public function configAction()
 {
     // get the theme name and theme object
     $themeName = $this->_getParam('name');
     $theme = Theme::getTheme($themeName);
     $themeOptions = Theme::getOptions($themeName);
     // get the configuration form
     $form = new Omeka_Form_ThemeConfiguration(array('themeName' => $themeName));
     $form->removeDecorator('Form');
     // process the form if posted
     if ($this->getRequest()->isPost()) {
         $configHelper = new Omeka_Controller_Action_Helper_ThemeConfiguration();
         if ($newOptions = $configHelper->processForm($form, $_POST, $themeOptions)) {
             Theme::setOptions($themeName, $newOptions);
             $this->_helper->flashMessenger(__('The theme settings were successfully saved!'), 'success');
             $this->_helper->redirector('browse');
         } else {
             $this->_helper->_flashMessenger(__('There was an error on the form. Please try again.'), 'error');
         }
     }
     $this->view->configForm = $form;
     $this->view->theme = $theme;
 }
 /**
  * Theme configuration page for an exhibit.
  */
 public function themeConfigAction()
 {
     $exhibit = $this->_helper->db->findById();
     $themeName = (string) $exhibit->theme;
     // Abort if no specific theme is selected.
     if ($themeName == '') {
         $this->_helper->flashMessenger(__('You must specifically select a theme in order to configure it.'), 'error');
         $this->_helper->redirector->gotoRoute(array('action' => 'edit', 'id' => $exhibit->id), 'exhibitStandard');
         return;
     }
     $theme = Theme::getTheme($themeName);
     $previousOptions = $exhibit->getThemeOptions();
     $form = new Omeka_Form_ThemeConfiguration(array('themeName' => $themeName, 'themeOptions' => $previousOptions));
     $form->removeDecorator('Form');
     $themeConfigIni = $theme->path . DIRECTORY_SEPARATOR . 'config.ini';
     if (file_exists($themeConfigIni) && is_readable($themeConfigIni)) {
         try {
             $pluginsIni = new Zend_Config_Ini($themeConfigIni, 'plugins');
             $excludeFields = $pluginsIni->exclude_fields;
             $excludeFields = explode(',', $excludeFields);
         } catch (Exception $e) {
             $excludeFields = array();
         }
         foreach ($excludeFields as $excludeField) {
             trim($excludeField);
             $form->removeElement($excludeField);
         }
     }
     // process the form if posted
     if ($this->getRequest()->isPost()) {
         $configHelper = new Omeka_Controller_Action_Helper_ThemeConfiguration();
         if ($newOptions = $configHelper->processForm($form, $_POST, $previousOptions)) {
             $exhibit->setThemeOptions($newOptions);
             $exhibit->save();
             $this->_helper->_flashMessenger(__('The theme settings were successfully saved!'), 'success');
             $this->_helper->redirector->gotoRoute(array('action' => 'edit', 'id' => $exhibit->id), 'exhibitStandard');
         } else {
             $this->_helper->_flashMessenger(__('There was an error on the form. Please try again.'), 'error');
         }
     }
     $this->view->assign(compact('exhibit', 'form', 'theme'));
 }