当前位置: 首页>>代码示例>>PHP>>正文


PHP JSON::setContent方法代码示例

本文整理汇总了PHP中JSON::setContent方法的典型用法代码示例。如果您正苦于以下问题:PHP JSON::setContent方法的具体用法?PHP JSON::setContent怎么用?PHP JSON::setContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JSON的用法示例。


在下文中一共展示了JSON::setContent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAutocompleteSource

 function getAutocompleteSource($args, &$request)
 {
     //FIXME: add validation here?
     $this->setupTemplate();
     $sourceArray = $this->getPossibleItemList($request);
     $sourceJson = new JSON('true', null, 'false', 'local');
     $sourceContent = array();
     foreach ($sourceArray as $i => $item) {
         // The autocomplete code requires the JSON data to use 'label' as the array key for labels, and 'value' for the id
         $additionalAttributes = array('label' => sprintf('%s (%s)', $item['name'], $item['abbrev']), 'value' => $item['id']);
         $itemJson = new JSON('true', '', 'false', null, $additionalAttributes);
         $sourceContent[] = $itemJson->getString();
         unset($itemJson);
     }
     $sourceJson->setContent('[' . implode(',', $sourceContent) . ']');
     echo $sourceJson->getString();
 }
开发者ID:ramonsodoma,项目名称:omp,代码行数:17,代码来源:SeriesEditorsListbuilderHandler.inc.php

示例2: getCopyeditUserAutocomplete

 /**
  * Get users for copyediting autocomplete.
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function getCopyeditUserAutocomplete($args, &$request)
 {
     // Identify the Monograph we are working with
     $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
     // Retrieve the users for the autocomplete control: Any author or press assistant user assigned to this stage
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     /* @var $signoffDao SignoffDAO */
     $stageUsers =& $signoffDao->getAllBySymbolic('SIGNOFF_STAGE', ASSOC_TYPE_MONOGRAPH, $monograph->getId(), null, WORKFLOW_STAGE_ID_EDITING);
     $itemList = array();
     $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
     /* @var $userGroupDao UserGroupDAO */
     $userDao =& DAORegistry::getDAO('UserDAO');
     while ($stageUser =& $stageUsers->next()) {
         $userGroup =& $userGroupDao->getById($stageUser->getUserGroupId());
         // Disallow if the user's user group is a reviewer role
         if ($userGroup->getRoleId() != ROLE_ID_REVIEWER) {
             $user =& $userDao->getUser($stageUser->getUserId());
             $itemList[] = array('id' => $user->getId(), 'name' => $user->getFullName(), 'abbrev' => $userGroup->getLocalizedName(), 'userGroupId' => $stageUser->getUserGroupId());
         }
     }
     import('lib.pkp.classes.core.JSON');
     $sourceJson = new JSON(true, null, false, 'local');
     $sourceContent = array();
     foreach ($itemList as $i => $item) {
         // The autocomplete code requires the JSON data to use 'label' as the array key for labels, and 'value' for the id
         $additionalAttributes = array('label' => sprintf('%s (%s)', $item['name'], $item['abbrev']), 'value' => $item['id'] . "-" . $item['userGroupId']);
         $itemJson = new JSON(true, '', false, null, $additionalAttributes);
         $sourceContent[] = $itemJson->getString();
         unset($itemJson);
     }
     $sourceJson->setContent('[' . implode(',', $sourceContent) . ']');
     echo $sourceJson->getString();
 }
开发者ID:jerico-dev,项目名称:omp,代码行数:39,代码来源:CopyeditingFilesGridHandler.inc.php

示例3: getReviewerRoleAssignmentAutocomplete

 /**
  * Get a list of all non-reviewer users in the system to populate the reviewer role assignment autocomplete.
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function getReviewerRoleAssignmentAutocomplete($args, &$request)
 {
     $press =& $request->getPress();
     $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
     /* @var $userGroupDao UserGroupDAO */
     $users =& $userGroupDao->getUsersByContextId($press->getId());
     $itemList = array();
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     /* @var $roleDao RoleDAO */
     while ($user =& $users->next()) {
         // Check that the reviewer is not in the current round.  We need to do the comparison here to avoid nested selects.
         if (!$roleDao->userHasRole($press->getId(), $user->getId(), ROLE_ID_REVIEWER)) {
             $itemList[] = array('id' => $user->getId(), 'name' => $user->getFullName(), 'abbrev' => $user->getUsername());
         }
         unset($user);
     }
     import('lib.pkp.classes.core.JSON');
     $sourceJson = new JSON(true, null, false, 'local');
     $sourceContent = array();
     foreach ($itemList as $i => $item) {
         // The autocomplete code requires the JSON data to use 'label' as the array key for labels, and 'value' for the id
         $additionalAttributes = array('label' => sprintf('%s (%s)', $item['name'], $item['abbrev']), 'value' => $item['id']);
         $itemJson = new JSON(true, '', false, null, $additionalAttributes);
         $sourceContent[] = $itemJson->getString();
         unset($itemJson);
     }
     $sourceJson->setContent('[' . implode(',', $sourceContent) . ']');
     echo $sourceJson->getString();
 }
开发者ID:jerico-dev,项目名称:omp,代码行数:35,代码来源:ReviewerGridHandler.inc.php


注:本文中的JSON::setContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。