|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* @package sitemaker |
|
5
|
|
|
* @copyright (c) 2013 Daniel A. (blitze) |
|
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
|
7
|
|
|
* |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace blitze\content\services\form\field; |
|
11
|
|
|
|
|
12
|
|
|
class share extends base |
|
13
|
|
|
{ |
|
14
|
|
|
/** @var \blitze\sitemaker\services\util */ |
|
15
|
|
|
protected $util; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Constructor |
|
19
|
|
|
* |
|
20
|
|
|
* @param \phpbb\language\language $language Language object |
|
21
|
|
|
* @param \phpbb\request\request_interface $request Request object |
|
22
|
|
|
* @param \blitze\sitemaker\services\template $ptemplate Sitemaker template object |
|
23
|
|
|
* @param \blitze\sitemaker\services\util $util Sitemaker utility object |
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct(\phpbb\language\language $language, \phpbb\request\request_interface $request, \blitze\sitemaker\services\template $ptemplate, \blitze\sitemaker\services\util $util) |
|
26
|
|
|
{ |
|
27
|
|
|
parent::__construct($language, $request, $ptemplate); |
|
28
|
|
|
|
|
29
|
|
|
$this->util = $util; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @inheritdoc |
|
34
|
|
|
*/ |
|
35
|
|
|
public function get_field_value(array $data) |
|
36
|
|
|
{ |
|
37
|
|
|
return ''; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @inheritdoc |
|
42
|
|
|
*/ |
|
43
|
|
|
public function show_form_field($name, array &$data) |
|
44
|
|
|
{ |
|
45
|
|
|
return ''; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @inheritdoc |
|
50
|
|
|
*/ |
|
51
|
|
|
public function display_field(array $data, $mode = '') |
|
52
|
|
|
{ |
|
53
|
|
|
$props = $data['field_props']; |
|
54
|
|
|
|
|
55
|
|
|
$this->util->add_assets(array( |
|
56
|
|
|
'js' => array( |
|
57
|
|
|
'@blitze_content/vendor/jssocials/dist/jssocials.min.js', |
|
58
|
|
|
'@blitze_content/assets/fields/display.min.js', |
|
59
|
|
|
), |
|
60
|
|
|
'css' => array( |
|
61
|
|
|
'@blitze_content/assets/fields/share/' . $props['theme'] . '.min.css', |
|
62
|
|
|
) |
|
63
|
|
|
)); |
|
64
|
|
|
|
|
65
|
|
|
$classes = ['social-share', $props['corners'], $props['placement']]; |
|
66
|
|
|
$attributes = [ |
|
67
|
|
|
'class="' . join(' ', array_filter($classes)) . '"', |
|
68
|
|
|
'data-show-label="' . $props['show_label'] . '"', |
|
69
|
|
|
'data-show-count="' . $props['show_count'] . '"', |
|
70
|
|
|
'data-share-in="' . $props['sharein'] . '"', |
|
71
|
|
|
'data-shares="' . join(',', $props['defaults']) . '"', |
|
72
|
|
|
'style="font-size: ' . $props['size'] . 'px"', |
|
73
|
|
|
]; |
|
74
|
|
|
|
|
75
|
|
|
return '<div ' . join(' ', $attributes) . '></div>'; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @inheritdoc |
|
80
|
|
|
*/ |
|
81
|
|
|
public function get_default_props() |
|
82
|
|
|
{ |
|
83
|
|
|
return array( |
|
84
|
|
|
'corners' => '', |
|
85
|
|
|
'placement' => '', |
|
86
|
|
|
'sharein' => 'popup', |
|
87
|
|
|
'show_label' => 'true', |
|
88
|
|
|
'show_count' => 'false', |
|
89
|
|
|
'size' => 14, |
|
90
|
|
|
'theme' => 'flat', |
|
91
|
|
|
'options' => ['twitter', 'facebook', 'googleplus', 'linkedin', 'pinterest', 'email', 'stumbleupon', 'whatsapp', 'telegram', 'line', 'viber', 'pocket', 'messenger', 'vkontakte'], |
|
92
|
|
|
'defaults' => ['twitter', 'facebook', 'googleplus', 'linkedin', 'pinterest', 'stumbleupon', 'pocket', 'email'], |
|
93
|
|
|
); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @inheritdoc |
|
98
|
|
|
*/ |
|
99
|
|
|
public function get_name() |
|
100
|
|
|
{ |
|
101
|
|
|
return 'share'; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|