v1.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace zin;
  3. require_once dirname(__DIR__) . DS . 'relatedlist' . DS . 'v1.php';
  4. class caseRelatedList extends relatedList
  5. {
  6. /**
  7. * @var mixed[]
  8. */
  9. protected static $defineProps = array
  10. (
  11. 'case' => '?object' // 当前用例。
  12. );
  13. protected function created()
  14. {
  15. global $config, $lang;
  16. $case = $this->prop('case', data('case'));
  17. if(!$case) return array();
  18. $data = array();
  19. $data['linkBugs'] = array
  20. (
  21. 'title' => $lang->testcase->legendLinkBugs,
  22. 'items' => array_filter(array_merge($case->toBugs, array($case->fromBugData))),
  23. 'url' => hasPriv('bug', 'view') ? createLink('bug', 'view', 'bugID={id}') : false
  24. );
  25. if($config->edition == 'open')
  26. {
  27. $linkCases = array();
  28. foreach($case->linkCaseTitles as $caseID => $linkCaseTitle)
  29. {
  30. $linkCase = new \stdclass();
  31. $linkCase->id = $caseID;
  32. $linkCase->title = $linkCaseTitle;
  33. $linkCases[] = $linkCase;
  34. }
  35. $data['linkCases'] = array
  36. (
  37. 'title' => $lang->testcase->linkCase,
  38. 'items' => $linkCases,
  39. 'url' => hasPriv('testcase', 'view') ? createLink('testcase', 'view', 'caseID={id}') : false
  40. );
  41. }
  42. $this->setProp('data', $data);
  43. }
  44. }