Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
Application description:

App starts from "dispatch.php" entry point, which calls init.php from top of vesta 
project directory.

"app.init.php": loads all necessary files, used inside the application. (V_ROOT_DIR) constant
can be used from now on in every file, which contains project path (with triling slash at the end)
Files included by "app.init.php"
    -   'core/exceptions/SystemException.class.php';
    -   'core/exceptions/ProtectionException.class.php';
    -   'core/utils/Message.class.php';
    -   'core/Request.class.php';
    -   'api/AjaxHandler.php';

Main core file: AjaxHandler.class.php
After necessary files are included, AjaxHandler::getInstance()->dispatch(new Request()) is triggered. This
methods make all the processings. This method is wrapped by AjaxHandler::makeReply() which prepares and formats
the response.

AjaxHandler::getInstance()->dispatch(new Request()) - processes post/get params,
parsing jedi_method parameter and grabbing namespace and function names from it.

If jedi_method is parsed correctly, AjaxHandler loads $namespace.class.php and 
triggers its $function if exist. In case something went wrong, exception is thrown 
respectively.

$namespace stands for corresponding classes:
    -   CRON.class.php
    -   DB.class.php
    -   DNS.class.php
    -   IP.class.php
    -   MAIN.class.php
    -   USERS.class.php
    -   WEBDOMAIN.class.php

Each class contains collection of available methods for specific group.
Internal api calls to vesta, and other specific processing should be performed 
by Vesta.class.php

Developer reference:

In order to implement an action, you should:

API METHODS:
 Add function to the specific api namespace with postfix "$methodExecute".
   Execute mthods take $request object as first parameter, @see core/Request.class.php
    Eg.:
    class DNS extends MAIN{
    
        function aboutExecute($request){
            // .. processing
            $data = array('vestacp.com', 'vestacp.org');
            $result = true; // processed successfully or not
            $message = 'Optional message string';
            $extra = array('info' => 'optional info var, can be array, string, int');

            return $this->reply($result, $data, $message, $extra);
        }

    }

    $this->reply() formats the response, @see AjaxHandler.class.php

    That's it. Ajax reques will get a valid reply in the following format:
    {"result":true,"data":['vestacp.com', 'vestacp.org'],"message":"Optional message string","extra":{'info': 'optional info var, can be array, string, int'}}  



Minidiagram:
    1) dispatch.php is called
    2) app.init.php is included by dispatch.php
    3) app.init.php prepares environment:
        loads necessary files, AjaxHandler::getInstance()->dispatch(new Request())
    4) AjaxHandler::dispatch() parses post/get jedi_method parameters
    5) Api function is executed
    6) reply is returned, wrapped by AjaxHandler::makeReply()



JS:

action classes: do_action_ Eg: do_action_edit_ip