1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Images;
13
14 use ICanBoogie\Errors;
15
16 use ICanBoogie\Modules\Thumbnailer\Versions;
17
18 class Module extends \Icybee\Modules\Files\Module
19 {
20 const ICON_WIDTH = 24;
21 const ICON_HEIGHT = 24;
22 const THUMBNAIL_WIDTH = 200;
23 const THUMBNAIL_HEIGHT = 200;
24
25 static private $thumbnail_versions = array
26 (
27 '$icon' => array
28 (
29 'w' => self::ICON_WIDTH,
30 'h' => self::ICON_HEIGHT,
31 'format' => 'png'
32 ),
33
34 '$icon-m' => array
35 (
36 'w' => 64,
37 'h' => 64
38 ),
39
40 '$popimage' => array
41 (
42 'w' => 96,
43 'h' => 96,
44 'method' => 'surface'
45 ),
46
47 '$popover' => array
48 (
49 'w' => self::THUMBNAIL_WIDTH,
50 'h' => self::THUMBNAIL_HEIGHT,
51 'method' => 'surface',
52 'no-upscale' => true,
53 'quality' => 90
54 ),
55
56 '$gallery' => array
57 (
58 'w' => 128,
59 'h' => 128,
60 'method' => 'constrained',
61 'quality' => 90
62 )
63 );
64
65 66 67
68 public function is_installed(Errors $errors)
69 {
70 global $core;
71
72 $versions = $core->thumbnailer_versions;
73
74 foreach (self::$thumbnail_versions as $version => $options)
75 {
76 if (isset($versions[$version]))
77 {
78 continue;
79 }
80
81 $errors[$this->id] = $errors->format("Thumbnail version %version is not defined.", array('version' => $version));
82 }
83
84 return parent::is_installed($errors);
85 }
86
87 88 89
90 public function install(Errors $errors)
91 {
92 global $core;
93
94 $versions = $core->thumbnailer_versions;
95
96 foreach (self::$thumbnail_versions as $version => $options)
97 {
98 $versions[$version] = $options;
99 }
100
101 $versions->save();
102
103 return parent::install($errors);
104 }
105 }