1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Grido (http://grido.bugyik.cz) |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2011 Petr Bugyík (http://petr.bugyik.cz) |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view |
9
|
|
|
* the file LICENSE.md that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Grido; |
13
|
|
|
|
14
|
|
|
use Nette\Object; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Customization. |
18
|
|
|
* |
19
|
|
|
* @package Grido |
20
|
|
|
* @author Petr Bugyík |
21
|
|
|
* |
22
|
|
|
* @property string|array $buttonClass |
23
|
|
|
* @property string|array $iconClass |
24
|
|
|
*/ |
25
|
|
|
class Customization extends Object |
26
|
1 |
|
{ |
27
|
|
|
|
28
|
|
|
/** @var string|array */ |
29
|
|
|
protected $buttonClass; |
30
|
|
|
|
31
|
|
|
/** @var string|array */ |
32
|
|
|
protected $iconClass; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param string|array $class |
36
|
|
|
* @return \Grido\Customization |
37
|
|
|
*/ |
38
|
|
|
public function setButtonClass($class) |
39
|
|
|
{ |
40
|
1 |
|
$this->buttonClass = $class; |
41
|
1 |
|
return $this; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param string|array $class |
46
|
|
|
* @return \Grido\Customization |
47
|
|
|
*/ |
48
|
|
|
public function setIconClass($class) |
49
|
|
|
{ |
50
|
1 |
|
$this->iconClass = $class; |
51
|
1 |
|
return $this; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return string |
56
|
|
|
*/ |
57
|
|
|
public function getButtonClass() |
58
|
|
|
{ |
59
|
1 |
|
return is_array($this->buttonClass) |
60
|
1 |
|
? implode(' ', $this->buttonClass) |
61
|
1 |
|
: $this->buttonClass; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param string $icon |
66
|
|
|
* @return string |
67
|
|
|
*/ |
68
|
|
|
public function getIconClass($icon = NULL) |
69
|
|
|
{ |
70
|
1 |
|
if ($icon === NULL) { |
71
|
1 |
|
$class = $this->iconClass; |
72
|
1 |
|
} else { |
73
|
1 |
|
$this->iconClass = (array) $this->iconClass; |
74
|
1 |
|
$classes = []; |
75
|
1 |
|
foreach ($this->iconClass as $fontClass) { |
76
|
1 |
|
$classes[] = "{$fontClass} {$fontClass}-{$icon}"; |
77
|
1 |
|
} |
78
|
1 |
|
$class = implode(' ', $classes); |
79
|
|
|
} |
80
|
|
|
|
81
|
1 |
|
return $class; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return array |
86
|
|
|
*/ |
87
|
|
|
public function getTemplateFiles() |
88
|
|
|
{ |
89
|
1 |
|
$list = []; |
90
|
1 |
|
foreach (new \DirectoryIterator(__DIR__ . '/templates') as $file) { |
91
|
1 |
|
if ($file->isFile()) { |
92
|
1 |
|
$list[$file->getBasename('.latte')] = realpath($file->getPathname()); |
93
|
1 |
|
} |
94
|
1 |
|
} |
95
|
|
|
|
96
|
1 |
|
return $list; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|