From 28118cf33afc02a56f6bc2f1a7fc356ceb97a1e4 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Fri, 11 Oct 2013 10:40:57 +0200 Subject: [PATCH 1/5] // Code cleaning (backoffice javascript) --- admin-dev/themes/default/js/admin-theme.js | 53 +++++++++++++++---- .../controllers/modules/favorites.tpl | 26 ++++++++- .../template/controllers/modules/page.tpl | 23 +------- .../template/controllers/modules/top.tpl | 45 ++++++++++++++++ admin-dev/themes/default/template/header.tpl | 2 + .../default/template/page_header_toolbar.tpl | 53 ++++--------------- admin-dev/themes/default/template/toolbar.tpl | 53 ++++--------------- 7 files changed, 134 insertions(+), 121 deletions(-) create mode 100644 admin-dev/themes/default/template/controllers/modules/top.tpl diff --git a/admin-dev/themes/default/js/admin-theme.js b/admin-dev/themes/default/js/admin-theme.js index 1955c9116..83afba909 100755 --- a/admin-dev/themes/default/js/admin-theme.js +++ b/admin-dev/themes/default/js/admin-theme.js @@ -110,16 +110,6 @@ $( document ).ready(function() { $('.expanded').removeClass('expanded'); }); - function animateGoTop() { - if ($(window).scrollTop()) - { - $('#go-top:hidden').stop(true, true).fadeIn(); - $('#go-top:hidden').removeClass('hide'); - } - else - $('#go-top').stop(true, true).fadeOut(); - } - $("#go-top").click(function() { $("html, body").animate({ scrollTop: 0 }, "slow"); return false; @@ -129,4 +119,45 @@ $( document ).ready(function() { }); animateGoTop(); -}); \ No newline at end of file +}); + +function animateGoTop() { + if ($(window).scrollTop()) + { + $('#go-top:hidden').stop(true, true).fadeIn(); + $('#go-top:hidden').removeClass('hide'); + } + else + $('#go-top').stop(true, true).fadeOut(); +} + +function openModulesList() +{ + if (!modules_list_loaded) + { + $.ajax({ + type: "POST", + url : admin_modules_link, + async: true, + data : { + ajax : "1", + controller : "AdminModules", + action : "getTabModulesList", + tab_modules_list : tab_modules_list, + back_tab_modules_list : window.location.href + }, + success : function(data) + { + $('#modules_list_container_tab').html(data).slideDown(); + $('#modules_list_loader').hide(); + modules_list_loaded = true; + } + }); + } + else + { + $('#modules_list_container_tab').slideDown(); + $('#modules_list_loader').hide(); + } + return false; +} \ No newline at end of file diff --git a/admin-dev/themes/default/template/controllers/modules/favorites.tpl b/admin-dev/themes/default/template/controllers/modules/favorites.tpl index 1596032a0..738e56c5b 100755 --- a/admin-dev/themes/default/template/controllers/modules/favorites.tpl +++ b/admin-dev/themes/default/template/controllers/modules/favorites.tpl @@ -1,4 +1,28 @@ - {include file='controllers/modules/header.tpl'} +{* +* 2007-2013 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} +{include file='controllers/modules/top.tpl'}
diff --git a/admin-dev/themes/default/template/controllers/modules/page.tpl b/admin-dev/themes/default/template/controllers/modules/page.tpl index e18bfe7f4..d088fd9a2 100644 --- a/admin-dev/themes/default/template/controllers/modules/page.tpl +++ b/admin-dev/themes/default/template/controllers/modules/page.tpl @@ -22,28 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - -{$kpis} - -
-

- {l s='List of modules'} -

-
-
- -
-
-
+{include file='controllers/modules/top.tpl'} {if $add_permission eq '1'}
diff --git a/admin-dev/themes/default/template/controllers/modules/top.tpl b/admin-dev/themes/default/template/controllers/modules/top.tpl new file mode 100644 index 000000000..91029ef1b --- /dev/null +++ b/admin-dev/themes/default/template/controllers/modules/top.tpl @@ -0,0 +1,45 @@ +{* +* 2007-2013 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} +{$kpis} + +
+

+ {l s='List of modules'} +

+
+
+ +
+
+
\ No newline at end of file diff --git a/admin-dev/themes/default/template/header.tpl b/admin-dev/themes/default/template/header.tpl index 3eca86fd3..397b224e9 100644 --- a/admin-dev/themes/default/template/header.tpl +++ b/admin-dev/themes/default/template/header.tpl @@ -72,6 +72,8 @@ var currentIndex = '{$currentIndex}'; var default_language = '{$default_language|intval}'; var choose_language_translate = "{l s='Choose language' slashes=1}"; + var admin_modules_link = '{$link->getAdminLink("AdminModules")|addslashes}'; + var tab_modules_list = '{if isset($tab_modules_list) && $tab_modules_list}{$tab_modules_list|addslashes}{/if}'; {/if} {if isset($css_files)} diff --git a/admin-dev/themes/default/template/page_header_toolbar.tpl b/admin-dev/themes/default/template/page_header_toolbar.tpl index eeaba22db..92116296b 100644 --- a/admin-dev/themes/default/template/page_header_toolbar.tpl +++ b/admin-dev/themes/default/template/page_header_toolbar.tpl @@ -68,8 +68,7 @@ if (btn_submit.html().length > 0) lbl_save.find('span').html(btn_submit.html()); - if (btn_save_and_stay.length > 0) - { + if (btn_save_and_stay.length > 0) { //get reference on current save link label lbl_save_and_stay = $('#page-header-desc-{$table}-save-and-stay'); @@ -100,12 +99,10 @@ return false; }); - if (btn_save_and_stay) - { + if (btn_save_and_stay) { btn_save_and_stay.click(function() { //add hidden input to emulate submit button click when posting the form -> field name posted btn_submit.before(''); - $('#{$table}_form').submit(); return false; }); @@ -113,47 +110,17 @@ {/block} } - {if isset($tab_modules_open)} - if ({$tab_modules_open}) - openModulesList(); + {if isset($tab_modules_open) && $tab_modules_open} + $('#modules_list_container').modal('show'); + openModulesList(); {/if} }); + {if isset($tab_modules_list)} - $('.process-icon-modules-list').parent('a').unbind().bind('click', function (){ - openModulesList(); - }); - - function openModulesList() - { - $('#modules_list_container').modal('show'); - if (!modules_list_loaded) - { - $.ajax({ - type: "POST", - url : '{$admin_module_ajax_url}', - async: true, - data : { - ajax : "1", - controller : "AdminModules", - action : "getTabModulesList", - tab_modules_list : '{$tab_modules_list}', - back_tab_modules_list : '{$back_tab_modules_list}' - }, - success : function(data) - { - $('#modules_list_container_tab').html(data).slideDown(); - $('#modules_list_loader').hide(); - modules_list_loaded = true; - } - }); - } - else - { - $('#modules_list_container_tab').slideDown(); - $('#modules_list_loader').hide(); - } - return false; - } + $('.process-icon-modules-list').parent('a').unbind().bind('click', function (){ + $('#modules_list_container').modal('show'); + openModulesList(); + }); {/if} //]]> diff --git a/admin-dev/themes/default/template/toolbar.tpl b/admin-dev/themes/default/template/toolbar.tpl index b59459ebc..c2eb566ee 100644 --- a/admin-dev/themes/default/template/toolbar.tpl +++ b/admin-dev/themes/default/template/toolbar.tpl @@ -46,7 +46,7 @@ {/foreach} - From f95a4d74dfa60254afb39eed457ba6006692ec3f Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Fri, 11 Oct 2013 10:47:35 +0200 Subject: [PATCH 2/5] // Added Google Plus to the BO footer --- admin-dev/themes/default/template/footer.tpl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/admin-dev/themes/default/template/footer.tpl b/admin-dev/themes/default/template/footer.tpl index d13be1447..dee3e7560 100644 --- a/admin-dev/themes/default/template/footer.tpl +++ b/admin-dev/themes/default/template/footer.tpl @@ -32,15 +32,18 @@ PrestaShop™ {$ps_version} - {l s='Load time: '} {number_format(microtime(true) - $timer_start, 3, '.', '')}s
From 49a9f0bcaae3620261921d7138a947245cfb4d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Fri, 11 Oct 2013 10:58:05 +0200 Subject: [PATCH 3/5] // unlink class_index tmp file if not rename --- classes/Autoload.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/Autoload.php b/classes/Autoload.php index 5f832d932..111d6e652 100644 --- a/classes/Autoload.php +++ b/classes/Autoload.php @@ -139,14 +139,18 @@ class Autoload else { $filename_tmp = tempnam(dirname($filename), basename($filename.'.')); - if($filename_tmp !== FALSE and file_put_contents($filename_tmp, $content, LOCK_EX) !== FALSE) + if ($filename_tmp !== false AND file_put_contents($filename_tmp, $content, LOCK_EX) !== false) { @rename($filename_tmp, $filename); @chmod($filename, 0666); } else + { // $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die. error_log('Cannot write temporary file '.$filename_tmp); + if ($filename_tmp !== false) + unlink($filename_tmp); + } } $this->index = $classes; } @@ -189,4 +193,4 @@ class Autoload { return isset($this->index[$classname]) ? $this->index[$classname] : null; } -} +} \ No newline at end of file From f80b348d864a251f7ca871a3f097adf74a468eb5 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Fri, 11 Oct 2013 11:02:24 +0200 Subject: [PATCH 4/5] // Default vertical menu in BO --- classes/Employee.php | 2 +- install-dev/data/db_structure.sql | 2 +- install-dev/upgrade/sql/1.6.0.1.sql | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/Employee.php b/classes/Employee.php index 25a4fb383..8c6397337 100644 --- a/classes/Employee.php +++ b/classes/Employee.php @@ -64,7 +64,7 @@ class EmployeeCore extends ObjectModel public $bo_width; /** @var bool, false */ - public $bo_menu; + public $bo_menu = 1; /* Deprecated */ public $bo_show_screencast = false; diff --git a/install-dev/data/db_structure.sql b/install-dev/data/db_structure.sql index e0a2a934f..8d6096eb4 100644 --- a/install-dev/data/db_structure.sql +++ b/install-dev/data/db_structure.sql @@ -724,7 +724,7 @@ CREATE TABLE `PREFIX_employee` ( `bo_theme` varchar(32) default NULL, `default_tab` int(10) unsigned NOT NULL DEFAULT 0, `bo_width` int(10) unsigned NOT NULL DEFAULT 0, - `bo_menu` tinyint(1) NOT NULL default '0', + `bo_menu` tinyint(1) NOT NULL default '1', `active` tinyint(1) unsigned NOT NULL default '0', `id_last_order` int(10) unsigned NOT NULL default '0', `id_last_customer_message` int(10) unsigned NOT NULL default '0', diff --git a/install-dev/upgrade/sql/1.6.0.1.sql b/install-dev/upgrade/sql/1.6.0.1.sql index f870067b3..f03d2a719 100644 --- a/install-dev/upgrade/sql/1.6.0.1.sql +++ b/install-dev/upgrade/sql/1.6.0.1.sql @@ -3,8 +3,8 @@ SET NAMES 'utf8'; INSERT INTO `PREFIX_configuration` (`name`, `value`, `date_add`, `date_upd`) VALUES('PS_DASHBOARD_USE_PUSH', '0', NOW(), NOW()); UPDATE `PREFIX_configuration` SET `value` = 'graphnvd3' WHERE `name` = 'PS_STATS_RENDER'; -ALTER TABLE `PREFIX_employee` CHANGE `bo_show_screencast` `bo_menu` TINYINT(1) NOT NULL DEFAULT '0'; -UPDATE `PREFIX_employee` SET bo_menu = 0; +ALTER TABLE `PREFIX_employee` CHANGE `bo_show_screencast` `bo_menu` TINYINT(1) NOT NULL DEFAULT '1'; +UPDATE `PREFIX_employee` SET bo_menu = 1; CREATE TABLE `PREFIX_configuration_kpi` ( `id_configuration_kpi` int(10) unsigned NOT NULL auto_increment, @@ -30,4 +30,4 @@ CREATE TABLE `PREFIX_configuration_kpi_lang` ( /* PHP:ps1600_add_missing_index(); */; -UPDATE `PREFIX_configuration` SET `value`='-' WHERE `name`='PS_ATTRIBUTE_ANCHOR_SEPARATOR'; \ No newline at end of file +UPDATE `PREFIX_configuration` SET `value`='-' WHERE `name` = 'PS_ATTRIBUTE_ANCHOR_SEPARATOR'; From 49cdfb56c6cd5d6b90c6375a06666e4761159afe Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Fri, 11 Oct 2013 11:15:14 +0200 Subject: [PATCH 5/5] // Fix class_index generation --- classes/Autoload.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/classes/Autoload.php b/classes/Autoload.php index 111d6e652..dc780e1b8 100644 --- a/classes/Autoload.php +++ b/classes/Autoload.php @@ -141,17 +141,14 @@ class Autoload $filename_tmp = tempnam(dirname($filename), basename($filename.'.')); if ($filename_tmp !== false AND file_put_contents($filename_tmp, $content, LOCK_EX) !== false) { - @rename($filename_tmp, $filename); + if (!@rename($filename_tmp, $filename)) + unlink($filename_tmp); @chmod($filename, 0666); } + // $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die. else - { - // $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die. error_log('Cannot write temporary file '.$filename_tmp); - if ($filename_tmp !== false) - unlink($filename_tmp); - } - } + } $this->index = $classes; }