Version Notes
Stable Release
Download this release
Release Info
| Developer | Juicy Media |
| Extension | Juicy_GeoIP |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/local/Juicy/Geoip/Block/Countrydefine.php +73 -0
- app/code/local/Juicy/Geoip/Helper/Data.php +297 -0
- app/code/local/Juicy/Geoip/Model/Geoip.php +73 -0
- app/code/local/Juicy/Geoip/Model/Observer.php +22 -0
- app/code/local/Juicy/Geoip/etc/adminhtml.xml +32 -0
- app/code/local/Juicy/Geoip/etc/config.xml +55 -0
- app/code/local/Juicy/Geoip/etc/system.xml +143 -0
- app/design/adminhtml/default/default/template/juicy/geoip/system/config/form/field/array.phtml +175 -0
- app/etc/modules/Juicy_Geoip.xml +9 -0
- package.xml +18 -0
app/code/local/Juicy/Geoip/Block/Countrydefine.php
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Juicy_Geoip_Block_Countrydefine extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
| 4 |
+
{
|
| 5 |
+
protected $magentoOptions;
|
| 6 |
+
|
| 7 |
+
public function __construct()
|
| 8 |
+
{
|
| 9 |
+
// create columns
|
| 10 |
+
$this->addColumn('countryCode', array(
|
| 11 |
+
'label' => Mage::helper('adminhtml')->__('Country Code'),
|
| 12 |
+
'size' => 28,
|
| 13 |
+
));
|
| 14 |
+
$this->addColumn('currencyCode', array(
|
| 15 |
+
'label' => Mage::helper('adminhtml')->__('Currency Code'),
|
| 16 |
+
'size' => 28
|
| 17 |
+
));
|
| 18 |
+
|
| 19 |
+
$this->addColumn('store', array(
|
| 20 |
+
'label' => Mage::helper('adminhtml')->__('Store'),
|
| 21 |
+
'size' => 28
|
| 22 |
+
));
|
| 23 |
+
|
| 24 |
+
$this->_addAfter = false;
|
| 25 |
+
$this->_addButtonLabel = Mage::helper('adminhtml')->__('Add Line');
|
| 26 |
+
|
| 27 |
+
parent::__construct();
|
| 28 |
+
$this->setTemplate('juicy/geoip/system/config/form/field/array.phtml');
|
| 29 |
+
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
protected function _renderCellTemplate($columnName)
|
| 33 |
+
{
|
| 34 |
+
if (empty($this->_columns[$columnName])) {
|
| 35 |
+
throw new Exception('Wrong column name specified.');
|
| 36 |
+
}
|
| 37 |
+
$column = $this->_columns[$columnName];
|
| 38 |
+
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
|
| 39 |
+
|
| 40 |
+
if($columnName === "currencyCode"){
|
| 41 |
+
$currencyStr = "";
|
| 42 |
+
$currencyArr = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
|
| 43 |
+
foreach($currencyArr as $code => $currency){
|
| 44 |
+
$currencyStr .= '<option value="'.$currency.'">'.$currency.'</option>';
|
| 45 |
+
}
|
| 46 |
+
return '<select name="' . $inputName . '">'.$currencyStr.'</select>';
|
| 47 |
+
} else if($columnName === "countryCode"){
|
| 48 |
+
$countryStr = "";
|
| 49 |
+
$countryArr = Mage::helper('geoip')->getCountryList();
|
| 50 |
+
foreach($countryArr as $code => $country){
|
| 51 |
+
$countryStr .= '<option value="'.$code.'">'.$country.'</option>';
|
| 52 |
+
}
|
| 53 |
+
return '<select name="' . $inputName . '">'.$countryStr.'</select>';
|
| 54 |
+
} else if($columnName === "store"){
|
| 55 |
+
$storeStr = "";
|
| 56 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
| 57 |
+
foreach ($website->getGroups() as $group) {
|
| 58 |
+
$stores = $group->getStores();
|
| 59 |
+
$storeStr .= '<optgroup label="'.$group->getName().'">';
|
| 60 |
+
foreach ($stores as $store) {
|
| 61 |
+
$storeStr .= '<option value="'.$store->getId().'">'.$store->getName().'</option>';
|
| 62 |
+
}
|
| 63 |
+
$storeStr .= '</optgroup>';
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
return '<select name="' . $inputName . '">'.$storeStr.'</select>';
|
| 67 |
+
}else{
|
| 68 |
+
return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}" ' . ($column['size'] ? 'size="' . $column['size'] . '"' : '') . '/>';
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
}
|
| 73 |
+
}
|
app/code/local/Juicy/Geoip/Helper/Data.php
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Juicy_Geoip_Helper_Data extends Mage_Core_Helper_Abstract {
|
| 4 |
+
public function isPrivateIp()
|
| 5 |
+
{
|
| 6 |
+
return !filter_var(Mage::helper('core/http')->getRemoteAddr(), FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);
|
| 7 |
+
}
|
| 8 |
+
public function getConfig($key)
|
| 9 |
+
{
|
| 10 |
+
return Mage::getStoreConfig('geoip/'.$key);
|
| 11 |
+
}
|
| 12 |
+
public function isEnabled()
|
| 13 |
+
{
|
| 14 |
+
return Mage::getStoreConfig('geoip/general/status');
|
| 15 |
+
}
|
| 16 |
+
public function isTestMode()
|
| 17 |
+
{
|
| 18 |
+
return Mage::getStoreConfig('geoip/general/testing');
|
| 19 |
+
}
|
| 20 |
+
public function testOverrideCountry()
|
| 21 |
+
{
|
| 22 |
+
return Mage::getStoreConfig('geoip/general/country_override');
|
| 23 |
+
}
|
| 24 |
+
public function canSwitch($key)
|
| 25 |
+
{
|
| 26 |
+
return Mage::getStoreConfig('geoip/general/switch_'.$key);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
public function getCountryList(){
|
| 30 |
+
return array (
|
| 31 |
+
'AF' => 'Afghanistan',
|
| 32 |
+
'AL' => 'Albania',
|
| 33 |
+
'DZ' => 'Algeria',
|
| 34 |
+
'AS' => 'American Samoa',
|
| 35 |
+
'AD' => 'Andorra',
|
| 36 |
+
'AO' => 'Angola',
|
| 37 |
+
'AI' => 'Anguilla',
|
| 38 |
+
'AQ' => 'Antarctica',
|
| 39 |
+
'AG' => 'Antigua and Barbuda',
|
| 40 |
+
'AR' => 'Argentina',
|
| 41 |
+
'AM' => 'Armenia',
|
| 42 |
+
'AW' => 'Aruba',
|
| 43 |
+
'AU' => 'Australia',
|
| 44 |
+
'AT' => 'Austria',
|
| 45 |
+
'AZ' => 'Azerbaijan',
|
| 46 |
+
'BS' => 'Bahamas',
|
| 47 |
+
'BH' => 'Bahrain',
|
| 48 |
+
'BD' => 'Bangladesh',
|
| 49 |
+
'BB' => 'Barbados',
|
| 50 |
+
'BY' => 'Belarus',
|
| 51 |
+
'BE' => 'Belgium',
|
| 52 |
+
'BZ' => 'Belize',
|
| 53 |
+
'BJ' => 'Benin',
|
| 54 |
+
'BM' => 'Bermuda',
|
| 55 |
+
'BT' => 'Bhutan',
|
| 56 |
+
'BO' => 'Bolivia',
|
| 57 |
+
'BA' => 'Bosnia and Herzegovina',
|
| 58 |
+
'BW' => 'Botswana',
|
| 59 |
+
'BV' => 'Bouvet Island',
|
| 60 |
+
'BR' => 'Brazil',
|
| 61 |
+
'BQ' => 'British Antarctic Territory',
|
| 62 |
+
'IO' => 'British Indian Ocean Territory',
|
| 63 |
+
'VG' => 'British Virgin Islands',
|
| 64 |
+
'BN' => 'Brunei',
|
| 65 |
+
'BG' => 'Bulgaria',
|
| 66 |
+
'BF' => 'Burkina Faso',
|
| 67 |
+
'BI' => 'Burundi',
|
| 68 |
+
'KH' => 'Cambodia',
|
| 69 |
+
'CM' => 'Cameroon',
|
| 70 |
+
'CA' => 'Canada',
|
| 71 |
+
'CT' => 'Canton and Enderbury Islands',
|
| 72 |
+
'CV' => 'Cape Verde',
|
| 73 |
+
'KY' => 'Cayman Islands',
|
| 74 |
+
'CF' => 'Central African Republic',
|
| 75 |
+
'TD' => 'Chad',
|
| 76 |
+
'CL' => 'Chile',
|
| 77 |
+
'CN' => 'China',
|
| 78 |
+
'CX' => 'Christmas Island',
|
| 79 |
+
'CC' => 'Cocos [Keeling] Islands',
|
| 80 |
+
'CO' => 'Colombia',
|
| 81 |
+
'KM' => 'Comoros',
|
| 82 |
+
'CG' => 'Congo - Brazzaville',
|
| 83 |
+
'CD' => 'Congo - Kinshasa',
|
| 84 |
+
'CK' => 'Cook Islands',
|
| 85 |
+
'CR' => 'Costa Rica',
|
| 86 |
+
'HR' => 'Croatia',
|
| 87 |
+
'CU' => 'Cuba',
|
| 88 |
+
'CY' => 'Cyprus',
|
| 89 |
+
'CZ' => 'Czech Republic',
|
| 90 |
+
'CI' => 'Côte d’Ivoire',
|
| 91 |
+
'DK' => 'Denmark',
|
| 92 |
+
'DJ' => 'Djibouti',
|
| 93 |
+
'DM' => 'Dominica',
|
| 94 |
+
'DO' => 'Dominican Republic',
|
| 95 |
+
'NQ' => 'Dronning Maud Land',
|
| 96 |
+
'DD' => 'East Germany',
|
| 97 |
+
'EC' => 'Ecuador',
|
| 98 |
+
'EG' => 'Egypt',
|
| 99 |
+
'SV' => 'El Salvador',
|
| 100 |
+
'GQ' => 'Equatorial Guinea',
|
| 101 |
+
'ER' => 'Eritrea',
|
| 102 |
+
'EE' => 'Estonia',
|
| 103 |
+
'ET' => 'Ethiopia',
|
| 104 |
+
'FK' => 'Falkland Islands',
|
| 105 |
+
'FO' => 'Faroe Islands',
|
| 106 |
+
'FJ' => 'Fiji',
|
| 107 |
+
'FI' => 'Finland',
|
| 108 |
+
'FR' => 'France',
|
| 109 |
+
'GF' => 'French Guiana',
|
| 110 |
+
'PF' => 'French Polynesia',
|
| 111 |
+
'TF' => 'French Southern Territories',
|
| 112 |
+
'FQ' => 'French Southern and Antarctic Territories',
|
| 113 |
+
'GA' => 'Gabon',
|
| 114 |
+
'GM' => 'Gambia',
|
| 115 |
+
'GE' => 'Georgia',
|
| 116 |
+
'DE' => 'Germany',
|
| 117 |
+
'GH' => 'Ghana',
|
| 118 |
+
'GI' => 'Gibraltar',
|
| 119 |
+
'GR' => 'Greece',
|
| 120 |
+
'GL' => 'Greenland',
|
| 121 |
+
'GD' => 'Grenada',
|
| 122 |
+
'GP' => 'Guadeloupe',
|
| 123 |
+
'GU' => 'Guam',
|
| 124 |
+
'GT' => 'Guatemala',
|
| 125 |
+
'GG' => 'Guernsey',
|
| 126 |
+
'GN' => 'Guinea',
|
| 127 |
+
'GW' => 'Guinea-Bissau',
|
| 128 |
+
'GY' => 'Guyana',
|
| 129 |
+
'HT' => 'Haiti',
|
| 130 |
+
'HM' => 'Heard Island and McDonald Islands',
|
| 131 |
+
'HN' => 'Honduras',
|
| 132 |
+
'HK' => 'Hong Kong SAR China',
|
| 133 |
+
'HU' => 'Hungary',
|
| 134 |
+
'IS' => 'Iceland',
|
| 135 |
+
'IN' => 'India',
|
| 136 |
+
'ID' => 'Indonesia',
|
| 137 |
+
'IR' => 'Iran',
|
| 138 |
+
'IQ' => 'Iraq',
|
| 139 |
+
'IE' => 'Ireland',
|
| 140 |
+
'IM' => 'Isle of Man',
|
| 141 |
+
'IL' => 'Israel',
|
| 142 |
+
'IT' => 'Italy',
|
| 143 |
+
'JM' => 'Jamaica',
|
| 144 |
+
'JP' => 'Japan',
|
| 145 |
+
'JE' => 'Jersey',
|
| 146 |
+
'JT' => 'Johnston Island',
|
| 147 |
+
'JO' => 'Jordan',
|
| 148 |
+
'KZ' => 'Kazakhstan',
|
| 149 |
+
'KE' => 'Kenya',
|
| 150 |
+
'KI' => 'Kiribati',
|
| 151 |
+
'KW' => 'Kuwait',
|
| 152 |
+
'KG' => 'Kyrgyzstan',
|
| 153 |
+
'LA' => 'Laos',
|
| 154 |
+
'LV' => 'Latvia',
|
| 155 |
+
'LB' => 'Lebanon',
|
| 156 |
+
'LS' => 'Lesotho',
|
| 157 |
+
'LR' => 'Liberia',
|
| 158 |
+
'LY' => 'Libya',
|
| 159 |
+
'LI' => 'Liechtenstein',
|
| 160 |
+
'LT' => 'Lithuania',
|
| 161 |
+
'LU' => 'Luxembourg',
|
| 162 |
+
'MO' => 'Macau SAR China',
|
| 163 |
+
'MK' => 'Macedonia',
|
| 164 |
+
'MG' => 'Madagascar',
|
| 165 |
+
'MW' => 'Malawi',
|
| 166 |
+
'MY' => 'Malaysia',
|
| 167 |
+
'MV' => 'Maldives',
|
| 168 |
+
'ML' => 'Mali',
|
| 169 |
+
'MT' => 'Malta',
|
| 170 |
+
'MH' => 'Marshall Islands',
|
| 171 |
+
'MQ' => 'Martinique',
|
| 172 |
+
'MR' => 'Mauritania',
|
| 173 |
+
'MU' => 'Mauritius',
|
| 174 |
+
'YT' => 'Mayotte',
|
| 175 |
+
'FX' => 'Metropolitan France',
|
| 176 |
+
'MX' => 'Mexico',
|
| 177 |
+
'FM' => 'Micronesia',
|
| 178 |
+
'MI' => 'Midway Islands',
|
| 179 |
+
'MD' => 'Moldova',
|
| 180 |
+
'MC' => 'Monaco',
|
| 181 |
+
'MN' => 'Mongolia',
|
| 182 |
+
'ME' => 'Montenegro',
|
| 183 |
+
'MS' => 'Montserrat',
|
| 184 |
+
'MA' => 'Morocco',
|
| 185 |
+
'MZ' => 'Mozambique',
|
| 186 |
+
'MM' => 'Myanmar [Burma]',
|
| 187 |
+
'NA' => 'Namibia',
|
| 188 |
+
'NR' => 'Nauru',
|
| 189 |
+
'NP' => 'Nepal',
|
| 190 |
+
'NL' => 'Netherlands',
|
| 191 |
+
'AN' => 'Netherlands Antilles',
|
| 192 |
+
'NT' => 'Neutral Zone',
|
| 193 |
+
'NC' => 'New Caledonia',
|
| 194 |
+
'NZ' => 'New Zealand',
|
| 195 |
+
'NI' => 'Nicaragua',
|
| 196 |
+
'NE' => 'Niger',
|
| 197 |
+
'NG' => 'Nigeria',
|
| 198 |
+
'NU' => 'Niue',
|
| 199 |
+
'NF' => 'Norfolk Island',
|
| 200 |
+
'KP' => 'North Korea',
|
| 201 |
+
'VD' => 'North Vietnam',
|
| 202 |
+
'MP' => 'Northern Mariana Islands',
|
| 203 |
+
'NO' => 'Norway',
|
| 204 |
+
'OM' => 'Oman',
|
| 205 |
+
'PC' => 'Pacific Islands Trust Territory',
|
| 206 |
+
'PK' => 'Pakistan',
|
| 207 |
+
'PW' => 'Palau',
|
| 208 |
+
'PS' => 'Palestinian Territories',
|
| 209 |
+
'PA' => 'Panama',
|
| 210 |
+
'PZ' => 'Panama Canal Zone',
|
| 211 |
+
'PG' => 'Papua New Guinea',
|
| 212 |
+
'PY' => 'Paraguay',
|
| 213 |
+
'YD' => 'Peoples Democratic Republic of Yemen',
|
| 214 |
+
'PE' => 'Peru',
|
| 215 |
+
'PH' => 'Philippines',
|
| 216 |
+
'PN' => 'Pitcairn Islands',
|
| 217 |
+
'PL' => 'Poland',
|
| 218 |
+
'PT' => 'Portugal',
|
| 219 |
+
'PR' => 'Puerto Rico',
|
| 220 |
+
'QA' => 'Qatar',
|
| 221 |
+
'RO' => 'Romania',
|
| 222 |
+
'RU' => 'Russia',
|
| 223 |
+
'RW' => 'Rwanda',
|
| 224 |
+
'RE' => 'Réunion',
|
| 225 |
+
'BL' => 'Saint Barthélemy',
|
| 226 |
+
'SH' => 'Saint Helena',
|
| 227 |
+
'KN' => 'Saint Kitts and Nevis',
|
| 228 |
+
'LC' => 'Saint Lucia',
|
| 229 |
+
'MF' => 'Saint Martin',
|
| 230 |
+
'PM' => 'Saint Pierre and Miquelon',
|
| 231 |
+
'VC' => 'Saint Vincent and the Grenadines',
|
| 232 |
+
'WS' => 'Samoa',
|
| 233 |
+
'SM' => 'San Marino',
|
| 234 |
+
'SA' => 'Saudi Arabia',
|
| 235 |
+
'SN' => 'Senegal',
|
| 236 |
+
'RS' => 'Serbia',
|
| 237 |
+
'CS' => 'Serbia and Montenegro',
|
| 238 |
+
'SC' => 'Seychelles',
|
| 239 |
+
'SL' => 'Sierra Leone',
|
| 240 |
+
'SG' => 'Singapore',
|
| 241 |
+
'SK' => 'Slovakia',
|
| 242 |
+
'SI' => 'Slovenia',
|
| 243 |
+
'SB' => 'Solomon Islands',
|
| 244 |
+
'SO' => 'Somalia',
|
| 245 |
+
'ZA' => 'South Africa',
|
| 246 |
+
'GS' => 'South Georgia and the South Sandwich Islands',
|
| 247 |
+
'KR' => 'South Korea',
|
| 248 |
+
'ES' => 'Spain',
|
| 249 |
+
'LK' => 'Sri Lanka',
|
| 250 |
+
'SD' => 'Sudan',
|
| 251 |
+
'SR' => 'Suriname',
|
| 252 |
+
'SJ' => 'Svalbard and Jan Mayen',
|
| 253 |
+
'SZ' => 'Swaziland',
|
| 254 |
+
'SE' => 'Sweden',
|
| 255 |
+
'CH' => 'Switzerland',
|
| 256 |
+
'SY' => 'Syria',
|
| 257 |
+
'ST' => 'São Tomé and Príncipe',
|
| 258 |
+
'TW' => 'Taiwan',
|
| 259 |
+
'TJ' => 'Tajikistan',
|
| 260 |
+
'TZ' => 'Tanzania',
|
| 261 |
+
'TH' => 'Thailand',
|
| 262 |
+
'TL' => 'Timor-Leste',
|
| 263 |
+
'TG' => 'Togo',
|
| 264 |
+
'TK' => 'Tokelau',
|
| 265 |
+
'TO' => 'Tonga',
|
| 266 |
+
'TT' => 'Trinidad and Tobago',
|
| 267 |
+
'TN' => 'Tunisia',
|
| 268 |
+
'TR' => 'Turkey',
|
| 269 |
+
'TM' => 'Turkmenistan',
|
| 270 |
+
'TC' => 'Turks and Caicos Islands',
|
| 271 |
+
'TV' => 'Tuvalu',
|
| 272 |
+
'UM' => 'U.S. Minor Outlying Islands',
|
| 273 |
+
'PU' => 'U.S. Miscellaneous Pacific Islands',
|
| 274 |
+
'VI' => 'U.S. Virgin Islands',
|
| 275 |
+
'UG' => 'Uganda',
|
| 276 |
+
'UA' => 'Ukraine',
|
| 277 |
+
'SU' => 'Union of Soviet Socialist Republics',
|
| 278 |
+
'AE' => 'United Arab Emirates',
|
| 279 |
+
'GB' => 'United Kingdom',
|
| 280 |
+
'US' => 'United States',
|
| 281 |
+
'ZZ' => 'Unknown or Invalid Region',
|
| 282 |
+
'UY' => 'Uruguay',
|
| 283 |
+
'UZ' => 'Uzbekistan',
|
| 284 |
+
'VU' => 'Vanuatu',
|
| 285 |
+
'VA' => 'Vatican City',
|
| 286 |
+
'VE' => 'Venezuela',
|
| 287 |
+
'VN' => 'Vietnam',
|
| 288 |
+
'WK' => 'Wake Island',
|
| 289 |
+
'WF' => 'Wallis and Futuna',
|
| 290 |
+
'EH' => 'Western Sahara',
|
| 291 |
+
'YE' => 'Yemen',
|
| 292 |
+
'ZM' => 'Zambia',
|
| 293 |
+
'ZW' => 'Zimbabwe',
|
| 294 |
+
'AX' => 'Åland Islands',
|
| 295 |
+
);
|
| 296 |
+
}
|
| 297 |
+
}
|
app/code/local/Juicy/Geoip/Model/Geoip.php
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
define("GEOIP_STANDARD", 0);
|
| 4 |
+
|
| 5 |
+
class Juicy_Geoip_Model_Geoip
|
| 6 |
+
{
|
| 7 |
+
|
| 8 |
+
public function runGeoip(){
|
| 9 |
+
$countryCode = $this->_getCountryCode();
|
| 10 |
+
$pairArr = $this->_getPairArray();
|
| 11 |
+
foreach($pairArr as $searchArr){
|
| 12 |
+
if(in_array($countryCode, $searchArr)){
|
| 13 |
+
$this->_setCurrency($searchArr);
|
| 14 |
+
//This method returns the redirect for store if it needs one
|
| 15 |
+
//@TODO Make this a bit nicer
|
| 16 |
+
return $this->_setStore($searchArr);
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
protected function _setCurrency($searchArr)
|
| 21 |
+
{
|
| 22 |
+
if(Mage::helper('geoip')->canSwitch("currency")){
|
| 23 |
+
Mage::app()->getStore()->setCurrentCurrencyCode(next($searchArr));
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
protected function _setStore($searchArr)
|
| 27 |
+
{
|
| 28 |
+
if(Mage::helper('geoip')->canSwitch("store")){
|
| 29 |
+
$storeName = Mage::app()->getStore($searchArr['store'])->getName();
|
| 30 |
+
if ($storeName) {
|
| 31 |
+
$store = Mage::getModel('core/store')->load($storeName, 'name');
|
| 32 |
+
if ($store->getName() != Mage::app()->getStore()->getName()) {
|
| 33 |
+
//Needs to return store URL for observer to redirect using event
|
| 34 |
+
return $store->getCurrentUrl(false);
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
protected function _getCountryCode()
|
| 40 |
+
{
|
| 41 |
+
return Mage::helper('geoip')->isTestMode()
|
| 42 |
+
? Mage::helper('geoip')->testOverrideCountry()
|
| 43 |
+
: $this->_getCountryCodeFromIp($this->_getIp());
|
| 44 |
+
}
|
| 45 |
+
protected function _getPairArray()
|
| 46 |
+
{
|
| 47 |
+
return unserialize(Mage::getStoreConfig('geoip/geoipset/ippair', Mage::app()->getStore()));
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
protected function _getIp(){
|
| 51 |
+
//Using Mage HTTP helper because Varnish can confuse PHP method
|
| 52 |
+
return Mage::helper('core/http')->getRemoteAddr();
|
| 53 |
+
}
|
| 54 |
+
protected function _getCountryCodeFromIp($ip){
|
| 55 |
+
//If its 0, that means we're using Apache else we're using a file
|
| 56 |
+
if(Mage::helper('geoip')->getConfig('general/apache_or_file') == 0){
|
| 57 |
+
return geoip_country_code_by_name($ip);
|
| 58 |
+
}else{
|
| 59 |
+
/*
|
| 60 |
+
try{
|
| 61 |
+
$fileName = Mage::helper('geoip')->getConfig('general/file_location');
|
| 62 |
+
*
|
| 63 |
+
*
|
| 64 |
+
return $country;
|
| 65 |
+
}catch(Exception $e){
|
| 66 |
+
Mage::throwException($e->getMessage());
|
| 67 |
+
}
|
| 68 |
+
*/
|
| 69 |
+
return geoip_country_code_by_name($ip);
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
|
app/code/local/Juicy/Geoip/Model/Observer.php
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Juicy_Geoip_Model_Observer
|
| 4 |
+
{
|
| 5 |
+
public function controllerActionPredispatch($e)
|
| 6 |
+
{
|
| 7 |
+
if(Mage::helper("geoip")->isModuleEnabled() == 1 && !Mage::helper("geoip")->isPrivateIp()){
|
| 8 |
+
if(Mage::helper("geoip")->isTestMode() == 1){
|
| 9 |
+
Mage::getModel('core/session')->unsGeoipChecked();
|
| 10 |
+
}
|
| 11 |
+
$session = Mage::getModel('core/session')->getGeoipChecked();
|
| 12 |
+
if(!isset($session) || $session == false){
|
| 13 |
+
|
| 14 |
+
$redirStore = Mage::getModel('geoip/geoip')->runGeoip();
|
| 15 |
+
if($redirStore){
|
| 16 |
+
$e->getControllerAction()->getResponse()->setRedirect($redirStore);
|
| 17 |
+
}
|
| 18 |
+
Mage::getSingleton("core/session")->setGeoipChecked(true);
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
}
|
app/code/local/Juicy/Geoip/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<!--
|
| 3 |
+
To change this license header, choose License Headers in Project Properties.
|
| 4 |
+
To change this template file, choose Tools | Templates
|
| 5 |
+
and open the template in the editor.
|
| 6 |
+
-->
|
| 7 |
+
|
| 8 |
+
<config>
|
| 9 |
+
<acl>
|
| 10 |
+
<resources>
|
| 11 |
+
<all>
|
| 12 |
+
<title>Allow Everything</title>
|
| 13 |
+
</all>
|
| 14 |
+
<admin>
|
| 15 |
+
<children>
|
| 16 |
+
<system>
|
| 17 |
+
<children>
|
| 18 |
+
<config>
|
| 19 |
+
<children>
|
| 20 |
+
<geoip module="geoip">
|
| 21 |
+
<title>GeoIP Config</title>
|
| 22 |
+
<sort_order>99</sort_order>
|
| 23 |
+
</geoip>
|
| 24 |
+
</children>
|
| 25 |
+
</config>
|
| 26 |
+
</children>
|
| 27 |
+
</system>
|
| 28 |
+
</children>
|
| 29 |
+
</admin>
|
| 30 |
+
</resources>
|
| 31 |
+
</acl>
|
| 32 |
+
</config>
|
app/code/local/Juicy/Geoip/etc/config.xml
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
<config>
|
| 5 |
+
<modules>
|
| 6 |
+
<Juicy_Geoip>
|
| 7 |
+
<version>0.2.0</version>
|
| 8 |
+
</Juicy_Geoip>
|
| 9 |
+
</modules>
|
| 10 |
+
<global>
|
| 11 |
+
<helpers>
|
| 12 |
+
<geoip>
|
| 13 |
+
<class>Juicy_Geoip_Helper</class>
|
| 14 |
+
</geoip>
|
| 15 |
+
</helpers>
|
| 16 |
+
<blocks>
|
| 17 |
+
<geoip>
|
| 18 |
+
<class>Juicy_Geoip_Block</class>
|
| 19 |
+
</geoip>
|
| 20 |
+
</blocks>
|
| 21 |
+
<models>
|
| 22 |
+
<geoip>
|
| 23 |
+
<class>Juicy_Geoip_Model</class>
|
| 24 |
+
</geoip>
|
| 25 |
+
</models>
|
| 26 |
+
</global>
|
| 27 |
+
<frontend>
|
| 28 |
+
<events>
|
| 29 |
+
<controller_action_predispatch>
|
| 30 |
+
<observers>
|
| 31 |
+
<geoip>
|
| 32 |
+
<class>geoip/observer</class>
|
| 33 |
+
<method>controllerActionPredispatch</method>
|
| 34 |
+
</geoip>
|
| 35 |
+
</observers>
|
| 36 |
+
</controller_action_predispatch>
|
| 37 |
+
</events>
|
| 38 |
+
</frontend>
|
| 39 |
+
<default>
|
| 40 |
+
<geoip>
|
| 41 |
+
<general>
|
| 42 |
+
<status>0</status>
|
| 43 |
+
<testing>0</testing>
|
| 44 |
+
<country_override></country_override>
|
| 45 |
+
<switch_currency>0</switch_currency>
|
| 46 |
+
<switch_store>0</switch_store>
|
| 47 |
+
<apache_or_file>0</apache_or_file>
|
| 48 |
+
<file_location>EXAMPLE: geoip.dat</file_location>
|
| 49 |
+
</general>
|
| 50 |
+
<geoipset>
|
| 51 |
+
|
| 52 |
+
</geoipset>
|
| 53 |
+
</geoip>
|
| 54 |
+
</default>
|
| 55 |
+
</config>
|
app/code/local/Juicy/Geoip/etc/system.xml
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<!--
|
| 3 |
+
To change this license header, choose License Headers in Project Properties.
|
| 4 |
+
To change this template file, choose Tools | Templates
|
| 5 |
+
and open the template in the editor.
|
| 6 |
+
-->
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
<config>
|
| 10 |
+
<tabs>
|
| 11 |
+
<juicy translate="label" module="geoip">
|
| 12 |
+
<label>Juicy Media</label>
|
| 13 |
+
<sort_order>10</sort_order>
|
| 14 |
+
</juicy>
|
| 15 |
+
</tabs>
|
| 16 |
+
<sections>
|
| 17 |
+
<geoip translate="label" module="geoip">
|
| 18 |
+
<label>GeoIP</label>
|
| 19 |
+
<tab>juicy</tab>
|
| 20 |
+
<sort_order>0</sort_order>
|
| 21 |
+
<show_in_default>1</show_in_default>
|
| 22 |
+
<show_in_website>1</show_in_website>
|
| 23 |
+
<show_in_store>1</show_in_store>
|
| 24 |
+
<groups>
|
| 25 |
+
<general translate="label" module="geoip">
|
| 26 |
+
<label>General</label>
|
| 27 |
+
<frontend_type>text</frontend_type>
|
| 28 |
+
<sort_order>1000</sort_order>
|
| 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 |
+
<fields>
|
| 33 |
+
<status translate="label">
|
| 34 |
+
<label>GeoIP Ext</label>
|
| 35 |
+
<frontend_type>select</frontend_type>
|
| 36 |
+
<comment>Enable/Disable GeoIP Extension</comment>
|
| 37 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
| 38 |
+
<sort_order>20</sort_order>
|
| 39 |
+
<show_in_default>1</show_in_default>
|
| 40 |
+
<show_in_website>1</show_in_website>
|
| 41 |
+
<show_in_store>0</show_in_store>
|
| 42 |
+
</status>
|
| 43 |
+
<testing translate="label">
|
| 44 |
+
<label>GeoIP Testing Mode</label>
|
| 45 |
+
<frontend_type>select</frontend_type>
|
| 46 |
+
<comment>Enable/Disable testing mode</comment>
|
| 47 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
| 48 |
+
<sort_order>25</sort_order>
|
| 49 |
+
<show_in_default>1</show_in_default>
|
| 50 |
+
<show_in_website>1</show_in_website>
|
| 51 |
+
<show_in_store>0</show_in_store>
|
| 52 |
+
<depends><status>1</status></depends>
|
| 53 |
+
</testing>
|
| 54 |
+
<country_override translate="label">
|
| 55 |
+
<label>Country Override</label>
|
| 56 |
+
<frontend_type>text</frontend_type>
|
| 57 |
+
<comment>ISO 3166 country code to mimic. Must be filled in for testing mode to work.</comment>
|
| 58 |
+
<sort_order>30</sort_order>
|
| 59 |
+
<show_in_default>1</show_in_default>
|
| 60 |
+
<show_in_website>1</show_in_website>
|
| 61 |
+
<show_in_store>0</show_in_store>
|
| 62 |
+
<depends><testing>1</testing></depends>
|
| 63 |
+
</country_override>
|
| 64 |
+
<switch_currency translate="label">
|
| 65 |
+
<label>Allow Currency Switching</label>
|
| 66 |
+
<frontend_type>select</frontend_type>
|
| 67 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
| 68 |
+
<sort_order>40</sort_order>
|
| 69 |
+
<show_in_default>1</show_in_default>
|
| 70 |
+
<show_in_website>1</show_in_website>
|
| 71 |
+
<show_in_store>0</show_in_store>
|
| 72 |
+
<depends><status>1</status></depends>
|
| 73 |
+
</switch_currency>
|
| 74 |
+
<!--
|
| 75 |
+
<switch_locale translate="label">
|
| 76 |
+
<label>Allow Locale(Translation) Switching</label>
|
| 77 |
+
<frontend_type>select</frontend_type>
|
| 78 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
| 79 |
+
<sort_order>50</sort_order>
|
| 80 |
+
<show_in_default>1</show_in_default>
|
| 81 |
+
<show_in_website>1</show_in_website>
|
| 82 |
+
<show_in_store>0</show_in_store>
|
| 83 |
+
</switch_locale>
|
| 84 |
+
-->
|
| 85 |
+
<switch_store translate="label">
|
| 86 |
+
<label>Allow Store Switching</label>
|
| 87 |
+
<frontend_type>select</frontend_type>
|
| 88 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
| 89 |
+
<sort_order>60</sort_order>
|
| 90 |
+
<show_in_default>1</show_in_default>
|
| 91 |
+
<show_in_website>1</show_in_website>
|
| 92 |
+
<show_in_store>0</show_in_store>
|
| 93 |
+
<depends><status>1</status></depends>
|
| 94 |
+
</switch_store>
|
| 95 |
+
<!--
|
| 96 |
+
<apache_or_file translate="label">
|
| 97 |
+
<label>Use my own GeoIP file</label>
|
| 98 |
+
<frontend_type>select</frontend_type>
|
| 99 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
| 100 |
+
<sort_order>70</sort_order>
|
| 101 |
+
<comment> <![CDATA[ <span>Enable if you do not need/want to use the Apache GeoIP module <b style="color:red;">EXPERIMENTAL ONLY</b></span> ]]></comment>
|
| 102 |
+
<show_in_default>1</show_in_default>
|
| 103 |
+
<show_in_website>1</show_in_website>
|
| 104 |
+
<show_in_store>0</show_in_store>
|
| 105 |
+
<depends><status>1</status></depends>
|
| 106 |
+
</apache_or_file>
|
| 107 |
+
<file_location translate="label">
|
| 108 |
+
<label>GeoIP data Override file name</label>
|
| 109 |
+
<frontend_type>text</frontend_type>
|
| 110 |
+
<sort_order>80</sort_order>
|
| 111 |
+
<comment>Place .dat file in [Mage Dir]/var/juicy/geoip</comment>
|
| 112 |
+
<show_in_default>1</show_in_default>
|
| 113 |
+
<show_in_website>1</show_in_website>
|
| 114 |
+
<show_in_store>0</show_in_store>
|
| 115 |
+
<depends><apache_or_file>1</apache_or_file></depends>
|
| 116 |
+
</file_location>
|
| 117 |
+
-->
|
| 118 |
+
</fields>
|
| 119 |
+
</general>
|
| 120 |
+
<geoipset translate="label" module="geoip">
|
| 121 |
+
<label>GeoIP Pairing</label>
|
| 122 |
+
<frontend_type>text</frontend_type>
|
| 123 |
+
<sort_order>2000</sort_order>
|
| 124 |
+
<show_in_default>1</show_in_default>
|
| 125 |
+
<show_in_website>1</show_in_website>
|
| 126 |
+
<show_in_store>1</show_in_store>
|
| 127 |
+
<fields>
|
| 128 |
+
<ippair translate="label">
|
| 129 |
+
<label>GeoIP Pairing</label>
|
| 130 |
+
<frontend_model>juicy_geoip_block_countrydefine</frontend_model>
|
| 131 |
+
<backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
|
| 132 |
+
<sort_order>0</sort_order>
|
| 133 |
+
<show_in_default>1</show_in_default>
|
| 134 |
+
<show_in_website>1</show_in_website>
|
| 135 |
+
<show_in_store>1</show_in_store>
|
| 136 |
+
<comment><!--<![CDATA[ ]]>--></comment>
|
| 137 |
+
</ippair>
|
| 138 |
+
</fields>
|
| 139 |
+
</geoipset>
|
| 140 |
+
</groups>
|
| 141 |
+
</geoip>
|
| 142 |
+
</sections>
|
| 143 |
+
</config>
|
app/design/adminhtml/default/default/template/juicy/geoip/system/config/form/field/array.phtml
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package default_default
|
| 23 |
+
* @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
?>
|
| 27 |
+
|
| 28 |
+
<?php
|
| 29 |
+
$_htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid();
|
| 30 |
+
|
| 31 |
+
$_colspan = 2;
|
| 32 |
+
if (!$this->_addAfter) {
|
| 33 |
+
$_colspan -= 1;
|
| 34 |
+
}
|
| 35 |
+
$_colspan = $_colspan > 1 ? 'colspan="' . $_colspan . '"' : '';
|
| 36 |
+
?>
|
| 37 |
+
|
| 38 |
+
<div class="grid" id="grid<?php echo $_htmlId ?>">
|
| 39 |
+
<table cellpadding="0" cellspacing="0" class="border">
|
| 40 |
+
<tbody>
|
| 41 |
+
|
| 42 |
+
<tr class="headings" id="headings<?php echo $_htmlId ?>">
|
| 43 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
| 44 |
+
<th><?php echo $column['label'] ?></th>
|
| 45 |
+
<?php endforeach;?>
|
| 46 |
+
<th <?php echo $_colspan?>></th>
|
| 47 |
+
</tr>
|
| 48 |
+
|
| 49 |
+
<tr id="addRow<?php echo $_htmlId ?>">
|
| 50 |
+
<td colspan="<?php echo count($this->_columns) ?>"></td>
|
| 51 |
+
<td <?php echo $_colspan?>>
|
| 52 |
+
<button style="" onclick="" class="scalable add" type="button" id="addToEndBtn<?php echo $_htmlId ?>">
|
| 53 |
+
<span><span><span><?php echo $this->_addButtonLabel ?></span></span></span>
|
| 54 |
+
</button>
|
| 55 |
+
</td>
|
| 56 |
+
</tr>
|
| 57 |
+
|
| 58 |
+
</tbody>
|
| 59 |
+
</table>
|
| 60 |
+
<input type="hidden" name="<?php echo $this->getElement()->getName() ?>[__empty]" value="" />
|
| 61 |
+
</div>
|
| 62 |
+
<div id="empty<?php echo $_htmlId ?>">
|
| 63 |
+
<button style="" onclick="" class="scalable add" type="button" id="emptyAddBtn<?php echo $_htmlId ?>">
|
| 64 |
+
<span><span><span><?php echo $this->_addButtonLabel ?></span></span></span>
|
| 65 |
+
</button>
|
| 66 |
+
</div>
|
| 67 |
+
|
| 68 |
+
<script type="text/javascript">
|
| 69 |
+
//<![CDATA[
|
| 70 |
+
// create row creator
|
| 71 |
+
var arrayRow<?php echo $_htmlId ?> = {
|
| 72 |
+
// define row prototypeJS template
|
| 73 |
+
template : new Template(
|
| 74 |
+
'<tr id="#{_id}">'
|
| 75 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
| 76 |
+
+'<td class="#{_id}-<?php echo $columnName ?>">'
|
| 77 |
+
+'<?php echo $this->_renderCellTemplate($columnName)?>'
|
| 78 |
+
+'<\/td>'
|
| 79 |
+
<?php endforeach;?>
|
| 80 |
+
<?php if ($this->_addAfter):?>
|
| 81 |
+
+'<td><button onclick="" class="scalable add" type="button" id="addAfterBtn#{_id}"><span><span><span><?php echo Mage::helper('adminhtml')->__('Add after') ?><\/span><\/span><\/span><\/button><\/td>'
|
| 82 |
+
<?php endif;?>
|
| 83 |
+
+'<td><button onclick="arrayRow<?php echo $_htmlId ?>.del(\'#{_id}\')" class="scalable delete" type="button"><span><span><span><?php echo Mage::helper('adminhtml')->__('Delete') ?><\/span><\/span><\/span><\/button><\/td>'
|
| 84 |
+
+'<\/tr>'
|
| 85 |
+
),
|
| 86 |
+
|
| 87 |
+
rowsCount : 0,
|
| 88 |
+
|
| 89 |
+
add : function(templateData, insertAfterId)
|
| 90 |
+
{
|
| 91 |
+
// generate default template data
|
| 92 |
+
if ('' == templateData) {
|
| 93 |
+
var d = new Date();
|
| 94 |
+
var templateData = {
|
| 95 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
| 96 |
+
<?php echo $columnName ?> : '',
|
| 97 |
+
<?php endforeach;?>
|
| 98 |
+
_id : '_' + d.getTime() + '_' + d.getMilliseconds()
|
| 99 |
+
};
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
// insert before last row
|
| 103 |
+
if ('' == insertAfterId) {
|
| 104 |
+
Element.insert($('addRow<?php echo $_htmlId ?>'), {before: this.template.evaluate(templateData)});
|
| 105 |
+
}
|
| 106 |
+
// insert after specified row
|
| 107 |
+
else {
|
| 108 |
+
Element.insert($(insertAfterId), {after: this.template.evaluate(templateData)});
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
// set the selected drop-down list item
|
| 112 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
| 113 |
+
var options = $$('td.' + templateData._id + '-' + '<?php echo $columnName?>' + ' option');
|
| 114 |
+
for (var index = 0; index < options.length; ++index) {
|
| 115 |
+
var option = options[index]
|
| 116 |
+
if (option.getAttribute('value') == templateData.<?php echo $columnName?>) {
|
| 117 |
+
option.selected = true
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
<?php endforeach;?>
|
| 121 |
+
|
| 122 |
+
<?php if ($this->_addAfter):?>
|
| 123 |
+
Event.observe('addAfterBtn' + templateData._id, 'click', this.add.bind(this, '', templateData._id));
|
| 124 |
+
<?php endif;?>
|
| 125 |
+
|
| 126 |
+
this.rowsCount += 1;
|
| 127 |
+
},
|
| 128 |
+
|
| 129 |
+
del : function(rowId)
|
| 130 |
+
{
|
| 131 |
+
$(rowId).remove();
|
| 132 |
+
this.rowsCount -= 1;
|
| 133 |
+
if (0 == this.rowsCount) {
|
| 134 |
+
this.showButtonOnly();
|
| 135 |
+
}
|
| 136 |
+
},
|
| 137 |
+
|
| 138 |
+
showButtonOnly : function()
|
| 139 |
+
{
|
| 140 |
+
$('grid<?php echo $_htmlId ?>').hide();
|
| 141 |
+
$('empty<?php echo $_htmlId ?>').show();
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
// bind add action to "Add" button in last row
|
| 146 |
+
Event.observe('addToEndBtn<?php echo $_htmlId ?>', 'click', arrayRow<?php echo $_htmlId ?>.add.bind(arrayRow<?php echo $_htmlId ?>, '', ''));
|
| 147 |
+
|
| 148 |
+
// add existing rows
|
| 149 |
+
<?php
|
| 150 |
+
$_addAfterId = "headings{$_htmlId}";
|
| 151 |
+
foreach ($this->getArrayRows() as $_rowId => $_row) {
|
| 152 |
+
echo "arrayRow{$_htmlId}.add(" . $_row->toJson() . ", '{$_addAfterId}');\n";
|
| 153 |
+
$_addAfterId = $_rowId;
|
| 154 |
+
}
|
| 155 |
+
?>
|
| 156 |
+
|
| 157 |
+
// initialize standalone button
|
| 158 |
+
$('empty<?php echo $_htmlId ?>').hide();
|
| 159 |
+
Event.observe('emptyAddBtn<?php echo $_htmlId ?>', 'click', function () {
|
| 160 |
+
$('grid<?php echo $_htmlId ?>').show();
|
| 161 |
+
$('empty<?php echo $_htmlId ?>').hide();
|
| 162 |
+
arrayRow<?php echo $_htmlId ?>.add('', '');
|
| 163 |
+
});
|
| 164 |
+
|
| 165 |
+
// if no rows, hide grid and show button only
|
| 166 |
+
<?php if (!$this->getArrayRows()):?>
|
| 167 |
+
arrayRow<?php echo $_htmlId ?>.showButtonOnly();
|
| 168 |
+
<?php endif;?>
|
| 169 |
+
|
| 170 |
+
// toggle the grid, if element is disabled (depending on scope)
|
| 171 |
+
<?php if ($this->getElement()->getDisabled()):?>
|
| 172 |
+
toggleValueElements({checked:true}, $('grid<?php echo $_htmlId ?>').parentNode);
|
| 173 |
+
<?php endif;?>
|
| 174 |
+
//]]>
|
| 175 |
+
</script>
|
app/etc/modules/Juicy_Geoip.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Juicy_Geoip>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
</Juicy_Geoip>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Juicy_GeoIP</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>GPL</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Change currency using the visitors IP address and the PHP GeoIP module</summary>
|
| 10 |
+
<description>Gets the customers current country using PHP's GeoIP module, filters through a list of countries and grabs the associated currency code for Magento</description>
|
| 11 |
+
<notes>Stable Release</notes>
|
| 12 |
+
<authors><author><name>Jonathan Webb</name><user>JuicyMedia</user><email>jonathan.webb@juicymedia.co.uk</email></author></authors>
|
| 13 |
+
<date>2015-01-19</date>
|
| 14 |
+
<time>11:03:07</time>
|
| 15 |
+
<contents><target name="magelocal"><dir name="Juicy"><dir name="Geoip"><dir name="Block"><file name="Countrydefine.php" hash="0032d7797b0dc464fe0edc99d6a7fe7e"/></dir><dir name="Helper"><file name="Data.php" hash="d724ae9ca937562e91e8b45a052beff2"/></dir><dir name="Model"><file name="Geoip.php" hash="537242b732c5bcd2e087137c864359e9"/><file name="Observer.php" hash="176a89109b18c4322ec109c465067e8a"/></dir><dir name="etc"><file name="adminhtml.xml" hash="5ac9ab6f0f5b9bb998fa7666dbe54803"/><file name="config.xml" hash="8926d6a0f8d457c837b5972fbd42c90c"/><file name="system.xml" hash="91e1e5163d0b725fd810e41a1339a875"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Juicy_Geoip.xml" hash="c4ebc7b11208b6c6b6020cb581ba9b12"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="juicy"><dir name="geoip"><dir name="system"><dir name="config"><dir name="form"><dir name="field"><file name="array.phtml" hash="83994a57e699b206fe5fa898d1f99690"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php><extension><name>geoip</name><min/><max>100</max></extension></required></dependencies>
|
| 18 |
+
</package>
|
