1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Aimeos GmbH (aimeos.com), 2022 |
5
|
|
|
* @package Admin |
6
|
|
|
* @subpackage JQAdm |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\Admin\JQAdm\Settings\Theme; |
11
|
|
|
|
12
|
|
|
sprintf( 'theme' ); // for translation |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Default implementation of settings theme JQAdm client. |
17
|
|
|
* |
18
|
|
|
* @package Admin |
19
|
|
|
* @subpackage JQAdm |
20
|
|
|
*/ |
21
|
|
|
class Standard |
22
|
|
|
extends \Aimeos\Admin\JQAdm\Common\Admin\Factory\Base |
23
|
|
|
implements \Aimeos\Admin\JQAdm\Common\Admin\Factory\Iface |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Saves the data |
27
|
|
|
* |
28
|
|
|
* @return string|null HTML output |
29
|
|
|
*/ |
30
|
|
|
public function save() : ?string |
31
|
|
|
{ |
32
|
|
|
$context = $this->context(); |
33
|
|
|
$site = $context->locale()->getSiteItem(); |
34
|
|
|
$theme = $site->getTheme() ?: 'default'; |
35
|
|
|
|
36
|
|
|
$site->setConfigValue( 'theme', $this->view()->param( 'theme/' . $theme, [] ) ); |
37
|
|
|
return null; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Returns the resource |
43
|
|
|
* |
44
|
|
|
* @return string|null HTML output |
45
|
|
|
*/ |
46
|
|
|
public function search() : ?string |
47
|
|
|
{ |
48
|
|
|
$context = $this->context(); |
49
|
|
|
$site = $context->locale()->getSiteItem(); |
50
|
|
|
$theme = $site->getTheme() ?: 'default'; |
51
|
|
|
|
52
|
|
|
$themeData = $site->getConfigValue( 'theme/' . $theme, [] ); |
53
|
|
|
$themeData = array_replace_recursive( $context->config()->get( 'client/html/theme-presets/' . $theme ), $themeData ); |
54
|
|
|
|
55
|
|
|
$view = $this->object()->data( $this->view() ); |
56
|
|
|
$view->themeData = $themeData; |
57
|
|
|
|
58
|
|
|
return $this->render( $view ); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Returns the sub-client given by its name. |
64
|
|
|
* |
65
|
|
|
* @param string $type Name of the client type |
66
|
|
|
* @param string|null $name Name of the sub-client (Default if null) |
67
|
|
|
* @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
68
|
|
|
*/ |
69
|
|
|
public function getSubClient( string $type, string $name = null ) : \Aimeos\Admin\JQAdm\Iface |
70
|
|
|
{ |
71
|
|
|
return $this->createSubClient( 'settings/theme/' . $type, $name ); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Returns the list of sub-client names configured for the client. |
77
|
|
|
* |
78
|
|
|
* @return array List of JQAdm client names |
79
|
|
|
*/ |
80
|
|
|
protected function getSubClientNames() : array |
81
|
|
|
{ |
82
|
|
|
return $this->context()->config()->get( 'admin/jqadm/settings/theme/subparts', [] ); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Returns the rendered template including the view data |
88
|
|
|
* |
89
|
|
|
* @param \Aimeos\Base\View\Iface $view View object with data assigned |
90
|
|
|
* @return string HTML output |
91
|
|
|
*/ |
92
|
|
|
protected function render( \Aimeos\Base\View\Iface $view ) : string |
93
|
|
|
{ |
94
|
|
|
$tplconf = 'admin/jqadm/settings/theme/template-item'; |
95
|
|
|
$default = 'settings/item-theme'; |
96
|
|
|
|
97
|
|
|
return $view->render( $view->config( $tplconf, $default ) ); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|