ajaxgetdropmenu.html.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * The ajaxgetdropmenu view file of doc module of ZenTaoPMS.
  4. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  5. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  6. * @author Yanyi Cao <caoyanyi@easycorp.ltd>
  7. * @package doc
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. /**
  12. * 定义每个分组下的选项数据列表。
  13. * Define the grouped data list.
  14. */
  15. $data = array('normal' => array(), 'closed' => array());
  16. $normalObjectNames = array_values($normalObjects);
  17. $normalObjectPinyinNames = common::convert2Pinyin($normalObjectNames);
  18. /* 处理分组数据。Process grouped data. */
  19. foreach($normalObjects as $normalObjectID => $normalObjectName)
  20. {
  21. $item = array();
  22. $item['id'] = $normalObjectID;
  23. $item['text'] = $normalObjectName;
  24. $item['active'] = $normalObjectID == $objectID;
  25. $item['keys'] = zget($normalObjectPinyinNames, $normalObjectName, '');
  26. $data['normal'][] = $item;
  27. }
  28. $closedObjectNames = array_values($closedObjects);
  29. $closedObjectPinyinNames = common::convert2Pinyin($closedObjectNames);
  30. foreach($closedObjects as $closedObjectID => $closedObjectName)
  31. {
  32. $item = array();
  33. $item['id'] = $closedObjectID;
  34. $item['text'] = $closedObjectName;
  35. $item['active'] = $closedObjectID == $objectID;
  36. $item['keys'] = zget($closedObjectPinyinNames, $closedObjectName, '');
  37. $data['closed'][] = $item;
  38. }
  39. /* 将分组数据转换为索引数组。Format grouped data to indexed array. */
  40. /**
  41. * 定义每个分组名称信息,包括可展开的已关闭分组。
  42. * Define every group name, include expanded group.
  43. */
  44. $tabs = array();
  45. $tabs[] = array('name' => 'normal', 'text' => '');
  46. $tabs[] = array('name' => 'closed', 'text' => $lang->doc->closed);
  47. /**
  48. * 定义最终的 JSON 数据。
  49. * Define the final json data.
  50. */
  51. $params = "objectID=%s";
  52. if($method == 'showfiles' || $objectType == 'custom') $params = "type=$objectType&objectID=%s";
  53. if($method == 'create') $params = "objectType=$objectType&objectID=%s&libID=$libID&moduleID=0";
  54. $link = $this->createLink($module, $method, $params);
  55. $json = array();
  56. $json['data'] = $data;
  57. $json['tabs'] = $tabs;
  58. $json['searchHint'] = $lang->searchAB;
  59. $json['link'] = sprintf($link, '{id}');
  60. $json['expandName'] = 'closed';
  61. $json['itemType'] = 'doc';
  62. /**
  63. * 渲染 JSON 字符串并发送到客户端。
  64. * Render json data to string and send to client.
  65. */
  66. renderJson($json);