[+] BO : added new cool feature

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16619 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
vAugagneur
2012-07-31 09:30:30 +00:00
parent b37a36eba5
commit 62c3e09cc6
4 changed files with 81 additions and 28 deletions
+1 -1
View File
@@ -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 .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 {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.non-install { background-color:#ec7000;}
#moduleContainer .setup.top-ranking { background-color: #ec2b25;}
#moduleContainer .setup.off{ background-color:#ccc;} #moduleContainer .setup.off{ background-color:#ccc;}
#moduleContainer .row-actions-module span { padding-right:5px;} #moduleContainer .row-actions-module span { padding-right:5px;}
#moduleContainer .row-actions-module span a { font-size:12px;} #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 .moduleName {font-size:12px; color:#3A6EA7;font-weight:bold;}
#moduleContainer .moduleFavDesc { font-family:Georgia; font-style:italic; color:#666;} #moduleContainer .moduleFavDesc { font-family:Georgia; font-style:italic; color:#666;}
/*FOOTER*/ /*FOOTER*/
#footer {height:40px; font-size:12px;clear:both;font-size:0.9em;color:#666666} #footer {height:40px; font-size:12px;clear:both;font-size:0.9em;color:#666666}
#footer .footer_link, #footer .footer_link:hover {color:#D41958;} #footer .footer_link, #footer .footer_link:hover {color:#D41958;}
@@ -48,7 +48,16 @@
<td><img class="imgm" alt="" src="{if isset($module->image)}{$module->image}{else}../modules/{$module->name}/{$module->logo}{/if}"></td> <td><img class="imgm" alt="" src="{if isset($module->image)}{$module->image}{else}../modules/{$module->name}/{$module->logo}{/if}"></td>
<td> <td>
<div class="moduleDesc" id="anchor{$module->name|ucfirst}"> <div class="moduleDesc" id="anchor{$module->name|ucfirst}">
<h3>{$module->displayName}{if isset($module->id) && $module->id gt 0}<span class="setup{if isset($module->active) && $module->active eq 0} off{/if}">{l s='Installed'}</span>{else}<span class="setup non-install">{l s='Not installed'}</span>{/if}</h3> <h3>{$module->displayName}
{if isset($module->id) && $module->id gt 0}
<span class="setup{if isset($module->active) && $module->active eq 0} off{/if}">{l s='Installed'}</span>
{else}
<span class="setup non-install">{l s='Not installed'}</span>
{/if}
{if isset($module->type) && $module->type == 'addonsTopRanking'}
<span class="setup top-ranking">{l s='Top Ranking'}</span>
{/if}
</h3>
<div class="metadata"> <div class="metadata">
{if isset($module->author) && !empty($module->author)} {if isset($module->author) && !empty($module->author)}
<dl class=""> <dl class="">
@@ -76,12 +85,20 @@
</td> </td>
<td> <td>
<ul id="list-action-button"> <ul id="list-action-button">
{if $module->id && isset($module->version_addons) && $module->version_addons} {if isset($module->type) && $module->type == 'addonsTopRanking'}
<li><a href="{$module->options.update_url}" class="button updated"><span>{l s='Update it!'}</span></a></li> <li>
{/if} <a href="{$module->addons_buy_url}" target="_blank" class="button updated"><span>{l s='Buy it'} - {displayPrice price=$module->price currency=$module->id_currency}</span></a>
<li> </li>
<a {if isset($module->id) && $module->id gt 0 && !empty($module->options.uninstall_onclick)}onclick="{$module->options.uninstall_onclick}"{/if} href="{if isset($module->id) && $module->id gt 0}{$module->options.uninstall_url}{else}{$module->options.install_url}{/if}" class="button installed"><span>{if isset($module->id) && $module->id gt 0}{l s='Uninstall'}{else}{l s='Install'}{/if}</span></a> {else}
</li> {if $module->id && isset($module->version_addons) && $module->version_addons}
<li><a href="{$module->options.update_url}" class="button updated"><span>{l s='Update it!'}</span></a></li>
{/if}
<li>
<a {if isset($module->id) && $module->id gt 0 && !empty($module->options.uninstall_onclick)}onclick="{$module->options.uninstall_onclick}"{/if} href="{if isset($module->id) && $module->id gt 0}{$module->options.uninstall_url}{else}{$module->options.install_url}{/if}" class="button installed">
<span>{if isset($module->id) && $module->id gt 0}{l s='Uninstall'}{else}{l s='Install'}{/if}</span>
</a>
</li>
{/if}
</ul> </ul>
</td> </td>
</tr> </tr>
+27 -3
View File
@@ -119,6 +119,15 @@ abstract class ModuleCore
/** @var Smarty_Data */ /** @var Smarty_Data */
protected $smarty; 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 * Constructor
* *
@@ -1077,8 +1086,9 @@ abstract class ModuleCore
// Get Default Country Modules and customer module // Get Default Country Modules and customer module
$files_list = array( $files_list = array(
array('type' => 'addonsNative', 'file' => _PS_ROOT_DIR_.'/config/xml/default_country_modules_list.xml', 'loggedOnAddons' => 0), array('type' => 'addonsNative', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0),
array('type' => 'addonsBought', 'file' => _PS_ROOT_DIR_.'/config/xml/customer_modules_list.xml', 'loggedOnAddons' => 1), 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) foreach ($files_list as $f)
if (file_exists($f['file']) && ($f['loggedOnAddons'] == 0 || $loggedOnAddons)) 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')) if (file_exists('../img/tmp/'.md5($modaddons->name).'.jpg'))
$item->image = '../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; $module_list[] = $item;
} }
} }
@@ -1193,7 +1217,7 @@ abstract class ModuleCore
{ {
$db = Db::getInstance(); $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 = simplexml_load_file($module_list_xml);
$native_modules = $native_modules->modules; $native_modules = $native_modules->modules;
foreach ($native_modules as $native_modules_type) foreach ($native_modules as $native_modules_type)
+27 -15
View File
@@ -57,9 +57,6 @@ class AdminModulesControllerCore extends AdminController
protected $xml_modules_list = 'api.prestashop.com/xml/modules_list_15.xml'; protected $xml_modules_list = 'api.prestashop.com/xml/modules_list_15.xml';
protected $addons_url = 'api.addons.prestashop.com'; protected $addons_url = 'api.addons.prestashop.com';
protected $logged_on_addons = false; 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 * Admin Modules Controller Constructor
@@ -114,8 +111,8 @@ class AdminModulesControllerCore extends AdminController
// Load cache file modules list (natives and partners modules) // Load cache file modules list (natives and partners modules)
$xmlModules = false; $xmlModules = false;
if (file_exists(_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_.$this->cache_file_modules_list); $xmlModules = @simplexml_load_file(_PS_ROOT_DIR_.Module::CACHE_FILE_MODULES_LIST);
if ($xmlModules) if ($xmlModules)
foreach ($xmlModules->children() as $xmlModule) foreach ($xmlModules->children() as $xmlModule)
foreach ($xmlModule->children() as $module) foreach ($xmlModule->children() as $module)
@@ -170,6 +167,12 @@ class AdminModulesControllerCore extends AdminController
$protocolsList = array('https://' => 443, 'http://' => 80); $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); $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') if ($request == 'customer')
{ {
// Define protocol accepted and post data values for this request // Define protocol accepted and post data values for this request
@@ -224,11 +227,11 @@ class AdminModulesControllerCore extends AdminController
public function ajaxProcessRefreshModuleList() public function ajaxProcessRefreshModuleList()
{ {
// Refresh modules_list.xml every week // 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'; $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'; $this->status = 'refresh';
else else
$this->status = 'error'; $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 logged to Addons Webservices, refresh default country native modules list every day
if ($this->status != 'error') 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'; $this->status = 'refresh';
else else
$this->status = 'error'; $this->status = 'error';
@@ -254,9 +267,9 @@ class AdminModulesControllerCore extends AdminController
// If logged to Addons Webservices, refresh customer modules list every day // If logged to Addons Webservices, refresh customer modules list every day
if ($this->logged_on_addons && $this->status != 'error') 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'; $this->status = 'refresh';
else else
$this->status = 'error'; $this->status = 'error';
@@ -642,8 +655,8 @@ class AdminModulesControllerCore extends AdminController
if (!is_dir('../modules/'.$name.'/')) if (!is_dir('../modules/'.$name.'/'))
{ {
$filesList = array( $filesList = array(
array('type' => 'addonsNative', 'file' => $this->cache_file_default_country_modules_list, 'loggedOnAddons' => 0), array('type' => 'addonsNative', 'file' => Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0),
array('type' => 'addonsBought', 'file' => $this->cache_file_customer_modules_list, 'loggedOnAddons' => 1), array('type' => 'addonsBought', 'file' => Module::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1),
); );
foreach ($filesList as $f) foreach ($filesList as $f)
if (file_exists(_PS_ROOT_DIR_.$f['file'])) 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); $modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee);
$this->initModulesList($modules); $this->initModulesList($modules);
$this->nb_modules_total = count($modules); $this->nb_modules_total = count($modules);
$module_errors = array(); $module_errors = array();
$module_success = array(); $module_success = array();