-
Notifications
You must be signed in to change notification settings - Fork 1
/
e_shortcode.php
148 lines (115 loc) · 4.23 KB
/
e_shortcode.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2018 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* xpandSlider plugin - Perfect responsive image, HTML slider for e107 CMS
* Author: rolla <[email protected]>
*
*/
if (!defined('e107_INIT')) {
exit;
}
require_once("conf.php");
class xpandslider_shortcodes extends e_shortcode
{
function init()
{
$sql = e107::getDB();
$sql->db_Set_Charset("utf8");
$xpandSliderPrefs = e107::getPlugPref(XPNSLD_NAME); // get plugin prefs
$slides = $sql->retrieve(XPNSLD_DB, '*', 'visibility IN (' . USERCLASS_LIST . ') ORDER BY position ASC', true);
if (varset($xpandSliderPrefs['xpnsld_camerarandom'])) {
shuffle($slides);
}
$this->setVars(compact('slides'));
}
function sc_xpandslider($parm = '')
{
$tp = e107::getParser();
$template = e107::getTemplate(XPNSLD_NAME);
$text = $tp->parseTemplate($template['start']);
foreach ($this->var['slides'] as $slide) {
$this->addVars(compact('slide')); // set current slide
$text .= $tp->parseTemplate($template['item']);
}
$text .= $tp->parseTemplate($template['end']);
return $text;
}
function sc_xpandslider_id($parm = '')
{
$tp = e107::getParser();
return $tp->replaceConstants($this->var['slide']['id']);
}
function sc_xpandslider_caption($parm = '')
{
$tp = e107::getParser();
return $tp->replaceConstants($this->var['slide']['caption']);
}
function sc_xpandslider_content($parm = '')
{
$tp = e107::getParser();
return $tp->toHTML($this->var['slide']['content'], true);
}
function sc_xpandslider_image($parm = '')
{
$tp = e107::getParser();
return $tp->replaceConstants($this->var['slide']['image']);
}
function sc_xpandslider_thumb($parm = '')
{
$tp = e107::getParser();
$thumb = e_BASE .'thumb.php?src=' . e_PLUGIN_ABS . XPNSLD_DIR;
$thumb .= XPNSLD_IMG_DIR . $this->var['slide']['image'] .'&w=300&h=300';
return $tp->replaceConstants($thumb);
}
function sc_xpandslider_data($parm = '')
{
$dataArray = json_decode(html_entity_decode($this->var['slide']['extra']));
$htmlData = '';
foreach ($dataArray as $attr => $val) {
$htmlData .= 'data-' . $attr . '="' . $val . '" ';
}
$tp = e107::getParser();
return $tp->replaceConstants($htmlData);
}
function sc_xpandslider_cameraskin($parm = '')
{
$xpandSliderPrefs = e107::getPlugPref(XPNSLD_NAME); // get plugin prefs
require_once(e_PLUGIN . XPNSLD_NAME . '/includes/xpandslider.php');
$xpandSliderRepo = new xpandslider;
return $xpandSliderPrefs['xpnsld_cameraskin'] ? $xpandSliderRepo->cameraSkins[$xpandSliderPrefs['xpnsld_cameraskin']] : "";
}
function sc_xpandslider_captionfx($parm = '')
{
$dataArray = json_decode(html_entity_decode($this->var['slide']['extra']));
$captionFx = 'fadeIn';
if (isset($dataArray->captionFx)) {
$captionFx = $dataArray->captionFx;
}
$tp = e107::getParser();
return $tp->replaceConstants($captionFx);
}
function sc_xpandslider_cameraoptions()
{
$xpandSliderPrefs = e107::getPlugPref(XPNSLD_NAME);
$cameraOptionsArr = [
'width' => $xpandSliderPrefs['xpnsld_camerawidth'],
'height' => $xpandSliderPrefs['xpnsld_cameraheight'],
'pagination' => $xpandSliderPrefs['xpnsld_camerapagination'],
'thumbnails' => $xpandSliderPrefs['xpnsld_camerathumbnails'],
'loader' => $xpandSliderPrefs['xpnsld_cameraloader'],
'navigationHover' => false,
'alignment' => 'bottomCenter',
'autoAdvance' => $xpandSliderPrefs['xpnsld_cameraautoplay'],
'imagePath' => e_PLUGIN_ABS . XPNSLD_DIR . XPNSLD_IMG_DIR,
//'hover' => true,
//'navigation' => true,
];
$tp = e107::getParser();
return $tp->replaceConstants(json_encode($cameraOptionsArr));
}
}