selectapi.html.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * The selectlibtype 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 Chenxuan Song<songchenxuan@easycorp.ltd>
  7. * @package doc
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. // In this page, $objectType = api
  12. // $params may have four key: apiType|objectID|executionID|libID
  13. $apiType = isset($params['apiType']) ? $params['apiType'] : 'product';
  14. $products = $this->loadModel('product')->getPairs();
  15. $projects = $this->loadModel('project')->getPairsByProgram(0, 'all', false, 'order_asc');
  16. $libs = array();
  17. if($apiType == 'product')
  18. {
  19. $useType = $apiType;
  20. $objectID = isset($params['objectID']) ? (int)$params['objectID'] : key($products);
  21. $libs = $this->doc->getApiLibs(0, $useType, (int)$objectID);
  22. }
  23. elseif($apiType == 'project')
  24. {
  25. $useType = $apiType;
  26. $objectID = isset($params['objectID']) ? (int)$params['objectID'] : key($projects);
  27. $libs = $this->doc->getApiLibs(0, $useType, (int)$objectID);
  28. }
  29. elseif($apiType == 'nolink')
  30. {
  31. $libs = $this->doc->getApiLibs(0, 'nolink');
  32. }
  33. $libPairs = array();
  34. foreach($libs as $libID => $lib) $libPairs[$libID] = $lib->name;
  35. $libID = isset($params['libID']) && isset($libPairs[$params['libID']]) ? $params['libID'] : key($libPairs);
  36. $modules = $this->loadModel('tree')->getOptionMenu((int)$libID, 'doc', 0);
  37. $moduleID = key($modules);
  38. form
  39. (
  40. setID('selectLibTypeForm'),
  41. set::submitBtnText($lang->doc->nextStep),
  42. on::change('[name=rootSpace]', "changeSpace"),
  43. on::change('[name=apiType]', "reloadApiByApiType"),
  44. on::change('[name=project]', "reloadApi"),
  45. on::change('[name=execution]', "reloadApi"),
  46. on::change('[name=product]', "reloadApi"),
  47. on::change('[name=lib]', "reloadApi"),
  48. formGroup
  49. (
  50. set::label($lang->doc->selectSpace),
  51. radioList(set::name('rootSpace'), set::items($spaceList), set::value($objectType), set::inline(true))
  52. ),
  53. formRow
  54. (
  55. formGroup
  56. (
  57. set::width('2/5'),
  58. set::label($lang->doc->apiType),
  59. set::control(array('control' => 'picker', 'name' => 'apiType', 'items' => $lang->doc->apiTypeList, 'value' => $apiType, 'required' => true))
  60. )
  61. ),
  62. $apiType == 'project' ? formRow
  63. (
  64. formGroup
  65. (
  66. set::label($lang->doc->project),
  67. set::width('4/5'),
  68. set::name('project'),
  69. set::items(createLink('project', 'ajaxGetDropMenu', "objectID=$objectID&module=&method=&extra=selectmode&useLink=0")),
  70. set::value($objectID),
  71. set::required(true)
  72. )
  73. ) : null,
  74. $apiType == 'product' ? formRow
  75. (
  76. formGroup
  77. (
  78. set::width('4/5'),
  79. set::label($lang->doc->product),
  80. set::name('product'),
  81. set::items(createLink('product', 'ajaxGetDropMenu', "objectID=$objectID&module=&method=&extra=selectmode&useLink=0")),
  82. set::value($objectID),
  83. set::required(true)
  84. )
  85. ) : null,
  86. formGroup
  87. (
  88. set::width('4/5'),
  89. set::label($lang->doc->lib),
  90. set::required(true),
  91. set::control(array('control' => 'picker', 'name' => 'lib', 'items' => $libPairs, 'value' => $libID, 'required' => true))
  92. ),
  93. formGroup
  94. (
  95. setClass('moduleBox'),
  96. set::width('4/5'),
  97. set::label($lang->doc->module),
  98. set::required(true),
  99. set::control(array('control' => 'picker', 'name' => 'module', 'items' => $modules, 'value' => $moduleID, 'required' => true))
  100. )
  101. );