Esempio n. 1
0
 /**
  * Perform management functions
  */
 function manage($verb, $args, &$message, &$messageparams)
 {
     if (!parent::manage($verb, $args, $message, $messageParams)) {
         return false;
     }
     $request =& $this->getRequest();
     $conference =& $request->getConference();
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
     $templateMgr->assign('pagesPath', $request->url(null, null, 'pages', 'view', 'REPLACEME'));
     $pageCrumbs = array(array($request->url(null, null, 'user'), 'navigation.user'), array($request->url(null, null, 'manager'), 'user.role.manager'));
     switch ($verb) {
         case 'settings':
             $this->import('StaticPagesSettingsForm');
             $form = new StaticPagesSettingsForm($this, $conference->getId());
             $templateMgr->assign('pageHierarchy', $pageCrumbs);
             $form->initData($request);
             $form->display();
             return true;
         case 'edit':
         case 'add':
             $this->import('StaticPagesEditForm');
             $staticPageId = isset($args[0]) ? (int) $args[0] : null;
             $form = new StaticPagesEditForm($this, $conference->getId(), $staticPageId);
             if ($form->isLocaleResubmit()) {
                 $form->readInputData();
                 $form->addTinyMCE($request);
             } else {
                 $form->initData();
             }
             $pageCrumbs[] = array($request->url(null, null, 'manager', 'plugin', array('generic', $this->getName(), 'settings')), $this->getDisplayName(), true);
             $templateMgr->assign('pageHierarchy', $pageCrumbs);
             $form->display();
             return true;
         case 'save':
             $this->import('StaticPagesEditForm');
             $staticPageId = isset($args[0]) ? (int) $args[0] : null;
             $form = new StaticPagesEditForm($this, $conference->getId(), $staticPageId);
             if ($request->getUserVar('edit')) {
                 $form->readInputData();
                 if ($form->validate()) {
                     $form->save();
                     $templateMgr->assign(array('currentUrl' => $request->url(null, null, null, null, array($this->getCategory(), $this->getName(), 'settings')), 'pageTitle' => 'plugins.generic.staticPages.displayName', 'pageHierarchy' => $pageCrumbs, 'message' => 'plugins.generic.staticPages.pageSaved', 'backLink' => $request->url(null, null, null, null, array($this->getCategory(), $this->getName(), 'settings')), 'backLinkLabel' => 'common.continue'));
                     $templateMgr->display('common/message.tpl');
                     exit;
                 } else {
                     $form->addTinyMCE($request);
                     $form->display();
                     exit;
                 }
             }
             $request->redirect(null, null, null, 'manager', 'plugins');
             return false;
         case 'delete':
             $staticPageId = isset($args[0]) ? (int) $args[0] : null;
             $staticPagesDao = DAORegistry::getDAO('StaticPagesDAO');
             $staticPagesDao->deleteStaticPageById($staticPageId);
             $templateMgr->assign(array('currentUrl' => $request->url(null, null, null, null, array($this->getCategory(), $this->getName(), 'settings')), 'pageTitle' => 'plugins.generic.staticPages.displayName', 'message' => 'plugins.generic.staticPages.pageDeleted', 'backLink' => $request->url(null, null, null, null, array($this->getCategory(), $this->getName(), 'settings')), 'backLinkLabel' => 'common.continue'));
             $templateMgr->assign('pageHierarchy', $pageCrumbs);
             $templateMgr->display('common/message.tpl');
             return true;
         default:
             // Unknown management verb
             assert(false);
             return false;
     }
 }
Esempio n. 2
0
 /**
  * Perform management functions
  */
 function manage($verb, $args)
 {
     $returner = true;
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
     $templateMgr->assign('pagesPath', Request::url(null, 'pages', 'view', 'REPLACEME'));
     $pageCrumbs = array(array(Request::url(null, 'user'), 'navigation.user'), array(Request::url(null, 'manager'), 'user.role.manager'));
     switch ($verb) {
         case 'settings':
             $journal =& Request::getJournal();
             $this->import('StaticPagesSettingsForm');
             $form = new StaticPagesSettingsForm($this, $journal->getId());
             $templateMgr->assign('pageHierarchy', $pageCrumbs);
             $form->initData();
             $form->display();
             break;
         case 'edit':
         case 'add':
             $journal =& Request::getJournal();
             $this->import('StaticPagesEditForm');
             $staticPageId = isset($args[0]) ? (int) $args[0] : null;
             $form = new StaticPagesEditForm($this, $journal->getId(), $staticPageId);
             if ($form->isLocaleResubmit()) {
                 $form->readInputData();
                 $form->addTinyMCE();
             } else {
                 $form->initData();
             }
             $pageCrumbs[] = array(Request::url(null, 'manager', 'plugin', array('generic', $this->getName(), 'settings')), $this->getDisplayName(), true);
             $templateMgr->assign('pageHierarchy', $pageCrumbs);
             $form->display();
             $returner = true;
             break;
         case 'save':
             $journal =& Request::getJournal();
             $this->import('StaticPagesEditForm');
             $staticPageId = isset($args[0]) ? (int) $args[0] : null;
             $form = new StaticPagesEditForm($this, $journal->getId(), $staticPageId);
             if (Request::getUserVar('edit')) {
                 $form->readInputData();
                 if ($form->validate()) {
                     $form->save();
                     $templateMgr->assign(array('currentUrl' => Request::url(null, null, null, array($this->getCategory(), $this->getName(), 'settings')), 'pageTitle' => 'plugins.generic.staticPages.displayName', 'pageHierarchy' => $pageCrumbs, 'message' => 'plugins.generic.staticPages.pageSaved', 'backLink' => Request::url(null, null, null, array($this->getCategory(), $this->getName(), 'settings')), 'backLinkLabel' => 'common.continue'));
                     $templateMgr->display('common/message.tpl');
                     exit;
                 } else {
                     $form->addTinyMCE();
                     $form->display();
                     exit;
                 }
             }
             Request::redirect(null, null, 'manager', 'plugins');
             $returner = true;
             break;
         case 'delete':
             $journal =& Request::getJournal();
             $staticPageId = isset($args[0]) ? (int) $args[0] : null;
             $staticPagesDAO =& DAORegistry::getDAO('StaticPagesDAO');
             $staticPagesDAO->deleteStaticPageById($staticPageId);
             $templateMgr->assign(array('currentUrl' => Request::url(null, null, null, array($this->getCategory(), $this->getName(), 'settings')), 'pageTitle' => 'plugins.generic.staticPages.displayName', 'message' => 'plugins.generic.staticPages.pageDeleted', 'backLink' => Request::url(null, null, null, array($this->getCategory(), $this->getName(), 'settings')), 'backLinkLabel' => 'common.continue'));
             $templateMgr->assign('pageHierarchy', $pageCrumbs);
             $templateMgr->display('common/message.tpl');
             $returner = true;
             break;
         case 'enable':
             $this->setEnabled(true);
             $returner = false;
             break;
         case 'disable':
             $this->setEnabled(false);
             $returner = false;
             break;
     }
     return $returner;
 }