| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Jaxon; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Jaxon\App\Ajax; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Jaxon\Exception\SetupException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Jaxon\Request\Factory\ParameterFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Jaxon\Request\Factory\JsCallFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Jaxon\Request\Js\Selector; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * start.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * This file is automatically loaded by the Composer autoloader | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * The Jaxon global functions are defined here, and the library is initialised. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * @package jaxon-core | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * @author Thierry Feuzeu <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * @copyright 2016 Thierry Feuzeu <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * @link https://github.com/jaxon-php/jaxon-core | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * Return the singleton instance of the Ajax class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  * @return Ajax | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | function jaxon(): Ajax | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     return Ajax::getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  * Factory for ajax calls to a registered PHP class or function. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  * @param string $sClassName | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  * @return JsCallFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  * @throws SetupException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | function rq(string $sClassName = ''): JsCallFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     return jaxon()->factory()->rq($sClassName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  * Get the factory for calls to a js object or function. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  * @param string $sJsObject | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  * @return JsCallFactory | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 54 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  | function js(string $sJsObject = ''): JsCallFactory | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |     return jaxon()->factory()->js($sJsObject, false); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  * Get the single instance of the parameter factory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  * @return ParameterFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | function pm(): ParameterFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     return jaxon()->factory()->pm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  * Create a JQuery Selector with a given path | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  * The returned element is not linked to any Jaxon response, so this function shall be used | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  * to insert jQuery's code into a javascript function, or as a parameter of a Jaxon function call. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  * @param string $sPath    The jQuery selector path | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  * @param mixed $xContext    A context associated to the selector | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  * @return Selector | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | function jq(string $sPath = '', $xContext = null): Selector | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     return new Selector($sPath, $xContext); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | // Register the Jaxon request and response plugins | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 87 |  |  | jaxon()->di()->getPluginManager()->registerPlugins(); | 
            
                                                        
            
                                    
            
            
                | 88 |  |  |  |