-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathe_shortcode.php
More file actions
91 lines (74 loc) · 1.8 KB
/
e_shortcode.php
File metadata and controls
91 lines (74 loc) · 1.8 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2017 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
* #######################################
* # e107 masthead plugin #
* # by Jimako #
* # https://www.e107sk.com #
* #######################################
*/
if (!defined('e107_INIT'))
{
exit;
}
class masthead_shortcodes extends e_shortcode
{
/* {MASTHEAD: mode=solid&template=solid} */
public function sc_masthead($parm = '')
{
$mode = $parm['mode'];
$template_key = $parm['template'];
if (empty($mode))
{
return '';
}
if (empty($template_key))
{
$template_key = $mode;
}
if (empty($template_key))
{
return '';
}
$where = "element_mode LIKE '" . $mode . "' AND element_visibility IN (" . USERCLASS_LIST . ") LIMIT 1";
$settings = e107::getDb()->retrieve('masthead', '*', $where);
$values = e107::unserialize($settings['element_options']);
if (empty($values))
{
return '';
}
$template = e107::getTemplate('masthead', 'masthead', $template_key);
if (empty($template))
{
return '';
}
$start = '';
$end = '';
$text = '';
$fieldvar = array();
$var = array();
/* only if element uses single fields */
if (array_key_exists('fields', $values))
{
foreach ($values['fields'] as $key => $field)
{
if (!empty($field))
{
$key = strtoupper($key);
$field = e107::getParser()->replaceConstants($field, 'full');
$field = e107::getParser()->toHTML($field, true);
$fieldsvar[$key] = $field;
}
}
}
$element = e107::getParser()->simpleParse($template['element'], $fieldsvar);
$element = e107::getParser()->parseTemplate($element);
return $element;
}
}