|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* AbstractDialogLibrary.php |
|
5
|
|
|
* |
|
6
|
|
|
* Base class for javascript dialog libraries. |
|
7
|
|
|
* |
|
8
|
|
|
* @package jaxon-core |
|
9
|
|
|
* @author Thierry Feuzeu <[email protected]> |
|
10
|
|
|
* @copyright 2016 Thierry Feuzeu <[email protected]> |
|
11
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License |
|
12
|
|
|
* @link https://github.com/jaxon-php/jaxon-dialogs |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Jaxon\Dialogs\Dialog; |
|
16
|
|
|
|
|
17
|
|
|
use Jaxon\Plugin\Code\Scripts; |
|
18
|
|
|
|
|
19
|
|
|
use function Jaxon\Dialogs\dialog; |
|
20
|
|
|
|
|
21
|
|
|
abstract class AbstractLibrary |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* The dialog library helper |
|
25
|
|
|
* |
|
26
|
|
|
* @var LibraryHelper |
|
27
|
|
|
*/ |
|
28
|
|
|
private $xHelper = null; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* The css files |
|
32
|
|
|
* |
|
33
|
|
|
* @var array |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $aCssFiles = []; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* The js files |
|
39
|
|
|
* |
|
40
|
|
|
* @var array |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $aJsFiles = []; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Get the library name |
|
46
|
|
|
* |
|
47
|
|
|
* @return string |
|
48
|
|
|
*/ |
|
49
|
|
|
abstract public function getName(): string; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Get the helper |
|
53
|
|
|
* |
|
54
|
|
|
* @return LibraryHelper |
|
55
|
|
|
*/ |
|
56
|
|
|
public function helper(): LibraryHelper |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->xHelper ?: $this->xHelper = dialog()->getLibraryHelper($this->getName()); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Get the library base URI |
|
63
|
|
|
* |
|
64
|
|
|
* @return string |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getUri(): string |
|
67
|
|
|
{ |
|
68
|
|
|
return ''; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Get the CSS header code and file includes |
|
73
|
|
|
* |
|
74
|
|
|
* @return string |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getJs(): string |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->helper()->getJs($this->aJsFiles); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Get the javascript header code and file includes |
|
83
|
|
|
* |
|
84
|
|
|
* @return string |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getCss(): string |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->helper()->getCss($this->aCssFiles); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Get the javascript code to be printed into the page |
|
93
|
|
|
* |
|
94
|
|
|
* @return string |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getScript(): string |
|
97
|
|
|
{ |
|
98
|
|
|
return ''; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Get the javascript code to be executed on page load |
|
103
|
|
|
* |
|
104
|
|
|
* @return Scripts|null |
|
105
|
|
|
*/ |
|
106
|
|
|
public function getScripts(): ?Scripts |
|
107
|
|
|
{ |
|
108
|
|
|
$xScripts = new Scripts(); |
|
109
|
|
|
$xScripts->sJs = $this->helper()->getScript(); |
|
110
|
|
|
return $xScripts; |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|