control.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. /**
  3. * The control file of dev module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @author chunsheng wang <chunsheng@cnezsoft.com>
  7. * @package
  8. * @uses control
  9. * @license LGPL
  10. * @version $Id$
  11. * @Link http://www.zentao.net
  12. */
  13. class dev extends control
  14. {
  15. /**
  16. * Get API of system.
  17. *
  18. * @param string $module
  19. * @param int $apiID
  20. * @access public
  21. * @return void
  22. */
  23. public function api($module = 'restapi', $apiID = 1)
  24. {
  25. if($module == 'restapi') return print($this->fetch('dev', 'restAPI', "apiID=$apiID"));
  26. $this->view->title = $this->lang->dev->api;
  27. $this->view->tab = 'api';
  28. $this->view->selectedModule = $module;
  29. $this->view->apis = $module ? $this->dev->getAPIs($module) : array();
  30. $this->view->moduleTree = $this->dev->getTree($module, 'module');
  31. $this->display();
  32. }
  33. /**
  34. * Get rest api list.
  35. *
  36. * @param int $apiID
  37. * @access public
  38. * @return void
  39. */
  40. public function restAPI($apiID = 1)
  41. {
  42. list($api, $typeList, $menu) = $this->dev->getAPIData($apiID);
  43. if($api) $api->desc = htmlspecialchars_decode($api->desc);
  44. $this->view->title = $this->lang->dev->api;
  45. $this->view->selectedModule = 'restapi';
  46. $this->view->moduleTree = $menu;
  47. $this->view->typeList = $typeList;
  48. $this->view->api = $api;
  49. $this->view->apiID = $apiID;
  50. $this->display();
  51. }
  52. /**
  53. * Get schema of database.
  54. *
  55. * @param string $table
  56. * @access public
  57. * @return void
  58. */
  59. public function db($table = '')
  60. {
  61. if(empty($table)) $table = $this->config->db->prefix . 'todo';
  62. $this->view->title = $this->lang->dev->db;
  63. $this->view->tableTree = $this->dev->getTree($table, 'table');
  64. $this->view->selectedTable = $table;
  65. $this->view->tab = 'db';
  66. $this->view->fields = $table ? $this->dev->getFields($table) : array();
  67. $this->display();
  68. }
  69. /**
  70. * Editor.
  71. *
  72. * @access public
  73. * @return void
  74. */
  75. public function editor()
  76. {
  77. $this->view->title = $this->lang->dev->editor;
  78. $this->view->tab = 'editor';
  79. $this->display();
  80. }
  81. /**
  82. * Custom menu lang item.
  83. *
  84. * @param string $type common|first|second|third|tag
  85. * @param string $module
  86. * @param string $method
  87. * @param string $language zh_cn|en|fr|de|zh_tw
  88. * @access public
  89. * @return void
  90. */
  91. public function langItem($type = 'common', $module = '', $method = '', $language = '')
  92. {
  93. $clientLang = $this->app->getClientLang();
  94. if(empty($language)) $language = $clientLang;
  95. $language = str_replace('_', '-', $language);
  96. if($type == 'second' and empty($module)) $module = 'my';
  97. $moduleName = $module;
  98. if($type == 'common' or $type == 'first') $moduleName = 'common';
  99. if($type == 'second') $moduleName = $module . 'Menu';
  100. if($type == 'third')
  101. {
  102. if($this->config->vision == 'lite')
  103. {
  104. $module = $module == '' ? 'kanbanProject' : $module;
  105. $method = $method == '' ? 'settings' : $method;
  106. }
  107. elseif(empty($method))
  108. {
  109. $module = 'my';
  110. $method = 'work';
  111. }
  112. $moduleName = $module . 'SubMenu';
  113. if($moduleName == 'qa' && $method = 'automation') $this->loadModel('zanode')->setMenu();
  114. }
  115. if($type == 'tag')
  116. {
  117. if(empty($module)) $module = 'my';
  118. if(empty($method)) $method = 'todo';
  119. $moduleName = $module;
  120. }
  121. if($this->server->request_method == 'POST')
  122. {
  123. $this->dev->saveCustomedLang($type, $moduleName, $method, $language);
  124. return $this->send(array('result' => 'success', 'load' => true, 'message' => $this->lang->saveSuccess));
  125. }
  126. if($clientLang != $language)
  127. {
  128. $currentCommonLang = $this->config->custom->commonLang;
  129. $commonLang = $this->dev->getOriginalLang('common', '', '', $language);
  130. $commonLang = array_merge($commonLang, $this->dev->getCustomedLang('common', '', '', $language));
  131. foreach($commonLang as $commonKey => $langValue)
  132. {
  133. $upperKey = '$' . strtoupper($commonKey);
  134. if(isset($this->config->custom->commonLang[$upperKey])) $this->config->custom->commonLang[$upperKey] = $langValue;
  135. }
  136. $currentLangs = $this->dev->getOriginalLang($type, $module, $method, $clientLang);
  137. $currentCommonLang = $currentCommonLang;
  138. }
  139. $this->view->title = $this->lang->langItem;
  140. $this->view->type = $type;
  141. $this->view->originalLangs = $this->dev->getOriginalLang($type, $module, $method, $language);
  142. $this->view->customedLangs = $this->dev->getCustomedLang($type, $module, $method, $language);
  143. $this->view->menuTree = $this->dev->getMenuTree($type, $module, $method);
  144. $this->view->moduleName = $moduleName;
  145. $this->view->module = $module;
  146. $this->view->method = $method;
  147. $this->view->language = str_replace('-', '_', $language);
  148. $this->view->currentLangs = isset($currentLangs) ? $currentLangs : array();
  149. $this->view->currentCommonLang = isset($currentCommonLang) ? $currentCommonLang : array();
  150. $this->display();
  151. }
  152. /**
  153. * Reset customed menu lang.
  154. *
  155. * @param string $type common|first|second|third|tag
  156. * @param string $module
  157. * @param string $method
  158. * @param string $language zh_cn|en|fr|de|zh_tw
  159. * @access public
  160. * @return void
  161. */
  162. public function resetLang($type = 'common', $module = '', $method = '', $language = 'zh_cn')
  163. {
  164. $section = '';
  165. $language = str_replace('_', '-', $language);
  166. if($type == 'common') $section = '&section=';
  167. if($type == 'first') $section = '&section=mainNav';
  168. if($type == 'tag')
  169. {
  170. if($this->config->vision == 'lite' and isset($this->config->dev->liteTagMethod["$module-$method"])) $method = $this->config->dev->liteTagMethod["$module-$method"];
  171. $section = str_replace('_', '-', "&section=featureBar-{$method}");
  172. $this->dao->delete()->from(TABLE_LANG)->where('lang')->eq($language)->andWhere('module')->eq($module)->andWhere('section')->like("moreSelects-$method%")->andWhere('vision')->eq($this->config->vision)->exec();
  173. }
  174. $key = '';
  175. if($type == 'common') $key = '&key=projectCommon,productCommon,executionCommon,ERCommon,URCommon,SRCommon';
  176. $this->loadModel('custom')->deleteItems("lang={$language}&module={$module}&vision={$this->config->vision}{$section}{$key}");
  177. if($this->config->vision == 'rnd' and $type == 'common' and $this->config->custom->URSR)
  178. {
  179. $oldValue = $this->dao->select('*')->from(TABLE_LANG)->where('`key`')->eq($this->config->custom->URSR)->andWhere('section')->eq('URSRList')->andWhere('lang')->eq($language)->andWhere('module')->eq('custom')->fetch('value');
  180. if($oldValue)
  181. {
  182. $oldValue = json_decode($oldValue);
  183. $setting = array(
  184. 'ERName' => zget($oldValue, 'defaultERName', $oldValue->ERName),
  185. 'SRName' => zget($oldValue, 'defaultSRName', $oldValue->SRName),
  186. 'URName' => zget($oldValue, 'defaultURName', $oldValue->URName)
  187. );
  188. $this->custom->updateURAndSR($this->config->custom->URSR, $language, $setting);
  189. }
  190. }
  191. return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => true));
  192. }
  193. }