本文整理汇总了PHP中JSONMessage::getString方法的典型用法代码示例。如果您正苦于以下问题:PHP JSONMessage::getString方法的具体用法?PHP JSONMessage::getString怎么用?PHP JSONMessage::getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONMessage
的用法示例。
在下文中一共展示了JSONMessage::getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateUserMessageState
/**
* Update the information whether user messages should be
* displayed or not.
* @param $args array
* @param $request PKPRequest
* @return string a JSON message
*/
function updateUserMessageState($args, &$request)
{
// Exit with a fatal error if request parameters are missing.
if (!isset($args['setting-name']) && isset($args['setting-value'])) {
fatalError('Required request parameter "setting-name" or "setting-value" missing!');
}
// Retrieve the user from the session.
$user =& $request->getUser();
assert(is_a($user, 'User'));
// Validate the setting.
// FIXME: We don't have to retrieve the setting type (which is always bool
// for user messages) but only whether the setting name is valid and the
// value is boolean.
$settingName = $args['setting-name'];
$settingValue = $args['setting-value'];
$settingType = $this->_settingType($settingName);
switch ($settingType) {
case 'bool':
if (!($settingValue === 'false' || $settingValue === 'true')) {
// Exit with a fatal error when the setting value is invalid.
fatalError('Invalid setting value! Must be "true" or "false".');
}
$settingValue = $settingValue === 'true' ? true : false;
break;
default:
// Exit with a fatal error when an unknown setting is found.
fatalError('Unknown setting!');
}
// Persist the validated setting.
$userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO');
$userSettingsDao->updateSetting($user->getId(), $settingName, $settingValue, $settingType);
// Return a success message.
$json = new JSONMessage(true);
return $json->getString();
}
示例2: series
/**
* Display series admin page.
* @param $args array
* @param $request PKPRequest
*/
function series($args, $request)
{
$this->setupTemplate($request);
$templateMgr = TemplateManager::getManager($request);
$jsonMessage = new JSONMessage(true, $templateMgr->fetch('management/series.tpl'));
return $jsonMessage->getString();
}
示例3: selectFiles
/**
* Show the form to allow the user to select review files
* (bring in/take out files from submission stage to review stage)
*
* FIXME: Move to its own handler so that it can be re-used among grids.
*
* @param $args array
* @param $request PKPRequest
* @return string Serialized JSON object
*/
function selectFiles($args, $request)
{
$submission = $this->getSubmission();
import('lib.pkp.controllers.grid.files.review.form.ManageReviewFilesForm');
$manageReviewFilesForm = new ManageReviewFilesForm($submission->getId(), $this->getRequestArg('stageId'), $this->getRequestArg('reviewRoundId'));
$manageReviewFilesForm->initData($args, $request);
$json = new JSONMessage(true, $manageReviewFilesForm->fetch($request));
return $json->getString();
}
示例4: selectFiles
/**
* Show the form to allow the user to select review files
* (bring in/take out files from submission stage to review stage)
*
* FIXME: Move to it's own handler so that it can be re-used among grids.
*
* @param $args array
* @param $request PKPRequest
* @return string Serialized JSON object
*/
function selectFiles($args, $request)
{
$submission = $this->getSubmission();
import('lib.pkp.controllers.grid.files.final.form.ManageFinalDraftFilesForm');
$manageFinalDraftFilesForm = new ManageFinalDraftFilesForm($submission->getId());
$manageFinalDraftFilesForm->initData($args, $request);
$json = new JSONMessage(true, $manageFinalDraftFilesForm->fetch($request));
return $json->getString();
}
示例5: toggleHelp
/**
* Persist the status for a user's preference to see inline help.
* @param $args array
* @param $request PKPRequest
* @return string Serialized JSON object
*/
function toggleHelp($args, $request)
{
$user = $request->getUser();
$user->setInlineHelp($user->getInlineHelp() ? 0 : 1);
$userDao = DAORegistry::getDAO('UserDAO');
$userDao->updateObject($user);
import('lib.pkp.classes.core.JSONMessage');
$json = new JSONMessage(true);
return $json->getString();
}
示例6: publicationMetadata
/**
* Show the publication metadata form.
* @param $request Request
* @param $args array
* @return string JSON message
*/
function publicationMetadata($args, $request)
{
import('controllers.tab.issueEntry.form.IssueEntryPublicationMetadataForm');
$submission = $this->getSubmission();
$stageId = $this->getStageId();
$user = $request->getUser();
$issueEntryPublicationMetadataForm = new IssueEntryPublicationMetadataForm($submission->getId(), $user->getId(), $stageId, array('displayedInContainer' => true));
$issueEntryPublicationMetadataForm->initData($args, $request);
$json = new JSONMessage(true, $issueEntryPublicationMetadataForm->fetch($request));
return $json->getString();
}
示例7: testGetString
/**
* @covers JSONMessage
*/
public function testGetString()
{
// Create a test object.
$testObject = new stdClass();
$testObject->someInt = 5;
$testObject->someFloat = 5.5;
$json = new JSONMessage($status = true, $content = 'test content', $elementId = '0', $additionalAttributes = array('testObj' => $testObject));
$json->setEvent('someEvent', array('eventDataKey' => array('item1', 'item2')));
// Render the JSON message.
$expectedString = '{"status":true,"content":"test content",' . '"elementId":"0","testObj":{"someInt":5,"someFloat":5.5},' . '"event":{"name":"someEvent","data":{"eventDataKey":["item1","item2"]}}}';
self::assertEquals($expectedString, $json->getString());
}
示例8: getSubmissions
/**
* Get a list of submission options for new catalog entries.
* @param $args array
* @param $request PKPRequest
*/
function getSubmissions($args, $request)
{
$press = $request->getPress();
$monographDao = DAORegistry::getDAO('MonographDAO');
$submissionsIterator = $monographDao->getUnpublishedMonographsByPressId($press->getId());
$submissions = array();
while ($monograph = $submissionsIterator->next()) {
$submissions[$monograph->getId()] = $monograph->getLocalizedTitle();
}
$jsonMessage = new JSONMessage(true, $submissions);
return $jsonMessage->getString();
}
示例9: 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;
}
示例10: fetchTemplateBody
/**
* Fetches an email template's message body and returns it via AJAX.
* @param $args array
* @param $request PKPRequest
*/
function fetchTemplateBody($args, $request)
{
$templateId = $request->getUserVar('template');
import('lib.pkp.classes.mail.SubmissionMailTemplate');
$template = new SubmissionMailTemplate($this->getSubmission(), $templateId);
if ($template) {
$user = $request->getUser();
$dispatcher = $request->getDispatcher();
$context = $request->getContext();
$template->assignParams(array('editorialContactSignature' => $user->getContactSignature(), 'signatureFullName' => $user->getFullname()));
$json = new JSONMessage(true, $template->getBody() . "\n" . $context->getSetting('emailSignature'));
return $json->getString();
}
}
示例11: 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();
}
示例12: save
/**
* Display the grid's containing page.
* @param $args array
* @param $request PKPRequest
*/
function save($args, $request)
{
$filename = $this->_getFilename($request);
$notificationManager = new NotificationManager();
$user = $request->getUser();
$contents = $this->correctCr($request->getUserVar('fileContents'));
if (file_put_contents($filename, $contents)) {
$notificationManager->createTrivialNotification($user->getId());
} else {
// Could not write the file
$notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR, array('contents' => __('plugins.generic.translator.couldNotWriteFile', array('filename' => $filename))));
}
$message = new JSONMessage(true);
return $message->getString();
}
示例13: uploadImage
/**
* Handle file uploads for cover/image art for things like Series and Categories.
* @param $args array
* @param $request PKPRequest
*/
function uploadImage($args, $request)
{
$router = $request->getRouter();
$context = $request->getContext();
$user = $request->getUser();
import('lib.pkp.classes.file.TemporaryFileManager');
$temporaryFileManager = new TemporaryFileManager();
$temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
if ($temporaryFile) {
$json = new JSONMessage(true);
$json->setAdditionalAttributes(array('temporaryFileId' => $temporaryFile->getId()));
} else {
$json = new JSONMessage(false, __('common.uploadFailed'));
}
return $json->getString();
}
示例14: updateFinalDraftFiles
/**
* Save 'manage final draft files' form
* @param $args array
* @param $request PKPRequest
* @return string Serialized JSON object
*/
function updateFinalDraftFiles($args, $request)
{
$submission = $this->getSubmission();
import('lib.pkp.controllers.grid.files.final.form.ManageFinalDraftFilesForm');
$manageFinalDraftFilesForm = new ManageFinalDraftFilesForm($submission->getId());
$manageFinalDraftFilesForm->readInputData();
if ($manageFinalDraftFilesForm->validate()) {
$dataProvider = $this->getDataProvider();
$manageFinalDraftFilesForm->execute($args, $request, $dataProvider->getCategoryData($this->getStageId()));
// Let the calling grid reload itself
return DAO::getDataChangedEvent();
} else {
$json = new JSONMessage(false);
return $json->getString();
}
}
示例15: 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();
}