diff --git a/admin-dev/themes/default/css/modules.css b/admin-dev/themes/default/css/modules.css
index 2f7ac9d5d..8338b1f3f 100644
--- a/admin-dev/themes/default/css/modules.css
+++ b/admin-dev/themes/default/css/modules.css
@@ -232,6 +232,7 @@ form#product, form#access_form{ background-color:#ebedf4; border:1px solid #cc
#moduleContainer .moduleDesc p.desc { color:#666; font-size:12px; display:block; clear:both;}
#moduleContainer .setup {background-color:#6db300; font-size:10px; color:#fff; text-transform:uppercase; position:relative; left:10px; padding:0px 4px; display: inline-block; border-radius:3px;}
#moduleContainer .setup.non-install { background-color:#ec7000;}
+#moduleContainer .setup.top-ranking { background-color: #ec2b25;}
#moduleContainer .setup.off{ background-color:#ccc;}
#moduleContainer .row-actions-module span { padding-right:5px;}
#moduleContainer .row-actions-module span a { font-size:12px;}
@@ -243,7 +244,6 @@ form#product, form#access_form{ background-color:#ebedf4; border:1px solid #cc
#moduleContainer .moduleName {font-size:12px; color:#3A6EA7;font-weight:bold;}
#moduleContainer .moduleFavDesc { font-family:Georgia; font-style:italic; color:#666;}
-
/*FOOTER*/
#footer {height:40px; font-size:12px;clear:both;font-size:0.9em;color:#666666}
#footer .footer_link, #footer .footer_link:hover {color:#D41958;}
diff --git a/admin-dev/themes/default/template/controllers/modules/list.tpl b/admin-dev/themes/default/template/controllers/modules/list.tpl
index bbf5fd85e..d2ef57600 100644
--- a/admin-dev/themes/default/template/controllers/modules/list.tpl
+++ b/admin-dev/themes/default/template/controllers/modules/list.tpl
@@ -48,7 +48,16 @@
}{$module->image}{else}../modules/{$module->name}/{$module->logo}{/if}) |
- {$module->displayName}{if isset($module->id) && $module->id gt 0}{l s='Installed'}{else}{l s='Not installed'}{/if}
+ {$module->displayName}
+ {if isset($module->id) && $module->id gt 0}
+ {l s='Installed'}
+ {else}
+ {l s='Not installed'}
+ {/if}
+ {if isset($module->type) && $module->type == 'addonsTopRanking'}
+ {l s='Top Ranking'}
+ {/if}
+
|
|
diff --git a/classes/module/Module.php b/classes/module/Module.php
index 74b80203d..0d32ecad9 100644
--- a/classes/module/Module.php
+++ b/classes/module/Module.php
@@ -118,7 +118,16 @@ abstract class ModuleCore
/** @var Smarty_Data */
protected $smarty;
-
+
+
+ const CACHE_FILE_MODULES_LIST = '/config/xml/modules_list.xml';
+
+ const CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST = '/config/xml/default_country_modules_list.xml';
+
+ const CACHE_FILE_CUSTOMER_MODULES_LIST = '/config/xml/customer_modules_list.xml';
+
+ const CACHE_FILE_TOP_RANKING_MODULES_LIST = '/config/xml/top_ranking_modules_list.xml';
+
/**
* Constructor
*
@@ -1077,8 +1086,9 @@ abstract class ModuleCore
// Get Default Country Modules and customer module
$files_list = array(
- array('type' => 'addonsNative', 'file' => _PS_ROOT_DIR_.'/config/xml/default_country_modules_list.xml', 'loggedOnAddons' => 0),
- array('type' => 'addonsBought', 'file' => _PS_ROOT_DIR_.'/config/xml/customer_modules_list.xml', 'loggedOnAddons' => 1),
+ array('type' => 'addonsNative', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0),
+ array('type' => 'addonsBought', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1),
+ array('type' => 'addonsTopRanking', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_TOP_RANKING_MODULES_LIST, 'loggedOnAddons' => 0),
);
foreach ($files_list as $f)
if (file_exists($f['file']) && ($f['loggedOnAddons'] == 0 || $loggedOnAddons))
@@ -1125,6 +1135,20 @@ abstract class ModuleCore
if (file_exists('../img/tmp/'.md5($modaddons->name).'.jpg'))
$item->image = '../img/tmp/'.md5($modaddons->name).'.jpg';
}
+ if ($item->type == 'addonsTopRanking')
+ {
+ $item->addons_buy_url = strip_tags((string)$modaddons->url);
+ $prices = (array)$modaddons->price;
+ $id_default_currency = Configuration::get('PS_CURRENCY_DEFAULT');
+ foreach ($prices as $currency => $price)
+ if ($id_currency = Currency::getIdByIsoCode($currency))
+ if ($id_default_currency == $id_currency)
+ {
+ $item->price = (float)$price;
+ $item->id_currency = (int)$id_currency;
+ }
+
+ }
$module_list[] = $item;
}
}
@@ -1193,7 +1217,7 @@ abstract class ModuleCore
{
$db = Db::getInstance();
- $module_list_xml = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'modules_list.xml';
+ $module_list_xml = _PS_ROOT_DIR_.self::CACHE_FILE_MODULES_LIST;
$native_modules = simplexml_load_file($module_list_xml);
$native_modules = $native_modules->modules;
foreach ($native_modules as $native_modules_type)
diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php
index e52345263..c4fa1852e 100644
--- a/controllers/admin/AdminModulesController.php
+++ b/controllers/admin/AdminModulesController.php
@@ -57,9 +57,6 @@ class AdminModulesControllerCore extends AdminController
protected $xml_modules_list = 'api.prestashop.com/xml/modules_list_15.xml';
protected $addons_url = 'api.addons.prestashop.com';
protected $logged_on_addons = false;
- protected $cache_file_modules_list = '/config/xml/modules_list.xml';
- protected $cache_file_default_country_modules_list = '/config/xml/default_country_modules_list.xml';
- protected $cache_file_customer_modules_list = '/config/xml/customer_modules_list.xml';
/**
* Admin Modules Controller Constructor
@@ -114,8 +111,8 @@ class AdminModulesControllerCore extends AdminController
// Load cache file modules list (natives and partners modules)
$xmlModules = false;
- if (file_exists(_PS_ROOT_DIR_.$this->cache_file_modules_list))
- $xmlModules = @simplexml_load_file(_PS_ROOT_DIR_.$this->cache_file_modules_list);
+ if (file_exists(_PS_ROOT_DIR_.Module::CACHE_FILE_MODULES_LIST))
+ $xmlModules = @simplexml_load_file(_PS_ROOT_DIR_.Module::CACHE_FILE_MODULES_LIST);
if ($xmlModules)
foreach ($xmlModules->children() as $xmlModule)
foreach ($xmlModule->children() as $module)
@@ -170,6 +167,12 @@ class AdminModulesControllerCore extends AdminController
$protocolsList = array('https://' => 443, 'http://' => 80);
$postData = 'version='._PS_VERSION_.'&method=listing&action=native&iso_code='.strtolower(Configuration::get('PS_LOCALE_COUNTRY')).'&iso_lang='.strtolower(Context::getContext()->language->iso_code);
}
+ if ($request == 'top_ranking')
+ {
+ // Define protocol accepted and post data values for this request
+ $protocolsList = array('https://' => 443, 'http://' => 80);
+ $postData = 'version='._PS_VERSION_.'&method=listing&action=top_ranking&iso_code='.strtolower(Configuration::get('PS_LOCALE_COUNTRY')).'&iso_lang='.strtolower(Context::getContext()->language->iso_code);
+ }
if ($request == 'customer')
{
// Define protocol accepted and post data values for this request
@@ -224,11 +227,11 @@ class AdminModulesControllerCore extends AdminController
public function ajaxProcessRefreshModuleList()
{
// Refresh modules_list.xml every week
- if (!$this->isFresh($this->cache_file_modules_list, 604800))
+ if (!$this->isFresh(Module::CACHE_FILE_MODULES_LIST, 604800))
{
- if ($this->refresh($this->cache_file_modules_list, 'https://'.$this->xml_modules_list))
+ if ($this->refresh(Module::CACHE_FILE_MODULES_LIST, 'https://'.$this->xml_modules_list))
$this->status = 'refresh';
- else if ($this->refresh($this->cache_file_modules_list, 'http://'.$this->xml_modules_list))
+ else if ($this->refresh(Module::CACHE_FILE_MODULES_LIST, 'http://'.$this->xml_modules_list))
$this->status = 'refresh';
else
$this->status = 'error';
@@ -240,9 +243,19 @@ class AdminModulesControllerCore extends AdminController
// If logged to Addons Webservices, refresh default country native modules list every day
if ($this->status != 'error')
{
- if (!$this->isFresh($this->cache_file_default_country_modules_list, 86400))
+ if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 86400))
{
- if (file_put_contents(_PS_ROOT_DIR_.$this->cache_file_default_country_modules_list, $this->addonsRequest('native')))
+ if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, $this->addonsRequest('native')))
+ $this->status = 'refresh';
+ else
+ $this->status = 'error';
+ }
+ else
+ $this->status = 'cache';
+
+ if (!$this->isFresh(Module::CACHE_FILE_TOP_RANKING_MODULES_LIST, 86400))
+ {
+ if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_TOP_RANKING_MODULES_LIST, $this->addonsRequest('top_ranking')))
$this->status = 'refresh';
else
$this->status = 'error';
@@ -254,9 +267,9 @@ class AdminModulesControllerCore extends AdminController
// If logged to Addons Webservices, refresh customer modules list every day
if ($this->logged_on_addons && $this->status != 'error')
{
- if (!$this->isFresh($this->cache_file_customer_modules_list, 60))
+ if (!$this->isFresh(Module::CACHE_FILE_CUSTOMER_MODULES_LIST, 60))
{
- if (file_put_contents(_PS_ROOT_DIR_.$this->cache_file_customer_modules_list, $this->addonsRequest('customer')))
+ if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_CUSTOMER_MODULES_LIST, $this->addonsRequest('customer')))
$this->status = 'refresh';
else
$this->status = 'error';
@@ -642,8 +655,8 @@ class AdminModulesControllerCore extends AdminController
if (!is_dir('../modules/'.$name.'/'))
{
$filesList = array(
- array('type' => 'addonsNative', 'file' => $this->cache_file_default_country_modules_list, 'loggedOnAddons' => 0),
- array('type' => 'addonsBought', 'file' => $this->cache_file_customer_modules_list, 'loggedOnAddons' => 1),
+ array('type' => 'addonsNative', 'file' => Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0),
+ array('type' => 'addonsBought', 'file' => Module::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1),
);
foreach ($filesList as $f)
if (file_exists(_PS_ROOT_DIR_.$f['file']))
@@ -1050,7 +1063,6 @@ class AdminModulesControllerCore extends AdminController
$modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee);
$this->initModulesList($modules);
$this->nb_modules_total = count($modules);
-
$module_errors = array();
$module_success = array();
@@ -1195,4 +1207,4 @@ class AdminModulesControllerCore extends AdminController
}
$smarty->assign($tpl_vars);
}
-}
\ No newline at end of file
+}