示例#1
0
 /**
  * @copydoc Plugin::manage()
  */
 function manage($args, $request)
 {
     $user = $request->getUser();
     $router = $request->getRouter();
     $context = $router->getContext($request);
     $form = $this->_instantiateSettingsForm($context);
     $notificationManager = new NotificationManager();
     switch ($request->getUserVar('verb')) {
         case 'save':
             $form->readInputData();
             if ($form->validate()) {
                 $form->execute();
                 $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS);
                 return new JSONMessage();
             } else {
                 return new JSONMessage(true, $form->fetch($request));
             }
         case 'index':
             $form->initData();
             return new JSONMessage(true, $form->fetch($request));
     }
     return parent::manage($args, $request);
 }
 /**
  * @see Plugin::manage()
  */
 function manage($verb, $args, &$message, &$messageParams, &$pluginModalContent = null)
 {
     parent::manage($verb, $args, $message, $messageParams, $pluginModalContent);
     switch ($verb) {
         case 'settings':
             $request = $this->getRequest();
             $router = $request->getRouter();
             $journal = $router->getContext($request);
             $form = $this->_instantiateSettingsForm($journal);
             if ($request->getUserVar('save')) {
                 $form->readInputData();
                 if ($form->validate()) {
                     $form->execute();
                     $request->redirect(null, 'manager', 'importexport', array('plugin', $this->getName()));
                 } else {
                     $form->display();
                 }
             } else {
                 $form->initData();
                 $form->display();
             }
             return true;
         default:
             // Unknown management verb.
             assert(false);
     }
     return false;
 }
 /**
  * @see ImportExportPlugin::manage()
  */
 function manage($verb, $args, &$message, &$messageParams, &$request)
 {
     parent::manage($verb, $args, $message, $messageParams, $request);
     switch ($verb) {
         case 'settings':
             $journal =& $request->getJournal();
             $form =& $this->_instantiateSettingsForm($journal);
             // FIXME: JM: duplicate code from _displayPluginHomePage()
             // Check for configuration errors:
             $configurationErrors = array();
             // 1) missing DOI prefix
             $doiPrefix = null;
             $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true);
             if (isset($pubIdPlugins['DOIPubIdPlugin'])) {
                 $doiPrefix = $pubIdPlugins['DOIPubIdPlugin']->getSetting($journal->getId(), 'doiPrefix');
             }
             if (empty($doiPrefix)) {
                 $configurationErrors[] = DOI_EXPORT_CONFIGERROR_DOIPREFIX;
             }
             // 2) missing plug-in setting.
             $form =& $this->_instantiateSettingsForm($journal);
             foreach ($form->getFormFields() as $fieldName => $fieldType) {
                 if ($form->isOptional($fieldName)) {
                     continue;
                 }
                 $setting = $this->getSetting($journal->getId(), $fieldName);
                 if (empty($setting)) {
                     $configurationErrors[] = DOI_EXPORT_CONFIGERROR_SETTINGS;
                     break;
                 }
             }
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->assign_by_ref('configurationErrors', $configurationErrors);
             // JM end duplicate code
             if ($request->getUserVar('save')) {
                 $form->readInputData();
                 if ($form->validate()) {
                     $form->execute();
                     $request->redirect(null, 'manager', 'importexport', array('plugin', $this->getName()));
                 } else {
                     $this->setBreadCrumbs(array(), true);
                     $form->display($request);
                 }
             } else {
                 $this->setBreadCrumbs(array(), true);
                 $form->initData();
                 $form->display($request);
             }
             return true;
         default:
             // Unknown management verb.
             assert(false);
     }
     return false;
 }