-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.php
134 lines (117 loc) · 3.28 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* Package Controller File.
*
* PHP version 5.4
*
* @author Oliver Green <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GPL3
* @link https://c5labs.com/add-ons/image-box
*/
namespace Concrete\Package\ImageBoxBlock;
defined('C5_EXECUTE') or die('Access Denied.');
use Concrete\Core\Block\BlockType\BlockType;
use Concrete\Core\File\File;
use Concrete\Core\Http\Response;
use Concrete\Core\Package\Package;
use Core;
use Illuminate\Filesystem\Filesystem;
/**
* Package Controller Class.
*
* @author Oliver Green <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GPL3
* @link https://c5labs.com/add-ons/image-box
*/
class Controller extends Package
{
/**
* Package handle.
*
* @var string
*/
protected $pkgHandle = 'image-box-block';
/**
* Minimum concrete5 version.
*
* @var string
*/
protected $appVersionRequired = '8.5.4';
/**
* Package version.
*
* @var string
*/
protected $pkgVersion = '1.0';
/**
* Get the package name.
*
* @return string
*/
public function getPackageName()
{
return t('Image Box');
}
/**
* Get the package description.
*
* @return string
*/
public function getPackageDescription()
{
return t('A block to allow easy addition of combined image, text & link units.');
}
/**
* Install routine.
*
* @return \Concrete\Core\Package\Package
*/
public function install()
{
$pkg = parent::install();
// Install the image box block type
$bt = BlockType::installBlockTypeFromPackage('image_box', $pkg);
// Install the file type
$type = new \Concrete\Core\File\Image\Thumbnail\Type\Type;
if (class_exists(\Concrete\Core\Entity\File\Image\Thumbnail\Type\Type::class)) {
$type = new \Concrete\Core\Entity\File\Image\Thumbnail\Type\Type;
}
$type->setHandle('image_box_image');
$type->setName('Image Box Image');
$type->setWidth(360);
$type->setHeight(200);
$type->setIsUpscalingEnabled(true);
$type->setSizingMode(\Concrete\Core\File\Image\Thumbnail\Type\Type::RESIZE_EXACT);
$type->save();
return $pkg;
}
/**
* The packages upgrade routine.
*
* @return void
*/
public function upgrade()
{
parent::upgrade();
if (! \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('image_box_image')) {
// Install the file type
$type = new \Concrete\Core\File\Image\Thumbnail\Type\Type;
$type->setHandle('image_box_image');
$type->setName('Image Box Image');
$type->setWidth(360);
$type->setHeight(200);
$type->setIsUpscalingEnabled(true);
$type->setSizingMode(\Concrete\Core\File\Image\Thumbnail\Type\Type::RESIZE_EXACT);
$type->save();
}
}
public function uninstall()
{
// Remove the file type
$type = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('image_box_image');
if ($type instanceof \Concrete\Core\File\Image\Thumbnail\Type\Type) {
$type->delete();
}
parent::uninstall();
}
}