ItemHeadingFrontend.php
2.3 KB
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
65
66
67
68
69
70
71
72
<?php
namespace Nextend\SmartSlider3\Renderable\Item\Heading;
use Nextend\Framework\Misc\Base64;
use Nextend\Framework\View\Html;
use Nextend\SmartSlider3\Renderable\Item\AbstractItemFrontend;
class ItemHeadingFrontend extends AbstractItemFrontend {
public function render() {
return $this->getHtml();
}
private function getHtml() {
$owner = $this->layer->getOwner();
$attributes = array();
$font = $owner->addFont($this->data->get('font'), 'hover');
$style = $owner->addStyle($this->data->get('style'), 'heading');
$linkAttributes = array(
'class' => 'n2-ow'
);
if ($this->isEditor) {
$linkAttributes['onclick'] = 'return false;';
}
$title = $this->data->get('title', '');
if (!empty($title)) {
$attributes['title'] = $title;
}
$href = $this->data->get('href', '');
if (!empty($href) && $href != '#') {
$linkAttributes['class'] .= ' ' . $font . $style;
$font = '';
$style = '';
}
$linkAttributes['style'] = "display:" . ($this->data->get('fullwidth', 1) ? 'block' : 'inline-block') . ";";
$allowedTags = '<a><span><sub><sup><em><i><var><cite><b><strong><small><bdo>';
$strippedHtml = strip_tags($owner->fill($this->data->get('heading', '')), $allowedTags);
return $this->heading($this->data->get('priority', 'div'), $attributes + array(
"id" => $this->id,
"class" => $font . $style . " " . $owner->fill($this->data->get('class', '')) . ' n2-ss-item-content n2-ss-text n2-ow',
"style" => "display:" . ($this->data->get('fullwidth', 1) ? 'block' : 'inline-block') . ";" . ($this->data->get('nowrap', 0) ? 'white-space:nowrap;' : '')
), $this->getLink(str_replace("\n", '<br>', $strippedHtml), $linkAttributes));
}
private function heading($type, $attributes, $content) {
if (is_numeric($type) && $type > 0) {
return Html::tag("h{$type}", $attributes, $content);
}
return Html::tag("div", $attributes, $content);
}
public function renderAdminTemplate() {
return $this->getHtml();
}
public function isAuto() {
return !$this->data->get('fullwidth', 1);
}
}