Ant.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. Lib::loadClass('RouteBase');
  3. Lib::loadClass('UI');
  4. Lib::loadClass('DBG');
  5. Lib::loadClass('Route_Ant');
  6. class Route_UrlAction_Ant extends Route_Ant {// @doc @see Route_Ant
  7. public function defaultAction() {
  8. UI::gora();
  9. UI::tag('h1', [], 'Ant');
  10. try {
  11. $taskList = $this->getAntUrlActionList();
  12. DBG::nicePrint($taskList, 'ant-url_action');
  13. $featureID = V::get('featureID', '', $_GET);
  14. $namespace = V::get('namespace', '', $_GET);
  15. // TODO: validate missing ...
  16. UI::startTag('ul');
  17. foreach ($taskList as $path => $label) {
  18. $link = "index.php?_route=UrlAction_Ant&_task=ant&path={$path}&namespace={$namespace}&featureID={$featureID}";
  19. echo UI::h('li', [], [
  20. UI::h('a', ['href'=>$link], "Uruchom '{$label}'")
  21. ]);
  22. }
  23. UI::endTag('ul');
  24. } catch (Exception $e) {
  25. UI::alert('danger', $e->getMessage());
  26. DBG::log($e);
  27. }
  28. UI::dol();
  29. }
  30. public function antAction() {
  31. UI::gora();
  32. try {
  33. echo UI::h('h1', [], "Ant action");
  34. $path = V::get('path', '', $_GET);
  35. if (!$path) throw new Exception("Missing Ant path!");
  36. $featureID = V::get('featureID', '', $_GET);
  37. $namespace = V::get('namespace', '', $_GET);
  38. // TODO: validate missing ...
  39. DBG::nicePrint($path, '$path');
  40. DBG::nicePrint($featureID, '$featureID');
  41. DBG::nicePrint($namespace, '$namespace');
  42. $taskList = $this->getAntUrlActionList();
  43. if (!array_key_exists($path, $taskList)) throw new Exception("Ant path not exists! '{$path}'");
  44. echo UI::h('hr');
  45. $cmd = "cd {$this->pathTools}{$path} && {$this->antBin} 2>&1";// wymaga java jdk
  46. DBG::nicePrint(str_replace(APP_PATH_ROOT, 'SE', $cmd), 'command');
  47. V::exec($cmd, $out, $ret);
  48. DBG::nicePrint($out, 'output');
  49. } catch (Exception $e) {
  50. UI::alert('danger', $e->getMessage());
  51. DBG::log($e);
  52. }
  53. UI::dol();
  54. }
  55. }