model.php 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212
  1. <?php
  2. class devModel extends model
  3. {
  4. /**
  5. * Default lang object.
  6. *
  7. * @var object
  8. * @access public
  9. */
  10. public $defaultLang;
  11. /**
  12. * Get All tables.
  13. *
  14. * @access public
  15. * @return array
  16. */
  17. public function getTables()
  18. {
  19. $this->dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
  20. $tables = array();
  21. $datatables = $this->dao->showTables();
  22. foreach($datatables as $table)
  23. {
  24. $table = current($table);
  25. if(empty($this->config->db->prefix) or strpos($table, $this->config->db->prefix) !== false)
  26. {
  27. if(strpos($table, $this->config->db->prefix . 'flow_') === 0) continue;
  28. $subTable = substr($table, strpos($table, '_') + 1);
  29. $group = zget($this->config->dev->group, $subTable, 'other');
  30. $tables[$group][$subTable] = $table;
  31. }
  32. }
  33. $this->dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
  34. return $tables;
  35. }
  36. /**
  37. * Get fields of table.
  38. *
  39. * @param string $table
  40. * @access public
  41. * @return void
  42. */
  43. public function getFields($table)
  44. {
  45. if(empty($table)) return array();
  46. $module = substr($table, strpos($table, '_') + 1);
  47. $aliasModule = $subLang = '';
  48. $this->app->loadLang($module);
  49. try
  50. {
  51. if(isset($this->config->dev->tableMap[$module])) $aliasModule = $this->config->dev->tableMap[$module];
  52. if(strpos($aliasModule, '-') !== false) list($aliasModule, $subLang) = explode('-', $aliasModule);
  53. if(!empty($aliasModule) and strpos($module, 'im_') === false) $this->app->loadLang($aliasModule);
  54. }
  55. catch(PDOException $e)
  56. {
  57. $this->lang->$module = new stdclass();
  58. }
  59. try
  60. {
  61. $rawFields = $this->dao->descTable($table);
  62. }
  63. catch (PDOException $e)
  64. {
  65. $this->dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
  66. $this->sqlError($e);
  67. }
  68. foreach($rawFields as $rawField)
  69. {
  70. $firstPOS = strpos($rawField->type, '(');
  71. $type = substr($rawField->type, 0, $firstPOS > 0 ? $firstPOS : strlen($rawField->type));
  72. $type = str_replace(array('big', 'small', 'medium', 'tiny'), '', $type);
  73. $field = array();
  74. $tableName = zget($this->lang->dev->tableList, $module, $module);
  75. $field['name'] = (isset($this->lang->$module->{$rawField->field}) and is_string($this->lang->$module->{$rawField->field})) ? str_replace('%s', $tableName, $this->lang->$module->{$rawField->field}) : '';
  76. if((empty($field['name']) or !is_string($field['name'])) and $aliasModule) $field['name'] = isset($this->lang->$aliasModule->{$rawField->field}) ? $this->lang->$aliasModule->{$rawField->field} : '';
  77. if($subLang) $field['name'] = isset($this->lang->$aliasModule->$subLang->{$rawField->field}) ? $this->lang->$aliasModule->$subLang->{$rawField->field} : $field['name'];
  78. if(!is_string($field['name'])) $field['name'] = '';
  79. $field['null'] = $rawField->null;
  80. $fields[$rawField->field] = $this->setField($field, $rawField, $type, $firstPOS);
  81. }
  82. return $fields;
  83. }
  84. /**
  85. * Set table fields field.
  86. *
  87. * @param array $field
  88. * @param array $rawField
  89. * @param string $type
  90. * @param int $firstPOS
  91. * @access public
  92. * @return array
  93. */
  94. public function setField($field, $rawField, $type, $firstPOS)
  95. {
  96. if($type == 'enum' or $type == 'set')
  97. {
  98. $rangeBegin = $firstPOS + 2; // Remove the first quote.
  99. $rangeEnd = strrpos($rawField->type, ')') - 1; // Remove the last quote.
  100. $range = substr($rawField->type, $rangeBegin, $rangeEnd - $rangeBegin);
  101. $field['type'] = $rawField->type;
  102. $field['options']['enum'] = str_replace("','", ',', $range);
  103. }
  104. elseif($type == 'varchar' or $type == 'char' or $type == 'int')
  105. {
  106. $begin = $firstPOS + 1;
  107. $end = strpos($rawField->type, ')', $begin);
  108. $length = substr($rawField->type, $begin, $end - $begin);
  109. $field['type'] = $type;
  110. $field['options']['max'] = $length;
  111. $field['options']['min'] = 0;
  112. }
  113. elseif($type == 'float' or $type == 'double')
  114. {
  115. $field['type'] = 'float';
  116. }
  117. else
  118. {
  119. $field['type'] = $type;
  120. }
  121. return $field;
  122. }
  123. /**
  124. * Get APIs of a module.
  125. *
  126. * @param string $module
  127. * @access public
  128. * @return void
  129. */
  130. public function getAPIs($module)
  131. {
  132. $fileName = $this->app->getModuleRoot() . $module . DS . 'control.php';
  133. if(!file_exists($fileName))
  134. {
  135. $extPaths = $this->getModuleExtPath();
  136. foreach($extPaths as $extPath)
  137. {
  138. $fileName = $extPath . $module . DS . 'control.php';
  139. if(file_exists($fileName)) break;
  140. }
  141. }
  142. if($module != 'common' and $module != 'dev') include $fileName;
  143. $classReflect = new ReflectionClass($module);
  144. $methods = $classReflect->getMethods();
  145. $apis = array();
  146. foreach($methods as $method)
  147. {
  148. if($method->class == 'baseControl' or $method->class == 'control' or $method->name == '__construct') continue;
  149. $api = array('name' => $method->name, 'post' => false, 'param' => array(), 'desc' => '');
  150. $methodReflect = new ReflectionMethod($module, $method->name);
  151. foreach($methodReflect->getParameters() as $param)
  152. {
  153. $paramName = $param->getName();
  154. $api['param'][$paramName] = array('var' => $paramName, 'type' => '', 'desc' => '');
  155. }
  156. $startLine = $methodReflect->getStartLine();
  157. $endLine = $methodReflect->getEndLine();
  158. $comment = $methodReflect->getDocComment();
  159. if($startLine > 0)
  160. {
  161. $file = file($fileName);
  162. for($i = $startLine - 1; $i <= $endLine; $i++)
  163. {
  164. if(strpos($file[$i], '$this->post') or strpos($file[$i], 'fixer::input') or strpos($file[$i], '$_POST')) $api['post'] = true;
  165. }
  166. }
  167. if($comment)
  168. {
  169. // Strip the opening and closing tags of the docblock.
  170. $comment = substr($comment, 3, -2);
  171. // Split into arrays of lines.
  172. $comment = preg_split('/\r?\n\r?/', $comment);
  173. // Trim asterisks and whitespace from the beginning and whitespace from the end of lines.
  174. $comment = array_map(array('devModel', "trimSpace"), $comment);
  175. // Group the lines together by @tags
  176. $blocks = array();
  177. $b = -1;
  178. foreach($comment as $line)
  179. {
  180. if(isset($line[1]) && $line[0] == '@' && ctype_alpha($line[1])) $b++;
  181. if($b == -1) $b = 0;
  182. if(!isset($blocks[$b])) $blocks[$b] = array();
  183. $blocks[$b][] = $line;
  184. }
  185. // Parse the blocks
  186. foreach($blocks as $block => $body)
  187. {
  188. $body = trim(implode("\n", $body));
  189. if($block == 0 && !(isset($body[1]) && $body[0] == '@' && ctype_alpha($body[1])))
  190. {
  191. // This is the description block
  192. $api['desc'] = $body;
  193. continue;
  194. }
  195. // This block is tagged
  196. if(preg_match('/^@[a-z0-9_]+/', $body, $matches))
  197. {
  198. $tag = substr($matches[0], 1);
  199. $body = substr($body, strlen($tag) + 2);
  200. if($tag != 'param')
  201. {
  202. $api[$tag][] = $body;
  203. continue;
  204. }
  205. $parts = preg_split('/\s+/', trim($body), 3);
  206. $parts = array_pad($parts, 3, null);
  207. $property = array('type', 'var', 'desc');
  208. $param = array_combine($property, $parts);
  209. $paramName = substr($param['var'], 1);
  210. $param['var'] = $paramName;
  211. if(isset($api['param'][$paramName])) $api['param'][$paramName] = $param;
  212. }
  213. }
  214. }
  215. $apis[] = $api;
  216. }
  217. return $apis;
  218. }
  219. /**
  220. * Get all modules.
  221. *
  222. * @access public
  223. * @return array
  224. */
  225. public function getModules()
  226. {
  227. $moduleList = glob($this->app->getModuleRoot() . '*');
  228. $modules = array();
  229. foreach($moduleList as $module)
  230. {
  231. if(!file_exists($module . DS . 'control.php')) continue;
  232. $module = basename($module);
  233. if($module == 'editor' or $module == 'help' or $module == 'setting' or $module == 'common') continue;
  234. $group = zget($this->config->dev->group, $module, 'other');
  235. $modules[$group][$module] = $module;
  236. }
  237. $extPaths = $this->getModuleExtPath();
  238. foreach($extPaths as $extPath)
  239. {
  240. if(empty($extPath)) continue;
  241. foreach(glob($extPath . '*') as $path)
  242. {
  243. if(!file_exists($path . DS . 'control.php')) continue;
  244. $module = basename($path);
  245. if($module == 'editor' or $module == 'help' or $module == 'setting' or $module == 'common') continue;
  246. $group = zget($this->config->dev->group, $module, 'other');
  247. $modules[$group][$module] = $module;
  248. }
  249. }
  250. return $modules;
  251. }
  252. /**
  253. * Get module ext path.
  254. *
  255. * @access public
  256. * @return array
  257. */
  258. public function getModuleExtPath()
  259. {
  260. $extPaths = array();
  261. if($this->config->edition != 'open') $extPaths['common'] = $this->app->getExtensionRoot() . $this->config->edition . DS;
  262. $extPaths['xuan'] = $this->app->getExtensionRoot() . 'xuan' . DS;
  263. return $extPaths;
  264. }
  265. /**
  266. * Get nav lang.
  267. *
  268. * @param string $type
  269. * @param string $module
  270. * @param string $method
  271. * @param string $language
  272. * @param object $defaultLang
  273. * @access public
  274. * @return object
  275. */
  276. public function getNavLang($type, $module, $method, $language = 'zh-cn', $defaultLang = null)
  277. {
  278. if(empty($defaultLang)) $defaultLang = $this->loadDefaultLang($language);
  279. $menus = new stdclass();
  280. if($type == 'second')
  281. {
  282. if(isset($defaultLang->$module->homeMenu))
  283. {
  284. foreach($defaultLang->$module->homeMenu as $menuKey => $menu)
  285. {
  286. $menuKey = 'homeMenu_' . $menuKey;
  287. $menus->{$menuKey} = $menu;
  288. }
  289. }
  290. if(isset($defaultLang->$module->menu))
  291. {
  292. if($module == 'product')
  293. {
  294. $defaultLang->product->menu->system = $defaultLang->product->system;
  295. $defaultLang->product->menuOrder[41] = 'system';
  296. }
  297. $menuList = $defaultLang->$module->menu;
  298. if(isset($defaultLang->$module->menuOrder)) $menuList->menuOrder = $defaultLang->$module->menuOrder;
  299. $menuList = $this->sortMenus($menuList);
  300. foreach($menuList as $menuKey => $menu)
  301. {
  302. if(is_array($menu) and !isset($menu['link'])) continue;
  303. $newKey = 'menu_' . $menuKey;
  304. $menus->{$newKey} = $menu;
  305. if(!isset($menu['dropMenu'])) continue;
  306. foreach($menu['dropMenu'] as $key => $menu)
  307. {
  308. $dropMenuKey = $menuKey . 'DropMenu_' . $key;
  309. $menus->{$dropMenuKey} = $menu;
  310. }
  311. }
  312. }
  313. }
  314. else
  315. {
  316. $menus = ($type == 'third' and isset($defaultLang->$module->menu->{$method}['subMenu'])) ? $defaultLang->$module->menu->{$method}['subMenu'] : $defaultLang->mainNav;
  317. if(!empty($module) and isset($defaultLang->$module->menu->{$method}['menuOrder'])) $menus->menuOrder = $defaultLang->$module->menu->{$method}['menuOrder'];
  318. $menus = $this->sortMenus($menus);
  319. }
  320. return $menus;
  321. }
  322. /**
  323. * Sort menus.
  324. *
  325. * @param array|object $menus
  326. * @access public
  327. * @return array
  328. */
  329. public function sortMenus($menus)
  330. {
  331. if(!is_array($menus)) $menus = (array)$menus;
  332. if(!isset($menus['menuOrder'])) return $menus;
  333. $sortedMenus = array();
  334. $menuOrders = $menus['menuOrder'];
  335. ksort($menuOrders);
  336. foreach($menuOrders as $menuKey)
  337. {
  338. if($menuKey == 'project')
  339. {
  340. $projectTypeList = array('scrum', 'waterfall', 'kanbanProject');
  341. foreach($projectTypeList as $projectType)
  342. {
  343. if(isset($menus[$projectType])) $sortedMenus[$projectType] = $menus[$projectType];
  344. }
  345. }
  346. if(isset($menus[$menuKey])) $sortedMenus[$menuKey] = $menus[$menuKey];
  347. }
  348. $sortedMenus = array_merge($sortedMenus, $menus);
  349. return $sortedMenus;
  350. }
  351. /**
  352. * Get original lang.
  353. *
  354. * @param string $type
  355. * @param string $module
  356. * @param string $method
  357. * @param string $language
  358. * @access public
  359. * @return array
  360. */
  361. public function getOriginalLang($type, $module = '', $method = '', $language = 'zh-cn')
  362. {
  363. if(empty($language)) $language = $this->app->getClientLang();
  364. $originalLangs = array();
  365. $defaultLang = $this->loadDefaultLang($language);
  366. if($type == 'tag')
  367. {
  368. if(in_array($module, $this->config->dev->projectMenus)) $module = 'project';
  369. $this->defaultLang = $defaultLang;
  370. $defaultLang = $this->loadDefaultLang($language, $module);
  371. }
  372. $lang = new stdClass();
  373. $langKey = '';
  374. if($type == 'common')
  375. {
  376. if($this->config->vision == 'rnd')
  377. {
  378. $projectKey = (int)$this->loadModel('setting')->getItem('owner=system&key=sprintConcept');
  379. $originalLangs['productCommon'] = $this->config->productCommonList[$language][PRODUCT_KEY];
  380. $originalLangs['projectCommon'] = $this->config->projectCommonList[$language][PROJECT_KEY];
  381. $originalLangs['executionCommon'] = $this->config->executionCommonList[$language][$projectKey];
  382. $originalLangs['ERCommon'] = $this->lang->dev->ER;
  383. $originalLangs['URCommon'] = $this->lang->dev->UR;
  384. $originalLangs['SRCommon'] = $this->lang->dev->SR;
  385. $URSRList = $this->loadModel('custom')->getItems("lang={$language}&module=custom&section=URSRList&key={$this->config->custom->URSR}&vision={$this->config->vision}");
  386. if(empty($URSRList)) $URSRList = $this->custom->getItems("lang={$language}&module=custom&section=URSRList&vision={$this->config->vision}");
  387. $URSRList = array_shift($URSRList);
  388. if($URSRList)
  389. {
  390. $URSRList = json_decode($URSRList->value);
  391. $originalLangs['ERCommon'] = isset($URSRList->defaultERName) ? $URSRList->defaultERName : $URSRList->ERName;
  392. $originalLangs['URCommon'] = isset($URSRList->defaultURName) ? $URSRList->defaultURName : $URSRList->URName;
  393. $originalLangs['SRCommon'] = isset($URSRList->defaultSRName) ? $URSRList->defaultSRName : $URSRList->SRName;
  394. }
  395. if(!$this->config->URAndSR) unset($originalLangs['URCommon']);
  396. if(!$this->config->enableER) unset($originalLangs['ERCommon']);
  397. }
  398. else
  399. {
  400. $originalLangs['projectCommon'] = $this->config->projectCommonList[$language][PROJECT_KEY];
  401. }
  402. }
  403. elseif($type == 'tag')
  404. {
  405. if(!isset($defaultLang->$module->featureBar)) return $originalLangs;
  406. if($this->config->vision == 'lite' and isset($this->config->dev->liteTagMethod["$module-$method"])) $method = $this->config->dev->liteTagMethod["$module-$method"];
  407. $langKey = 'featureBar-' . $method . '_';
  408. $featureBars = zget($defaultLang->$module->featureBar, $method, array());
  409. if(strpos($method, '_') !== false)
  410. {
  411. $langKey = 'featureBar-' . str_replace('_', '-', $method) . '_';
  412. list($subMethod, $thirdMethod) = explode('_', $method);
  413. $featureBars = $defaultLang->$module->featureBar[$subMethod][$thirdMethod];
  414. }
  415. foreach($featureBars as $feature => $featureName)
  416. {
  417. if(isset($this->config->dev->skipTags["$module-$method"]) and in_array($feature, $this->config->dev->skipTags["$module-$method"])) continue;
  418. $moreSelectsTags = isset($defaultLang->{$module}->moreSelects[$method][$feature]) ? $defaultLang->{$module}->moreSelects[$method][$feature] : '';
  419. if($moreSelectsTags)
  420. {
  421. foreach($moreSelectsTags as $tagKey => $tagName) $originalLangs["moreSelects-{$method}-{$feature}_" . $tagKey] = $tagName;
  422. continue;
  423. }
  424. $originalLangs[$langKey . $feature] = $featureName;
  425. }
  426. }
  427. else
  428. {
  429. $lang = $this->getNavLang($type, $module, $method, $language, $defaultLang);
  430. $langKey = $type == 'first' ? 'mainNav_' : ($type == 'third' ? "{$method}_" : '');
  431. $menus = $this->getLinkTitle($lang);
  432. foreach($menus as $linkKey => $menu)
  433. {
  434. foreach($this->config->dev->skipMenus as $menuType => $skipMenus)
  435. {
  436. if($type == $menuType and in_array($linkKey, $skipMenus)) continue 2;
  437. }
  438. if(in_array($module, array('scrum', 'waterfall', 'execution')) and in_array($linkKey, $this->config->dev->skipMenus[$module])) continue;
  439. if($menu == '@branch@') $menu = $this->lang->dev->branch;
  440. $originalLangs[$langKey . $linkKey] = $menu;
  441. }
  442. }
  443. return $originalLangs;
  444. }
  445. /**
  446. * Get customed lang.
  447. *
  448. * @param string $type
  449. * @param string $module
  450. * @param string $method
  451. * @param string $language
  452. * @access public
  453. * @return array
  454. */
  455. public function getCustomedLang($type, $module = '', $method = '', $language = 'zh-cn')
  456. {
  457. $customedLangs = array();
  458. $langKey = '';
  459. $customeds = array();
  460. switch($type)
  461. {
  462. case 'common':
  463. $customeds = $this->loadModel('custom')->getItems("lang={$language}&module=common&section=&vision={$this->config->vision}");
  464. foreach($customeds as $customed) $customedLangs[$customed->key] = $customed->value;
  465. $customedLangs['URCommon'] = $this->lang->dev->UR == $this->lang->URCommon ? '' : $this->lang->URCommon;
  466. $customedLangs['SRCommon'] = $this->lang->dev->SR == $this->lang->SRCommon ? '' : $this->lang->SRCommon;
  467. $URSRList = $this->custom->getItems("lang={$language}&module=custom&section=URSRList&key={$this->config->custom->URSR}&vision={$this->config->vision}");
  468. if(empty($URSRList)) $URSRList = $this->custom->getItems("lang={$language}&module=custom&section=URSRList&vision={$this->config->vision}");
  469. $URSRList = array_shift($URSRList);
  470. if($URSRList)
  471. {
  472. $URSRList = json_decode($URSRList->value);
  473. $defaultERName = isset($URSRList->defaultERName) ? $URSRList->defaultERName : $URSRList->ERName;
  474. $defaultURName = isset($URSRList->defaultURName) ? $URSRList->defaultURName : $URSRList->URName;
  475. $defaultSRName = isset($URSRList->defaultSRName) ? $URSRList->defaultSRName : $URSRList->SRName;
  476. $customedLangs['ERCommon'] = $defaultERName == $URSRList->ERName ? '' : $URSRList->ERName;
  477. $customedLangs['URCommon'] = $defaultURName == $URSRList->URName ? '' : $URSRList->URName;
  478. $customedLangs['SRCommon'] = $defaultSRName == $URSRList->SRName ? '' : $URSRList->SRName;
  479. }
  480. if(!$this->config->enableER) unset($customedLangs['ERCommon']);
  481. if(!$this->config->URAndSR) unset($customedLangs['URCommon']);
  482. break;
  483. case 'first':
  484. $customeds = $this->loadModel('custom')->getItems("lang={$language}&module=common&section=mainNav&vision={$this->config->vision}");
  485. $langKey = 'mainNav_';
  486. break;
  487. case 'second':
  488. $customeds = $this->loadModel('custom')->getItems("lang={$language}&module={$module}Menu&vision={$this->config->vision}");
  489. break;
  490. case 'third':
  491. $customeds = $this->loadModel('custom')->getItems("lang={$language}&module={$module}SubMenu&section=$method&vision={$this->config->vision}");
  492. $langKey = "{$method}_";
  493. break;
  494. case 'tag':
  495. if($this->config->vision == 'lite' and isset($this->config->dev->liteTagMethod["$module-$method"])) $method = $this->config->dev->liteTagMethod["$module-$method"];
  496. $method = str_replace('_', '-', $method);
  497. $customeds['featureBar'] = $this->loadModel('custom')->getItems("lang={$language}&module={$module}&section=featureBar-$method&vision={$this->config->vision}");
  498. $customeds['moreSelects'] = $this->dao->select('*')->from(TABLE_LANG)->where('`lang`')->eq($language)->andWhere('module')->eq($module)->andWhere('section')->like("moreSelects-$method%")->andWhere('vision')->eq($this->config->vision)->fetchAll();
  499. break;
  500. }
  501. foreach($customeds as $customType => $customed)
  502. {
  503. if(is_array($customed))
  504. {
  505. foreach($customed as $row)
  506. {
  507. $langKey = $customType == 'featureBar' ? "featureBar-{$method}_" : $row->section . '_';
  508. $rowKey = $row->key;
  509. $customedLangs[$langKey . $rowKey] = $row->value;
  510. }
  511. }
  512. else
  513. {
  514. $customedKey = $customed->key;
  515. if($type == 'second') $customedKey = $customed->section . '_' . $customed->key;
  516. $customedLangs[$langKey . $customedKey] = $customed->value;
  517. }
  518. }
  519. return $customedLangs;
  520. }
  521. /**
  522. * Trim asterisks and whitespace from the beginning and whitespace from the end of lines.
  523. *
  524. * @param string $line
  525. * @access public
  526. * @return string
  527. */
  528. public function trimSpace($line)
  529. {
  530. return ltrim(rtrim($line), "* \t\n\r\0\x0B");
  531. }
  532. /**
  533. * Load default lang.
  534. *
  535. * @param string $language
  536. * @param string $module
  537. * @access public
  538. * @return object
  539. */
  540. public function loadDefaultLang($language = 'zh-cn', $module = 'common')
  541. {
  542. if(empty($language)) $language = 'zh-cn';
  543. if(empty($module)) $module = 'common';
  544. if($module != 'common' and !isset($this->defaultLang)) return null;
  545. $clientLang = $this->app->clientLang;
  546. if($language and $language != $clientLang) $this->app->clientLang = $language;
  547. $langFilesToLoad = $this->app->getMainAndExtFiles($module);
  548. if($language != $clientLang) $this->app->clientLang = $clientLang;
  549. if(empty($langFilesToLoad)) return false;
  550. $lang = $module == 'common' ? new language() : $this->defaultLang;
  551. $lang->ERCommon = '$ERCOMMON';
  552. $lang->URCommon = '$URCOMMON';
  553. $lang->SRCommon = '$SRCOMMON';
  554. $lang->productCommon = '$PRODUCTCOMMON';
  555. $lang->projectCommon = '$PROJECTCOMMON';
  556. $lang->executionCommon = '$EXECUTIONCOMMON';
  557. $lang->hourCommon = $this->lang->hourCommon;
  558. if(!isset($lang->common)) $lang->common = new stdclass();
  559. foreach($langFilesToLoad as $langFile) include $langFile;
  560. return $lang;
  561. }
  562. /**
  563. * Get second menus.
  564. *
  565. * @param string $menu
  566. * @param string $module
  567. * @param string $method
  568. * @access public
  569. * @return array
  570. */
  571. public function getSecondMenus($menu, $module = '', $method = '')
  572. {
  573. $menus = array();
  574. if($menu == 'project')
  575. {
  576. $menusPinYin = common::convert2Pinyin($this->lang->dev->projectMenu);
  577. foreach($this->config->dev->projectMenus as $subMenuKey) $menus[] = $this->getMenuObject($this->lang->dev->projectMenu[$subMenuKey], $subMenuKey, '', ($module == $subMenuKey and $method == ''), $menusPinYin);
  578. }
  579. return $menus;
  580. }
  581. /**
  582. * Get third menus.
  583. *
  584. * @param string $menu
  585. * @param string $module
  586. * @param string $method
  587. * @access public
  588. * @return array
  589. */
  590. public function getThirdMenus($menu, $module = '', $method = '')
  591. {
  592. $menus = array();
  593. if(!isset($this->lang->$menu->menu)) return $menus;
  594. if(isset($this->lang->$menu->menuOrder)) $this->lang->$menu->menu->menuOrder = $this->lang->$menu->menuOrder;
  595. $menuLang = $this->getLinkTitle($this->lang->$menu->menu);
  596. $menusPinYin = common::convert2Pinyin($menuLang);
  597. foreach($menuLang as $menuKey => $menuName)
  598. {
  599. if(!isset($this->lang->$menu->menu->{$menuKey}['subMenu']) or (is_object($this->lang->$menu->menu->{$menuKey}['subMenu']) and !get_object_vars($this->lang->$menu->menu->{$menuKey}['subMenu']))) continue;
  600. $menus[] = $this->getMenuObject($menuName, $menu, $menuKey, ($module == $menu and $method == $menuKey), $menusPinYin);
  601. }
  602. return $menus;
  603. }
  604. /**
  605. * Get tags.
  606. *
  607. * @param string $menu
  608. * @param string $module
  609. * @param string $method
  610. * @access public
  611. * @return array
  612. */
  613. public function getTagMenus($module, $moduleName = '', $methodName = '')
  614. {
  615. $menus = array();
  616. if(!$module or ($this->config->vision == 'lite' and $module == 'execution')) return $menus;
  617. $titleList = array();
  618. $tagMethods = array();
  619. /* Convenience secondary menu. */
  620. foreach(array('homeMenu', 'menu') as $menu)
  621. {
  622. if(!isset($this->lang->$module->$menu)) continue;
  623. /* Sort menu. */
  624. $menuList = $this->lang->$module->$menu;
  625. if($menu == 'menu' and isset($this->lang->$module->menuOrder))
  626. {
  627. $menuList->menuOrder = $this->lang->$module->menuOrder;
  628. $menuList = $this->sortMenus($menuList);
  629. }
  630. if(!is_array($menuList)) $menuList = (array)$menuList;
  631. /* Construct menu tree. */
  632. foreach($menuList as $menuKey => $menuValue)
  633. {
  634. $link = $this->getLinkParams($menuValue);
  635. if(!$link) continue;
  636. list($label, $thisModule, $thisMethod) = $link;
  637. /* Replace menu params. */
  638. if(isset($this->config->dev->linkMethods[$module]["{$thisModule}-{$thisMethod}"]))
  639. {
  640. list($thisModule, $thisMethod) = $this->config->dev->linkMethods[$module]["{$thisModule}-{$thisMethod}"];
  641. }
  642. if($this->config->vision == 'lite' and $module == 'kanbanProject' and $thisMethod == 'index') continue;
  643. $subMenu = $this->getMenuObject($label, $thisModule, $thisMethod, ($methodName == $thisMethod and $moduleName == $thisModule));
  644. $titleList[] = $subMenu->title;
  645. $tagMethods[] = $thisMethod;
  646. /* Set three-level menu. */
  647. $this->app->loadLang($thisModule);
  648. $hasFeatureBar = false;
  649. if(isset($this->lang->$thisModule->featureBar[$thisMethod])) $hasFeatureBar = true;
  650. if(is_array($menuValue))
  651. {
  652. /* Convenience third menu and secondary drop menu. */
  653. foreach(array('subMenu', 'dropMenu') as $menu)
  654. {
  655. if(!isset($menuValue[$menu])) continue;
  656. if($menu == 'subMenu' and isset($menuValue['menuOrder']))
  657. {
  658. $menuValue[$menu]->menuOrder = $menuValue['menuOrder'];
  659. $menuValue[$menu] = $this->sortMenus($menuValue[$menu]);
  660. }
  661. foreach($menuValue[$menu] as $subMenuKey => $subMenuValue)
  662. {
  663. $link = $this->getLinkParams($subMenuValue);
  664. if(!$link) continue;
  665. list($label, $thisModule, $thisMethod) = $link;
  666. if($label == '@branch@') $label = $this->lang->dev->branch;
  667. /* Get the three-level menu under the drop menu. */
  668. $moduleList = array($thisModule);
  669. if(isset($subMenuValue['subModule'])) $moduleList = array_merge($moduleList, explode(',', $subMenuValue['subModule']));
  670. $moduleList = array_unique($moduleList);
  671. foreach($moduleList as $moduleKey)
  672. {
  673. if(empty($moduleKey)) continue;
  674. if(isset($menuList[$subMenuKey]) and isset($menuList[$subMenuKey]['subMenu']) and isset($menuList[$subMenuKey]['subMenu']->$moduleKey))
  675. {
  676. $labelList = $this->getLinkTitle(array($moduleKey => $menuList[$subMenuKey]['subMenu']->$moduleKey));
  677. $label = zget($labelList, $moduleKey, $label);
  678. }
  679. $this->app->loadLang($moduleKey);
  680. /* Construct secondary menu subitems. */
  681. if(isset($this->lang->$moduleKey->featureBar[$menuKey][$subMenuKey]))
  682. {
  683. $titleList[] = $label;
  684. $tagMethods[] = $thisMethod;
  685. $methodKey = "{$thisMethod}_{$subMenuKey}";
  686. $subMenu->children[] = $this->getMenuObject($label, $moduleKey, $methodKey, ($methodName == $methodKey and $moduleName == $moduleKey));
  687. $hasFeatureBar = true;
  688. }
  689. /* Replace secondary menu. */
  690. if(isset($this->lang->$moduleKey->featureBar[$thisMethod]))
  691. {
  692. if(is_array($this->lang->$moduleKey->featureBar[$thisMethod]))
  693. {
  694. $arrayKey = key($this->lang->$moduleKey->featureBar[$thisMethod]);
  695. if(is_array($this->lang->$moduleKey->featureBar[$thisMethod][$arrayKey])) continue;
  696. }
  697. $titleList[] = $label;
  698. $tagMethods[] = $thisMethod;
  699. $subMenu = $this->getMenuObject($label, $moduleKey, $thisMethod, ($methodName == $thisMethod and $moduleName == $moduleKey));
  700. $menus["$moduleKey-$thisMethod"] = $subMenu;
  701. $hasFeatureBar = false;
  702. }
  703. }
  704. }
  705. }
  706. }
  707. if($hasFeatureBar) $menus[$menuKey] = $subMenu;
  708. }
  709. }
  710. /* Merge other feature bar menu tree. */
  711. if($this->config->vision == 'rnd' or in_array($module, $this->config->dev->onlyMainMenu))
  712. {
  713. $this->app->loadLang($module);
  714. if(isset($this->lang->$module->featureBar))
  715. {
  716. foreach($this->lang->$module->featureBar as $method => $tags)
  717. {
  718. if(in_array($method, $tagMethods)) continue;
  719. $label = zget($this->lang->$module, $method, $this->lang->$module->common);
  720. $titleList[] = $label;
  721. $tagMethods[] = $method;
  722. $menus[$method] = $this->getMenuObject($label, $module, $method, ($methodName == $method and $moduleName == $module));
  723. }
  724. }
  725. }
  726. $titlePinYin = common::convert2Pinyin($titleList);
  727. foreach($menus as &$menu) $menu->key = !empty($titlePinYin) ? zget($titlePinYin, $menu->title, '') : '';
  728. return $menus;
  729. }
  730. /**
  731. * Get menu tree.
  732. *
  733. * @param string $type
  734. * @param string $module
  735. * @param string $method
  736. * @access public
  737. * @return array
  738. */
  739. public function getMenuTree($type = 'second', $module = '', $method = '')
  740. {
  741. $menuTree = array();
  742. if(!in_array($type, $this->config->dev->navTypes)) return $menuTree;
  743. $mainNav = $type == 'second' ? $this->lang->mainNav : array();
  744. if($this->config->vision != 'open' and $type == 'second')
  745. {
  746. $flowNav = $this->dao->select('module')->from(TABLE_WORKFLOW)
  747. ->where('buildin')->eq(0)
  748. ->andWhere('vision')->eq($this->config->vision)
  749. ->andWhere('navigator')->in('primary,secondary')
  750. ->fetchPairs();
  751. foreach($flowNav as $nav) unset($mainNav->$nav);
  752. }
  753. if($type != 'second')
  754. {
  755. /* Set main nav list. */
  756. foreach($this->lang->mainNav as $menuKey => $menu)
  757. {
  758. if($menuKey == 'project')
  759. {
  760. foreach($this->config->dev->projectMenus as $subMenuKey) $mainNav[$subMenuKey] = $this->lang->dev->projectMenu[$subMenuKey];
  761. }
  762. $mainNav[$menuKey] = $menu;
  763. }
  764. }
  765. /* Get menu tree by menu setting. */
  766. $mainNav = $this->getLinkTitle($mainNav);
  767. $mainNavPinYin = common::convert2Pinyin($mainNav);
  768. foreach($mainNav as $menuKey => $menu)
  769. {
  770. $menuItem = $this->getMenuObject($menu, $menuKey, '', ($module == $menuKey and $method == ''), $mainNavPinYin);
  771. $childFunc = 'get' . ucfirst($type) . 'Menus';
  772. if($type == 'tag' and in_array($menuKey, $this->config->dev->projectMenus))
  773. {
  774. if($menuKey != 'project') continue;
  775. foreach($this->config->dev->projectMenus as $projectModule)
  776. {
  777. $children = $this->getTagMenus($projectModule, $module, $method);
  778. $menuItem->children = array_merge($menuItem->children, $children);
  779. }
  780. }
  781. else
  782. {
  783. $menuItem->children = $this->$childFunc($menuKey, $module, $method);
  784. }
  785. $menuItem->children = array_values($menuItem->children);
  786. if($type != 'second' and empty($menuItem->children)) continue;
  787. if($type == 'second' and in_array($menuKey, $this->config->dev->hideMainMenu)) continue;
  788. $menuTree[] = $menuItem;
  789. }
  790. /* Unique menu tree by module and method. */
  791. if($type == 'tag')
  792. {
  793. $methods = array();
  794. foreach($menuTree as $menuItem)
  795. {
  796. foreach($menuItem->children as $subIndex => $subMenuItem)
  797. {
  798. $key = "{$subMenuItem->module}|{$subMenuItem->method}";
  799. if(isset($methods[$key]))
  800. {
  801. unset($menuItem->children[$subIndex]);
  802. continue;
  803. }
  804. $methods[$key] = true;
  805. }
  806. $menuItem->children = array_values($menuItem->children);
  807. }
  808. }
  809. return $menuTree;
  810. }
  811. /**
  812. * Get links title.
  813. *
  814. * @param array $menus
  815. * @access public
  816. * @return void
  817. */
  818. public function getLinkTitle($menus)
  819. {
  820. $linksTitle = array();
  821. $menus = $this->sortMenus($menus);
  822. foreach($menus as $menuKey => $menu)
  823. {
  824. if(is_array($menu) and !isset($menu['link'])) continue;
  825. $link = is_array($menu) ? strip_tags($menu['link']) : strip_tags($menu);
  826. $link = explode('|', $link);
  827. $linksTitle[$menuKey] = trim($link[0]);
  828. }
  829. return $linksTitle;
  830. }
  831. /**
  832. * Get link params.
  833. *
  834. * @param string $link
  835. * @access public
  836. * @return array|bool
  837. */
  838. public function getLinkParams($link)
  839. {
  840. if(is_array($link))
  841. {
  842. if(!isset($link['link'])) return false;
  843. $link = $link['link'];
  844. }
  845. if(strpos($link, '|') === false) return false;
  846. return explode('|', $link);
  847. }
  848. /**
  849. * Parse lang that with commonLang.
  850. *
  851. * @param string $lang
  852. * @access public
  853. * @return string|array
  854. */
  855. public function parseCommonLang($lang)
  856. {
  857. if(empty($lang)) return $lang;
  858. $reg = implode('|', str_replace('$', '\$', array_keys($this->config->custom->commonLang)));
  859. if(!preg_match("/($reg)/", $lang)) return $lang;
  860. $lang = preg_replace("/($reg)/", '$$$1$$', $lang);
  861. $subLangs = array_filter(explode('$$', $lang));
  862. return array_values($subLangs);
  863. }
  864. /**
  865. * Check original lang changed.
  866. *
  867. * @param string|array $defaultValue
  868. * @param string|array $customedLang
  869. * @access public
  870. * @return bool
  871. */
  872. public function isOriginalLangChanged($defaultValue, $customedLang)
  873. {
  874. if(empty($customedLang)) return false;
  875. if(!is_array($defaultValue) and !is_array($customedLang)) return false;
  876. if(!is_array($defaultValue) and is_array($customedLang)) return true;
  877. if(!is_array($customedLang) or count($defaultValue) != count($customedLang)) return true;
  878. $commonLang = $this->config->custom->commonLang;
  879. foreach($defaultValue as $i => $subLang)
  880. {
  881. if(!isset($customedLang[$i])) return true;
  882. $customedSubLang = $customedLang[$i];
  883. if(!isset($commonLang[$subLang]) and isset($commonLang[$customedSubLang])) return true;
  884. if(isset($commonLang[$subLang]) and !isset($commonLang[$customedSubLang])) return true;
  885. if(isset($commonLang[$subLang]) and $subLang != $customedSubLang) return true;
  886. }
  887. return false;
  888. }
  889. /**
  890. * Save customed lang.
  891. *
  892. * @param string $type common|first|second|third|tag
  893. * @param string $moduleName
  894. * @param string $method
  895. * @param string $language zh-cn|zh-tw|en|fr|de
  896. * @access public
  897. * @return void
  898. */
  899. public function saveCustomedLang($type, $moduleName, $method, $language)
  900. {
  901. $section = '';
  902. if($type == 'common') $section = '&section=';
  903. if($type == 'first') $section = '&section=mainNav';
  904. if($type == 'tag')
  905. {
  906. $section = str_replace('_', '-', "&section=featureBar-{$method}");
  907. $this->dao->delete()->from(TABLE_LANG)->where('lang')->eq($language)->andWhere('module')->eq($moduleName)->andWhere('section')->like("moreSelects-$method%")->andWhere('vision')->eq($this->config->vision)->exec();
  908. }
  909. $key = '';
  910. if($type == 'common') $key = '&key=projectCommon,productCommon,executionCommon';
  911. $this->loadModel('custom')->deleteItems("lang={$language}&module={$moduleName}&vision={$this->config->vision}{$section}{$key}");
  912. $data = fixer::input('post')->get();
  913. foreach($data as $langKey => $customedLang)
  914. {
  915. if(strpos($langKey, "{$moduleName}_") !== 0) continue;
  916. if(is_array($customedLang))
  917. {
  918. $isCustomed = false;
  919. foreach($customedLang as $subLang)
  920. {
  921. if(!isset($this->config->custom->commonLang[$subLang]) and !empty($subLang)) $isCustomed = true;
  922. }
  923. $customedLang = $isCustomed ? implode(common::checkNotCN() ? ' ' : '', $customedLang) : '';
  924. }
  925. if(empty($customedLang)) continue;
  926. $this->custom->setItem("{$language}." . str_replace('_', '.', $langKey), $customedLang);
  927. }
  928. if($type == 'common' and $this->config->custom->URSR)
  929. {
  930. $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');
  931. $URSRList = $this->loadModel('custom')->getItems("lang={$language}&module=custom&section=URSRList&key={$this->config->custom->URSR}&vision={$this->config->vision}");
  932. if(empty($URSRList)) $URSRList = $this->custom->getItems("lang={$language}&module=custom&section=URSRList&vision={$this->config->vision}");
  933. $URSRList = array_shift($URSRList);
  934. $this->config->custom->URSR = $URSRList->key;
  935. $oldValue = json_decode($URSRList->value);
  936. $setting = array(
  937. 'SRName' => $this->post->common_SRCommon !== false ? $this->post->common_SRCommon : zget($oldValue, 'defaultSRName', $oldValue->SRName),
  938. 'URName' => $this->post->common_URCommon !== false ? $this->post->common_URCommon : zget($oldValue, 'defaultURName', $oldValue->URName),
  939. 'ERName' => $this->post->common_ERCommon !== false ? $this->post->common_ERCommon : zget($oldValue, 'defaultERName', $oldValue->ERName)
  940. );
  941. $this->custom->updateURAndSR($this->config->custom->URSR, $language, $setting);
  942. }
  943. }
  944. /**
  945. * Get tree menu object.
  946. *
  947. * @param string $label
  948. * @param string $module
  949. * @param string $method
  950. * @param bool $active
  951. * @param array $titlePinYin
  952. * @access public
  953. * @return object
  954. */
  955. public function getMenuObject($label, $module, $method, $active = false, $titlePinYin = array())
  956. {
  957. $menu = new stdclass();
  958. $menu->title = isset($this->lang->dev->replaceLable["$module-$method"]) ? $this->lang->dev->replaceLable["$module-$method"] : $label;
  959. $menu->key = !empty($titlePinYin) ? zget($titlePinYin, $menu->title, '') : '';
  960. $menu->module = $module;
  961. $menu->method = $method;
  962. $menu->active = (int)$active;
  963. $menu->children = array();
  964. return $menu;
  965. }
  966. /**
  967. * Get tree by type.
  968. *
  969. * @param string $currentObject
  970. * @param string $type module|table
  971. * @access public
  972. * @return array
  973. */
  974. public function getTree($currentObject, $type)
  975. {
  976. $tree = array();
  977. if(!in_array($type, array('module', 'table'))) return $tree;
  978. $currentModule = $this->app->getModuleName();
  979. $currentMethod = $this->app->getMethodName();
  980. $currentParamName = $type == 'module' ? 'module' : 'table';
  981. $objects = $type == 'module' ? $this->getModules() : $this->getTables();
  982. $groupList = array_merge($this->lang->dev->groupList, $this->lang->dev->endGroupList);
  983. foreach($groupList as $moduleKey => $moduleName)
  984. {
  985. if(empty($objects[$moduleKey])) continue;
  986. $module = new stdclass();
  987. $module->id = $moduleKey;
  988. $module->key = $moduleKey;
  989. $module->name = $moduleName;
  990. $module->url = '';
  991. $module->active = 0;
  992. $module->children = array();
  993. foreach($objects[$moduleKey] as $objectKey => $objectName)
  994. {
  995. $defaultValue = $type == 'module' ? $objectName : $this->config->db->prefix . $objectKey;
  996. $object = new stdclass();
  997. $object->id = $objectName;
  998. $object->key = $objectName;
  999. $object->name = zget($this->lang->dev->tableList, $objectKey, $defaultValue);
  1000. $object->url = helper::createLink($currentModule, $currentMethod, "{$currentParamName}={$objectName}");
  1001. $object->active = $objectName == $currentObject ? 1 : 0;
  1002. if($object->active) $module->active = 1;
  1003. $module->children[] = $object;
  1004. }
  1005. $tree[] = $module;
  1006. }
  1007. return $tree;
  1008. }
  1009. /**
  1010. * Create demo data.
  1011. *
  1012. * @param int $apiID
  1013. * @param string $version
  1014. * @access public
  1015. * @return int
  1016. */
  1017. public function getAPIData($apiID = 0, $version = '16.0')
  1018. {
  1019. $modules = $this->loadModel('api')->getDemoData('module', $version);
  1020. foreach($modules as $index => $module)
  1021. {
  1022. $modules[$module->order] = $module;
  1023. unset($modules[$index]);
  1024. $moduleiNames[$module->id] = $module->name;
  1025. }
  1026. ksort($modules);
  1027. $apis = $this->api->getDemoData('api', $version);
  1028. $structs = $this->api->getDemoData('apistruct', $version);
  1029. $restApi = new stdClass();
  1030. $moduleAPIs = array();
  1031. foreach($apis as $api)
  1032. {
  1033. if(!isset($moduleAPIs[$api->module])) $moduleAPIs[$api->module] = array();
  1034. $moduleAPIs[$api->module][] = $api;
  1035. if($api->id == $apiID)
  1036. {
  1037. $api->moduleName = zget($moduleiNames, $api->module, '');
  1038. $api->params = json_decode($api->params, true);
  1039. $api->response = json_decode($api->response, true);
  1040. $restApi = $api;
  1041. }
  1042. }
  1043. $typeList = array();
  1044. foreach($this->lang->api->paramsTypeOptions as $key => $item) $typeList[$key] = $item;
  1045. foreach($structs as $struct) $typeList[$struct->id] = $struct->name;
  1046. $this->loadModel('doc');
  1047. $treeMenu = array();
  1048. foreach($modules as $module)
  1049. {
  1050. $treeNode = new stdclass();
  1051. $treeNode->id = $module->id;
  1052. $treeNode->name = $module->name;
  1053. $treeNode->url = '';
  1054. $treeNode->active = 0;
  1055. $treeNode->children = array();
  1056. foreach($moduleAPIs[$module->id] as $moduleAPI)
  1057. {
  1058. $child = new stdclass();
  1059. $child->id = $moduleAPI->id;
  1060. $child->icon = 'icon-file-text';
  1061. $child->name = $moduleAPI->title;
  1062. $child->url = helper::createLink('dev', 'api', "module=restapi&apiID={$moduleAPI->id}");
  1063. $child->active = $apiID == $moduleAPI->id ? 1 : 0;
  1064. if($child->active) $treeNode->active = 1;
  1065. $treeNode->children[] = $child;
  1066. }
  1067. $treeMenu[] = $treeNode;
  1068. }
  1069. return array($restApi, $typeList, $treeMenu);
  1070. }
  1071. }