share   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 36
c 1
b 0
f 0
dl 0
loc 96
ccs 0
cts 55
cp 0
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A get_default_props() 0 12 1
A __construct() 0 5 1
A display_field() 0 31 2
A get_field_value() 0 3 1
A show_form_field() 0 3 1
A get_name() 0 3 1
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 */
0 ignored issues
show
Bug introduced by
The type blitze\sitemaker\services\util was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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)
0 ignored issues
show
Bug introduced by
The type blitze\sitemaker\services\template was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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(array &$data)
44
	{
45
		return '';
46
	}
47
48
	/**
49
	 * @inheritdoc
50
	 */
51
	public function display_field(array $data, array $topic_data, $view_mode)
52
	{
53
		if ($this->request->is_set_post('cp'))
54
		{
55
			return '';
56
		}
57
58
		$props = $data['field_props'];
59
60
		$this->util->add_assets(array(
61
			'js'	=> array(
62
				'@blitze_content/vendor/jssocials/dist/jssocials.min.js',
63
				'@blitze_content/assets/fields/display.min.js',
64
			),
65
			'css'	=> array(
66
				'@blitze_content/assets/fields/share/' . $props['theme'] . '.min.css',
67
			)
68
		));
69
70
		$classes = ['social-share', $props['corners'], $props['placement']];
71
		$attributes = [
72
			'class="' . join(' ', array_filter($classes)) . '"',
73
			'data-show-label="' . $props['show_label'] . '"',
74
			'data-show-count="' . $props['show_count'] . '"',
75
			'data-share-in="' . $props['sharein'] . '"',
76
			'data-shares="' . join(',', $props['defaults']) . '"',
77
			'data-url="' . $topic_data['PERMA_LINK'] . '"',
78
			'style="font-size: ' . $props['size'] . 'px"',
79
		];
80
81
		return '<div ' . join(' ', $attributes) . '></div>';
82
	}
83
84
	/**
85
	 * @inheritdoc
86
	 */
87
	public function get_default_props()
88
	{
89
		return array(
90
			'corners'		=> '',
91
			'placement'		=> '',
92
			'sharein'		=> 'popup',
93
			'show_label'	=> 'true',
94
			'show_count'	=> 'false',
95
			'size'			=> 14,
96
			'theme'			=> 'flat',
97
			'options'		=> ['twitter', 'facebook', 'googleplus', 'linkedin', 'pinterest', 'email', 'stumbleupon', 'whatsapp', 'telegram', 'line', 'viber', 'pocket', 'messenger', 'vkontakte'],
98
			'defaults'		=> ['twitter', 'facebook', 'googleplus', 'linkedin', 'pinterest', 'stumbleupon', 'pocket', 'email'],
99
		);
100
	}
101
102
	/**
103
	 * @inheritdoc
104
	 */
105
	public function get_name()
106
	{
107
		return 'share';
108
	}
109
}
110