1: <?php
2:
3: namespace WebLoader\Nette;
4:
5: use Nette\Utils\Html;
6:
7: /**
8: * Css loader
9: *
10: * @author Jan Marek
11: * @license MIT
12: */
13: class CssLoader extends WebLoader
14: {
15:
16: /** @var string */
17: private $media;
18:
19: /** @var string */
20: private $title;
21:
22: /** @var string */
23: private $type = 'text/css';
24:
25: /** @var bool */
26: private $alternate = FALSE;
27:
28: /**
29: * Get media
30: * @return string
31: */
32: public function getMedia()
33: {
34: return $this->media;
35: }
36:
37: /**
38: * Get type
39: * @return string
40: */
41: public function getType()
42: {
43: return $this->type;
44: }
45:
46: /**
47: * Get title
48: * @return string
49: */
50: public function getTitle()
51: {
52: return $this->title;
53: }
54:
55: /**
56: * Is alternate ?
57: * @return bool
58: */
59: public function isAlternate()
60: {
61: return $this->alternate;
62: }
63:
64: /**
65: * Set media
66: * @param string $media
67: * @return CssLoader
68: */
69: public function setMedia($media)
70: {
71: $this->media = $media;
72: return $this;
73: }
74:
75: /**
76: * Set type
77: * @param string $type
78: * @return CssLoader
79: */
80: public function setType($type)
81: {
82: $this->type = $type;
83: return $this;
84: }
85:
86: /**
87: * Set title
88: * @param string $title
89: * @return CssLoader
90: */
91: public function setTitle($title)
92: {
93: $this->title = $title;
94: return $this;
95: }
96:
97: /**
98: * Set alternate
99: * @param bool $alternate
100: * @return CssLoader
101: */
102: public function setAlternate($alternate)
103: {
104: $this->alternate = $alternate;
105: return $this;
106: }
107:
108: /**
109: * Get link element
110: * @param string $source
111: * @return Html
112: */
113: public function getElement($source)
114: {
115: if ($this->alternate) {
116: $alternate = ' alternate';
117: } else {
118: $alternate = '';
119: }
120:
121: return Html::el("link")->rel("stylesheet".$alternate)->type($this->type)->media($this->media)->title($this->title)->href($source);
122: }
123:
124: }
125: