00001 <?php
00002
00015
00016 import('classes.handler.Handler');
00017
00018 class CatalogEntryHandler extends Handler {
00019
00021 var $_monograph;
00022
00024 var $_stageId;
00025
00027 var $_tabPosition;
00028
00030 var $_selectedFormatId;
00031
00035 function CatalogEntryHandler() {
00036 parent::Handler();
00037 $this->addRoleAssignment(
00038 array(ROLE_ID_SERIES_EDITOR, ROLE_ID_PRESS_MANAGER),
00039 array('fetch', 'fetchFormatInfo'));
00040 }
00041
00042
00043
00044
00045
00049 function initialize(&$request, $args = null) {
00050 parent::initialize($request, $args);
00051
00052 $monographDao =& DAORegistry::getDAO('MonographDAO');
00053 $this->_monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00054 $this->_stageId =& $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
00055 $this->_tabPosition = (int) $request->getUserVar('tabPos');
00056 $this->_selectedFormatId = (int) $request->getUserVar('selectedFormatId');
00057
00058
00059 AppLocale::requireComponents(LOCALE_COMPONENT_APPLICATION_COMMON, LOCALE_COMPONENT_OMP_SUBMISSION);
00060 $this->setupTemplate();
00061 }
00062
00069 function authorize(&$request, $args, $roleAssignments) {
00070 $stageId = (int) $request->getUserVar('stageId');
00071 import('classes.security.authorization.OmpWorkflowStageAccessPolicy');
00072 $this->addPolicy(new OmpWorkflowStageAccessPolicy($request, $args, $roleAssignments, 'monographId', $stageId));
00073 return parent::authorize($request, $args, $roleAssignments);
00074 }
00075
00076
00077
00078
00079
00084 function &getMonograph() {
00085 return $this->_monograph;
00086 }
00087
00092 function getStageId() {
00093 return $this->_stageId;
00094 }
00095
00100 function getTabPosition() {
00101 return $this->_tabPosition;
00102 }
00103
00108 function getSelectedFormatId() {
00109 return $this->_selectedFormatId;
00110 }
00111
00112
00113
00114
00115
00121 function fetch($request, $args) {
00122 $templateMgr =& TemplateManager::getManager();
00123
00124 $monograph =& $this->getMonograph();
00125
00126 $templateMgr->assign('monographId', $monograph->getId());
00127 $templateMgr->assign('stageId', $this->getStageId());
00128
00129
00130 $publishedMonographDao =& DAORegistry::getDAO('PublishedMonographDAO');
00131 $publishedMonograph =& $publishedMonographDao->getById($monograph->getId());
00132 $tabPosition = (int) $this->getTabPosition();
00133 $templateMgr->assign('selectedTab', $tabPosition);
00134 $templateMgr->assign('selectedFormatId', $this->getSelectedFormatId());
00135
00136
00137 $publicationFormatDao =& DAORegistry::getDAO('PublicationFormatDAO');
00138 $formats =& $publicationFormatDao->getByMonographId($monograph->getId());
00139 $publicationFormats = array();
00140 while ($publicationFormat =& $formats->next()) {
00141 $publicationFormats[] =& $publicationFormat;
00142 }
00143
00144 $templateMgr->assign_by_ref('publicationFormats', $publicationFormats);
00145
00146 $application =& Application::getApplication();
00147 $request =& $application->getRequest();
00148 $router =& $request->getRouter();
00149 $dispatcher =& $router->getDispatcher();
00150
00151 $tabsUrl = $dispatcher->url($request, ROUTE_COMPONENT, null, 'modals.submissionMetadata.CatalogEntryHandler', 'fetchFormatInfo', null, array('monographId' => $monograph->getId(), 'stageId' => $this->getStageId()));
00152 $templateMgr->assign('tabsUrl', $tabsUrl);
00153
00154 $tabContentUrl = $dispatcher->url($request, ROUTE_COMPONENT, null, 'tab.catalogEntry.CatalogEntryTabHandler', 'publicationMetadata', null, array('monographId' => $monograph->getId(), 'stageId' => $this->getStageId()));
00155 $templateMgr->assign('tabContentUrl', $tabContentUrl);
00156
00157 $this->setupTemplate();
00158 return $templateMgr->fetchJson('controllers/modals/submissionMetadata/catalogEntryTabs.tpl');
00159 }
00160
00167 function fetchFormatInfo($request, $args) {
00168 $monograph =& $this->getMonograph();
00169
00170 $publishedMonographDao =& DAORegistry::getDAO('PublishedMonographDAO');
00171 $json = new JSONMessage();
00172
00173 $publicationFormatDao =& DAORegistry::getDAO('PublicationFormatDAO');
00174 $formats =& $publicationFormatDao->getByMonographId($monograph->getId());
00175 $publicationFormats = array();
00176 while ($format =& $formats->next()) {
00177 $publicationFormats[$format->getId()] = $format->getLocalizedName();
00178 }
00179 $json->setStatus(true);
00180 $json->setContent(true);
00181 $json->setAdditionalAttributes(array('formats' => $publicationFormats));
00182 return $json->getString();
00183 }
00184 }
00185
00186 ?>