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