|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace CSSPrites\Generator; |
|
4
|
|
|
|
|
5
|
|
|
class CSSGenerator extends AbstractGenerator |
|
6
|
|
|
{ |
|
7
|
|
|
protected $imagename = ''; |
|
8
|
|
|
|
|
9
|
|
|
protected $selector = ''; |
|
10
|
|
|
protected $prefix = ''; |
|
11
|
|
|
|
|
12
|
|
|
protected $mainLine = ''; |
|
13
|
|
|
protected $spriteLine = ''; |
|
14
|
|
|
|
|
15
|
39 |
|
public function setImage($imagename) |
|
16
|
|
|
{ |
|
17
|
39 |
|
$this->imagename = $imagename; |
|
18
|
|
|
|
|
19
|
39 |
|
return $this; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
36 |
|
public function setSelector($value) |
|
23
|
|
|
{ |
|
24
|
36 |
|
$this->selector = $this->slugifier->slugify($value); |
|
25
|
|
|
|
|
26
|
36 |
|
return $this; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
36 |
|
public function setPrefix($value) |
|
30
|
|
|
{ |
|
31
|
36 |
|
$this->prefix = $this->slugifier->slugify($value); |
|
32
|
|
|
|
|
33
|
36 |
|
return $this; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
36 |
|
public function setMainLine($value) |
|
37
|
|
|
{ |
|
38
|
36 |
|
$this->mainLine = $value; |
|
39
|
|
|
|
|
40
|
36 |
|
return $this; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
36 |
|
public function setSpriteLine($value) |
|
44
|
|
|
{ |
|
45
|
36 |
|
$this->spriteLine = $value; |
|
46
|
|
|
|
|
47
|
36 |
|
return $this; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
24 |
|
public function getSelector() |
|
51
|
|
|
{ |
|
52
|
24 |
|
return $this->selector; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
24 |
|
public function getPrefix() |
|
56
|
|
|
{ |
|
57
|
24 |
|
return $this->prefix; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
33 |
|
public function addLine($filename, $x, $y, $w, $h) |
|
61
|
|
|
{ |
|
62
|
33 |
|
$this->content .= str_replace( |
|
63
|
33 |
|
['{{filename}}', '{{x}}', '{{y}}', '{{w}}', '{{h}}'], |
|
64
|
33 |
|
[$this->slugifier->slugify($filename), $x, $y, $w, $h], |
|
65
|
33 |
|
$this->spriteLine |
|
66
|
33 |
|
); |
|
67
|
|
|
|
|
68
|
33 |
|
return $this; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
27 |
|
public function process() |
|
72
|
|
|
{ |
|
73
|
27 |
|
$this->content = str_replace( |
|
74
|
27 |
|
['{{image}}', '{{selector}}', '{{prefix}}'], |
|
75
|
27 |
|
[$this->imagename, $this->selector, $this->prefix], |
|
76
|
27 |
|
$this->mainLine.$this->content |
|
77
|
27 |
|
); |
|
78
|
|
|
|
|
79
|
27 |
|
return $this->content; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|