c3-environment-banner - Version 1.1.0

Version Notes


  • Safe. DOES NOT display on production sites - fails safe to display nothing if it does not recognise the environment

  • Display corner banner on front end pages

  • Optionally change colour in admin

  • Fully modifiable and extensible list of environments

  • Use safety colours (defaults to traffic lights) or set your own

Download this release

Release Info

Developer C3 Media
Extension c3-environment-banner
Version 1.1.0
Comparing to
See all releases


Version 1.1.0

app/code/local/C3/EnvironmentBanner/Block/Adminhtml/Page/Header.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * C3 Media Ltd
4
+ *
5
+ * @title Environment Banner.
6
+ * @category C3
7
+ * @package C3_EnvironmentBanner
8
+ * @author C3 Development Team <development@c3media.co.uk>
9
+ * @copyright Copyright (c) 2014 C3 Media Ltd (http://www.c3media.co.uk)
10
+ */
11
+
12
+ /**
13
+ * Overriding Adminhtml header block
14
+ */
15
+ class C3_EnvironmentBanner_Block_Adminhtml_Page_Header extends Mage_Adminhtml_Block_Page_Header
16
+ {
17
+ public function __construct()
18
+ {
19
+ parent::__construct();
20
+ $this->setTemplate('c3_environmentbanner/header.phtml');
21
+ }
22
+ }
app/code/local/C3/EnvironmentBanner/Block/Adminhtml/System/Config/Form/Field/Environment.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * C3 Media Ltd
4
+ *
5
+ * @title Environment Banner.
6
+ * @category C3
7
+ * @package C3_EnvironmentBanner
8
+ * @author C3 Development Team <development@c3media.co.uk>
9
+ * @copyright Copyright (c) 2014 C3 Media Ltd (http://www.c3media.co.uk)
10
+ */
11
+
12
+ class C3_EnvironmentBanner_Block_Adminhtml_System_Config_Form_Field_Environment
13
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
14
+ {
15
+ public function __construct()
16
+ {
17
+ $this->addColumn('env', array(
18
+ 'label' => Mage::helper('c3_environmentbanner')->__('Environment Code'),
19
+ 'style' => 'width:100px',
20
+ ));
21
+ $this->addColumn('fe_bgcolor', array(
22
+ 'label' => Mage::helper('c3_environmentbanner')->__('Frontend Banner Hex'),
23
+ 'style' => 'width:100px',
24
+ ));
25
+ $this->addColumn('be_color', array(
26
+ 'label' => Mage::helper('c3_environmentbanner')->__('Backend Banner Hex'),
27
+ 'style' => 'width:100px',
28
+ ));
29
+ $this->_addAfter = false;
30
+ $this->_addButtonLabel = Mage::helper('c3_environmentbanner')->__('Add New Environment');
31
+ parent::__construct();
32
+ }
33
+ }
app/code/local/C3/EnvironmentBanner/Helper/Data.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * C3 Media Ltd
4
+ *
5
+ * @title Environment Banner.
6
+ * @category C3
7
+ * @package C3_EnvironmentBanner
8
+ * @author C3 Development Team <development@c3media.co.uk>
9
+ * @copyright Copyright (c) 2014 C3 Media Ltd (http://www.c3media.co.uk)
10
+ */
11
+
12
+ class C3_EnvironmentBanner_Helper_Data extends Mage_Core_Helper_Abstract
13
+ {
14
+ protected $_configPrefix = 'c3_environmentbanner';
15
+
16
+ protected $_environments = null;
17
+ protected $_colours = null;
18
+
19
+ /**
20
+ * Whether to display, given environment, settings etc.
21
+ *
22
+ * @return bool
23
+ */
24
+ public function isDisplayFrontendBanner()
25
+ {
26
+ // Check that output is enabled, else return false
27
+ if (!$this->isFrontendBannerEnabled()) {
28
+ return false;
29
+ }
30
+
31
+ // Check that the given environment is recognised, else false
32
+ if (!isset($this->getEnvironments()[$this->getEnvironment()])) {
33
+ return false;
34
+ }
35
+
36
+ // Never display on production or if no background colour set (can be used to indicate production)
37
+ if ($this->getEnvironment() == 'production' || $this->getEnvColours()->getFeBgcolor() === null) {
38
+ return false;
39
+ }
40
+
41
+ // We're enabled, in a recognised environment that is not production, so... display!
42
+ return true;
43
+ }
44
+
45
+ /**
46
+ * Get environments array, indexed by environment code
47
+ *
48
+ * @return array
49
+ */
50
+ protected function getEnvironments()
51
+ {
52
+ // Lazily load environments from config
53
+ if ($this->_environments === null) {
54
+ $envConfig = unserialize(Mage::getStoreConfig("{$this->_configPrefix}/environments/environments"));
55
+ // Make into associative array
56
+ $this->_environments = array();
57
+ foreach ($envConfig as $env) {
58
+ $this->_environments[$env['env']] = $env;
59
+ }
60
+ }
61
+
62
+ return $this->_environments;
63
+ }
64
+
65
+ /**
66
+ * Get colours set for current environment
67
+ *
68
+ * @return C3_EnvironmentBanner_Model_Colours|null Null if cannot find colours for current environment
69
+ */
70
+ public function getEnvColours()
71
+ {
72
+ // Lazily load colours from environment data
73
+ if ($this->_colours === null) {
74
+ if (!isset($this->getEnvironments()[$this->getEnvironment()])) {
75
+ return null;
76
+ }
77
+ $data = $this->getEnvironments()[$this->getEnvironment()];
78
+ $this->_colours = Mage::getModel('c3_environmentbanner/colours')
79
+ ->setData($data);
80
+ }
81
+
82
+ return $this->_colours;
83
+ }
84
+
85
+ /**
86
+ * Whether the display-banner functionality is turned on
87
+ *
88
+ * @return bool
89
+ */
90
+ public function isFrontendBannerEnabled()
91
+ {
92
+ return (Mage::getStoreConfig("{$this->_configPrefix}/frontend/enabled") == true);
93
+ }
94
+
95
+ /**
96
+ * Whether to change the colour of the admin banner according to the environment
97
+ *
98
+ * @return bool
99
+ */
100
+ public function isChangeAdminColour()
101
+ {
102
+ return (Mage::getStoreConfig("{$this->_configPrefix}/admin/colour_change") == true);
103
+ }
104
+
105
+ /**
106
+ * Whether to display the name of the environment in admin
107
+ *
108
+ * @return bool
109
+ */
110
+ public function isDisplayAdminEnv()
111
+ {
112
+ return (Mage::getStoreConfig("{$this->_configPrefix}/admin/display_env") == true);
113
+ }
114
+
115
+ /**
116
+ * Filename of the admin logo - defaults to 'logo.gif'.
117
+ *
118
+ * @return string
119
+ */
120
+ public function getAdminLogoFilename() {
121
+ return Mage::getStoreConfig("{$this->_configPrefix}/admin/logo_filename");
122
+ }
123
+
124
+ /**
125
+ * Return the current application environment. If not set, return null
126
+ *
127
+ * @return null|string
128
+ */
129
+ public function getEnvironment()
130
+ {
131
+ if (!isset($_SERVER['APPLICATION_ENV'])) {
132
+ return null;
133
+ }
134
+
135
+ return $_SERVER['APPLICATION_ENV'];
136
+ }
137
+ }
app/code/local/C3/EnvironmentBanner/Model/Colours.php ADDED
@@ -0,0 +1,541 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * C3 Media Ltd
4
+ *
5
+ * @title Environment Banner.
6
+ * @category C3
7
+ * @package C3_EnvironmentBanner
8
+ * @author C3 Development Team <development@c3media.co.uk>
9
+ * @copyright Copyright (c) 2014 C3 Media Ltd (http://www.c3media.co.uk)
10
+ */
11
+
12
+ /**
13
+ * Class for set of environment banner colours
14
+ *
15
+ * @method getEnv
16
+ * @method getFeBgcolor
17
+ * @method getBeColor
18
+ */
19
+ class C3_EnvironmentBanner_Model_Colours extends Mage_Core_Model_Abstract
20
+ {
21
+ const DEFAULT_COLOR = '#666666';
22
+
23
+ /**
24
+ * Return lighter version of the front-end background colour
25
+ *
26
+ * @return string Hex Colour
27
+ */
28
+ public function getFeLighterBgcolor()
29
+ {
30
+ $rgb = self::_convertHtmlToRgb($this->getFeBgcolor());
31
+ // If fail to convert, return default hex code
32
+ if ($rgb === null)
33
+ return self::DEFAULT_COLOR;
34
+ $hsl = self::_convertRgbToHsl($rgb);
35
+
36
+ // Change colour to make lighter and change hue slightly
37
+ $hsl['h'] = $hsl['h'] + 10 % 360;
38
+ $hsl['l'] = min($hsl['l'] + 0.25, 1.0);
39
+ $hsl['s'] = min($hsl['s'] + 0.1, 1.0);
40
+
41
+ $rgb2 = self::_convertHslToRgb($hsl);
42
+ $hex = self::_convertRgbToHex($rgb2);
43
+
44
+ return $hex;
45
+ }
46
+
47
+ public function getFeColor()
48
+ {
49
+ $rgb = self::_convertHtmlToRgb($this->getFeBgcolor());
50
+ // If fail to convert, return default hex code
51
+ if ($rgb === null)
52
+ return self::DEFAULT_COLOR;
53
+ $hsl = self::_convertRgbToHsl($rgb);
54
+
55
+ // Change colour to make darker
56
+ $hsl['l'] = max($hsl['l'] - 0.3, 0.0);
57
+ $hsl['s'] = min($hsl['s'] + 0.1, 1.0);
58
+
59
+ $rgb2 = self::_convertHslToRgb($hsl);
60
+ $hex = self::_convertRgbToHex($rgb2);
61
+
62
+ return $hex;
63
+ }
64
+
65
+ public function getBeBorderColor()
66
+ {
67
+ $rgb = self::_convertHtmlToRgb($this->getBeColor());
68
+ // If fail to convert, return default hex code
69
+ if ($rgb === null)
70
+ return self::DEFAULT_COLOR;
71
+ $hsl = self::_convertRgbToHsl($rgb);
72
+
73
+ // Change colour to make brighter
74
+ $hsl['l'] = min($hsl['l'] + 0.1, 1.0);
75
+ $hsl['s'] = min($hsl['s'] + 0.3, 1.0);
76
+
77
+ $rgb2 = self::_convertHslToRgb($hsl);
78
+ $hex = self::_convertRgbToHex($rgb2);
79
+
80
+ return $hex;
81
+ }
82
+
83
+ public function getBeLighterColor()
84
+ {
85
+ $rgb = self::_convertHtmlToRgb($this->getBeColor());
86
+ // If fail to convert, return default hex code
87
+ if ($rgb === null)
88
+ return self::DEFAULT_COLOR;
89
+ $hsl = self::_convertRgbToHsl($rgb);
90
+
91
+ // Change colour to make lighter
92
+ $hsl['h'] = $hsl['h'] + 5 % 360;
93
+ $hsl['l'] = min($hsl['l'] + 0.3, 1.0);
94
+ $hsl['s'] = max($hsl['s'] - 0.2, 0.0);
95
+
96
+ $rgb2 = self::_convertHslToRgb($hsl);
97
+ $hex = self::_convertRgbToHex($rgb2);
98
+
99
+ return $hex;
100
+ }
101
+
102
+ /**
103
+ * Convert from RGB to HSL
104
+ *
105
+ * @param array $rgb
106
+ * @return array
107
+ */
108
+ protected static function _convertRgbToHsl($rgb)
109
+ {
110
+ $r = $rgb['r'];
111
+ $g = $rgb['g'];
112
+ $b = $rgb['b'];
113
+
114
+ $r /= 255;
115
+ $g /= 255;
116
+ $b /= 255;
117
+
118
+ $max = max($r, $g, $b);
119
+ $min = min($r, $g, $b);
120
+
121
+ $h = 0;
122
+ $l = ($max + $min) / 2;
123
+ $d = $max - $min;
124
+
125
+ if ($d == 0) {
126
+ $h = $s = 0; // achromatic
127
+ } else {
128
+ $s = $d / (1 - abs(2 * $l - 1));
129
+
130
+ switch ($max) {
131
+ case $r:
132
+ $h = 60 * fmod((($g - $b) / $d), 6);
133
+ if ($b > $g) {
134
+ $h += 360;
135
+ }
136
+ break;
137
+
138
+ case $g:
139
+ $h = 60 * (($b - $r) / $d + 2);
140
+ break;
141
+
142
+ case $b:
143
+ $h = 60 * (($r - $g) / $d + 4);
144
+ break;
145
+ }
146
+ }
147
+
148
+ return array('h' => $h, 's' => $s, 'l' => $l);
149
+ }
150
+
151
+ /**
152
+ * Convert from HSL to RGB
153
+ *
154
+ * @param array $hsl
155
+ * @return array
156
+ */
157
+ protected function _convertHslToRgb($hsl)
158
+ {
159
+ $h = $hsl['h'];
160
+ $s = $hsl['s'];
161
+ $l = $hsl['l'];
162
+
163
+ $c = (1 - abs(2 * $l - 1)) * $s;
164
+ $x = $c * (1 - abs(fmod(($h / 60), 2) - 1));
165
+ $m = $l - ($c / 2);
166
+
167
+ if ($h < 60) {
168
+ $r = $c;
169
+ $g = $x;
170
+ $b = 0;
171
+ } else if ($h < 120) {
172
+ $r = $x;
173
+ $g = $c;
174
+ $b = 0;
175
+ } else if ($h < 180) {
176
+ $r = 0;
177
+ $g = $c;
178
+ $b = $x;
179
+ } else if ($h < 240) {
180
+ $r = 0;
181
+ $g = $x;
182
+ $b = $c;
183
+ } else if ($h < 300) {
184
+ $r = $x;
185
+ $g = 0;
186
+ $b = $c;
187
+ } else {
188
+ $r = $c;
189
+ $g = 0;
190
+ $b = $x;
191
+ }
192
+
193
+ $r = ($r + $m) * 255;
194
+ $g = ($g + $m) * 255;
195
+ $b = ($b + $m) * 255;
196
+
197
+ return array('r' => ceil($r), 'g' => ceil($g), 'b' => ceil($b));
198
+ }
199
+
200
+ /**
201
+ * Convert rgb array colour to hex string
202
+ *
203
+ * @param array $rgb
204
+ * @return string
205
+ */
206
+ protected static function _convertRgbToHex($rgb)
207
+ {
208
+ $r = dechex($rgb['r']);
209
+ If (strlen($r)<2)
210
+ $r='0'.$r;
211
+
212
+ $g = dechex($rgb['g']);
213
+ If (strlen($g)<2)
214
+ $g='0'.$g;
215
+
216
+ $b = dechex($rgb['b']);
217
+ If (strlen($b)<2)
218
+ $b='0'.$b;
219
+
220
+ return '#' . $r . $g . $b;
221
+ }
222
+
223
+ /**
224
+ * Creates an array of rgb values from the HTML representation.
225
+ *
226
+ * @param string $color May either be a hexidecimal number of the form
227
+ * #rrggbb or one of the 140 well-known names (black, white, blue, etc.)
228
+ * @return array|null Null in case of name not understood
229
+ */
230
+ protected static function _convertHtmlToRgb($color)
231
+ {
232
+ $pattern = '/^#([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})$/';
233
+ if (preg_match($pattern, $color, $matches)) {
234
+ $r = (hexdec($matches[1]));
235
+ $g = (hexdec($matches[2]));
236
+ $b = (hexdec($matches[3]));
237
+ return array('r' => $r, 'g' => $g, 'b' => $b);
238
+ } else {
239
+ return self::_namedColor($color);
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Returns components from named color
245
+ * Based on Zend_Pdf_Color_Html
246
+ *
247
+ * @param string $color One of the 140 well-known color names (black, white,
248
+ * blue, etc.)
249
+ * @return array
250
+ */
251
+ protected static function _namedColor($color)
252
+ {
253
+ switch (strtolower($color)) {
254
+ case 'aqua':
255
+ $r = 0.0; $g = 1.0; $b = 1.0; break;
256
+ case 'black':
257
+ $r = 0.0; $g = 0.0; $b = 0.0; break;
258
+ case 'blue':
259
+ $r = 0.0; $g = 0.0; $b = 1.0; break;
260
+ case 'fuchsia':
261
+ $r = 1.0; $g = 0.0; $b = 1.0; break;
262
+ case 'gray':
263
+ $r = 0.502; $g = 0.502; $b = 0.502; break;
264
+ case 'green':
265
+ $r = 0.0; $g = 0.502; $b = 0.0; break;
266
+ case 'lime':
267
+ $r = 0.0; $g = 1.0; $b = 0.0; break;
268
+ case 'maroon':
269
+ $r = 0.502; $g = 0.0; $b = 0.0; break;
270
+ case 'navy':
271
+ $r = 0.0; $g = 0.0; $b = 0.502; break;
272
+ case 'olive':
273
+ $r = 0.502; $g = 0.502; $b = 0.0; break;
274
+ case 'purple':
275
+ $r = 0.502; $g = 0.0; $b = 0.502; break;
276
+ case 'red':
277
+ $r = 1.0; $g = 0.0; $b = 0.0; break;
278
+ case 'silver':
279
+ $r = 0.753; $g = 0.753; $b = 0.753; break;
280
+ case 'teal':
281
+ $r = 0.0; $g = 0.502; $b = 0.502; break;
282
+ case 'white':
283
+ $r = 1.0; $g = 1.0; $b = 1.0; break;
284
+ case 'yellow':
285
+ $r = 1.0; $g = 1.0; $b = 0.0; break;
286
+
287
+ case 'aliceblue':
288
+ $r = 0.941; $g = 0.973; $b = 1.0; break;
289
+ case 'antiquewhite':
290
+ $r = 0.980; $g = 0.922; $b = 0.843; break;
291
+ case 'aquamarine':
292
+ $r = 0.498; $g = 1.0; $b = 0.831; break;
293
+ case 'azure':
294
+ $r = 0.941; $g = 1.0; $b = 1.0; break;
295
+ case 'beige':
296
+ $r = 0.961; $g = 0.961; $b = 0.863; break;
297
+ case 'bisque':
298
+ $r = 1.0; $g = 0.894; $b = 0.769; break;
299
+ case 'blanchedalmond':
300
+ $r = 1.0; $g = 1.0; $b = 0.804; break;
301
+ case 'blueviolet':
302
+ $r = 0.541; $g = 0.169; $b = 0.886; break;
303
+ case 'brown':
304
+ $r = 0.647; $g = 0.165; $b = 0.165; break;
305
+ case 'burlywood':
306
+ $r = 0.871; $g = 0.722; $b = 0.529; break;
307
+ case 'cadetblue':
308
+ $r = 0.373; $g = 0.620; $b = 0.627; break;
309
+ case 'chartreuse':
310
+ $r = 0.498; $g = 1.0; $b = 0.0; break;
311
+ case 'chocolate':
312
+ $r = 0.824; $g = 0.412; $b = 0.118; break;
313
+ case 'coral':
314
+ $r = 1.0; $g = 0.498; $b = 0.314; break;
315
+ case 'cornflowerblue':
316
+ $r = 0.392; $g = 0.584; $b = 0.929; break;
317
+ case 'cornsilk':
318
+ $r = 1.0; $g = 0.973; $b = 0.863; break;
319
+ case 'crimson':
320
+ $r = 0.863; $g = 0.078; $b = 0.235; break;
321
+ case 'cyan':
322
+ $r = 0.0; $g = 1.0; $b = 1.0; break;
323
+ case 'darkblue':
324
+ $r = 0.0; $g = 0.0; $b = 0.545; break;
325
+ case 'darkcyan':
326
+ $r = 0.0; $g = 0.545; $b = 0.545; break;
327
+ case 'darkgoldenrod':
328
+ $r = 0.722; $g = 0.525; $b = 0.043; break;
329
+ case 'darkgray':
330
+ $r = 0.663; $g = 0.663; $b = 0.663; break;
331
+ case 'darkgreen':
332
+ $r = 0.0; $g = 0.392; $b = 0.0; break;
333
+ case 'darkkhaki':
334
+ $r = 0.741; $g = 0.718; $b = 0.420; break;
335
+ case 'darkmagenta':
336
+ $r = 0.545; $g = 0.0; $b = 0.545; break;
337
+ case 'darkolivegreen':
338
+ $r = 0.333; $g = 0.420; $b = 0.184; break;
339
+ case 'darkorange':
340
+ $r = 1.0; $g = 0.549; $b = 0.0; break;
341
+ case 'darkorchid':
342
+ $r = 0.6; $g = 0.196; $b = 0.8; break;
343
+ case 'darkred':
344
+ $r = 0.545; $g = 0.0; $b = 0.0; break;
345
+ case 'darksalmon':
346
+ $r = 0.914; $g = 0.588; $b = 0.478; break;
347
+ case 'darkseagreen':
348
+ $r = 0.561; $g = 0.737; $b = 0.561; break;
349
+ case 'darkslateblue':
350
+ $r = 0.282; $g = 0.239; $b = 0.545; break;
351
+ case 'darkslategray':
352
+ $r = 0.184; $g = 0.310; $b = 0.310; break;
353
+ case 'darkturquoise':
354
+ $r = 0.0; $g = 0.808; $b = 0.820; break;
355
+ case 'darkviolet':
356
+ $r = 0.580; $g = 0.0; $b = 0.827; break;
357
+ case 'deeppink':
358
+ $r = 1.0; $g = 0.078; $b = 0.576; break;
359
+ case 'deepskyblue':
360
+ $r = 0.0; $g = 0.749; $b = 1.0; break;
361
+ case 'dimgray':
362
+ $r = 0.412; $g = 0.412; $b = 0.412; break;
363
+ case 'dodgerblue':
364
+ $r = 0.118; $g = 0.565; $b = 1.0; break;
365
+ case 'firebrick':
366
+ $r = 0.698; $g = 0.133; $b = 0.133; break;
367
+ case 'floralwhite':
368
+ $r = 1.0; $g = 0.980; $b = 0.941; break;
369
+ case 'forestgreen':
370
+ $r = 0.133; $g = 0.545; $b = 0.133; break;
371
+ case 'gainsboro':
372
+ $r = 0.863; $g = 0.863; $b = 0.863; break;
373
+ case 'ghostwhite':
374
+ $r = 0.973; $g = 0.973; $b = 1.0; break;
375
+ case 'gold':
376
+ $r = 1.0; $g = 0.843; $b = 0.0; break;
377
+ case 'goldenrod':
378
+ $r = 0.855; $g = 0.647; $b = 0.125; break;
379
+ case 'greenyellow':
380
+ $r = 0.678; $g = 1.0; $b = 0.184; break;
381
+ case 'honeydew':
382
+ $r = 0.941; $g = 1.0; $b = 0.941; break;
383
+ case 'hotpink':
384
+ $r = 1.0; $g = 0.412; $b = 0.706; break;
385
+ case 'indianred':
386
+ $r = 0.804; $g = 0.361; $b = 0.361; break;
387
+ case 'indigo':
388
+ $r = 0.294; $g = 0.0; $b = 0.510; break;
389
+ case 'ivory':
390
+ $r = 1.0; $g = 0.941; $b = 0.941; break;
391
+ case 'khaki':
392
+ $r = 0.941; $g = 0.902; $b = 0.549; break;
393
+ case 'lavender':
394
+ $r = 0.902; $g = 0.902; $b = 0.980; break;
395
+ case 'lavenderblush':
396
+ $r = 1.0; $g = 0.941; $b = 0.961; break;
397
+ case 'lawngreen':
398
+ $r = 0.486; $g = 0.988; $b = 0.0; break;
399
+ case 'lemonchiffon':
400
+ $r = 1.0; $g = 0.980; $b = 0.804; break;
401
+ case 'lightblue':
402
+ $r = 0.678; $g = 0.847; $b = 0.902; break;
403
+ case 'lightcoral':
404
+ $r = 0.941; $g = 0.502; $b = 0.502; break;
405
+ case 'lightcyan':
406
+ $r = 0.878; $g = 1.0; $b = 1.0; break;
407
+ case 'lightgoldenrodyellow':
408
+ $r = 0.980; $g = 0.980; $b = 0.824; break;
409
+ case 'lightgreen':
410
+ $r = 0.565; $g = 0.933; $b = 0.565; break;
411
+ case 'lightgrey':
412
+ $r = 0.827; $g = 0.827; $b = 0.827; break;
413
+ case 'lightpink':
414
+ $r = 1.0; $g = 0.714; $b = 0.757; break;
415
+ case 'lightsalmon':
416
+ $r = 1.0; $g = 0.627; $b = 0.478; break;
417
+ case 'lightseagreen':
418
+ $r = 0.125; $g = 0.698; $b = 0.667; break;
419
+ case 'lightskyblue':
420
+ $r = 0.529; $g = 0.808; $b = 0.980; break;
421
+ case 'lightslategray':
422
+ $r = 0.467; $g = 0.533; $b = 0.6; break;
423
+ case 'lightsteelblue':
424
+ $r = 0.690; $g = 0.769; $b = 0.871; break;
425
+ case 'lightyellow':
426
+ $r = 1.0; $g = 1.0; $b = 0.878; break;
427
+ case 'limegreen':
428
+ $r = 0.196; $g = 0.804; $b = 0.196; break;
429
+ case 'linen':
430
+ $r = 0.980; $g = 0.941; $b = 0.902; break;
431
+ case 'magenta':
432
+ $r = 1.0; $g = 0.0; $b = 1.0; break;
433
+ case 'mediumaquamarine':
434
+ $r = 0.4; $g = 0.804; $b = 0.667; break;
435
+ case 'mediumblue':
436
+ $r = 0.0; $g = 0.0; $b = 0.804; break;
437
+ case 'mediumorchid':
438
+ $r = 0.729; $g = 0.333; $b = 0.827; break;
439
+ case 'mediumpurple':
440
+ $r = 0.576; $g = 0.439; $b = 0.859; break;
441
+ case 'mediumseagreen':
442
+ $r = 0.235; $g = 0.702; $b = 0.443; break;
443
+ case 'mediumslateblue':
444
+ $r = 0.482; $g = 0.408; $b = 0.933; break;
445
+ case 'mediumspringgreen':
446
+ $r = 0.0; $g = 0.980; $b = 0.604; break;
447
+ case 'mediumturquoise':
448
+ $r = 0.282; $g = 0.820; $b = 0.8; break;
449
+ case 'mediumvioletred':
450
+ $r = 0.780; $g = 0.082; $b = 0.522; break;
451
+ case 'midnightblue':
452
+ $r = 0.098; $g = 0.098; $b = 0.439; break;
453
+ case 'mintcream':
454
+ $r = 0.961; $g = 1.0; $b = 0.980; break;
455
+ case 'mistyrose':
456
+ $r = 1.0; $g = 0.894; $b = 0.882; break;
457
+ case 'moccasin':
458
+ $r = 1.0; $g = 0.894; $b = 0.710; break;
459
+ case 'navajowhite':
460
+ $r = 1.0; $g = 0.871; $b = 0.678; break;
461
+ case 'oldlace':
462
+ $r = 0.992; $g = 0.961; $b = 0.902; break;
463
+ case 'olivedrab':
464
+ $r = 0.420; $g = 0.557; $b = 0.137; break;
465
+ case 'orange':
466
+ $r = 1.0; $g = 0.647; $b = 0.0; break;
467
+ case 'orangered':
468
+ $r = 1.0; $g = 0.271; $b = 0.0; break;
469
+ case 'orchid':
470
+ $r = 0.855; $g = 0.439; $b = 0.839; break;
471
+ case 'palegoldenrod':
472
+ $r = 0.933; $g = 0.910; $b = 0.667; break;
473
+ case 'palegreen':
474
+ $r = 0.596; $g = 0.984; $b = 0.596; break;
475
+ case 'paleturquoise':
476
+ $r = 0.686; $g = 0.933; $b = 0.933; break;
477
+ case 'palevioletred':
478
+ $r = 0.859; $g = 0.439; $b = 0.576; break;
479
+ case 'papayawhip':
480
+ $r = 1.0; $g = 0.937; $b = 0.835; break;
481
+ case 'peachpuff':
482
+ $r = 1.0; $g = 0.937; $b = 0.835; break;
483
+ case 'peru':
484
+ $r = 0.804; $g = 0.522; $b = 0.247; break;
485
+ case 'pink':
486
+ $r = 1.0; $g = 0.753; $b = 0.796; break;
487
+ case 'plum':
488
+ $r = 0.867; $g = 0.627; $b = 0.867; break;
489
+ case 'powderblue':
490
+ $r = 0.690; $g = 0.878; $b = 0.902; break;
491
+ case 'rosybrown':
492
+ $r = 0.737; $g = 0.561; $b = 0.561; break;
493
+ case 'royalblue':
494
+ $r = 0.255; $g = 0.412; $b = 0.882; break;
495
+ case 'saddlebrown':
496
+ $r = 0.545; $g = 0.271; $b = 0.075; break;
497
+ case 'salmon':
498
+ $r = 0.980; $g = 0.502; $b = 0.447; break;
499
+ case 'sandybrown':
500
+ $r = 0.957; $g = 0.643; $b = 0.376; break;
501
+ case 'seagreen':
502
+ $r = 0.180; $g = 0.545; $b = 0.341; break;
503
+ case 'seashell':
504
+ $r = 1.0; $g = 0.961; $b = 0.933; break;
505
+ case 'sienna':
506
+ $r = 0.627; $g = 0.322; $b = 0.176; break;
507
+ case 'skyblue':
508
+ $r = 0.529; $g = 0.808; $b = 0.922; break;
509
+ case 'slateblue':
510
+ $r = 0.416; $g = 0.353; $b = 0.804; break;
511
+ case 'slategray':
512
+ $r = 0.439; $g = 0.502; $b = 0.565; break;
513
+ case 'snow':
514
+ $r = 1.0; $g = 0.980; $b = 0.980; break;
515
+ case 'springgreen':
516
+ $r = 0.0; $g = 1.0; $b = 0.498; break;
517
+ case 'steelblue':
518
+ $r = 0.275; $g = 0.510; $b = 0.706; break;
519
+ case 'tan':
520
+ $r = 0.824; $g = 0.706; $b = 0.549; break;
521
+ case 'thistle':
522
+ $r = 0.847; $g = 0.749; $b = 0.847; break;
523
+ case 'tomato':
524
+ $r = 0.992; $g = 0.388; $b = 0.278; break;
525
+ case 'turquoise':
526
+ $r = 0.251; $g = 0.878; $b = 0.816; break;
527
+ case 'violet':
528
+ $r = 0.933; $g = 0.510; $b = 0.933; break;
529
+ case 'wheat':
530
+ $r = 0.961; $g = 0.871; $b = 0.702; break;
531
+ case 'whitesmoke':
532
+ $r = 0.961; $g = 0.961; $b = 0.961; break;
533
+ case 'yellowgreen':
534
+ $r = 0.604; $g = 0.804; $b = 0.196; break;
535
+ default:
536
+ return null;
537
+ }
538
+ return array('r' => $r * 255, 'g' => $g * 255, 'b' => $b * 255);
539
+ }
540
+
541
+ }
app/code/local/C3/EnvironmentBanner/etc/adminhtml.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * C3 Media Ltd
5
+ *
6
+ * @title Environment Banner.
7
+ * @category C3
8
+ * @package C3_EnvironmentBanner
9
+ * @author C3 Development Team <development@c3media.co.uk>
10
+ * @copyright Copyright (c) 2011 C3 Media Ltd (http://www.c3media.co.uk)
11
+ */
12
+ -->
13
+
14
+ <config>
15
+ <acl>
16
+ <resources>
17
+ <all>
18
+ <title>Allow Everything</title>
19
+ </all>
20
+ <admin>
21
+ <children>
22
+ <system>
23
+ <children>
24
+ <config>
25
+ <children>
26
+ <c3_environmentbanner>
27
+ <title>Environment Banner</title>
28
+ <sort_order>10</sort_order>
29
+ </c3_environmentbanner>
30
+ </children>
31
+ </config>
32
+ </children>
33
+ </system>
34
+ </children>
35
+ </admin>
36
+ </resources>
37
+ </acl>
38
+ </config>
app/code/local/C3/EnvironmentBanner/etc/config.xml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * C3 Media Ltd
5
+ *
6
+ * @title Skin Cache Override extension
7
+ * @category C3
8
+ * @package C3_EnvironmentBanner
9
+ * @author C3 Development Team <development@c3media.co.uk>
10
+ * @copyright Copyright (c) 2014 C3 Media Ltd (http://www.c3media.co.uk)
11
+ */
12
+ -->
13
+
14
+ <config>
15
+ <modules>
16
+ <C3_EnvironmentBanner>
17
+ <version>1.0.0</version>
18
+ </C3_EnvironmentBanner>
19
+ </modules>
20
+ <global>
21
+ <models>
22
+ <c3_environmentbanner>
23
+ <class>C3_EnvironmentBanner_Model</class>
24
+ </c3_environmentbanner>
25
+ </models>
26
+ <blocks>
27
+ <c3_environmentbanner>
28
+ <class>C3_EnvironmentBanner_Block</class>
29
+ </c3_environmentbanner>
30
+ <adminhtml>
31
+ <rewrite>
32
+ <page_header>C3_EnvironmentBanner_Block_Adminhtml_Page_Header</page_header>
33
+ </rewrite>
34
+ </adminhtml>
35
+ </blocks>
36
+ <helpers>
37
+ <c3_environmentbanner>
38
+ <class>C3_EnvironmentBanner_Helper</class>
39
+ </c3_environmentbanner>
40
+ </helpers>
41
+ </global>
42
+ <frontend>
43
+ <layout>
44
+ <updates>
45
+ <c3_environmentbanner>
46
+ <file>c3_environmentbanner.xml</file>
47
+ </c3_environmentbanner>
48
+ </updates>
49
+ </layout>
50
+ </frontend>
51
+ <adminhtml>
52
+ <layout>
53
+ <updates>
54
+ <c3_environmentbanner>
55
+ <file>c3_environmentbanner.xml</file>
56
+ </c3_environmentbanner>
57
+ </updates>
58
+ </layout>
59
+ </adminhtml>
60
+ <default>
61
+ <c3_environmentbanner>
62
+ <frontend>
63
+ <enabled>1</enabled>
64
+ </frontend>
65
+ <admin>
66
+ <colour_change>1</colour_change>
67
+ <display_env>1</display_env>
68
+ <logo_filename>logo.gif</logo_filename><!-- Allows override of admin logo via config variable as this extension overrides the admin header template -->
69
+ </admin>
70
+ <environments>
71
+ <environments><![CDATA[a:4:{s:18:"_1412161643703_703";a:3:{s:3:"env";s:10:"production";s:10:"fe_bgcolor";s:0:"";s:8:"be_color";s:7:"#7a0200";}s:17:"_1412161786097_97";a:3:{s:3:"env";s:11:"development";s:10:"fe_bgcolor";s:7:"#8ebf45";s:8:"be_color";s:7:"#135916";}s:18:"_1412161792273_273";a:3:{s:3:"env";s:7:"staging";s:10:"fe_bgcolor";s:7:"#d45d12";s:8:"be_color";s:7:"#994100";}s:18:"_1412161795108_108";a:3:{s:3:"env";s:7:"preview";s:10:"fe_bgcolor";s:7:"#7c43bf";s:8:"be_color";s:7:"#513180";}}]]></environments>
72
+ </environments>
73
+ </c3_environmentbanner>
74
+ </default>
75
+ </config>
app/code/local/C3/EnvironmentBanner/etc/system.xml ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * C3 Media Ltd
5
+ *
6
+ * @title Quick Order Form.
7
+ * @category C3
8
+ * @package C3_QuickOrderForm
9
+ * @author C3 Development Team <development@c3media.co.uk>
10
+ * @copyright Copyright (c) 2014 C3 Media Ltd (http://www.c3media.co.uk)
11
+ */
12
+ -->
13
+
14
+ <config>
15
+ <tabs>
16
+ <c3extensions translate="label">
17
+ <label>C3 Extensions</label>
18
+ <sort_order>900</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+ </c3extensions>
23
+ </tabs>
24
+ <sections>
25
+ <c3_environmentbanner translate="label" module="c3_environmentbanner">
26
+ <class>separator-top</class>
27
+ <label>Environment Banner</label>
28
+ <tab>c3extensions</tab>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>1</show_in_store>
32
+ <sort_order>500</sort_order>
33
+ <groups>
34
+ <frontend translate="label">
35
+ <label>Frontend</label>
36
+ <frontend_type>text</frontend_type>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ <expanded>1</expanded>
41
+ <sort_order>100</sort_order>
42
+ <fields>
43
+ <enabled translate="label">
44
+ <label>Corner-banner Enabled</label>
45
+ <frontend_type>select</frontend_type>
46
+ <sort_order>90</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>1</show_in_store>
50
+ <source_model>adminhtml/system_config_source_yesno</source_model>
51
+ </enabled>
52
+ </fields>
53
+ </frontend>
54
+ <admin translate="label">
55
+ <label>Admin</label>
56
+ <frontend_type>text</frontend_type>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ <expanded>1</expanded>
61
+ <sort_order>110</sort_order>
62
+ <fields>
63
+ <colour_change translate="label">
64
+ <label>Change admin banner colour</label>
65
+ <frontend_type>select</frontend_type>
66
+ <sort_order>90</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ <source_model>adminhtml/system_config_source_yesno</source_model>
71
+ </colour_change>
72
+ <display_env translate="label">
73
+ <label>Display environment name</label>
74
+ <frontend_type>select</frontend_type>
75
+ <sort_order>100</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ <source_model>adminhtml/system_config_source_yesno</source_model>
80
+ </display_env>
81
+ </fields>
82
+ </admin>
83
+ <environments translate="label">
84
+ <label>Environments</label>
85
+ <frontend_type>text</frontend_type>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ <expanded>1</expanded>
90
+ <sort_order>120</sort_order>
91
+ <fields>
92
+ <environments translate="label">
93
+ <label>Environment Details</label>
94
+ <frontend_model>c3_environmentbanner/adminhtml_system_config_form_field_environment</frontend_model>
95
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
96
+ <sort_order>10</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ </environments>
101
+ </fields>
102
+ </environments>
103
+ </groups>
104
+ </c3_environmentbanner>
105
+ </sections>
106
+ </config>
app/design/adminhtml/default/default/template/c3_environmentbanner/header.phtml ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * C3 Media Ltd
4
+ *
5
+ * @title Environment Banner.
6
+ * @category C3
7
+ * @package C3_EnvironmentBanner
8
+ * @author C3 Development Team <development@c3media.co.uk>
9
+ * @copyright Copyright (c) 2014 C3 Media Ltd (http://www.c3media.co.uk)
10
+ */
11
+
12
+ /** @modification Setting banner colour based on environment. Also inserts name of environment after logo */
13
+ /** @var C3_EnvironmentBanner_Helper_Data $envHelper */
14
+ $envHelper = Mage::helper("c3_environmentbanner");
15
+ $env = $envHelper->getEnvironment();
16
+ $cols = $envHelper->getEnvColours();
17
+ ?>
18
+ <style type="text/css">
19
+ h2.env {
20
+ float: left;
21
+ margin-top: 13px;
22
+ color: white;
23
+ }
24
+ <?php
25
+ // Change colour of heading if that option is turned on
26
+ if ($envHelper->isChangeAdminColour()):
27
+ ?>
28
+ .ebborder {
29
+ position:fixed;
30
+ z-index: 10000;
31
+ }
32
+ #ebtop,#ebbottom {
33
+ left:0;
34
+ width:100%;
35
+ height:3px;
36
+ }
37
+ #ebtop {
38
+ top:0;
39
+ }
40
+ #ebbottom {
41
+ bottom:0;
42
+ }
43
+ #ebleft,#ebright {
44
+ top:0;
45
+ height:100%;
46
+ width:3px;
47
+ }
48
+ #ebleft {
49
+ left:0;
50
+ }
51
+ #ebright {
52
+ right:0;
53
+ }
54
+
55
+ .header {
56
+ background-color: <?php echo $cols->getBeLighterColor() ?>;
57
+ background-image: -webkit-gradient(linear, left top, left bottom, from(<?php echo $cols->getBeLighterColor() ?>), to(<?php echo $cols->getBeColor() ?>));
58
+ background-image: -webkit-linear-gradient(top, <?php echo $cols->getBeLighterColor() ?>, <?php echo $cols->getBeColor() ?>);
59
+ background-image: -moz-linear-gradient(top, <?php echo $cols->getBeLighterColor() ?>, <?php echo $cols->getBeColor() ?>);
60
+ background-image: -ms-linear-gradient(top, <?php echo $cols->getBeLighterColor() ?>, <?php echo $cols->getBeColor() ?>);
61
+ background-image: -o-linear-gradient(top, <?php echo $cols->getBeLighterColor() ?>, <?php echo $cols->getBeColor() ?>);
62
+ }
63
+ .ebborder {
64
+ background-color: <?php echo $cols->getBeBorderColor() ?>;
65
+ }
66
+ <?php endif; ?>
67
+ </style>
68
+ <?php
69
+ /** @var $this Mage_Adminhtml_Block_Page_Header */
70
+ ?>
71
+ <div id="ebtop" class="ebborder"></div>
72
+ <div id="ebbottom" class="ebborder"></div>
73
+ <div id="ebleft" class="ebborder"></div>
74
+ <div id="ebright" class="ebborder"></div>
75
+ <div class="header-top">
76
+ <a href="<?php echo $this->getHomeLink() ?>"><img src="<?php echo $this->getSkinUrl('images/' . $envHelper->getAdminLogoFilename()) ?>" alt="<?php echo $this->__('Magento Logo') ?>" class="logo"/><?php if ($envHelper->isDisplayAdminEnv()) { echo '<h2 class="env">'.ucfirst($env).'</h2>'; } ?></a>
77
+ <div class="header-right">
78
+ <p class="super">
79
+ <?php echo $this->__("Logged in as %s", $this->escapeHtml($this->getUser()->getUsername())) ?><span class="separator">|</span><?php echo $this->formatDate(null, 'full') ?><span class="separator">|</span><a href="http://golinks.magento.com/CE15" onclick="this.target='_blank'" class="go-try"><?php echo $this->__('Try Magento Go for Free') ?></a><span class="separator">|</span><a href="<?php echo $this->getLogoutLink() ?>" class="link-logout"><?php echo $this->__('Log Out') ?></a>
80
+ </p>
81
+ <?php if ( Mage::getSingleton('admin/session')->isAllowed('admin/global_search') ): ?>
82
+ <fieldset>
83
+ <legend>Search</legend>
84
+ <span id="global_search_indicator" class="autocomplete-indicator" style="display: none">
85
+ <img src="<?php echo $this->getSkinUrl('images/ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading...') ?>" class="v-middle"/>
86
+ </span>
87
+ <?php $defSearch = $this->__('Global Record Search') ?>
88
+ <input id="global_search" name="query" type="text" class="input-text" value="<?php if(!empty($query)): ?><?php echo $query ?><?php else: ?><?php echo $defSearch ?><?php endif ?>" onfocus="if(this.value=='<?php echo $defSearch ?>')this.value=''; " onblur="if(this.value=='')this.value='<?php echo $defSearch ?>';" />
89
+ <div id="global_search_autocomplete" class="autocomplete"></div>
90
+ <script type="text/javascript">
91
+ new Ajax.Autocompleter(
92
+ 'global_search',
93
+ 'global_search_autocomplete',
94
+ '<?php echo $this->getUrl('adminhtml/index/globalSearch') ?>',
95
+ {
96
+ paramName:"query",
97
+ minChars:2,
98
+ indicator:"global_search_indicator",
99
+ updateElement:getSelectionId,
100
+ evalJSON:'force'
101
+ }
102
+ );
103
+ function getSelectionId(li) {
104
+ location.href = li.getAttribute('url');
105
+ }
106
+ </script>
107
+ </fieldset>
108
+ <?php endif; ?>
109
+ </div>
110
+ </div>
app/design/frontend/base/default/layout/c3_environmentbanner.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * C3 Media Ltd
5
+ *
6
+ * @title Environment Banner.
7
+ * @category C3
8
+ * @package C3_EnvironmentBanner
9
+ * @author C3 Development Team <development@c3media.co.uk>
10
+ * @copyright Copyright (c) 2014 C3 Media Ltd (http://www.c3media.co.uk)
11
+ */
12
+ -->
13
+ <layout version="1.0.0">
14
+ <default>
15
+ <reference name="after_body_start">
16
+ <block type="core/template" name="environment.banner" as="environmentBanner" template="c3_environmentbanner/banner.phtml"/>
17
+ </reference>
18
+ </default>
19
+ </layout>
app/design/frontend/base/default/template/c3_environmentbanner/banner.phtml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * C3 Media Ltd
4
+ *
5
+ * @title Environment Banner.
6
+ * @category C3
7
+ * @package C3_EnvironmentBanner
8
+ * @author C3 Development Team <development@c3media.co.uk>
9
+ * @copyright Copyright (c) 2014 C3 Media Ltd (http://www.c3media.co.uk)
10
+ */
11
+
12
+ /** @var C3_EnvironmentBanner_Helper_Data $helper */
13
+ $helper = Mage::helper("c3_environmentbanner");
14
+ if ($helper->isDisplayFrontendBanner()):
15
+ $env = $helper->getEnvironment();
16
+ $cols = $helper->getEnvColours();
17
+ ?>
18
+ <style type="text/css">
19
+ .ribbon-wrapper {
20
+ width: 160px;
21
+ height: 160px;
22
+ overflow: hidden;
23
+ position: fixed;
24
+ top: 0px;
25
+ right: 0px;
26
+ z-index: 10000;
27
+ }
28
+
29
+ .ribbon-inner {
30
+ font: bold 18px Sans-Serif;
31
+ color: #333;
32
+ text-align: center;
33
+ text-shadow: rgba(255,255,255,0.5) 0px 1px 0px;
34
+ -webkit-transform: rotate(45deg);
35
+ -moz-transform: rotate(45deg);
36
+ -ms-transform: rotate(45deg);
37
+ -o-transform: rotate(45deg);
38
+ position: relative;
39
+ padding: 20px 0px;
40
+ left: 3px;
41
+ top: 22px;
42
+ width: 210px;
43
+ opacity: 0.9;
44
+ }
45
+ .ribbon-inner.<?php echo $env ?> {
46
+ background-color: <?php echo $cols->getFeLighterBgcolor() ?>;
47
+ background-image: -webkit-gradient(linear, left top, left bottom, from(<?php echo $cols->getFeLighterBgcolor() ?>), to(<?php echo $cols->getFeBgcolor() ?>));
48
+ background-image: -webkit-linear-gradient(top, <?php echo $cols->getFeLighterBgcolor() ?>, <?php echo $cols->getFeBgcolor() ?>);
49
+ background-image: -moz-linear-gradient(top, <?php echo $cols->getFeLighterBgcolor() ?>, <?php echo $cols->getFeBgcolor() ?>);
50
+ background-image: -ms-linear-gradient(top, <?php echo $cols->getFeLighterBgcolor() ?>, <?php echo $cols->getFeBgcolor() ?>);
51
+ background-image: -o-linear-gradient(top, <?php echo $cols->getFeLighterBgcolor() ?>, <?php echo $cols->getFeBgcolor() ?>);
52
+ color: <?php echo $cols->getFeColor() ?>;
53
+ }
54
+ </style>
55
+ <div class="ribbon-wrapper" onclick="document.getElementById('envbanner').style.display = 'none';" id="envbanner"><div class="ribbon-inner <?php echo $env ?>" title="click to hide"><?php echo ucfirst($env) ?></div></div>
56
+
57
+ <?php endif; ?>
app/etc/modules/C3_EnvironmentBanner.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <C3_EnvironmentBanner>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <depends></depends>
8
+ </C3_EnvironmentBanner>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>c3-environment-banner</name>
4
+ <version>1.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>GNU General Public License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Tell at a glance if you are in a production, staging or dev environment - visual banners on frontend and admin</summary>
10
+ <description>&lt;p&gt;For any Magento user who has both a live site and a test/staging site.&lt;/p&gt;&#xD;
11
+ &#xD;
12
+ &lt;p&gt;Have you ever performed an action - deleted a product or created a promotion live, only to realise that you've accidentally done it on the production site rather than a development copy? Be honest now.&lt;/p&gt;&#xD;
13
+ &#xD;
14
+ &lt;p&gt;If so, this extension is for you. It adds a discrete corner banner to the frontend of non-production websites (fail-safe - if it doesn't know what environment it is in then it assumes it is on a production server). It is more striking on the admin side, where the entire title bar is colour-coded, and a border added to the page so that no matter how long the page (I'm looking at you, system config), you'll always have a visual reminder of which environment you are in.&lt;/p&gt;&#xD;
15
+ &#xD;
16
+ &lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt; The environment is picked up from the commonly used APPLICATION_ENV environment variable. This is set by the web-server, and for apache it just means adding in a single line to your .htaccess file. e.g.&#xD;
17
+ SetEnv APPLICATION_ENV &amp;quot;staging&amp;quot;&lt;/p&gt;&#xD;
18
+ &#xD;
19
+ &lt;h1&gt;Information&lt;/h1&gt;&#xD;
20
+ &lt;p&gt;You can set any set of environments and colours in the admin interface. As default these are: production, staging, preview and development&lt;/p&gt;&#xD;
21
+ &lt;p&gt;The extension is &lt;a href="https://github.com/c3limited/magento-environment-banner"&gt;Open source on GitHub&lt;/a&gt;&lt;/p&gt;&#xD;
22
+ &lt;p&gt;Include via composer or modman&lt;/p&gt;&#xD;
23
+ &lt;p&gt;Oldest supported CE version is 1.6.0.0&lt;/p&gt;&#xD;
24
+ &lt;p&gt;Tested in EE 1.13.0.0 to 1.14.0.1&lt;/p&gt;&#xD;
25
+ &lt;p&gt;Developed by C3 Media, a full service &lt;a href="http://www.c3media.co.uk"&gt;Magento agency&lt;/a&gt;&lt;/p&gt;</description>
26
+ <notes>&lt;ul&gt;&#xD;
27
+ &lt;li&gt;Safe. DOES NOT display on production sites - fails safe to display nothing if it does not recognise the environment&lt;/li&gt;&#xD;
28
+ &lt;li&gt;Display corner banner on front end pages&lt;/li&gt;&#xD;
29
+ &lt;li&gt;Optionally change colour in admin&lt;/li&gt;&#xD;
30
+ &lt;li&gt;Fully modifiable and extensible list of environments&lt;/li&gt;&#xD;
31
+ &lt;li&gt;Use safety colours (defaults to traffic lights) or set your own&lt;/li&gt;&#xD;
32
+ &lt;/ul&gt;</notes>
33
+ <authors><author><name>C3 Media</name><user>c3media_ltd</user><email>hello@c3media.co.uk</email></author></authors>
34
+ <date>2014-10-01</date>
35
+ <time>15:59:30</time>
36
+ <contents><target name="mageetc"><dir name="modules"><file name="C3_EnvironmentBanner.xml" hash="35dfc2771b04c92c1a007103db954e7b"/></dir></target><target name="magelocal"><dir name="C3"><dir name="EnvironmentBanner"><dir name="Block"><dir name="Adminhtml"><dir name="Page"><file name="Header.php" hash="d0cb927ced912b84f9a495df946c0ac1"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Environment.php" hash="c5333c5851ba0c7b47520cdffa0ae53b"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="bf310c888e9305078db2d9afbaad95a6"/></dir><dir name="Model"><file name="Colours.php" hash="36cf70a33c0e8ee3b5ff6cc8239e86e3"/></dir><dir name="etc"><file name="adminhtml.xml" hash="8f49b5c04cdcfb2ff975c8227d30d33c"/><file name="config.xml" hash="82b5c13bc79878a3b2407d9a05063879"/><file name="system.xml" hash="4d6dfff3681f6df651cf8208767968a5"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="c3_environmentbanner"><file name="header.phtml" hash="2fb5086ba8f7129663a72b9eab4a4e62"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="c3_environmentbanner"><file name="banner.phtml" hash="1667bdc1fb1bf77c963280aba36c8c7e"/></dir></dir><dir name="layout"><file name="c3_environmentbanner.xml" hash="f080e3fefdd423257212a8ac9e6f1084"/></dir></dir></dir></dir></target></contents>
37
+ <compatible/>
38
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><extension><name>Core</name><min/><max/></extension></required></dependencies>
39
+ </package>