Version Notes
Features:
- Set the URL used for each of your environments
- Flag will show at the top of the Magento Admin screen clearly indicating with text and color which environment you're working in
- Header bar which displays when scrolled down on an admin page will display styling that matches the environment flag color
Download this release
Release Info
Developer | Tim Dolloff |
Extension | DLS_Environment |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/DLS/Base/Helper/Data.php +20 -0
- app/code/community/DLS/Base/Helper/Logo.php +83 -0
- app/code/community/DLS/Base/etc/config.xml +52 -0
- app/code/community/DLS/Base/etc/system.xml +10 -0
- app/code/community/DLS/Environment/Block/Adminhtml/Base.php +45 -0
- app/code/community/DLS/Environment/Block/Adminhtml/Flag.php +40 -0
- app/code/community/DLS/Environment/Helper/Data.php +151 -0
- app/code/community/DLS/Environment/Model/Settings.php +7 -0
- app/code/community/DLS/Environment/etc/config.xml +93 -0
- app/code/community/DLS/Environment/etc/system.xml +107 -0
- app/code/community/DLS/Utility/Helper/Color.php +29 -0
- app/code/community/DLS/Utility/Helper/Data.php +7 -0
- app/code/community/DLS/Utility/etc/config.xml +28 -0
- app/design/adminhtml/default/default/layout/dls/base.xml +8 -0
- app/design/adminhtml/default/default/layout/dls/environment.xml +12 -0
- app/design/adminhtml/default/default/layout/dls/environment/flag.xml +13 -0
- app/design/adminhtml/default/default/template/dls/environment.phtml +7 -0
- app/design/adminhtml/default/default/template/dls/environment/flag.phtml +18 -0
- app/etc/modules/DLS_Base.xml +12 -0
- app/etc/modules/DLS_Environment.xml +16 -0
- app/etc/modules/DLS_Utility.xml +9 -0
- js/dls/environment.js +57 -0
- js/dls/environment/flag.js +57 -0
- package.xml +24 -0
- skin/adminhtml/base/default/dls/base.css +7 -0
- skin/adminhtml/base/default/dls/environment/flag.css +28 -0
- skin/adminhtml/base/default/dls/environment/images/environment_flag.png +0 -0
- skin/adminhtml/base/default/dls/images/dls_logo.png +0 -0
- skin/adminhtml/base/default/images/dls/logo/dls_logo.png +0 -0
- skin/adminhtml/base/default/images/dls/logo/dls_logo_black.png +0 -0
- skin/adminhtml/base/default/images/dls/logo/dls_logo_white.png +0 -0
- skin/adminhtml/base/default/images/dls/logo/three_dots_logo.png +0 -0
- skin/adminhtml/base/default/images/dls/logo/three_dots_logo_black.png +0 -0
- skin/adminhtml/base/default/images/dls/logo/three_dots_logo_white.png +0 -0
app/code/community/DLS/Base/Helper/Data.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class DLS_Base_Helper_Data extends Mage_Core_Helper_Data
|
5 |
+
{
|
6 |
+
const DLS_WEBSITE_URL_CONFIG_PATH = 'dls_base/website_url';
|
7 |
+
|
8 |
+
protected $_dls_website_url = null;
|
9 |
+
|
10 |
+
public function getDLSWebsiteUrl()
|
11 |
+
{
|
12 |
+
if (is_null($this->_dls_website_url))
|
13 |
+
{
|
14 |
+
$dls_website_url = Mage::getStoreConfig(self::DLS_WEBSITE_URL_CONFIG_PATH);
|
15 |
+
$this->_dls_website_url = $dls_website_url;
|
16 |
+
}
|
17 |
+
|
18 |
+
return $this->_dls_website_url;
|
19 |
+
}
|
20 |
+
}
|
app/code/community/DLS/Base/Helper/Logo.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DLS_Base_Helper_Logo
|
4 |
+
{
|
5 |
+
const DLS_LOGO_SKIN_DIRECTORY = 'dls_base/logo/skin_directory';
|
6 |
+
const DLS_LIGHT_LOGO_IMAGE_NAME = 'dls_base/logo/logo_light_image_name';
|
7 |
+
const DLS_DARK_LOGO_IMAGE_NAME = 'dls_base/logo/logo_dark_image_name';
|
8 |
+
const DLS_LIGHT_LOGO_DOTS_IMAGE_NAME = 'dls_base/logo/logo_dots_light_image_name';
|
9 |
+
const DLS_DARK_LOGO_DOTS_IMAGE_NAME = 'dls_base/logo/logo_dots_dark_image_name';
|
10 |
+
|
11 |
+
protected $_dls_light_logo_image_url = null;
|
12 |
+
protected $_dls_dark_logo_image_url = null;
|
13 |
+
protected $_dls_light_logo_dots_image_url = null;
|
14 |
+
protected $_dls_dark_logo_dots_image_url = null;
|
15 |
+
|
16 |
+
public function getDLSLightLogoImageURL()
|
17 |
+
{
|
18 |
+
if (is_null($this->_dls_light_logo_image_url))
|
19 |
+
{
|
20 |
+
$dls_logo_skin_directory = Mage::getStoreConfig(self::DLS_LOGO_SKIN_DIRECTORY);
|
21 |
+
$dls_light_logo_image_name = Mage::getStoreConfig(self::DLS_LIGHT_LOGO_IMAGE_NAME);
|
22 |
+
$this->_dls_light_logo_image_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . DS . $dls_logo_skin_directory . DS . $dls_light_logo_image_name;
|
23 |
+
}
|
24 |
+
|
25 |
+
return $this->_dls_light_logo_image_url;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getDLSDarkLogoImageURL()
|
29 |
+
{
|
30 |
+
if (is_null($this->_dls_dark_logo_image_url))
|
31 |
+
{
|
32 |
+
$dls_logo_skin_directory = Mage::getStoreConfig(self::DLS_LOGO_SKIN_DIRECTORY);
|
33 |
+
$dls_dark_logo_image_name = Mage::getStoreConfig(self::DLS_DARK_LOGO_IMAGE_NAME);
|
34 |
+
$this->_dls_dark_logo_image_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . DS . $dls_logo_skin_directory . DS . $dls_dark_logo_image_name;
|
35 |
+
}
|
36 |
+
|
37 |
+
return $this->_dls_dark_logo_image_url;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getDLSLogoURL($light = true)
|
41 |
+
{
|
42 |
+
if ($light)
|
43 |
+
{
|
44 |
+
return $this->getDLSLightLogoImageURL();
|
45 |
+
}
|
46 |
+
|
47 |
+
return $this->getDLSDarkLogoImageURL();
|
48 |
+
}
|
49 |
+
|
50 |
+
public function getDLSDotsLightLogoImageURL()
|
51 |
+
{
|
52 |
+
if (is_null($this->_dls_light_logo_dots_image_url))
|
53 |
+
{
|
54 |
+
$dls_logo_skin_directory = Mage::getStoreConfig(self::DLS_LOGO_SKIN_DIRECTORY);
|
55 |
+
$dls_light_logo_image_name = Mage::getStoreConfig(self::DLS_LIGHT_LOGO_DOTS_IMAGE_NAME);
|
56 |
+
$this->_dls_light_logo_dots_image_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . DS . $dls_logo_skin_directory . DS . $dls_light_logo_image_name;
|
57 |
+
}
|
58 |
+
|
59 |
+
return $this->_dls_light_logo_dots_image_url;
|
60 |
+
}
|
61 |
+
|
62 |
+
public function getDLSDotsDarkLogoImageURL()
|
63 |
+
{
|
64 |
+
if (is_null($this->_dls_dark_logo_dots_image_url))
|
65 |
+
{
|
66 |
+
$dls_logo_skin_directory = Mage::getStoreConfig(self::DLS_LOGO_SKIN_DIRECTORY);
|
67 |
+
$dls_dark_logo_image_name = Mage::getStoreConfig(self::DLS_DARK_LOGO_DOTS_IMAGE_NAME);
|
68 |
+
$this->_dls_dark_logo_image_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . DS . $dls_logo_skin_directory . DS . $dls_dark_logo_image_name;
|
69 |
+
}
|
70 |
+
|
71 |
+
return $this->_dls_dark_logo_dots_image_url;
|
72 |
+
}
|
73 |
+
|
74 |
+
public function getDLSDotsLogoURL($light = true)
|
75 |
+
{
|
76 |
+
if ($light)
|
77 |
+
{
|
78 |
+
return $this->getDLSDotsLightLogoImageURL();
|
79 |
+
}
|
80 |
+
|
81 |
+
return $this->getDLSDotsDarkLogoImageURL();
|
82 |
+
}
|
83 |
+
}
|
app/code/community/DLS/Base/etc/config.xml
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<DLS_Base>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</DLS_Base>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<global>
|
10 |
+
<models>
|
11 |
+
<dls_base>
|
12 |
+
<class>DLS_Base_Model</class>
|
13 |
+
</dls_base>
|
14 |
+
</models>
|
15 |
+
|
16 |
+
<helpers>
|
17 |
+
<dls_base>
|
18 |
+
<class>DLS_Base_Helper</class>
|
19 |
+
</dls_base>
|
20 |
+
</helpers>
|
21 |
+
|
22 |
+
<blocks>
|
23 |
+
<dls_base>
|
24 |
+
<class>DLS_Base_Block</class>
|
25 |
+
</dls_base>
|
26 |
+
</blocks>
|
27 |
+
</global>
|
28 |
+
|
29 |
+
<adminhtml>
|
30 |
+
<layout>
|
31 |
+
<updates>
|
32 |
+
<dls_base_adminhtml>
|
33 |
+
<file>dls/base.xml</file>
|
34 |
+
</dls_base_adminhtml>
|
35 |
+
</updates>
|
36 |
+
</layout>
|
37 |
+
</adminhtml>
|
38 |
+
|
39 |
+
<default>
|
40 |
+
<dls_base>
|
41 |
+
<logo>
|
42 |
+
<skin_directory>adminhtml/base/default/images/dls/logo</skin_directory>
|
43 |
+
<logo_dark_image_name>dls_logo_black.png</logo_dark_image_name>
|
44 |
+
<logo_light_image_name>dls_logo_white.png</logo_light_image_name>
|
45 |
+
<logo_dots_image_name>three_dots_logo.png</logo_dots_image_name>
|
46 |
+
<logo_dots_dark_image_name>three_dots_logo_black.png</logo_dots_dark_image_name>
|
47 |
+
<logo_dots_light_image_name>three_dots_logo_white.png</logo_dots_light_image_name>
|
48 |
+
</logo>
|
49 |
+
<website_url>https://www.dlssoftwarestudios.com/</website_url>
|
50 |
+
</dls_base>
|
51 |
+
</default>
|
52 |
+
</config>
|
app/code/community/DLS/Base/etc/system.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<dls_extensions translate="label" module="dls_base">
|
5 |
+
<label>DLS Software Studios</label>
|
6 |
+
<sort_order>400</sort_order>
|
7 |
+
<class>dls-tab-block</class>
|
8 |
+
</dls_extensions>
|
9 |
+
</tabs>
|
10 |
+
</config>
|
app/code/community/DLS/Environment/Block/Adminhtml/Base.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DLS_Environment_Block_Adminhtml_Base extends Mage_Core_Block_Template
|
4 |
+
{
|
5 |
+
protected $_dlsEnvironmentHelper = null;
|
6 |
+
protected $_environment_config_data_json = null;
|
7 |
+
protected $_current_environment_config_data_json = null;
|
8 |
+
|
9 |
+
public function getEnvironmentConfigDataJson()
|
10 |
+
{
|
11 |
+
if (is_null($this->_environment_config_data_json))
|
12 |
+
{
|
13 |
+
$environment_config_data_array = $this->_getDlsEnvironmentHelper()->getEnvironmentConfigDataArray();
|
14 |
+
$this->_environment_config_data_json = json_encode($environment_config_data_array);
|
15 |
+
}
|
16 |
+
|
17 |
+
return $this->_environment_config_data_json;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function getCurrentEnvironmentConfigDataJson()
|
21 |
+
{
|
22 |
+
if (is_null($this->_current_environment_config_data_json))
|
23 |
+
{
|
24 |
+
$current_environment_config_data = $this->_getDlsEnvironmentHelper()->getCurrentEnvironmentData();
|
25 |
+
$this->_current_environment_config_data_json = json_encode($current_environment_config_data);
|
26 |
+
}
|
27 |
+
|
28 |
+
return $this->_current_environment_config_data_json;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getDLSWebsiteUrl()
|
32 |
+
{
|
33 |
+
return $this->_getDlsEnvironmentHelper()->getDLSWebsiteUrl();
|
34 |
+
}
|
35 |
+
|
36 |
+
protected function _getDlsEnvironmentHelper()
|
37 |
+
{
|
38 |
+
if (is_null($this->_dlsEnvironmentHelper))
|
39 |
+
{
|
40 |
+
$this->_dlsEnvironmentHelper = Mage::helper('dls_environment');
|
41 |
+
}
|
42 |
+
|
43 |
+
return $this->_dlsEnvironmentHelper;
|
44 |
+
}
|
45 |
+
}
|
app/code/community/DLS/Environment/Block/Adminhtml/Flag.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class DLS_Environment_Block_Adminhtml_Flag extends Mage_Core_Block_Template
|
5 |
+
{
|
6 |
+
protected $is_foreground_light = null;
|
7 |
+
|
8 |
+
public function getDLSLogoSrcUrl()
|
9 |
+
{
|
10 |
+
return Mage::helper('dls_base/logo')->getDLSLogoURL($this->isForegroundLight());
|
11 |
+
}
|
12 |
+
|
13 |
+
public function isForegroundLight()
|
14 |
+
{
|
15 |
+
if (is_null($this->is_foreground_light))
|
16 |
+
{
|
17 |
+
// Get the environment config data
|
18 |
+
$current_environment_config_data = Mage::helper('dls_environment')
|
19 |
+
->getCurrentEnvironmentData();
|
20 |
+
|
21 |
+
if (isset($current_environment_config_data[DLS_Environment_Helper_Data::BACKGROUND_COLOR_INDEX]))
|
22 |
+
{
|
23 |
+
$current_background_color = $current_environment_config_data[DLS_Environment_Helper_Data::BACKGROUND_COLOR_INDEX];
|
24 |
+
$this->is_foreground_light = Mage::helper('dls_utility/color')->isColorDark($current_background_color);
|
25 |
+
}
|
26 |
+
else
|
27 |
+
{
|
28 |
+
// Light by default
|
29 |
+
$this->is_foreground_light = true;
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
return $this->is_foreground_light;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getDLSWebsiteUrl()
|
37 |
+
{
|
38 |
+
return Mage::helper('dls_base')->getDLSWebsiteUrl();
|
39 |
+
}
|
40 |
+
}
|
app/code/community/DLS/Environment/Helper/Data.php
ADDED
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DLS_Environment_Helper_Data extends Mage_Core_Helper_Data
|
4 |
+
{
|
5 |
+
const DLS_ENVIRONMENT_CONFIG_PATH = 'environment_flag/environment_settings';
|
6 |
+
|
7 |
+
const LOCAL_CODE = 'local';
|
8 |
+
const DEV_CODE = 'dev';
|
9 |
+
const STAGE_CODE = 'stage';
|
10 |
+
const LIVE_CODE = 'live';
|
11 |
+
const DEFAULT_CODE = 'other';
|
12 |
+
const BACKGROUND_COLOR_INDEX = 'background_color';
|
13 |
+
|
14 |
+
protected $_base_urls_to_check = array();
|
15 |
+
|
16 |
+
protected $_environment_config_data = null;
|
17 |
+
protected $_environment_subdomain = null;
|
18 |
+
protected $_current_environment_data = null;
|
19 |
+
protected $_default_environment_data = null;
|
20 |
+
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
$this->_base_urls_to_check = array(
|
24 |
+
self::LOCAL_CODE => self::LOCAL_CODE . '_base_url',
|
25 |
+
self::DEV_CODE => self::DEV_CODE . '_base_url',
|
26 |
+
self::STAGE_CODE => self::STAGE_CODE . '_base_url',
|
27 |
+
self::LIVE_CODE => self::LIVE_CODE . '_base_url',
|
28 |
+
);
|
29 |
+
|
30 |
+
$this->_default_environment_data = array(
|
31 |
+
'name' => 'other',
|
32 |
+
self::BACKGROUND_COLOR_INDEX => '#4E3E07',
|
33 |
+
'color' => '#ffffff',
|
34 |
+
);
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getCurrentEnvironmentData()
|
38 |
+
{
|
39 |
+
if (is_null($this->_current_environment_data))
|
40 |
+
{
|
41 |
+
$matched_environment_code = $this->matchCurrentBaseUrlToEnvironment();
|
42 |
+
$environment_config_data = $this->getEnvironmentConfigDataArray();
|
43 |
+
|
44 |
+
if (isset($environment_config_data[$matched_environment_code]))
|
45 |
+
{
|
46 |
+
$this->_current_environment_data = $environment_config_data[$matched_environment_code];
|
47 |
+
}
|
48 |
+
else
|
49 |
+
{
|
50 |
+
$this->_current_environment_data = $this->_default_environment_data;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
return $this->_current_environment_data;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function matchCurrentBaseUrlToEnvironment()
|
58 |
+
{
|
59 |
+
$base_url = $this->getAdminBaseUrl();
|
60 |
+
$base_urls_to_match_against = $this->getBaseUrlsToMatchAgainst();
|
61 |
+
|
62 |
+
foreach ($base_urls_to_match_against as $environment_code => $base_url_to_check)
|
63 |
+
{
|
64 |
+
if (!strcmp($base_url, $base_url_to_check))
|
65 |
+
{
|
66 |
+
return $environment_code;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
return self::DEFAULT_CODE;
|
71 |
+
}
|
72 |
+
|
73 |
+
public function getAdminBaseUrl()
|
74 |
+
{
|
75 |
+
$urlModel = Mage::getModel('core/url');
|
76 |
+
$is_admin_url_secure = $urlModel->getSecure();
|
77 |
+
$url_params = array('_secure' => $is_admin_url_secure,
|
78 |
+
'_type' => Mage_Core_Model_Store::URL_TYPE_WEB,
|
79 |
+
'_store' => Mage_Core_Model_Store::ADMIN_CODE);
|
80 |
+
|
81 |
+
$admin_base_url = $urlModel->getBaseUrl($url_params);
|
82 |
+
return $admin_base_url;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* This is currently implemented to keep performance in mind, not keeping in mind the future possibility
|
87 |
+
* of allowing dynamic declaration of environments by the user
|
88 |
+
*
|
89 |
+
*/
|
90 |
+
public function getBaseUrlsToMatchAgainst()
|
91 |
+
{
|
92 |
+
$base_urls_to_match_against = array();
|
93 |
+
$environment_config_data = $this->getEnvironmentConfigDataArray();
|
94 |
+
foreach ($this->_base_urls_to_check as $environment_code => $base_url_to_check)
|
95 |
+
{
|
96 |
+
// Be overly cautious, make sure the config value is set
|
97 |
+
if (isset($environment_config_data[$base_url_to_check]))
|
98 |
+
{
|
99 |
+
$base_url_to_check_value = $environment_config_data[$base_url_to_check];
|
100 |
+
$base_urls_to_match_against[$environment_code] = $base_url_to_check_value;
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
return $base_urls_to_match_against;
|
105 |
+
}
|
106 |
+
|
107 |
+
public function getEnvironmentConfigDataArray()
|
108 |
+
{
|
109 |
+
if (is_null($this->_environment_config_data))
|
110 |
+
{
|
111 |
+
$environment_config_data = Mage::getStoreConfig(self::DLS_ENVIRONMENT_CONFIG_PATH);
|
112 |
+
$this->_environment_config_data = $environment_config_data;
|
113 |
+
}
|
114 |
+
|
115 |
+
return $this->_environment_config_data;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Returned the value before the first . in the Mage:getBaseUrl() domain
|
120 |
+
*
|
121 |
+
* This method is no longer in use
|
122 |
+
*
|
123 |
+
* @return mixed|null|string
|
124 |
+
*/
|
125 |
+
public function getCurrentEnvironmentSubdomain()
|
126 |
+
{
|
127 |
+
if (is_null($this->_environment_subdomain))
|
128 |
+
{
|
129 |
+
$url = Mage::getBaseUrl();
|
130 |
+
$split_on_slash = explode('/', $url);
|
131 |
+
if (!is_array($split_on_slash) || !isset($split_on_slash[2]))
|
132 |
+
{
|
133 |
+
$this->_environment_subdomain = self::DEFAULT_CODE;
|
134 |
+
return $this->_environment_subdomain;
|
135 |
+
}
|
136 |
+
|
137 |
+
$domain = $split_on_slash[2];
|
138 |
+
$split_on_dot = explode('.', $domain);
|
139 |
+
|
140 |
+
if (!is_array($split_on_slash) || (count($split_on_dot) < 1))
|
141 |
+
{
|
142 |
+
$this->_environment_subdomain = self::DEFAULT_CODE;
|
143 |
+
return $this->_environment_subdomain;
|
144 |
+
}
|
145 |
+
|
146 |
+
$this->_environment_subdomain = reset($split_on_dot);
|
147 |
+
}
|
148 |
+
|
149 |
+
return $this->_environment_subdomain;
|
150 |
+
}
|
151 |
+
}
|
app/code/community/DLS/Environment/Model/Settings.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class DLS_Environment_Model_Settings
|
5 |
+
{
|
6 |
+
|
7 |
+
}
|
app/code/community/DLS/Environment/etc/config.xml
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<DLS_Environment>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</DLS_Environment>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<global>
|
10 |
+
<blocks>
|
11 |
+
<dls_environment>
|
12 |
+
<class>DLS_Environment_Block</class>
|
13 |
+
</dls_environment>
|
14 |
+
</blocks>
|
15 |
+
|
16 |
+
<helpers>
|
17 |
+
<dls_environment>
|
18 |
+
<class>DLS_Environment_Helper</class>
|
19 |
+
</dls_environment>
|
20 |
+
</helpers>
|
21 |
+
|
22 |
+
<models>
|
23 |
+
<dls_environment>
|
24 |
+
<class>DLS_Environment_Model</class>
|
25 |
+
</dls_environment>
|
26 |
+
</models>
|
27 |
+
</global>
|
28 |
+
|
29 |
+
<adminhtml>
|
30 |
+
<layout>
|
31 |
+
<updates>
|
32 |
+
<dls_environment>
|
33 |
+
<file>dls/environment.xml</file>
|
34 |
+
</dls_environment>
|
35 |
+
<dls_environment_flag>
|
36 |
+
<file>dls/environment/flag.xml</file>
|
37 |
+
</dls_environment_flag>
|
38 |
+
</updates>
|
39 |
+
</layout>
|
40 |
+
|
41 |
+
<acl>
|
42 |
+
<resources>
|
43 |
+
<admin>
|
44 |
+
<children>
|
45 |
+
<system>
|
46 |
+
<children>
|
47 |
+
<config>
|
48 |
+
<children>
|
49 |
+
<environment_flag>
|
50 |
+
<title>DLS Environment Flag</title>
|
51 |
+
</environment_flag>
|
52 |
+
</children>
|
53 |
+
</config>
|
54 |
+
</children>
|
55 |
+
</system>
|
56 |
+
</children>
|
57 |
+
</admin>
|
58 |
+
</resources>
|
59 |
+
</acl>
|
60 |
+
</adminhtml>
|
61 |
+
|
62 |
+
<default>
|
63 |
+
<environment_flag>
|
64 |
+
<environment_settings>
|
65 |
+
<local>
|
66 |
+
<name>local</name>
|
67 |
+
<background_color>#ffffff</background_color>
|
68 |
+
<color>#003d3f</color>
|
69 |
+
</local>
|
70 |
+
<dev>
|
71 |
+
<name>dev</name>
|
72 |
+
<background_color>#85c300</background_color>
|
73 |
+
<color>#ffffff</color>
|
74 |
+
</dev>
|
75 |
+
<stage>
|
76 |
+
<name>staging</name>
|
77 |
+
<background_color>#0000FF</background_color>
|
78 |
+
<color>#FFFFFF</color>
|
79 |
+
</stage>
|
80 |
+
<live>
|
81 |
+
<name>live</name>
|
82 |
+
<background_color>#FF0000</background_color>
|
83 |
+
<color>#ffffff</color>
|
84 |
+
</live>
|
85 |
+
<other>
|
86 |
+
<name>other</name>
|
87 |
+
<background_color>#4E3E07</background_color>
|
88 |
+
<color>#ffffff</color>
|
89 |
+
</other>
|
90 |
+
</environment_settings>
|
91 |
+
</environment_flag>
|
92 |
+
</default>
|
93 |
+
</config>
|
app/code/community/DLS/Environment/etc/system.xml
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<environment_flag translate="label" module="dls_environment">
|
5 |
+
<label>Environment Flag</label>
|
6 |
+
<class>dls-environment-flag-block</class>
|
7 |
+
<tab>dls_extensions</tab>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<sort_order>50</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>0</show_in_website>
|
12 |
+
<show_in_store>0</show_in_store>
|
13 |
+
<groups>
|
14 |
+
<environment_settings translate="label">
|
15 |
+
<label>Environment Configuration Settings</label>
|
16 |
+
<expanded>1</expanded>
|
17 |
+
<sort_order>100</sort_order>
|
18 |
+
<show_in_default>1</show_in_default>
|
19 |
+
<show_in_website>0</show_in_website>
|
20 |
+
<show_in_store>0</show_in_store>
|
21 |
+
<comment><![CDATA[<h3>The settings below depend on your value entered for System -> Configuration -> Web -> Secure -> Use Secure URLs in Admin<br>
|
22 |
+
If the value is <font style="color:blue">No</font>, then enter the EXACT value in System -> Configuration -> Web -> <font style="color:blue">Unsecure</font> -> Base URL<br>
|
23 |
+
If the value is <font style="color:red">Yes</font>, then enter the EXACT value in System -> Configuration -> Web -> <font style="color:red">Secure</font> -> Base URL</h3>]]>
|
24 |
+
</comment>
|
25 |
+
<fields>
|
26 |
+
<!-- Local Environment Settings -->
|
27 |
+
<local_heading translate="label">
|
28 |
+
<label><![CDATA[<h3>Local Environment</h3>]]></label>
|
29 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
30 |
+
<sort_order>10</sort_order>
|
31 |
+
<show_in_default>1</show_in_default>
|
32 |
+
<show_in_website>0</show_in_website>
|
33 |
+
<show_in_store>0</show_in_store>
|
34 |
+
</local_heading>
|
35 |
+
<local_base_url translate="label">
|
36 |
+
<label>Local Environment Base Url</label>
|
37 |
+
<frontend_type>text</frontend_type>
|
38 |
+
<validate>validate-url</validate>
|
39 |
+
<sort_order>20</sort_order>
|
40 |
+
<show_in_default>1</show_in_default>
|
41 |
+
<show_in_website>0</show_in_website>
|
42 |
+
<show_in_store>0</show_in_store>
|
43 |
+
<comment>Enter the Base Url for the admin panel on your local environments here</comment>
|
44 |
+
</local_base_url>
|
45 |
+
<!-- Development Environment Settings -->
|
46 |
+
<dev_heading translate="label">
|
47 |
+
<label><![CDATA[<h3>Dev Environment</h3>]]></label>
|
48 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
49 |
+
<sort_order>30</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>0</show_in_website>
|
52 |
+
<show_in_store>0</show_in_store>
|
53 |
+
</dev_heading>
|
54 |
+
<dev_base_url translate="label">
|
55 |
+
<label>Dev Environment Base Url</label>
|
56 |
+
<frontend_type>text</frontend_type>
|
57 |
+
<validate>validate-url</validate>
|
58 |
+
<sort_order>40</sort_order>
|
59 |
+
<show_in_default>1</show_in_default>
|
60 |
+
<show_in_website>0</show_in_website>
|
61 |
+
<show_in_store>0</show_in_store>
|
62 |
+
<comment>Enter the Base Url for the admin panel on your dev environment here</comment>
|
63 |
+
</dev_base_url>
|
64 |
+
<!-- Staging Environment Settings -->
|
65 |
+
<stage_heading translate="label">
|
66 |
+
<label><![CDATA[<h3>Staging Environment</h3>]]></label>
|
67 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
68 |
+
<sort_order>50</sort_order>
|
69 |
+
<show_in_default>1</show_in_default>
|
70 |
+
<show_in_website>0</show_in_website>
|
71 |
+
<show_in_store>0</show_in_store>
|
72 |
+
</stage_heading>
|
73 |
+
<stage_base_url translate="label">
|
74 |
+
<label>Staging Environment Base Url</label>
|
75 |
+
<frontend_type>text</frontend_type>
|
76 |
+
<validate>validate-url</validate>
|
77 |
+
<sort_order>60</sort_order>
|
78 |
+
<show_in_default>1</show_in_default>
|
79 |
+
<show_in_website>0</show_in_website>
|
80 |
+
<show_in_store>0</show_in_store>
|
81 |
+
<comment>Enter the Base Url for the admin panel on your staging environment here</comment>
|
82 |
+
</stage_base_url>
|
83 |
+
<!-- Live Environment Settings -->
|
84 |
+
<live_heading translate="label">
|
85 |
+
<label><![CDATA[<h3>Live Environment</h3>]]></label>
|
86 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
87 |
+
<sort_order>70</sort_order>
|
88 |
+
<show_in_default>1</show_in_default>
|
89 |
+
<show_in_website>0</show_in_website>
|
90 |
+
<show_in_store>0</show_in_store>
|
91 |
+
</live_heading>
|
92 |
+
<live_base_url translate="label">
|
93 |
+
<label>Live Environment Base Url</label>
|
94 |
+
<frontend_type>text</frontend_type>
|
95 |
+
<validate>validate-url</validate>
|
96 |
+
<sort_order>80</sort_order>
|
97 |
+
<show_in_default>1</show_in_default>
|
98 |
+
<show_in_website>0</show_in_website>
|
99 |
+
<show_in_store>0</show_in_store>
|
100 |
+
<comment>Enter the Base Url for the admin panel on your live environment here</comment>
|
101 |
+
</live_base_url>
|
102 |
+
</fields>
|
103 |
+
</environment_settings>
|
104 |
+
</groups>
|
105 |
+
</environment_flag>
|
106 |
+
</sections>
|
107 |
+
</config>
|
app/code/community/DLS/Utility/Helper/Color.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DLS_Utility_Helper_Color
|
4 |
+
{
|
5 |
+
const IS_LIGHT_COLOR_RGB_THRESHOLD = 650;
|
6 |
+
|
7 |
+
public function isColorDark($color_as_hex_rgb)
|
8 |
+
{
|
9 |
+
// If the color has # in front of it, remove it
|
10 |
+
$first_char = substr($color_as_hex_rgb, 0, 1);
|
11 |
+
if (!strcmp('#', $first_char))
|
12 |
+
{
|
13 |
+
$color_as_hex_rgb = substr($color_as_hex_rgb, 1);
|
14 |
+
}
|
15 |
+
|
16 |
+
// MUST DO SOME MORE ERROR CHECKING HERE
|
17 |
+
$r_hex_value = substr($color_as_hex_rgb, 0, 2);
|
18 |
+
$g_hex_value = substr($color_as_hex_rgb, 2, 2);
|
19 |
+
$b_hex_value = substr($color_as_hex_rgb, 4, 2);
|
20 |
+
|
21 |
+
$r_int_value = hexdec($r_hex_value);
|
22 |
+
$g_int_value = hexdec($g_hex_value);
|
23 |
+
$b_int_value = hexdec($b_hex_value);
|
24 |
+
|
25 |
+
$rgb_int_sum = $r_int_value + $g_int_value + $b_int_value;
|
26 |
+
|
27 |
+
return ($rgb_int_sum <= self::IS_LIGHT_COLOR_RGB_THRESHOLD);
|
28 |
+
}
|
29 |
+
}
|
app/code/community/DLS/Utility/Helper/Data.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class DLS_Utility_Helper_Data extends Mage_Core_Helper_Data
|
5 |
+
{
|
6 |
+
|
7 |
+
}
|
app/code/community/DLS/Utility/etc/config.xml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<DLS_Utility>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</DLS_Utility>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<global>
|
10 |
+
<models>
|
11 |
+
<dls_utility>
|
12 |
+
<class>DLS_Utility_Model</class>
|
13 |
+
</dls_utility>
|
14 |
+
</models>
|
15 |
+
|
16 |
+
<helpers>
|
17 |
+
<dls_utility>
|
18 |
+
<class>DLS_Utility_Helper</class>
|
19 |
+
</dls_utility>
|
20 |
+
</helpers>
|
21 |
+
|
22 |
+
<blocks>
|
23 |
+
<dls_utility>
|
24 |
+
<class>DLS_Utility_Block</class>
|
25 |
+
</dls_utility>
|
26 |
+
</blocks>
|
27 |
+
</global>
|
28 |
+
</config>
|
app/design/adminhtml/default/default/layout/dls/base.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<adminhtml_system_config_edit>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addCss"><stylesheet>dls/base.css</stylesheet></action>
|
6 |
+
</reference>
|
7 |
+
</adminhtml_system_config_edit>
|
8 |
+
</layout>
|
app/design/adminhtml/default/default/layout/dls/environment.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<default>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addJs"><script>dls/environment.js</script></action>
|
6 |
+
</reference>
|
7 |
+
|
8 |
+
<reference name="before_body_end">
|
9 |
+
<block type="dls_environment/adminhtml_base" name="dls_environment" template="dls/environment.phtml" />
|
10 |
+
</reference>
|
11 |
+
</default>
|
12 |
+
</layout>
|
app/design/adminhtml/default/default/layout/dls/environment/flag.xml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<default>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addJs"><script>dls/environment/flag.js</script></action>
|
6 |
+
<action method="addCss"><script>dls/environment/flag.css</script></action>
|
7 |
+
</reference>
|
8 |
+
|
9 |
+
<reference name="header">
|
10 |
+
<block type="dls_environment/adminhtml_flag" name="dls_environment_flag" template="dls/environment/flag.phtml" output="toHtml" />
|
11 |
+
</reference>
|
12 |
+
</default>
|
13 |
+
</layout>
|
app/design/adminhtml/default/default/template/dls/environment.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$dls_current_environment_config_json = $this->getCurrentEnvironmentConfigDataJson();
|
3 |
+
?>
|
4 |
+
|
5 |
+
<script type="text/javascript">
|
6 |
+
DLSEnvironmentObject = new DLSEnvironment('<?php echo $dls_current_environment_config_json; ?>');
|
7 |
+
</script>
|
app/design/adminhtml/default/default/template/dls/environment/flag.phtml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @class DLS_Environment_Block_Adminhtml_Flag
|
4 |
+
*/
|
5 |
+
$dls_website_url = $this->getDLSWebsiteUrl();
|
6 |
+
$dls_logo_src_url = $this->getDLSLogoSrcUrl();
|
7 |
+
?>
|
8 |
+
|
9 |
+
<span id="dls_environment_flag" class="dlsenv-header-flag" style="display:none;">
|
10 |
+
<span id="dls_environment_flag_label"></span>
|
11 |
+
<a href="<?php echo $dls_website_url ?>">
|
12 |
+
<img class="dlsenv-header-brand-logo" src="<?php echo $dls_logo_src_url ?>" height="10" width="37">
|
13 |
+
</a>
|
14 |
+
</span>
|
15 |
+
|
16 |
+
<script type="text/javascript">
|
17 |
+
DLSEnvironmentObjectFlagsObject = new DLSEnvironmentObjectFlags();
|
18 |
+
</script>
|
app/etc/modules/DLS_Base.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<DLS_Base>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Core />
|
9 |
+
</depends>
|
10 |
+
</DLS_Base>
|
11 |
+
</modules>
|
12 |
+
</config>
|
app/etc/modules/DLS_Environment.xml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<DLS_Environment>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Core />
|
9 |
+
<Mage_Admin />
|
10 |
+
<Mage_Adminhtml />
|
11 |
+
<DLS_Base />
|
12 |
+
<DLS_Utility/>
|
13 |
+
</depends>
|
14 |
+
</DLS_Environment>
|
15 |
+
</modules>
|
16 |
+
</config>
|
app/etc/modules/DLS_Utility.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<DLS_Utility>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</DLS_Utility>
|
8 |
+
</modules>
|
9 |
+
</config>
|
js/dls/environment.js
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var DLSEnvironment = new Class.create();
|
2 |
+
DLSEnvironment.prototype = {
|
3 |
+
initialize : function(dls_current_environment_config_json)
|
4 |
+
{
|
5 |
+
var dlsEnvironmentConfigJson = JSON.parse(dls_current_environment_config_json);
|
6 |
+
|
7 |
+
this.current_env_vars = dlsEnvironmentConfigJson;
|
8 |
+
this.foreground_is_light = true;
|
9 |
+
this.foreground_is_dark_threshold = 650;
|
10 |
+
|
11 |
+
this.initializeCurrentEnvVariables();
|
12 |
+
},
|
13 |
+
|
14 |
+
initializeCurrentEnvVariables : function()
|
15 |
+
{
|
16 |
+
this.determineForegroundColorBasedOnBackground();
|
17 |
+
},
|
18 |
+
|
19 |
+
determineForegroundColorBasedOnBackground : function()
|
20 |
+
{
|
21 |
+
var background_color = this.current_env_vars.background_color;
|
22 |
+
// Remove the # in front of the color if it is set
|
23 |
+
var first_char = background_color.charAt(0);
|
24 |
+
if (first_char == '#')
|
25 |
+
{
|
26 |
+
background_color = background_color.substring(1);
|
27 |
+
}
|
28 |
+
|
29 |
+
if (background_color.length != 6)
|
30 |
+
{
|
31 |
+
// There's an issue with the color. Default to light for the foreground
|
32 |
+
this.foreground_is_light = true;
|
33 |
+
}
|
34 |
+
|
35 |
+
var r_value = background_color.substring(0,2);
|
36 |
+
var b_value = background_color.substring(2,4);
|
37 |
+
var g_value = background_color.substring(4,6);
|
38 |
+
|
39 |
+
var r_integer = parseInt(r_value, 16);
|
40 |
+
var b_integer = parseInt(b_value, 16);
|
41 |
+
var g_integer = parseInt(g_value, 16);
|
42 |
+
|
43 |
+
if ((r_integer + b_integer + g_integer) < this.foreground_is_dark_threshold)
|
44 |
+
{
|
45 |
+
this.foreground_is_light = true;
|
46 |
+
}
|
47 |
+
else
|
48 |
+
{
|
49 |
+
this.foreground_is_light = false;
|
50 |
+
}
|
51 |
+
},
|
52 |
+
|
53 |
+
getCurrentEnvVars : function()
|
54 |
+
{
|
55 |
+
return this.current_env_vars;
|
56 |
+
}
|
57 |
+
}
|
js/dls/environment/flag.js
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var DLSEnvironmentObjectFlags = new Class.create();
|
2 |
+
DLSEnvironmentObjectFlags.prototype =
|
3 |
+
{
|
4 |
+
initialize : function(){
|
5 |
+
|
6 |
+
},
|
7 |
+
|
8 |
+
createEnvironmentFlags : function()
|
9 |
+
{
|
10 |
+
var current_env_vars = DLSEnvironmentObject.getCurrentEnvVars();
|
11 |
+
|
12 |
+
var dlsHeaderEnvironmentFlagElement = document.getElementById("dls_environment_flag");
|
13 |
+
var header = document.getElementsByClassName('logo')[0].parentNode;
|
14 |
+
header.parentNode.insertBefore(dlsHeaderEnvironmentFlagElement, header.nextSibling);
|
15 |
+
|
16 |
+
// Set styles
|
17 |
+
dlsHeaderEnvironmentFlagElement.style.backgroundColor = current_env_vars.background_color;
|
18 |
+
dlsHeaderEnvironmentFlagElement.style.color = current_env_vars.color;
|
19 |
+
|
20 |
+
// Set content
|
21 |
+
var dlsEnvHeaderFlagLabelElement = document.getElementById("dls_environment_flag_label");
|
22 |
+
dlsEnvHeaderFlagLabelElement.innerHTML = current_env_vars.name + ' environment';
|
23 |
+
|
24 |
+
dlsHeaderEnvironmentFlagElement.style.display = "block";
|
25 |
+
},
|
26 |
+
|
27 |
+
styleContentHeaderFloatingElement : function()
|
28 |
+
{
|
29 |
+
var current_env_vars = DLSEnvironmentObject.getCurrentEnvVars();
|
30 |
+
|
31 |
+
// Set content-header-floating background_color
|
32 |
+
var contentHeaderFloatingElements = document.getElementsByClassName('content-header-floating');
|
33 |
+
|
34 |
+
for (var i = 0; i < contentHeaderFloatingElements.length; i++)
|
35 |
+
{
|
36 |
+
var contentHeaderFloatingElement = contentHeaderFloatingElements[i];
|
37 |
+
contentHeaderFloatingElement.style.background = current_env_vars.background_color;
|
38 |
+
}
|
39 |
+
|
40 |
+
// Set the text color for the floating content header div if its CSS path follows base Magento
|
41 |
+
var contentHeaderHeadingElement =
|
42 |
+
document.querySelector("div.content-header-floating .content-header h3");
|
43 |
+
|
44 |
+
if (!(contentHeaderHeadingElement === null))
|
45 |
+
{
|
46 |
+
contentHeaderHeadingElement.style.color = current_env_vars.color;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
document.observe('dom:loaded', function () {
|
52 |
+
DLSEnvironmentObjectFlagsObject.createEnvironmentFlags();
|
53 |
+
});
|
54 |
+
|
55 |
+
Event.observe(window, 'load', function(){
|
56 |
+
DLSEnvironmentObjectFlagsObject.styleContentHeaderFloatingElement()
|
57 |
+
});
|
package.xml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>DLS_Environment</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Environment Flag clearly displays your current Magento admin environment to prevent data errors.</summary>
|
10 |
+
<description>Features:
|
11 |
+
- Set the URL used for each of your environments
|
12 |
+
- Flag will show at the top of the Magento Admin screen clearly indicating with text and color which environment you're working in
|
13 |
+
- Header bar which displays when scrolled down on an admin page will display styling that matches the environment flag color</description>
|
14 |
+
<notes>Features:
|
15 |
+
- Set the URL used for each of your environments
|
16 |
+
- Flag will show at the top of the Magento Admin screen clearly indicating with text and color which environment you're working in
|
17 |
+
- Header bar which displays when scrolled down on an admin page will display styling that matches the environment flag color</notes>
|
18 |
+
<authors><author><name>Tim Dolloff</name><user>DLSStudios</user><email>marketing@dlsstudios.com</email></author></authors>
|
19 |
+
<date>2015-03-17</date>
|
20 |
+
<time>22:18:56</time>
|
21 |
+
<contents><target name="magecommunity"><dir name="DLS"><dir name="Base"><dir name="Helper"><file name="Data.php" hash="6930b52dce1a150e88921968b5cce622"/><file name="Logo.php" hash="5670ab26ae12a63d4d93e29eccd2ae22"/></dir><dir name="etc"><file name="config.xml" hash="31918105362860bbc9535cfd8146d464"/><file name="system.xml" hash="b78db49a0450f9f1ff2d9956e3802791"/></dir></dir><dir name="Environment"><dir name="Block"><dir name="Adminhtml"><file name="Base.php" hash="82a0a738ed696629fd13ba775d25000d"/><file name="Flag.php" hash="d7ab28b8c0452f0620e3d22ca9a01739"/></dir></dir><dir name="Helper"><file name="Data.php" hash="5ee398f9506390d4ac3abc9cacba6be2"/></dir><dir name="Model"><file name="Settings.php" hash="91141fb20729837be3d9198ec88bb6c6"/></dir><dir name="etc"><file name="config.xml" hash="d1e8f8a8bcf9f6b885ec95933d8019ba"/><file name="system.xml" hash="aabe089a8f2f46f54b4c857e32dc505f"/></dir></dir><dir name="Utility"><dir name="Helper"><file name="Color.php" hash="3a34299f12286057b56a6f064236d0ed"/><file name="Data.php" hash="44d274748c28eb422741cf6d90e1ab61"/></dir><dir name="etc"><file name="config.xml" hash="11cbd3cda3d8d0eb3a0227d846d23e0e"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="dls"><file name="base.xml" hash="fb4da29270e20737e6e1eb31b16e7c92"/><dir name="environment"><file name="flag.xml" hash="72c7f56d51d5d31fe395c1ff1cd5b0de"/></dir><file name="environment.xml" hash="5e5d6cdead083cf3ae88faffeb0dcf6f"/></dir></dir><dir name="template"><dir name="dls"><dir name="environment"><file name="flag.phtml" hash="f5b700625341794849622bc87e92d605"/></dir><file name="environment.phtml" hash="e2d7defc684f63179be58afe7d204226"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DLS_Base.xml" hash="5fc8fcb0cf944476a890c507c9fd3334"/><file name="DLS_Environment.xml" hash="90c642031b6ba2ba2dbb0ef99b231d94"/><file name="DLS_Utility.xml" hash="c3b736611ad4248767c8c8f68782c913"/></dir></target><target name="mageweb"><dir name="js"><dir name="dls"><dir name="environment"><file name="flag.js" hash="9844c0a4e8b46b5a8acdb115bbda3efe"/></dir><file name="environment.js" hash="a3e61fb8246d3db4226afa1b17a038c1"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="dls"><file name="base.css" hash="de3d3a6b93c170974f9b735c67ac0ca9"/><dir name="environment"><file name="flag.css" hash="c9b42c2b208aced990008edaa8153193"/><dir name="images"><file name="environment_flag.png" hash="7f0d3d7ce7af42063acd80611487beea"/></dir></dir><dir name="images"><file name="dls_logo.png" hash="46f5012411de43d68bbe0cb37de61b47"/></dir></dir><dir name="images"><dir name="dls"><dir name="logo"><file name="dls_logo.png" hash="88666b3f2ad27f60830d6585de961c25"/><file name="dls_logo_black.png" hash="b77eee1964fbfbbcf1ded6ce4286798a"/><file name="dls_logo_white.png" hash="cbdb9b775cd9c2e68bfc6eb63e57d790"/><file name="three_dots_logo.png" hash="50ea9ca48e8c96f2d91ffdfc80805f6f"/><file name="three_dots_logo_black.png" hash="0ab30ce681b75ea61cfdaa09ad9bfff2"/><file name="three_dots_logo_white.png" hash="bc9a34507e036f34c8e9ce0dadfdfd7a"/></dir></dir></dir></dir></dir></dir></target></contents>
|
22 |
+
<compatible/>
|
23 |
+
<dependencies><required><php><min>5.2.13</min><max>5.5.22</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5</min><max>1.9</max></package></required></dependencies>
|
24 |
+
</package>
|
skin/adminhtml/base/default/dls/base.css
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
li.dls-tab-block dl > dt.label:before {
|
2 |
+
content: url("images/dls_logo.png");
|
3 |
+
vertical-align: middle;
|
4 |
+
display: inline-block;
|
5 |
+
padding-right: 7px;
|
6 |
+
left: 16px;
|
7 |
+
}
|
skin/adminhtml/base/default/dls/environment/flag.css
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.dlsenv-header-flag {
|
2 |
+
float: left;
|
3 |
+
font-weight: bold;
|
4 |
+
margin: 11px 20px 10px 0;
|
5 |
+
text-transform: uppercase;
|
6 |
+
text-align: center;
|
7 |
+
padding: 0 2px 0px 10px;
|
8 |
+
line-height: 32px;
|
9 |
+
-webkit-border-radius: 4px;
|
10 |
+
-moz-border-radius: 4px;
|
11 |
+
border-radius: 4px;
|
12 |
+
-webkit-box-shadow: 0 0 20px #000;
|
13 |
+
-moz-box-shadow: 0 0 20px #000;
|
14 |
+
box-shadow: 0 0 20px #000;
|
15 |
+
z-index: 100;
|
16 |
+
}
|
17 |
+
|
18 |
+
.dlsenv-header-brand-logo {
|
19 |
+
float: right;
|
20 |
+
margin: 18px 0px 0px 3px;
|
21 |
+
z-index: 10000;
|
22 |
+
}
|
23 |
+
|
24 |
+
ul.tabs a.dls-environment-flag-block span {
|
25 |
+
background:url(images/environment_flag.png) no-repeat 18px 3px;
|
26 |
+
overflow:hidden;
|
27 |
+
padding-left:45px;
|
28 |
+
}
|
skin/adminhtml/base/default/dls/environment/images/environment_flag.png
ADDED
Binary file
|
skin/adminhtml/base/default/dls/images/dls_logo.png
ADDED
Binary file
|
skin/adminhtml/base/default/images/dls/logo/dls_logo.png
ADDED
Binary file
|
skin/adminhtml/base/default/images/dls/logo/dls_logo_black.png
ADDED
Binary file
|
skin/adminhtml/base/default/images/dls/logo/dls_logo_white.png
ADDED
Binary file
|
skin/adminhtml/base/default/images/dls/logo/three_dots_logo.png
ADDED
Binary file
|
skin/adminhtml/base/default/images/dls/logo/three_dots_logo_black.png
ADDED
Binary file
|
skin/adminhtml/base/default/images/dls/logo/three_dots_logo_white.png
ADDED
Binary file
|