5a5dc3b2a179143acabcf2d8340ced7b12da2b41.svn-base 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | project.php 后台管理 项目管理
  5. |--------------------------------------------------------------------------
  6. */
  7. namespace MazeApp\Manage;
  8. use Maze;
  9. use Maze\Config\Project as Config;
  10. use Maze\Http\Input;
  11. //Maze::load('manage/auth.init');
  12. class Project
  13. {
  14. /**
  15. * get
  16. *
  17. * @return string
  18. */
  19. public function get()
  20. {
  21. $list = Config::read();
  22. //unset($list['manage']);
  23. /*
  24. 取消排序,放到数据表中排序
  25. $order = array();
  26. foreach($list as $v)
  27. {
  28. $order[] = $v['order'];
  29. }
  30. array_multisort($order, SORT_DESC, $list);
  31. */
  32. return $list;
  33. }
  34. /**
  35. * 生成key->value的形式
  36. *
  37. * @return string
  38. */
  39. public function key()
  40. {
  41. $list = Config::read();
  42. //unset($list['manage']);
  43. return $list;
  44. }
  45. /**
  46. * set
  47. *
  48. * @return string
  49. */
  50. public function set()
  51. {
  52. $config = $this->get();
  53. $key = Input::get('key');
  54. $index = Input::get('index', 'lang');
  55. $value = Input::get('value');
  56. Config::update($key, $index, $value);
  57. }
  58. /**
  59. * name
  60. *
  61. * @return string
  62. */
  63. public function name($key)
  64. {
  65. $project = Config::load($key);
  66. if($project)
  67. {
  68. return $project['lang'];
  69. }
  70. else
  71. {
  72. return $key;
  73. }
  74. }
  75. /**
  76. * config
  77. *
  78. * @return string
  79. */
  80. public function config($key)
  81. {
  82. $project = Config::load($key);
  83. if($project)
  84. {
  85. return $project;
  86. }
  87. else
  88. {
  89. return $key;
  90. }
  91. }
  92. /**
  93. * path
  94. *
  95. * @return string
  96. */
  97. public function path($key)
  98. {
  99. $project = Config::load($key);
  100. if($project)
  101. {
  102. return $project['path'];
  103. }
  104. else
  105. {
  106. return $key;
  107. }
  108. }
  109. /**
  110. * cron
  111. *
  112. * @return string
  113. */
  114. public function cron()
  115. {
  116. $time = MAZE_TIME;
  117. # 获取所有的计划任务
  118. $data = Maze::load('manage/cron-get', array('where_ldate' => $time));
  119. if($data)
  120. {
  121. # 比如属于weixin项目的group_list
  122. # weixin.mazephp.com/data.group_list
  123. foreach($data as $k => $v)
  124. {
  125. Maze::daemon($v['interface'], $v['project']);
  126. $param['where_id'] = $v['id'];
  127. $param['set_ldate'] = $time + $v['time'];
  128. if($v['time'] <= 0)
  129. {
  130. $param['set_state'] = 2;
  131. }
  132. Maze::load('manage/cron-update',$param);
  133. }
  134. }
  135. }
  136. }