langs.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * The langs entry point of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Chunsheng Wang <chunsheng@cnezsoft.com>
  8. * @package entries
  9. * @version 1
  10. * @link https://www.zentao.net
  11. */
  12. class langsEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @access public
  18. * @return string
  19. */
  20. public function get()
  21. {
  22. $modules = $this->param('modules', '');
  23. $language = $this->param('lang', '');
  24. if($language and !isset($this->config->langs[$language])) return $this->sendError(400, 'Error lang parameter');
  25. if(empty($modules)) return $this->sendError(400, 'Need modules');
  26. if(empty($language)) $language = 'zh-cn';
  27. $this->app->setClientLang($language);
  28. global $filter;
  29. $rule = $filter->default->moduleName;
  30. $modules = explode(',', $modules);
  31. foreach($modules as $module)
  32. {
  33. if($module == 'all')
  34. {
  35. $loadedModule = array();
  36. foreach(glob($this->app->getModuleRoot() . '*') as $modulePath)
  37. {
  38. if(!is_dir($modulePath)) continue;
  39. $moduleName = basename($modulePath);
  40. if(!validater::checkByRule($moduleName, $rule)) continue;
  41. $this->app->loadLang($moduleName);
  42. $loadedModule[$moduleName] = $moduleName;
  43. }
  44. foreach(glob($this->app->getExtensionRoot() . '*') as $extensionPath)
  45. {
  46. if(!is_dir($extensionPath)) continue;
  47. $edition = basename($extensionPath);
  48. if($edition == 'lite') continue;
  49. if($edition == 'biz' or $edition == 'max')
  50. {
  51. if($this->config->edition == 'open') continue;
  52. if($this->config->edition != 'open' and $this->config->edition != $edition) continue;
  53. }
  54. foreach(glob($extensionPath . '/*') as $modulePath)
  55. {
  56. if(!is_dir($modulePath)) continue;
  57. $moduleName = basename($modulePath);
  58. if(!validater::checkByRule($moduleName, $rule)) continue;
  59. if(isset($loadedModule[$moduleName])) continue;
  60. $this->app->loadLang($moduleName);
  61. $loadedModule[$moduleName] = $moduleName;
  62. }
  63. }
  64. break;
  65. }
  66. if(validater::checkByRule($module, $rule)) $this->app->loadLang($module);
  67. }
  68. return $this->send(200, $this->lang);
  69. }
  70. }