Passed
Push — 2.1.0 ( ...c750ab )
by steve
15:24
created

ImageMultiple::getValueDisplay()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 4
eloc 11
nc 4
nop 1
dl 0
loc 15
ccs 0
cts 15
cp 0
crap 20
rs 9.9
c 1
b 0
f 1
1
<?php
2
3
4
namespace neon\core\form\fields;
5
6
7
use neon\core\helpers\Html;
8
9
class ImageMultiple extends Field
10
{
11
	/**
12
	 * @inheritdoc
13
	 */
14
	public $ddsDataType = 'json';
15
16
	/**
17
	 * @inheritdoc
18
	 */
19
	public function getFilterField()
20
	{
21
		return ['class' => 'neon\\core\\form\\fields\\Text'];
22
	}
23
24
	/**
25
	 * @inheritdoc
26
	 */
27
	public function getComponentDetails()
28
	{
29
		return [
30
			'icon' => 'fa fa-image', 'group' => 'Media', 'order' => 80
31
		];
32
	}
33
34
	public function getValueDisplay($context='')
35
	{
36
		$json = $this->getValue();
37
		if (empty($json))
38
			return neon()->formatter->asJson($this->getValue());
39
		if ($context==='grid') {
40
			$out = '';
41
			$images = json_decode($json);
42
			foreach($images as $image) {
43
				$url = neon()->firefly->getImage($image);
44
				$out .= "<img src='$url' />";
45
			}
46
			return $out;
47
		}
48
		return neon()->formatter->asJson($this->getValue());
49
	}
50
}
51