v1.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?php
  2. namespace zin;
  3. require_once dirname(__DIR__) . DS . 'datalist' . DS . 'v1.php';
  4. class bugBasicInfo extends wg
  5. {
  6. /**
  7. * @var mixed[]
  8. */
  9. protected static $defineProps = array
  10. (
  11. 'bug' => '?object', // 当前Bug。
  12. 'product' => '?object', // 当前产品。
  13. 'users' => '?array', // 用户列表。
  14. 'statusText' => '?string', // 状态信息。
  15. 'modulePath' => '?string' // 模块路径。
  16. );
  17. /**
  18. * @param null|bool|object $product
  19. * @param object $bug
  20. * @param mixed[] $branches
  21. */
  22. protected function getModuleItems($bug, $product, $branches)
  23. {
  24. $modulePath = $this->prop('modulePath', data('modulePath'));
  25. $items = array();
  26. if($modulePath)
  27. {
  28. if($bug->branch and isset($branches[$bug->branch]))
  29. {
  30. $items[] = array('text' => $branches[$bug->branch]);
  31. }
  32. foreach($modulePath as $key => $module)
  33. {
  34. $items[] = $product->shadow || !common::hasPriv('bug', 'browse') ? array('text' => $module->name) : array('text' => $module->name, 'url' => createLink('bug', 'browse', "productID={$bug->product}&branch={$bug->branch}&browseType=byModule&param={$module->id}"), 'icon' => '');
  35. }
  36. }
  37. if(!$items) $items = array('/');
  38. return $items;
  39. }
  40. protected function getItems()
  41. {
  42. global $lang, $config;
  43. $bug = $this->prop('bug', data('bug'));
  44. if(!$bug) return array();
  45. $canViewProduct = common::hasPriv('product', 'view');
  46. $canBrowseBug = common::hasPriv('bug', 'browse');
  47. $canViewPlan = common::hasPriv('productplan', 'view');
  48. $canViewCase = common::hasPriv('testcase', 'view');
  49. $product = $this->prop('product', data('product'));
  50. $project = $this->prop('project', data('project'));
  51. $users = $this->prop('users', data('users'));
  52. $statusText = $this->prop('statusText', data('statusText'));
  53. $branches = $this->prop('branches', data('branches'));
  54. $branchName = $this->prop('branchName', data('branchName'));
  55. $branchTitle = sprintf($lang->product->branch, $lang->product->branchName[$product->type]);
  56. $productLink = $bug->product && $canViewProduct ? helper::createLink('product', 'view', "productID={$bug->product}") : '';
  57. $branchLink = $bug->branch && $canBrowseBug ? helper::createLink('bug', 'browse', "productID={$bug->product}&branch={$bug->branch}") : '';
  58. $planLink = $bug->plan && $canViewPlan ? helper::createLink('productplan', 'view', "planID={$bug->plan}&type=bug") : '';
  59. $fromCaseLink = $bug->case && $canViewCase ? helper::createLink('testcase', 'view', "caseID={$bug->case}&caseVersion={$bug->caseVersion}") : '';
  60. $items = array();
  61. if(empty($product->shadow))
  62. {
  63. $items[$lang->bug->product] = $productLink ? array
  64. (
  65. 'control' => 'link',
  66. 'url' => $productLink,
  67. 'text' => $product->name,
  68. 'title' => $product->name,
  69. 'data-app' => 'product'
  70. ) : $product->name;
  71. }
  72. if($product->type != 'normal')
  73. {
  74. $items[$branchTitle] = $branchLink ? array
  75. (
  76. 'control' => 'link',
  77. 'url' => $branchLink,
  78. 'text' => $branchName
  79. ) : $branchName;
  80. }
  81. $items[$lang->task->module] = array
  82. (
  83. 'control' => 'breadcrumb',
  84. 'items' => $this->getModuleItems($bug, $product, $branches)
  85. );
  86. if(empty($product->shadow) || !empty($project->multiple))
  87. {
  88. $items[$lang->bug->plan] = $planLink ? array
  89. (
  90. 'control' => 'link',
  91. 'url' => $planLink,
  92. 'text' => $bug->planName
  93. ) : $bug->planName;
  94. }
  95. $caseText = $bug->case ? "#{$bug->case} {$bug->caseTitle}" : '';
  96. $items[$lang->bug->fromCase] = $fromCaseLink ? array
  97. (
  98. 'control' => 'link',
  99. 'url' => $fromCaseLink,
  100. 'text' => $caseText
  101. ) : $caseText;
  102. $items[$lang->bug->type] = zget($lang->bug->typeList, $bug->type, $bug->type);
  103. $items[$lang->bug->severity] = array
  104. (
  105. 'control' => 'severitylabel',
  106. 'level' => $bug->severity
  107. );
  108. $items[$lang->bug->pri] = array
  109. (
  110. 'control' => 'pri',
  111. 'pri' => $bug->pri,
  112. 'text' => $lang->bug->priList
  113. );
  114. $items[$lang->bug->status] = array
  115. (
  116. 'control' => 'status',
  117. 'class' => 'bug-status',
  118. 'status' => $bug->status,
  119. 'text' => $statusText
  120. );
  121. $items[$lang->bug->activatedCount] = $bug->activatedCount ? "{$bug->activatedCount}" : '';
  122. if($config->edition != 'open')
  123. {
  124. $found = '';
  125. if(!empty($bug->found)) $found .= span(zget($users, $bug->found));
  126. if(!empty($bug->feedback) && !empty($bug->feedbackTitle)) $found .= a("#{$bug->feedback} {$bug->feedbackTitle}", set::href(helper::createLink('feedback', 'adminView', "feedbackID={$bug->feedback}")));
  127. $items[$lang->bug->found] = array('content' => html($found));
  128. }
  129. $items[$lang->bug->activatedDate] = formatTime($bug->activatedDate);
  130. $items[$lang->bug->confirmed] = $lang->bug->confirmedList[$bug->confirmed];
  131. $items[$lang->bug->assignedTo] = $bug->assignedTo ? zget($users, $bug->assignedTo) . $lang->at . formatTime($bug->assignedDate) : '';
  132. $items[$lang->bug->deadline] = array
  133. (
  134. 'control' => 'html',
  135. 'content' => html(formatTime($bug->deadline) . (isset($bug->delay) ? sprintf($lang->bug->notice->delayWarning, $bug->delay) : ''))
  136. );
  137. $items[$lang->bug->feedbackBy] = $bug->feedbackBy;
  138. $items[$lang->bug->notifyEmail] = $bug->notifyEmail;
  139. $osList = explode(',', $bug->os);
  140. $osText = '';
  141. foreach($osList as $os) $osText .= zget($lang->bug->osList, $os) . ' ';
  142. $items[$lang->bug->os] = array('control' => 'text', 'text' => trim($osText), 'title' => trim($osText));
  143. $browserList = explode(',', $bug->browser);
  144. $browserText = '';
  145. foreach($browserList as $browser) $browserText .= zget($lang->bug->browserList, $browser) . ' ';
  146. $items[$lang->bug->browser] = array('control' => 'text', 'text' => trim($browserText), 'title' => trim($browserText));
  147. if(in_array($config->edition, array('max', 'ipd')))
  148. {
  149. $items[$lang->bug->injection] = $bug->injectionTitle;
  150. $items[$lang->bug->identify] = $bug->identifyTitle;
  151. }
  152. $items[$lang->bug->keywords] = $bug->keywords;
  153. $mailtoList = explode(',', $bug->mailto);
  154. $mailtoText = '';
  155. foreach($mailtoList as $account) $mailtoText .= zget($users, $account) . ' ';
  156. $items[$lang->bug->mailto] = array('control' => 'text', 'text' => trim($mailtoText), 'title' => trim($mailtoText));
  157. return $items;
  158. }
  159. protected function build()
  160. {
  161. global $app;
  162. $isEn = $app->getClientLang() == 'en';
  163. return new datalist
  164. (
  165. set::className('bug-basic-info break-all overflow-hidden text-clip'),
  166. $isEn ? set::labelWidth('105') : null,
  167. set::items($this->getItems())
  168. );
  169. }
  170. }