README 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. Application description:
  2. App starts from "dispatch.php" entry point, which calls init.php from top of vesta
  3. project directory.
  4. "app.init.php": loads all necessary files, used inside the application. (V_ROOT_DIR) constant
  5. can be used from now on in every file, which contains project path (with triling slash at the end)
  6. Files included by "app.init.php"
  7. - 'core/exceptions/SystemException.class.php';
  8. - 'core/exceptions/ProtectionException.class.php';
  9. - 'core/utils/Message.class.php';
  10. - 'core/Request.class.php';
  11. - 'api/AjaxHandler.php';
  12. Main core file: AjaxHandler.class.php
  13. After necessary files are included, AjaxHandler::getInstance()->dispatch(new Request()) is triggered. This
  14. methods make all the processings. This method is wrapped by AjaxHandler::makeReply() which prepares and formats
  15. the response.
  16. AjaxHandler::getInstance()->dispatch(new Request()) - processes post/get params,
  17. parsing jedi_method parameter and grabbing namespace and function names from it.
  18. If jedi_method is parsed correctly, AjaxHandler loads $namespace.class.php and
  19. triggers its $function if exist. In case something went wrong, exception is thrown
  20. respectively.
  21. $namespace stands for corresponding classes:
  22. - CRON.class.php
  23. - DB.class.php
  24. - DNS.class.php
  25. - IP.class.php
  26. - MAIN.class.php
  27. - USERS.class.php
  28. - WEBDOMAIN.class.php
  29. Each class contains collection of available methods for specific group.
  30. Internal api calls to vesta, and other specific processing should be performed
  31. by Vesta.class.php
  32. Developer reference:
  33. In order to implement an action, you should:
  34. API METHODS:
  35. Add function to the specific api namespace with postfix "$methodExecute".
  36. Execute mthods take $request object as first parameter, @see core/Request.class.php
  37. Eg.:
  38. class DNS extends MAIN{
  39. function aboutExecute($request){
  40. // .. processing
  41. $data = array('vestacp.com', 'vestacp.org');
  42. $result = true; // processed successfully or not
  43. $message = 'Optional message string';
  44. $extra = array('info' => 'optional info var, can be array, string, int');
  45. return $this->reply($result, $data, $message, $extra);
  46. }
  47. }
  48. $this->reply() formats the response, @see AjaxHandler.class.php
  49. That's it. Ajax reques will get a valid reply in the following format:
  50. {"result":true,"data":['vestacp.com', 'vestacp.org'],"message":"Optional message string","extra":{'info': 'optional info var, can be array, string, int'}}
  51. Minidiagram:
  52. 1) dispatch.php is called
  53. 2) app.init.php is included by dispatch.php
  54. 3) app.init.php prepares environment:
  55. loads necessary files, AjaxHandler::getInstance()->dispatch(new Request())
  56. 4) AjaxHandler::dispatch() parses post/get jedi_method parameters
  57. 5) Api function is executed
  58. 6) reply is returned, wrapped by AjaxHandler::makeReply()
  59. JS:
  60. action classes: do_action_ Eg: do_action_edit_ip