|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This class gives access to useful methods or objects of the framework. |
|
5
|
|
|
* Ubiquity\core |
|
6
|
|
|
* This class is part of Ubiquity |
|
7
|
|
|
* @author jcheron <[email protected]> |
|
8
|
|
|
* @version 1.0.3 |
|
9
|
|
|
* |
|
10
|
|
|
*/ |
|
11
|
|
|
namespace Ubiquity\core; |
|
12
|
|
|
|
|
13
|
|
|
use Ubiquity\controllers\Startup; |
|
14
|
|
|
use Ubiquity\controllers\Router; |
|
15
|
|
|
use Ubiquity\utils\http\URequest; |
|
16
|
|
|
use Ubiquity\utils\http\USession; |
|
17
|
|
|
use Ubiquity\utils\http\UCookie; |
|
18
|
|
|
use Ubiquity\orm\OrmUtils; |
|
19
|
|
|
use Ubiquity\translation\TranslatorManager; |
|
20
|
|
|
use Ubiquity\contents\normalizers\NormalizersManager; |
|
21
|
|
|
use Ubiquity\assets\AssetsManager; |
|
22
|
|
|
use Ubiquity\controllers\Controller; |
|
23
|
|
|
|
|
24
|
|
|
class Framework { |
|
25
|
|
|
public const version = '2.1.0'; |
|
26
|
|
|
|
|
27
|
4 |
|
public static function getVersion() { |
|
28
|
4 |
|
return self::version; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
4 |
|
public static function getController() { |
|
32
|
4 |
|
return Startup::getController (); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
5 |
|
public static function getAction() { |
|
36
|
5 |
|
return Startup::getAction (); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
4 |
|
public static function getUrl() { |
|
40
|
4 |
|
return \implode ( "/", Startup::$urlParts ); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
1 |
|
public static function getRouter() { |
|
44
|
1 |
|
return new Router (); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
1 |
|
public static function getORM() { |
|
48
|
1 |
|
return new OrmUtils (); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
1 |
|
public static function getRequest() { |
|
52
|
1 |
|
return new URequest (); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
1 |
|
public static function getSession() { |
|
56
|
1 |
|
return new USession (); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
1 |
|
public static function getCookies() { |
|
60
|
1 |
|
return new UCookie (); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
1 |
|
public static function getTranslator() { |
|
64
|
1 |
|
return new TranslatorManager (); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
1 |
|
public static function getNormalizer() { |
|
68
|
1 |
|
return new NormalizersManager (); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
4 |
|
public static function hasAdmin() { |
|
72
|
4 |
|
return \class_exists ( "controllers\Admin" ); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
1 |
|
public static function getAssets() { |
|
76
|
1 |
|
return new AssetsManager (); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Returns an instance of JsUtils initialized with Semantic (for di injection) |
|
81
|
|
|
* |
|
82
|
|
|
* @param Controller $controller |
|
83
|
|
|
* @param array $options |
|
84
|
|
|
* @return \Ajax\php\ubiquity\JsUtils |
|
85
|
|
|
*/ |
|
86
|
1 |
|
public static function diSemantic($controller, $options = ["defer"=>true,"gc"=>true]) { |
|
87
|
1 |
|
$jquery = new \Ajax\php\ubiquity\JsUtils ( $options, $controller ); |
|
88
|
1 |
|
$jquery->semantic ( new \Ajax\Semantic () ); |
|
89
|
1 |
|
$jquery->setAjaxLoader ( "<div class=\"ui active centered inline text loader\">Loading</div>" ); |
|
90
|
1 |
|
return $jquery; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Returns an instance of JsUtils initialized with Bootstrap (for di injection) |
|
95
|
|
|
* |
|
96
|
|
|
* @param Controller $controller |
|
97
|
|
|
* @param array $options |
|
98
|
|
|
* @return \Ajax\php\ubiquity\JsUtils |
|
99
|
|
|
*/ |
|
100
|
1 |
|
public static function diBootstrap($controller, $options = ["defer"=>true,"gc"=>true]) { |
|
101
|
1 |
|
$jquery = new \Ajax\php\ubiquity\JsUtils ( $options, $controller ); |
|
102
|
1 |
|
$jquery->bootstrap ( new \Ajax\Bootstrap () ); |
|
103
|
1 |
|
$jquery->setAjaxLoader ( "<div class=\"ui active centered inline text loader\">Loading</div>" ); |
|
104
|
1 |
|
return $jquery; |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
|