コード例 #1
0
 /**
  * @see LinkActionRequest::getLocalizedOptions()
  */
 function getLocalizedOptions()
 {
     $parentLocalizedOptions = parent::getLocalizedOptions();
     // override the modalHandler option.
     $parentLocalizedOptions['modalHandler'] = '$.pkp.controllers.modal.JsEventConfirmationModalHandler';
     $parentLocalizedOptions['jsEvent'] = $this->getEvent();
     if (is_array($this->getExtraArguments())) {
         $json = new JSONMessage();
         $json->setContent($this->getExtraArguments());
         $parentLocalizedOptions['extraArguments'] = $json->getString();
     }
     return $parentLocalizedOptions;
 }
コード例 #2
0
 /**
  * Fetch form to generate custom reports.
  * @param $args array
  * @param $request Request
  * @return JSONMessage JSON object
  */
 function fetchReportGenerator($args, $request)
 {
     $this->setupTemplate($request);
     $reportGeneratorForm = $this->_getReportGeneratorForm($request);
     $reportGeneratorForm->initData($request);
     $formContent = $reportGeneratorForm->fetch($request);
     $json = new JSONMessage(true);
     if ($request->getUserVar('refreshForm')) {
         $json->setEvent('refreshForm', $formContent);
     } else {
         $json->setContent($formContent);
     }
     return $json;
 }
コード例 #3
0
 /**
  * Returns a JSON response containing information regarding the galley formats enabled
  * for this submission.
  * @param $args array
  * @param $request Request
  */
 function fetchFormatInfo($args, $request)
 {
     $submission = $this->getSubmission();
     $json = new JSONMessage();
     $galleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
     $galleys = $galleyDao->getBySubmissionId($submission->getId());
     $formats = array();
     while ($galley = $galleys->next()) {
         $formats[$galley->getId()] = $galley->getLocalizedName();
     }
     $json->setStatus(true);
     $json->setContent(true);
     $json->setAdditionalAttributes(array('formats' => $formats));
     return $json->getString();
 }
コード例 #4
0
 /**
  * Render a category with all the rows inside of it.
  * @param $args array
  * @param $request Request
  * @return string the serialized row JSON message or a flag
  *  that indicates that the row has not been found.
  */
 function fetchCategory(&$args, &$request)
 {
     // Instantiate the requested row (includes a
     // validity check on the row id).
     $row =& $this->getRequestedCategoryRow($request, $args);
     $json = new JSONMessage(true);
     if (is_null($row)) {
         // Inform the client that the category does no longer exist.
         $json->setAdditionalAttributes(array('elementNotFound' => (int) $args['rowId']));
     } else {
         // Render the requested category
         $this->setFirstDataColumn();
         $json->setContent($this->_renderCategoryInternally($request, $row));
     }
     // Render and return the JSON message.
     return $json->getString();
 }
コード例 #5
0
ファイル: UserGroupForm.inc.php プロジェクト: doana/pkp-lib
 /**
  * @copydoc Form::initData()
  */
 function initData()
 {
     $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
     $userGroup = $userGroupDao->getById($this->getUserGroupId());
     $stages = WorkflowStageDAO::getWorkflowStageTranslationKeys();
     $this->setData('stages', $stages);
     $this->setData('assignedStages', array());
     // sensible default
     $roleDao = DAORegistry::getDAO('RoleDAO');
     /* @var $roleDao RoleDAO */
     import('lib.pkp.classes.core.JSONMessage');
     $jsonMessage = new JSONMessage();
     $jsonMessage->setContent($roleDao->getForbiddenStages());
     $this->setData('roleForbiddenStagesJSON', $jsonMessage->getString());
     if ($userGroup) {
         $assignedStages = $userGroupDao->getAssignedStagesByUserGroupId($this->getContextId(), $userGroup->getId());
         $data = array('userGroupId' => $userGroup->getId(), 'roleId' => $userGroup->getRoleId(), 'name' => $userGroup->getName(null), 'abbrev' => $userGroup->getAbbrev(null), 'assignedStages' => array_keys($assignedStages), 'showTitle' => $userGroup->getShowTitle(), 'permitSelfRegistration' => $userGroup->getPermitSelfRegistration());
         foreach ($data as $field => $value) {
             $this->setData($field, $value);
         }
     }
 }
コード例 #6
0
 /**
  * Fetch a file that has been uploaded.
  *
  * @param $args array
  * @param $request Request
  * @return string
  */
 function fetchFile($args, $request)
 {
     // Get the setting name.
     $settingName = $args['settingName'];
     // Try to fetch the file.
     $tabForm = $this->getTabForm();
     $tabForm->initData($request);
     $renderedElement = $tabForm->renderFileView($settingName, $request);
     $json = new JSONMessage();
     if ($renderedElement == false) {
         $json->setAdditionalAttributes(array('noData' => $settingName));
     } else {
         $json->setElementId($settingName);
         $json->setContent($renderedElement);
     }
     return $json->getString();
 }
コード例 #7
0
 /**
  * Return formatted notification data using Json.
  * @param $args array
  * @param $request Request
  *
  * @return JSONMessage
  */
 function fetchNotification($args, &$request)
 {
     $this->setupTemplate();
     $user =& $request->getUser();
     $context =& $request->getContext();
     $notificationDao =& DAORegistry::getDAO('NotificationDAO');
     $notifications = array();
     // Get the notification options from request.
     $notificationOptions = $request->getUserVar('requestOptions');
     if (is_array($notificationOptions)) {
         // Retrieve the notifications.
         $notifications = $this->_getNotificationsByOptions($notificationOptions, $context->getId(), $user->getId());
     } else {
         // No options, get only TRIVIAL notifications.
         $notifications =& $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TRIVIAL);
         $notifications =& $notifications->toArray();
     }
     import('lib.pkp.classes.core.JSONMessage');
     $json = new JSONMessage();
     if (is_array($notifications) && !empty($notifications)) {
         $formattedNotificationsData = array();
         $notificationManager = new NotificationManager();
         // Format in place notifications.
         $formattedNotificationsData['inPlace'] = $notificationManager->formatToInPlaceNotification($request, $notifications);
         // Format general notifications.
         $formattedNotificationsData['general'] = $notificationManager->formatToGeneralNotification($request, $notifications);
         // Delete trivial notifications from database.
         $notificationManager->deleteTrivialNotifications($notifications);
         $json->setContent($formattedNotificationsData);
     }
     return $json->getString();
 }
コード例 #8
0
ファイル: GridHandler.inc.php プロジェクト: jalperin/pkp-lib
 /**
  * Render a row and send it to the client. If the row no
  * longer exists then inform the client.
  * @param $args array
  * @param $request Request
  * @return JSONMessage JSON object.
  */
 function fetchRow(&$args, $request)
 {
     // Instantiate the requested row (includes a
     // validity check on the row id).
     $row = $this->getRequestedRow($request, $args);
     $json = new JSONMessage(true);
     if (is_null($row)) {
         // Inform the client that the row does no longer exist.
         $json->setAdditionalAttributes(array('elementNotFound' => $args['rowId']));
     } else {
         // Render the requested row
         $renderedRow = $this->renderRow($request, $row);
         $json->setContent($renderedRow);
         // Add the sequence map so grid can place the row at the correct position.
         $sequenceMap = $this->getRowsSequence($request);
         $json->setAdditionalAttributes(array('sequenceMap' => $sequenceMap));
     }
     $this->callFeaturesHook('fetchRow', array('request' => &$request, 'grid' => &$this, 'row' => &$row, 'jsonMessage' => &$json));
     // Render and return the JSON message.
     return $json;
 }
コード例 #9
0
 /**
  * Fetch regions from the passed request
  * variable country id.
  * @param $args array
  * @param $request Request
  * @return string JSON response
  */
 function fetchRegions(&$args, &$request)
 {
     $this->validate();
     $countryId = (string) $request->getUserVar('countryId');
     import('lib.pkp.classes.core.JSONMessage');
     $json = new JSONMessage(false);
     if ($countryId) {
         $geoLocationTool =& StatisticsHelper::getGeoLocationTool();
         if ($geoLocationTool) {
             $regions = $geoLocationTool->getRegions($countryId);
             if (!empty($regions)) {
                 $regionsData = array();
                 foreach ($regions as $id => $name) {
                     $regionsData[] = array('id' => $id, 'name' => $name);
                 }
                 $json->setStatus(true);
                 $json->setContent($regionsData);
             }
         }
     }
     return $json->getString();
 }
コード例 #10
0
 /**
  * Save the forms handled by this Handler.
  * @param $request Request
  * @param $args array
  * @return string JSON message
  */
 function saveForm($args, $request)
 {
     $json = new JSONMessage();
     $form = null;
     $submission = $this->getSubmission();
     $stageId = $this->getStageId();
     $notificationKey = null;
     $this->_getFormFromCurrentTab($form, $notificationKey, $request);
     if ($form) {
         // null if we didn't have a valid tab
         $form->readInputData();
         if ($form->validate($request)) {
             $form->execute($request);
             // Create trivial notification in place on the form
             $notificationManager = new NotificationManager();
             $user = $request->getUser();
             $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __($notificationKey)));
         } else {
             // Could not validate; redisplay the form.
             $json->setStatus(true);
             $json->setContent($form->fetch($request));
         }
         if ($request->getUserVar('displayedInContainer')) {
             $router = $request->getRouter();
             $dispatcher = $router->getDispatcher();
             $url = $dispatcher->url($request, ROUTE_COMPONENT, null, $this->_getHandlerClassPath(), 'fetch', null, array('submissionId' => $submission->getId(), 'stageId' => $stageId, 'tabPos' => $this->getTabPosition(), 'hideHelp' => true));
             $json->setAdditionalAttributes(array('reloadContainer' => true, 'tabsUrl' => $url));
             $json->setContent(true);
             // prevents modal closure
         }
         return $json;
     } else {
         fatalError('Unknown or unassigned format id!');
     }
 }
コード例 #11
0
 /**
  * Update submission pub ids.
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function updateIdentifiers($args, $request)
 {
     import('lib.pkp.controllers.tab.pubIds.form.PKPPublicIdentifiersForm');
     $submission = $this->getSubmission();
     $stageId = $this->getStageId();
     $form = new PKPPublicIdentifiersForm($submission, $stageId, array('displayedInContainer' => true));
     $form->readInputData();
     if ($form->validate($request)) {
         $form->execute($request);
         $json = new JSONMessage();
         if ($request->getUserVar('displayedInContainer')) {
             $router = $request->getRouter();
             $dispatcher = $router->getDispatcher();
             $url = $dispatcher->url($request, ROUTE_COMPONENT, null, $this->_getHandlerClassPath(), 'fetch', null, array('submissionId' => $submission->getId(), 'stageId' => $stageId, 'tabPos' => $this->getTabPosition(), 'hideHelp' => true));
             $json->setAdditionalAttributes(array('reloadContainer' => true, 'tabsUrl' => $url));
             $json->setContent(true);
             // prevents modal closure
         }
         return $json;
     } else {
         return new JSONMessage(true, $form->fetch($request));
     }
 }