1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Modules; |
4
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Modules\Html\Builder; |
6
|
|
|
use GeminiLabs\SiteReviews\Modules\Html\Form; |
7
|
|
|
use GeminiLabs\SiteReviews\Modules\Html\Partial; |
8
|
|
|
use GeminiLabs\SiteReviews\Modules\Html\Template; |
9
|
|
|
use GeminiLabs\SiteReviews\Modules\Notice; |
10
|
|
|
|
11
|
|
|
class Html |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var Builder |
15
|
|
|
*/ |
16
|
|
|
protected $builder; |
17
|
|
|
|
18
|
7 |
|
public function __construct( Builder $builder ) |
19
|
|
|
{ |
20
|
7 |
|
$this->builder = $builder; |
21
|
7 |
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @return Builder |
25
|
|
|
*/ |
26
|
|
|
public function build( array $globals = [] ) |
27
|
|
|
{ |
28
|
|
|
$this->builder->globals = $globals; |
29
|
|
|
$this->builder->render = false; |
30
|
|
|
return $this->builder; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param string $partialPath |
35
|
|
|
* @return string |
36
|
|
|
*/ |
37
|
|
|
public function buildPartial( $partialPath, array $args = [] ) |
38
|
|
|
{ |
39
|
|
|
return glsr( Partial::class )->build( $partialPath, $args ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param string $id |
44
|
|
|
* @return void|string |
45
|
|
|
*/ |
46
|
|
|
public function buildSettings( $id ) |
47
|
|
|
{ |
48
|
|
|
return glsr( Form::class )->buildFields( $id ); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param string $templatePath |
53
|
|
|
* @return void|string |
54
|
|
|
*/ |
55
|
7 |
|
public function buildTemplate( $templatePath, array $args = [] ) |
56
|
|
|
{ |
57
|
7 |
|
return glsr( Template::class )->build( $templatePath, $args ); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return Builder |
62
|
|
|
*/ |
63
|
7 |
|
public function render( array $globals = [] ) |
64
|
|
|
{ |
65
|
7 |
|
$this->builder->globals = $globals; |
66
|
7 |
|
$this->builder->render = true; |
67
|
7 |
|
return $this->builder; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return void |
72
|
|
|
*/ |
73
|
|
|
public function renderNotices() |
74
|
|
|
{ |
75
|
|
|
$this->render()->div( glsr( Notice::class )->get(), [ |
76
|
|
|
'id' => 'glsr-notices', |
77
|
|
|
]); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param string $partialPath |
82
|
|
|
* @return void |
83
|
|
|
*/ |
84
|
|
|
public function renderPartial( $partialPath, array $args = [] ) |
85
|
|
|
{ |
86
|
|
|
echo $this->buildPartial( $partialPath, $args ); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param string $id |
91
|
|
|
* @return void |
92
|
|
|
*/ |
93
|
|
|
public function renderSettings( $id ) |
94
|
|
|
{ |
95
|
|
|
echo $this->buildSettings( $id ); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param string $templatePath |
100
|
|
|
* @return void |
101
|
|
|
*/ |
102
|
|
|
public function renderTemplate( $templatePath, array $args = [] ) |
103
|
|
|
{ |
104
|
|
|
echo $this->buildTemplate( $templatePath, $args ); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|