/
HtmlHeaderAddPackageTag.php
64 lines (52 loc) · 1.94 KB
/
HtmlHeaderAddPackageTag.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* <!--
* This file is part of the adventure php framework (APF) published under
* https://adventure-php-framework.org.
*
* The APF is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The APF is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the APF. If not, see http://www.gnu.org/licenses/lgpl-3.0.txt.
* -->
*/
namespace APF\extensions\htmlheader\pres\taglib;
use APF\core\pagecontroller\Document;
use APF\extensions\htmlheader\biz\CssPackageNode;
use APF\extensions\htmlheader\biz\HtmlHeaderManager;
use APF\extensions\htmlheader\biz\JsPackageNode;
/**
* Enables you to add a package of combined CSS or JS files.
*
* @author Ralf Schubert <ralf.schubert@the-screeze.de>
* @version 0.1, 20.03.2010<br />
*/
class HtmlHeaderAddPackageTag extends Document {
public function transform() {
/* @var $header HtmlHeaderManager */
$header = $this->getServiceObject(HtmlHeaderManager::class);
$url = $this->getAttribute('url');
$name = $this->getAttribute('name');
$type = $this->getAttribute('type');
$media = $this->getAttribute('media');
if ($type == 'js') {
$node = new JsPackageNode($url, $name);
if (strtolower($this->getAttribute('appendtobody')) === 'true') {
$node->setAppendToBody(true);
}
} else {
$node = new CssPackageNode($url, $name, $media);
}
$node->setPriority(intval($this->getAttribute('priority')));
$header->addNode($node);
return '';
}
}