本文整理汇总了PHP中JSONMessage::setContent方法的典型用法代码示例。如果您正苦于以下问题:PHP JSONMessage::setContent方法的具体用法?PHP JSONMessage::setContent怎么用?PHP JSONMessage::setContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONMessage
的用法示例。
在下文中一共展示了JSONMessage::setContent方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLocalizedOptions
/**
* @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: fetchReportGenerator
/**
* 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: fetchFormatInfo
/**
* 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: fetchCategory
/**
* 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: initData
/**
* @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: fetchFile
/**
* 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: fetchNotification
/**
* 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: fetchRow
/**
* 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: fetchRegions
/**
* 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: saveForm
/**
* 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: updateIdentifiers
/**
* 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));
}
}