本文整理汇总了PHP中JSON::getString方法的典型用法代码示例。如果您正苦于以下问题:PHP JSON::getString方法的具体用法?PHP JSON::getString怎么用?PHP JSON::getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSON
的用法示例。
在下文中一共展示了JSON::getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUserSetting
/**
* Remotely set a user setting.
* @param $args array
* @param $request PKPRequest
* @return string a JSON message
*/
function setUserSetting($args, &$request)
{
// Retrieve the user from the session.
$user =& $request->getUser();
assert(is_a($user, 'User'));
// Exit with an error if request parameters are missing.
if (!isset($args['setting-name']) && isset($args['setting-value'])) {
$json = new JSON('false', 'Required request parameter "setting-name" or "setting-value" missing!');
return $json->getString();
}
// Validate the setting.
$settingName = $args['setting-name'];
$settingValue = $args['setting-value'];
$settingType = $this->_settingType($settingName);
switch ($settingType) {
case 'bool':
if (!($settingValue === 'false' || $settingValue === 'true')) {
$json = new JSON('false', 'Invalid setting value! Must be "true" or "false".');
return $json->getString();
}
$settingValue = $settingValue === 'true' ? true : false;
break;
default:
// Exit with a fatal error when an unknown setting is found.
$json = new JSON('false', 'Unknown setting!');
return $json->getString();
}
// Persist the validated setting.
$userSettingsDAO =& DAORegistry::getDAO('UserSettingsDAO');
$userSettingsDAO->updateSetting($user->getId(), $settingName, $settingValue, $settingType);
// Return a success message.
$json = new JSON('true');
return $json->getString();
}
示例2: deleteFile
/**
* Delete a file or revision
* @param $args array
* @param $request Request
* @return string a serialized JSON object
*/
function deleteFile($args, &$request)
{
// FIXME: authorize!
$fileId = (int) $request->getUserVar('fileId');
$success = false;
if ($fileId) {
// Delete all revisions or only one?
$revision = $request->getUserVar('revision') ? (int) $request->getUserVar('revision') : null;
// Delete the file/revision but only when it belongs to the authorized monograph
// and to the right file stage.
$monograph =& $this->getMonograph();
$submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
/* @var $submissionFileDao SubmissionFileDAO */
if ($revision) {
$success = (bool) $submissionFileDao->deleteRevisionById($fileId, $revision, $this->getFileStage(), $monograph->getId());
} else {
$success = (bool) $submissionFileDao->deleteAllRevisionsById($fileId, $this->getFileStage(), $monograph->getId());
}
}
if ($success) {
return DAO::getDataChangedEvent($fileId);
} else {
$json = new JSON(false);
return $json->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 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)
{
$monograph =& $this->getMonograph();
import('controllers.grid.files.review.form.ManageReviewFilesForm');
$manageReviewFilesForm = new ManageReviewFilesForm($monograph->getId(), $this->getRequestArg('reviewType'), $this->getRequestArg('round'));
$manageReviewFilesForm->initData($args, $request);
$json = new JSON(true, $manageReviewFilesForm->fetch($request));
return $json->getString();
}
示例4: getInterests
/**
* Get keywords for reviewer interests autocomplete.
* @param $args array
* @param $request PKPRequest
* @return string Serialized JSON object
*/
function getInterests($args, &$request)
{
// Get the input text used to filter on
$filter = $request->getUserVar('term');
import('lib.pkp.classes.user.InterestManager');
$interestManager = new InterestManager();
$interests = $interestManager->getAllInterests($filter);
import('lib.pkp.classes.core.JSON');
$json = new JSON(true, $interests);
return $json->getString();
}
示例5: fetch
/**
* Display the submission participants grid
* @param $args array
* @param $request PKPRequest
* @return string Serialized JSON object
* @see Form::fetch()
*/
function fetch($args, &$request)
{
// Identify the submission Id
$monographId = $request->getUserVar('monographId');
// Form handling
import('controllers.modals.submissionParticipants.form.SubmissionParticipantsForm');
$submissionParticipantsForm = new SubmissionParticipantsForm($monographId);
$submissionParticipantsForm->initData($args, $request);
$json = new JSON('true', $submissionParticipantsForm->fetch($request));
return $json->getString();
}
示例6: fetch
/**
* Display the submission's metadata
* @param $args array
* @param $request PKPRequest
* @return string Serialized JSON object
* @see Form::fetch()
*/
function fetch($args, &$request)
{
// Identify the submission Id
$monographId = $request->getUserVar('monographId');
Locale::requireComponents(array(LOCALE_COMPONENT_OMP_SUBMISSION));
// Form handling
import('controllers.modals.submissionMetadata.form.SubmissionMetadataForm');
$submissionMetadataForm = new SubmissionMetadataForm($monographId);
$submissionMetadataForm->initData($args, $request);
$json = new JSON('true', $submissionMetadataForm->fetch($request));
return $json->getString();
}
示例7: fetch
/**
* Display the submission's metadata
* @return string Serialized JSON object
* @see Form::fetch()
* @param $args array
* @param $request PKPRequest
*/
function fetch($args, &$request)
{
// Identify the press Id
$pressId = $request->getUserVar('pressId');
Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON));
// Form handling
import('controllers.modals.competingInterests.form.CompetingInterestsForm');
$competingInterestsForm = new CompetingInterestsForm($pressId);
$competingInterestsForm->initData($args, $request);
$json = new JSON(true, $competingInterestsForm->fetch($request));
return $json->getString();
}
示例8: updateReviewFiles
/**
* Save 'manage review files' form
* @param $args array
* @param $request PKPRequest
* @return string Serialized JSON object
*/
function updateReviewFiles($args, &$request)
{
$monograph =& $this->getMonograph();
import('controllers.grid.files.review.form.ManageReviewFilesForm');
$manageReviewFilesForm = new ManageReviewFilesForm($monograph->getId(), $this->getRequestArg('reviewType'), $this->getRequestArg('round'));
$manageReviewFilesForm->readInputData();
if ($manageReviewFilesForm->validate()) {
$manageReviewFilesForm->execute($args, $request);
// Let the calling grid reload itself
return DAO::getDataChangedEvent();
} else {
$json = new JSON(false);
return $json->getString();
}
}
示例9: index
/**
* Display the information page for the press..
*/
function index($args)
{
$this->validate();
$this->setupTemplate();
$press = Request::getPress();
$contentOnly = Request::getUserVar('contentOnly');
if ($press == null) {
Request::redirect('index');
return;
}
switch (isset($args[0]) ? $args[0] : null) {
case 'readers':
$content = $press->getLocalizedSetting('readerInformation');
$pageTitle = 'navigation.infoForReaders.long';
$pageCrumbTitle = 'navigation.infoForReaders';
break;
case 'authors':
$content = $press->getLocalizedSetting('authorInformation');
$pageTitle = 'navigation.infoForAuthors.long';
$pageCrumbTitle = 'navigation.infoForAuthors';
break;
case 'librarians':
$content = $press->getLocalizedSetting('librarianInformation');
$pageTitle = 'navigation.infoForLibrarians.long';
$pageCrumbTitle = 'navigation.infoForLibrarians';
break;
case 'competingInterestGuidelines':
$content = $press->getLocalizedSetting('competingInterestGuidelines');
$pageTitle = $pageCrumbTitle = 'navigation.competingInterestGuidelines';
break;
case 'sampleCopyrightWording':
$content = Locale::translate('manager.setup.authorCopyrightNotice.sample');
$pageTitle = $pageCrumbTitle = 'manager.setup.copyrightNotice';
break;
default:
Request::redirect($press->getPath());
return;
}
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign('pageCrumbTitle', $pageCrumbTitle);
$templateMgr->assign('pageTitle', $pageTitle);
$templateMgr->assign('content', $content);
$templateMgr->assign('contentOnly', $contentOnly);
// Hide the header and footer code
import('lib.pkp.classes.core.JSON');
$json = new JSON('true', $templateMgr->fetch('information/information.tpl'));
return $json->getString();
}
示例10: fetchForm
/**
* Display the reviewer filtering form
* @param $args array
* @param $request PKPRequest
*/
function fetchForm($args, &$request)
{
// Get the monograph
$monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
$interestDao =& DAORegistry::getDAO('InterestDAO');
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign('monograph', $monograph->getId());
$templateMgr->assign('existingInterests', $interestDao->getAllUniqueInterests());
Locale::requireComponents(array(LOCALE_COMPONENT_PKP_MANAGER));
// Form handling
import('controllers.reviewerSelector.form.ReviewerSelectorForm');
$reviewerSelectorForm = new ReviewerSelectorForm($monograph->getId());
$reviewerSelectorForm->initData();
$json = new JSON('true', $reviewerSelectorForm->fetch($request));
return $json->getString();
}
示例11: fetchGrid
/**
* Render the entire grid controller and send
* it to the client.
* @return string the grid HTML
*/
function fetchGrid($args, &$request)
{
// Prepare the template to render the grid
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign_by_ref('grid', $this);
// Add columns to the view
$columns =& $this->getColumns();
$templateMgr->assign_by_ref('columns', $columns);
$templateMgr->assign('numColumns', count($columns));
// Render the body elements (category groupings + rows inside a <tbody>)
$gridBodyParts = $this->_renderCategoriesInternally($request);
$templateMgr->assign_by_ref('gridBodyParts', $gridBodyParts);
// Let the view render the grid
$json = new JSON('true', $templateMgr->fetch($this->getTemplate()));
return $json->getString();
}
示例12: deleteSubmission
/**
* Delete a submission
* FIXME: Either delete this operation or add it as a row action, see #6396.
* @param $args array
* @param $request PKPRequest
* @return string Serialized JSON object
*/
function deleteSubmission($args, &$request)
{
$monographId = $request->getUserVar('monographId');
$this->validate($monographId);
$authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO');
$authorSubmission = $authorSubmissionDao->getAuthorSubmission($monographId);
// If the submission is incomplete, allow the author to delete it.
if ($authorSubmission->getSubmissionProgress() != 0) {
$monographDao =& DAORegistry::getDAO('MonographDAO');
/* @var $monographDao MonographDAO */
$monographDao->deleteMonographById($monographId);
$json = new JSON(true);
} else {
$json = new JSON(false, Locale::translate('settings.setup.errorDeletingItem'));
}
return $json->getString();
}
示例13: deleteUser
/**
* Delete a user's signoff
* @param $args array
* @param $request PKPRequest
* @return string
*/
function deleteUser($args, &$request)
{
$signoffId = (int) $request->getUserVar('signoffId');
if ($signoffId) {
// Remove the signoff
$signoffDao =& DAORegistry::getDAO('SignoffDAO');
/* @var $signoffDao SignoffDAO */
$signoffDao->deleteObjectById($signoffId);
$json = new JSON(true);
} else {
$json = new JSON(false, 'manager.setup.errorDeletingItem');
}
return $json->getString();
}
示例14: deleteContributor
/**
* Delete a contributor
* @param $args array
* @param $request PKPRequest
* @return string Serialized JSON object
*/
function deleteContributor($args, &$request)
{
$contributorId = isset($args['rowId']) ? $args['rowId'] : null;
$router =& $request->getRouter();
$press =& $router->getContext($request);
$pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO');
// get all of the contributors
$contributors = $pressSettingsDao->getSetting($press->getId(), 'contributors');
if (isset($contributors[$contributorId])) {
unset($contributors[$contributorId]);
$pressSettingsDao->updateSetting($press->getId(), 'contributors', $contributors, 'object');
$json = new JSON('true');
} else {
$json = new JSON('false', Locale::translate('manager.setup.errorDeletingItem'));
}
return $json->getString();
}
示例15: fetch
/**
* Display the Listbuilder
*/
function fetch(&$args, &$request, $additionalVars = null)
{
// FIXME: User validation
$templateMgr =& TemplateManager::getManager();
$this->setupTemplate();
$router =& $request->getRouter();
if (isset($additionalVars)) {
foreach ($additionalVars as $key => $value) {
$templateMgr->assign($key, $value);
}
} else {
$templateMgr->assign('addUrl', $router->url($request, array(), null, 'addItem'));
$templateMgr->assign('deleteUrl', $router->url($request, array(), null, 'deleteItems'));
}
// Translate modal submit/cancel buttons
$okButton = Locale::translate('common.ok');
$warning = Locale::translate('common.warning');
$templateMgr->assign('localizedButtons', "{$okButton}, {$warning}");
// initialize to create the columns
$columns =& $this->getColumns();
$templateMgr->assign_by_ref('columns', $columns);
$templateMgr->assign('numColumns', count($columns));
// Render the rows
$nullVar = null;
// Kludge
$rows = $this->_renderRowsInternally($request, $nullVar);
$templateMgr->assign_by_ref('rows', $rows);
$templateMgr->assign('listbuilder', $this);
$json = new JSON('true', $templateMgr->fetch($this->getTemplate()));
return $json->getString();
}