本文整理汇总了PHP中JSONMessage::setStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP JSONMessage::setStatus方法的具体用法?PHP JSONMessage::setStatus怎么用?PHP JSONMessage::setStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONMessage
的用法示例。
在下文中一共展示了JSONMessage::setStatus方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadFile
/**
* Upload a new file.
* @param $args array
* @param $request PKPRequest
* @return string
*/
function uploadFile($args, $request)
{
$fileUploadForm = $this->_getFileUploadForm($request);
$json = new JSONMessage();
$temporaryFileId = $fileUploadForm->uploadFile($request);
if ($temporaryFileId !== false) {
$json->setAdditionalAttributes(array('temporaryFileId' => $temporaryFileId));
} else {
$json->setStatus(false);
$json->setContent(__('common.uploadFailed'));
}
return $json->getString();
}
示例2: saveReportGenerator
/**
* Save form to generate custom reports.
* @param $args array
* @param $request Request
* @return JSONMessage JSON object
*/
function saveReportGenerator($args, $request)
{
$this->setupTemplate($request);
$reportGeneratorForm = $this->_getReportGeneratorForm($request);
$reportGeneratorForm->readInputData();
$json = new JSONMessage(true);
if ($reportGeneratorForm->validate()) {
$reportUrl = $reportGeneratorForm->execute($request);
$json->setAdditionalAttributes(array('reportUrl' => $reportUrl));
} else {
$json->setStatus(false);
}
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: saveForm
/**
* Save the submission metadata form.
* @param $args array
* @param $request Request
*/
function saveForm($args, $request)
{
$submissionId = $request->getUserVar('submissionId');
// Form handling
$submissionMetadataViewForm = $this->getFormInstance($submissionId);
$json = new JSONMessage();
// Try to save the form data.
$submissionMetadataViewForm->readInputData($request);
if ($submissionMetadataViewForm->validate()) {
$submissionMetadataViewForm->execute($request);
// Create trivial notification.
$notificationManager = new NotificationManager();
$user = $request->getUser();
$notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.savedSubmissionMetadata')));
} else {
$json->setStatus(false);
}
return $json->getString();
}
示例5: saveForm
/**
* Save the metadata tab.
* @param $args array
* @param $request PKPRequest
*/
function saveForm($args, $request)
{
$this->setupTemplate($request);
import('controllers.modals.submissionMetadata.form.SubmissionMetadataViewForm');
$submissionMetadataViewForm = new SubmissionMetadataViewForm($this->_submission->getId());
$json = new JSONMessage();
// Try to save the form data.
$submissionMetadataViewForm->readInputData($request);
if ($submissionMetadataViewForm->validate()) {
$submissionMetadataViewForm->execute($request);
// Create trivial notification.
$notificationManager = new NotificationManager();
$user = $request->getUser();
$notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.savedSubmissionMetadata')));
} else {
$json->setStatus(false);
}
return $json->getString();
}
示例6: fetchRows
/**
* Fetch all grid rows from loaded data.
* @param $args Array
* @param $request Request
* @return JSONMessage JSON object.
*/
function fetchRows($args, $request)
{
// Render the rows.
$this->setFirstDataColumn();
$elements = $this->getGridDataElements($request);
$renderedRows = $this->renderRowsInternally($request, $elements);
$json = new JSONMessage();
$json->setStatus(false);
if ($renderedRows) {
$renderedRowsString = null;
foreach ($renderedRows as $rowString) {
$renderedRowsString .= $rowString;
}
$json->setStatus(true);
$json->setContent($renderedRowsString);
}
$this->callFeaturesHook('fetchRows', array('request' => &$request, 'grid' => &$this, 'jsonMessage' => &$json));
return $json;
}
示例7: saveNotificationSettings
/**
* Save user notification settings.
* @param $args array
* @param $request PKPRequest
* @return JSONMessage JSON-formatted response
*/
function saveNotificationSettings($args, $request)
{
$this->setupTemplate($request);
import('classes.notification.form.NotificationSettingsForm');
$notificationSettingsForm = new NotificationSettingsForm();
$notificationSettingsForm->readInputData();
$json = new JSONMessage();
if ($notificationSettingsForm->validate()) {
$notificationSettingsForm->execute($request);
$user = $request->getUser();
$notificationMgr = new NotificationManager();
$notificationMgr->createTrivialNotification($user->getId());
} else {
$json->setStatus(false);
}
return $json;
}
示例8: 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();
}
示例9: 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!');
}
}