|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Jaxon\DI\Container; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* start.php - |
|
7
|
|
|
* |
|
8
|
|
|
* This file is automatically loaded by the Composer autoloader |
|
9
|
|
|
* |
|
10
|
|
|
* The Jaxon global functions are defined here, and the library is initialised. |
|
11
|
|
|
* |
|
12
|
|
|
* @package jaxon-core |
|
13
|
|
|
* @author Thierry Feuzeu <[email protected]> |
|
14
|
|
|
* @copyright 2016 Thierry Feuzeu <[email protected]> |
|
15
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License |
|
16
|
|
|
* @link https://github.com/jaxon-php/jaxon-core |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Return the only instance of the Jaxon/Jaxon class |
|
21
|
|
|
* |
|
22
|
|
|
* @return Jaxon\Jaxon |
|
23
|
|
|
*/ |
|
24
|
|
|
function jaxon() |
|
25
|
|
|
{ |
|
26
|
|
|
return Container::getInstance()->getJaxon(); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Translate a text to the selected language |
|
31
|
|
|
* |
|
32
|
|
|
* @param string $sText The text to translate |
|
33
|
|
|
* @param array $aPlaceHolders The placeholders in the text |
|
34
|
|
|
* @param string $sLanguage The language to translate to |
|
35
|
|
|
* |
|
36
|
|
|
* @return string |
|
37
|
|
|
*/ |
|
38
|
|
|
function jaxon_trans($sText, array $aPlaceHolders = [], $sLanguage = null) |
|
39
|
|
|
{ |
|
40
|
|
|
return Container::getInstance()->getTranslator()->trans($sText, $aPlaceHolders, $sLanguage); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Register a plugin |
|
45
|
|
|
* |
|
46
|
|
|
* @param Plugin $xPlugin An instance of a plugin |
|
47
|
|
|
* @param integer $nPriority The plugin priority, used to order the plugins |
|
48
|
|
|
* |
|
49
|
|
|
* @return void |
|
50
|
|
|
*/ |
|
51
|
|
|
function jaxon_register_plugin(\Jaxon\Plugin\Plugin $xPlugin, $nPriority = 1000) |
|
52
|
|
|
{ |
|
53
|
|
|
Container::getInstance()->getJaxon()->registerPlugin($xPlugin, $nPriority); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Get the single instance of the request factory |
|
58
|
|
|
* |
|
59
|
|
|
* @return Jaxon\Factory\Request |
|
60
|
|
|
*/ |
|
61
|
|
|
function rq($classname = null) |
|
62
|
|
|
{ |
|
63
|
|
|
return Container::getInstance()->getRequestFactory()->setClassName($classname); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Get the single instance of the request factory |
|
68
|
|
|
* |
|
69
|
|
|
* @return Jaxon\Factory\Parameter |
|
70
|
|
|
*/ |
|
71
|
|
|
function pr() |
|
72
|
|
|
{ |
|
73
|
|
|
return Container::getInstance()->getParameterFactory(); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Create a JQuery Element with a given selector |
|
78
|
|
|
* |
|
79
|
|
|
* The returned element is not linked to any Jaxon response, so this function shall be used |
|
80
|
|
|
* to insert jQuery code into a javascript function, or as a parameter of a Jaxon function call. |
|
81
|
|
|
* |
|
82
|
|
|
* @param string $sSelector The jQuery selector |
|
83
|
|
|
* @param string $sContext A context associated to the selector |
|
84
|
|
|
* |
|
85
|
|
|
* @return Jaxon\Response\Plugin\JQuery\Dom\Element |
|
86
|
|
|
*/ |
|
87
|
|
|
function jq($sSelector = '', $sContext = '') |
|
88
|
|
|
{ |
|
89
|
|
|
return new \Jaxon\Response\Plugin\JQuery\Dom\Element($sSelector, $sContext); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Create a JQuery Element with a given selector |
|
94
|
|
|
* |
|
95
|
|
|
* The returned element is not linked to any Jaxon response, so this function shall be used |
|
96
|
|
|
* to insert jQuery code into a javascript function, or as a parameter of a Jaxon function call. |
|
97
|
|
|
* |
|
98
|
|
|
* @param string $sSelector The jQuery selector |
|
99
|
|
|
* @param string $sContext A context associated to the selector |
|
100
|
|
|
* |
|
101
|
|
|
* @return Jaxon\Response\Plugin\JQuery\Dom\Element |
|
102
|
|
|
*/ |
|
103
|
|
|
function jQuery($sSelector = '', $sContext = '') |
|
104
|
|
|
{ |
|
105
|
|
|
return jq($sSelector, $sContext); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/* |
|
109
|
|
|
* Load the Jaxon request plugins |
|
110
|
|
|
*/ |
|
111
|
|
|
jaxon()->registerRequestPlugins(); |
|
112
|
|
|
|
|
113
|
|
|
/* |
|
114
|
|
|
* Load the Jaxon response plugins |
|
115
|
|
|
*/ |
|
116
|
|
|
jaxon()->registerResponsePlugins(); |
|
117
|
|
|
|