ImageCompare   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 48
ccs 0
cts 29
cp 0
rs 10
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A registerScripts() 0 4 1
A getFilterField() 0 3 1
A getComponentDetails() 0 4 1
A getValueDisplay() 0 14 4
1
<?php
2
/**
3
 * @link http://www.newicon.net/neon
4
 * @copyright Copyright (c) 2017 Newicon Ltd
5
 * @license http://www.newicon.net/neon/license/
6
 * @author Steve O'Brien <[email protected]> 17/04/2020
7
 * @package neon
8
 */
9
10
namespace neon\cms\form\fields;
11
12
use \neon\core\form\fields\Field;
13
use neon\core\form\fields\ImageMultiple;
14
15
class ImageCompare extends ImageMultiple
16
{
17
    /**
18
	 * @inheritdoc
19
	 */
20
    public $ddsDataType = 'json';
21
22
    /**
23
	 * @inheritdoc
24
	 */
25
	public function registerScripts($view)
26
	{
27
        $view->registerAssetBundle(\neon\cms\assets\CmsFormAsset::class);
28
		$view->registerAssetBundle(\neon\firefly\assets\BrowserAsset::class);
29
    }
30
31
    /**
32
	 * @inheritdoc
33
	 */
34
	public function getFilterField()
35
	{
36
		return ['class' => 'neon\\core\\form\\fields\\Text'];
37
	}
38
39
    /**
40
	 * @inheritdoc
41
	 */
42
	public function getComponentDetails()
43
	{
44
		return [
45
			'icon' => 'fa fa-image', 'group' => 'Media', 'order' => 612, 'label' => 'Image Compare'
46
		];
47
    }
48
49
    public function getValueDisplay($context='')
50
	{
51
		$json = $this->getValue();
52
		if (empty($json))
53
			return neon()->formatter->asJson($this->getValue());
54
		if ($context==='grid') {
55
			$out = '';
56
			foreach($json as $image) {
57
				$url = neon()->firefly->getImage($image);
58
				$out .= "<img src='$url' />";
59
			}
60
			return $out;
61
		}
62
		return neon()->formatter->asJson($this->getValue());
63
	}
64
65
}