-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.php
87 lines (79 loc) · 2.4 KB
/
controller.php
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
<?php
namespace Application\Block\C5jDummyImage;
use Concrete\Core\Block\BlockController;
use Concrete\Core\Error\ErrorList\Error\Error;
class Controller extends BlockController
{
protected $btInterfaceHeight = 500;
protected $btInterfaceWidth = 700;
protected $btTable = 'btDummyImage';
protected $btHandle = 'c5j_dummy_image';
protected $img_width;
protected $img_height;
protected $bg_color;
protected $fg_color;
protected $img_text;
public function getBlockTypeName()
{
return t('C5j Dummy image');
}
public function getBlockTypeDescription()
{
return t('Display a dummy image with the specified width, height, color and text content.');
}
public function validate($args)
{
if ($args['img_width'] <= 0) {
return new Error('Please enter a valid width.');
}
if ($args['img_height'] <= 0) {
return new Error('Please enter a valid height.');
}
}
public function save($args)
{
parent::save($args); // TODO: Change the autogenerated stub
}
public function view()
{
if (!isset($this->img_width) || empty($this->img_width)) {
$this->img_width = 200;
}
if (!isset($this->img_height) || empty($this->img_height)) {
$this->img_height = 200;
}
if ($this->bg_color == '1') {
$this->set('bg_color', 'green');
}
if ($this->bg_color == '2') {
$this->set('bg_color', 'yellow');
}
if ($this->bg_color == '3') {
$this->set('bg_color', 'red');
}
if ($this->bg_color == '4') {
$this->set('bg_color', 'blue');
}
if ($this->bg_color == '5') {
$this->set('bg_color', 'grey');
}
if ($this->bg_color == '6') {
$this->set('bg_color', 'brown');
}
if ($this->bg_color == '7') {
$this->set('bg_color', 'black');
}
if ($this->bg_color == '8') {
$this->set('bg_color', 'purple');
}
if ($this->fg_color == '1') {
$this->set('fg_color', 'white');
}
if ($this->fg_color == '2') {
$this->set('fg_color', 'black');
}
$this->set('img_width', $this->img_width);
$this->set('img_height', $this->img_height);
$this->set('img_text', $this->img_text);
}
}