diff --git a/admin-dev/themes/default/css/admin.css b/admin-dev/themes/default/css/admin.css index c995c233a..574b4d501 100644 --- a/admin-dev/themes/default/css/admin.css +++ b/admin-dev/themes/default/css/admin.css @@ -194,13 +194,13 @@ a.module_toggle_all{color: #268CCD;} .multishop_toolbar .chzn-container .chzn-results .shop{padding-left: 30px;background-color: #EAF2FC;} /*toolbarBox*/ -.toolbarBox { background-color: #F8F8F8; border: 1px solid #CCCCCC; margin-bottom:10px; padding: 5px 0; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px;} +.toolbarBox {background-color: #F8F8F8; border: 1px solid #CCCCCC; margin-bottom:10px; padding: 5px 0; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px;-o-border-radius:3px;position:relative} .toolbarBox .pageTitle { margin-left:10px; line-height:48px} .toolbarBox .pageTitle h3 {font-size: 2em; font-weight: normal; line-height: 52px; margin: 0; padding: 0; text-shadow:0 1px 0 #fff;} .toolbarBox ul.cc_button {float:right;margin:0 5px 0 0;padding:0;} .toolbarBox ul.cc_button li {color: #666666; float: left; height: 48px; list-style: none outside none; padding: 1px 1px 3px 4px; text-align: center;} .toolbarBox a.toolbar_btn { border:1px solid #f8f8f8; min-width:50px; border-width: 1px; font-size:11px;cursor: pointer; display: block; float: left; padding: 3px 5px; white-space: nowrap; text-shadow: 0 1px 0 #ffffff;} -.toolbarBox a.toolbar_btn:hover { background-color:#fff; border:1px inset #ccc; border-radius:3px;} +.toolbarBox a.toolbar_btn:hover { background-color:#fff; border:1px inset #ccc; border-radius:3px;-moz-border-radius:3px; -webkit-border-radius:3px;-o-border-radius:3px;} .toolbarBox .toolbar_btn span{ display: block;float: none;height: 32px;margin: 0 auto;width: 32px; /*hacking ie7*/ margin:0 !ie; position:relative !ie;} .toolbarBox .process-icon-delete { background-image: url('../img/process-icon-delete.png');} .toolbarBox .process-icon-duplicate { background-image: url('../img/process-icon-duplicate.png');} @@ -233,6 +233,76 @@ a.module_toggle_all{color: #268CCD;} .toolbarBox .process-icon-standardRefund{ background-image: url('../img/process-icon-standard-refund.png');} .toolbarBox .process-icon-help{ background-image: url('../img/process-icon-help.png');} .toolbarBox .process-icon-help-new{ background-image: url('../img/process-icon-help-new.png');} +.toolbarBox .process-icon-modules-list{ background-image: url('../img/process-icon-modules-list.png');} + +.toolbarBox #modules_list_container { + background: none repeat scroll 0 0 #FFF; + border: solid 1px #CCC; + display: block; + float: right; + height: auto; + width: 300px; + position: absolute; + right: 13px; + top: 63px; + z-index: 100; + padding: 10px; + box-shadow: 1px 5px 5px #CCCCCC; + -moz-box-shadow: 1px 5px 10px #CCCCCC; + -webkit-box-shadow: 1px 5px 10px #CCCCCC; + opacity: 1; + +} +.toolbarBox #modules_list_container #modules_list_container_content +{ + max-height: 500px; + overflow: auto; + +} + +.toolbarBox #modules_list_container #modules_list_container_tab {margin-top: 10px;width: auto;height: auto; } +.toolbarBox #modules_list_container #modules_list_container_tab table {width: 100%;border-spacing: 0px; } +.toolbarBox #modules_list_container #modules_list_container_tab tr { height: auto} +.toolbarBox #modules_list_container #modules_list_container_tab tr.rowalt {background-color: #EEE} +.toolbarBox #modules_list_container #modules_list_container_tab #tab_module_switch {margin-bottom: 10px;} +.toolbarBox #modules_list_container #modules_list_loader {margin-top: 10px} +.toolbarBox #modules_list_container .nav-tabs-modules:after {clear: both;} +.toolbarBox #modules_list_container .nav-tabs-modules > li {height: 19px;} +.toolbarBox #modules_list_container .nav-tabs-modules > li > a { + padding-right: 12px; + padding-left: 12px; + margin-right: 2px; + line-height: 14px; +} + +.toolbarBox #modules_list_container .nav-tabs-modules > li > a { + padding-top: 8px; + padding-bottom: 7px; + border: 1px solid transparent; + -webkit-border-radius: 4px 4px 0 0; + -moz-border-radius: 4px 4px 0 0; + -o-border-radius: 4px 4px 0 0; + border-radius: 4px 4px 0 0; +} + +.toolbarBox #modules_list_container .nav-tabs-modules > li > a:hover { + border-color: #C0C0C0; + background-color: #ffffff; +} + +.toolbarBox #modules_list_container .nav-tabs-modules > li > a {border: 1px solid #ddd;border-bottom:none;} + +.toolbarBox #modules_list_container .nav-tabs-modules > .active > a, +.toolbarBox #modules_list_container .nav-tabs-modules > .active > a:hover { + color: #555555; + cursor: default; + background-color: #EEE; + border: 1px solid #ddd; + border-bottom-color: transparent; +} + + + div.fix-toolbar {border-bottom: 1px solid #E0E0E0;position:fixed;top:0;opacity:0.9;z-index:500;} @@ -264,7 +334,8 @@ div.fix-toolbar {border-bottom: 1px solid #E0E0E0;position:fixed;top:0;opacity:0 #productBox { position:relative; width:100%; float:left;} /*tab-pane*/ -form#product_form, form#access_form, form#cart_rule_form { background-color:#ebedf4; border:1px solid #ccced7; min-height:404px; padding: 5px 10px 10px; margin-left:140px;} +form#product_form, form#access_form, form#cart_rule_form, #modules_tab_list { background-color:#ebedf4; border:1px solid #ccced7; min-height:404px; padding: 5px 10px 10px; margin-left:140px;} +#modules_tab_list {min-height: inherit} #content form.adminstockmanagement {margin-left:0px;} form#product_form h3 { font-size:14px; font-weight:normal;} form#product_form h4 { font-size:18px; font-weight:normal;} @@ -423,7 +494,7 @@ form#product_form h4 { font-size:18px; font-weight:normal;} #moduleContainer .table tr th { height:40px;} #moduleContainer .table tr td { font-size:12px; vertical-align:top; padding: 5px 7px 0; border-top:1px solid #ccc; border-bottom:none;} #moduleContainer .table tr:first-child {border-top:1px solid #ccc} -#moduleContainer .table tr td .imgm {width:32px;} +#moduleContainer .table tr td .imgm , #modules_list_container_tab .imgm {width:32px;} #moduleContainer .moduleDesc { font-size:12px; position:relative; margin-bottom:10px;} #moduleContainer .moduleDesc h3 { color:#3A6EA7; margin:0;} #moduleContainer .moduleDesc .metadata { float:left; display:block; margin:5px 0;} @@ -435,8 +506,8 @@ form#product_form h4 { font-size:18px; font-weight:normal;} #moduleContainer .setup {background-color:#6db300; font-weight:bold; 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.must-have { background-color: #ec7000;} -#moduleContainer .setup.off{ background-color:#ccc;} -#moduleContainer .row-actions-module span { padding-right:5px;} +#moduleContainer .setup.off{ background-color:#ccc; color:#666666} +#moduleContainer .row-actions-module span {padding-right:5px;} #moduleContainer .row-actions-module span a { font-size:12px;} #moduleContainer .button.uninstalled, #moduleContainer .button.installed { float:right; clear:both; margin-top:15px; font-size:12px;} @@ -446,6 +517,36 @@ form#product_form h4 { font-size:18px; font-weight:normal;} #moduleContainer .moduleGridDesc h3 { color:#3A6EA7; margin:0;} #moduleContainer ul.listing-grid-module li select { position:absolute; top:0; right:0px; } +/*TAB MODULES LIST*/ +#modules_list_container_tab table tr th { height:40px;} +#modules_list_container_tab table tr td { font-size:12px; padding: 3px 3px 3px; border-top:1px solid #ccc; border-bottom:none;} +#modules_list_container_tab table tr td tr td {border: none} +#modules_list_container_tab table tr:first-child {border-top:1px solid #ccc} +#modules_list_container_tab .imgm {width:32px;} +#modules_list_container_tab .moduleDesc { font-size:12px;} +#modules_list_container_tab .moduleDesc h3 { color:#3A6EA7;margin: 0;font-size: 1.1em;text-align: left} +#modules_list_container_tab .moduleDesc .metadata { float:left; display:block; margin:5px 0;} +#modules_list_container_tab .moduleDesc .metadata dl { float:left; margin:0; padding-right:10px;} +#modules_list_container_tab .moduleDesc .metadata dl dt, .moduleDesc .metadata dl dd { float:left; margin:0; padding:0;} +#modules_list_container_tab .moduleDesc .metadata dl dd { padding-right:10px;} +#modules_list_container_tab .moduleDesc .metadata dl dt { font-weight:bold; padding-right:5px;} +#modules_list_container_tab .moduleDesc p.desc { color:#666; font-family: Georgia; font-style: italic; font-size:12px; display:block; clear:both;text-align: left} +#modules_list_container_tab .setup {background-color:#6db300; font-weight:bold; font-size:10px; color:#fff; text-transform:uppercase; position:relative; padding:2px 3px; display: inline-block; border-radius:3px;} +#modules_list_container_tab .row-actions-module {float: right;} +#modules_list_container_tab .setup.non-install { background-color:#ec7000;} +#modules_list_container_tab .setup.must-have { background-color: #ec7000;} +#modules_list_container_tab .setup.off{ background-color:#ccc; color:#666666} +#modules_list_container_tab .row-actions-module span { padding-right:5px;} +#modules_list_container_tab .row-actions-module span a { font-size:12px;} +#modules_list_container_tab ul.listing-grid-module { position:relative; margin:0; padding:0;} +#modules_list_container_tab ul.listing-grid-module li { float:left; border:1px solid #ccc; width:400px; min-height:30px; margin:10px; padding:5px; border-radius:4px;} +#modules_list_container_tab .moduleGridDesc { position:relative; display:block; height:30px;} +#modules_list_container_tab .moduleGridDesc h3 { color:#3A6EA7; margin:0;} +#modules_list_container_tab ul.listing-grid-module li select { position:absolute; top:0; right:0px; } + +.default_modules_list_display_type #modules_list_container_content li table tr td{border: none} +.default_modules_list_display_type #modules_list_container_content li table {border: solid 1px #ccc; height: 115px} + /*MODULE POSITION*/ .blocLiveEdit { float:right; clear:right; background-color: #EBEDF4; border: 1px solid #C2C4D9;display: block; width:250px;} .blocLiveEdit h2 { background: transparent url('../img/live_edit.png') no-repeat scroll 10px 10px; height: 40px; line-height: 50px;margin: 0; padding: 0 10px; text-indent: 40px;} diff --git a/admin-dev/themes/default/img/process-icon-modules-list.png b/admin-dev/themes/default/img/process-icon-modules-list.png new file mode 100644 index 000000000..5c8af7d21 Binary files /dev/null and b/admin-dev/themes/default/img/process-icon-modules-list.png differ diff --git a/admin-dev/themes/default/template/controllers/modules/favorites.tpl b/admin-dev/themes/default/template/controllers/modules/favorites.tpl index 86275baa6..3df17a423 100755 --- a/admin-dev/themes/default/template/controllers/modules/favorites.tpl +++ b/admin-dev/themes/default/template/controllers/modules/favorites.tpl @@ -1,12 +1,10 @@
- {include file='controllers/modules/header.tpl'} -
@@ -16,6 +14,7 @@ + @@ -27,6 +26,7 @@ {l s='Module Name'} {l s='Description'} {l s='Status'} + {l s='Tab'} {l s='Categories:'} {l s='Interest'} {l s='Favorite'} @@ -40,6 +40,22 @@ {$module->displayName} {$module->description|truncate:80:'...'} {if isset($module->id) && $module->id gt 0}{l s='Installed'}{else}{l s='Not Installed'}{/if} + + {assign var="module_name" value=$module->name} + + {$module->categoryName}
+ {if isset($modules_list)} + {$modules_list} {/if}
diff --git a/admin-dev/themes/default/template/header.tpl b/admin-dev/themes/default/template/header.tpl index 0a6011446..9a0f43580 100644 --- a/admin-dev/themes/default/template/header.tpl +++ b/admin-dev/themes/default/template/header.tpl @@ -23,6 +23,10 @@ * International Registered Trademark & Property of PrestaShop SA *} + + + + diff --git a/admin-dev/themes/default/template/helpers/modules_list/list.tpl b/admin-dev/themes/default/template/helpers/modules_list/list.tpl new file mode 100644 index 000000000..2bab32eb1 --- /dev/null +++ b/admin-dev/themes/default/template/helpers/modules_list/list.tpl @@ -0,0 +1,40 @@ +{* +* 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 +*} + +

{l s='Modules list'}

+
+
    + {if count($modules_list)} + {foreach from=$modules_list item=module} +
  • + {include file='controllers/modules/tab_module_line.tpl' class_row={cycle values=",row alt"}} +
  • + {/foreach} + {else} + {l s='No modules available in this section.'} + {/if} +
+
+
\ No newline at end of file diff --git a/admin-dev/themes/default/template/toolbar.tpl b/admin-dev/themes/default/template/toolbar.tpl index fb985bd25..ac98914e5 100644 --- a/admin-dev/themes/default/template/toolbar.tpl +++ b/admin-dev/themes/default/template/toolbar.tpl @@ -33,6 +33,15 @@
{$btn.desc}
+ {if $k == 'modules-list'} + + {/if} {/foreach} @@ -40,6 +49,7 @@ {/block} diff --git a/classes/Tab.php b/classes/Tab.php index a00bdf716..3bf916f44 100644 --- a/classes/Tab.php +++ b/classes/Tab.php @@ -42,6 +42,8 @@ class TabCore extends ObjectModel /** @var integer active */ public $active = true; + + const TAB_MODULE_LIST_URL = 'api.prestashop.com/xml/tab_modules_list.xml'; /** * @see ObjectModel::$definition @@ -503,4 +505,48 @@ class TabCore extends ObjectModel { return Db::getInstance()->getValue('SELECT class_name FROM '._DB_PREFIX_.'tab WHERE id_tab = '.(int)$id_tab); } -} + + public static function getTabModulesList($id_tab) + { + $modules_list = array('default_list' => array(), 'slider_list' => array()); + $xml_tab_modules_list = false; + $db_tab_module_list = Db::getInstance()->executeS(' + SELECT module + FROM '._DB_PREFIX_.'tab_module_preference + WHERE `id_tab` = '.(int)$id_tab.' + AND `id_employee` = '.(int)Context::getContext()->employee->id + ); + + if (file_exists(_PS_ROOT_DIR_.Module::CACHE_FILE_TAB_MODULES_LIST)) + $xml_tab_modules_list = @simplexml_load_file(_PS_ROOT_DIR_.Module::CACHE_FILE_TAB_MODULES_LIST); + + $class_name = null; + $display_type = 'default_list'; + if ($xml_tab_modules_list) + foreach($xml_tab_modules_list->tab as $tab) + { + foreach($tab->attributes() as $key => $value) + if ($key == 'class_name') + $class_name = (string)$value; + + if (Tab::getIdFromClassName((string)$class_name) == $id_tab) + { + foreach($tab->attributes() as $key => $value) + if ($key == 'display_type') + $display_type = (string)$value; + + foreach ($tab->children() as $module) + foreach ($module->attributes() as $k => $v) + if ($k == 'name') + $modules_list[$display_type][] = (string)$v; + } + } + + //merge tab modules preferences from db with xml + foreach($db_tab_module_list as $m) + if (!in_array($m, $modules_list)) + $modules_list['slider_list'][] = $m['module']; + + return $modules_list; + } +} \ No newline at end of file diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 3c03a518b..20a8d5331 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -96,7 +96,13 @@ class AdminControllerCore extends Controller /** @var array list to be generated */ protected $fields_list; - + + /** @var array modules list filters */ + protected $filter_modules_list = null; + + /** @var array modules list filters */ + protected $modules_list = array(); + /** @var array edit form to be generated */ protected $fields_form; @@ -227,6 +233,7 @@ class AdminControllerCore extends Controller protected $action; protected $display; protected $_includeContainer = true; + protected $tab_modules_list = array('default_list' => array(), 'slider_list' => array()); public $tpl_folder; @@ -1016,7 +1023,7 @@ class AdminControllerCore extends Controller 'desc' => $this->l('Add new') ); } - + $this->addToolBarModulesListButton(); } /** @@ -1368,6 +1375,7 @@ class AdminControllerCore extends Controller $this->getLanguages(); // toolbar (save, cancel, new, ..) $this->initToolbar(); + $this->initTabModuleList(); if ($this->display == 'edit' || $this->display == 'add') { if (!$this->loadObject(true)) @@ -1384,7 +1392,7 @@ class AdminControllerCore extends Controller } elseif (!$this->ajax) { - + $this->content .= $this->renderModulesList(); $this->content .= $this->renderList(); $this->content .= $this->renderOptions(); @@ -1398,6 +1406,39 @@ class AdminControllerCore extends Controller 'url_post' => self::$currentIndex.'&token='.$this->token, )); } + + /** + * init tab modules list and add button in toolbar + */ + protected function initTabModuleList() + { + if (!$this->isFresh(Module::CACHE_FILE_TAB_MODULES_LIST, 604800)) + $this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, 'http://'.Tab::TAB_MODULE_LIST_URL); + + $this->tab_modules_list = Tab::getTabModulesList($this->id); + + if (is_array($this->tab_modules_list['default_list']) && count($this->tab_modules_list['default_list'])) + $this->filter_modules_list = $tab_modules_list['default_list']; + else if (is_array($this->tab_modules_list['slider_list']) && count($this->tab_modules_list['slider_list'])) + { + $this->addToolBarModulesListButton(); + $this->context->smarty->assign(array( + 'tab_modules_list' => implode(',', $this->tab_modules_list['slider_list']), + 'admin_module_ajax_url' => $this->context->link->getAdminLink('AdminModules'), + 'back_tab_modules_list' => $this->context->link->getAdminLink(Tools::getValue('controller')), + 'tab_modules_open' => (int)Tools::getValue('tab_modules_open') + )); + } + } + + protected function addToolBarModulesListButton() + { + if (is_array($this->tab_modules_list['slider_list']) && count($this->tab_modules_list['slider_list'])) + $this->toolbar_btn['modules-list'] = array( + 'href' => '#', + 'desc' => $this->l('Modules List') + ); + } /** * initialize the invalid doom page of death @@ -1424,7 +1465,17 @@ class AdminControllerCore extends Controller 'iso_is_fr' => strtoupper($this->context->language->iso_code) == 'FR', )); } - + + public function renderModulesList() + { + if ($this->getModulesList($this->filter_modules_list)) + { + $helper = new Helper(); + return $helper->renderModulesList($this->modules_list); + } + } + + /** * Function used to render the list to display for this controller */ @@ -2090,6 +2141,31 @@ class AdminControllerCore extends Controller else $this->_listTotal = Db::getInstance()->getValue('SELECT FOUND_ROWS() AS `'._DB_PREFIX_.$this->table.'`'); } + + public function getModulesList($filter_modules_list) + { + if (!is_array($filter_modules_list) && !is_null($filter_modules_list)) + $filter_modules_list = array($filter_modules_list); + + if (!count($filter_modules_list)) + return false; //if there is no modules to display just return false; + + $all_modules = Module::getModulesOnDisk(true); + $this->modules_list = array(); + foreach($all_modules as $module) + { + if (in_array($module->name, $filter_modules_list)) + { + $this->fillModuleData($module, 'select'); + $this->modules_list[] = $module; + } + } + if (count($this->modules_list)) + return true; + + return false; //no module found on disk just return false; + + } public function getLanguages() { @@ -2787,4 +2863,113 @@ class AdminControllerCore extends Controller // No content, return false return false; } + + public function fillModuleData(&$module, $output_type = 'link', $back = null) + { + $obj = null; + if ($module->onclick_option) + $obj = new $module->name(); + // Fill module data + $module->logo = '../../img/questionmark.png'; + if (file_exists('../modules/'.$module->name.'/logo.gif')) + $module->logo = 'logo.gif'; + if (file_exists('../modules/'.$module->name.'/logo.png')) + $module->logo = 'logo.png'; + $module->optionsHtml = $this->displayModuleOptions($module, $output_type); + $module->options['install_url'] = self::$currentIndex.'&install='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name); + $module->options['update_url'] = self::$currentIndex.'&update='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name); + $module->options['uninstall_url'] = self::$currentIndex.'&uninstall='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name); + + $module->options['uninstall_onclick'] = ((!$module->onclick_option) ? + ((empty($module->confirmUninstall)) ? '' : 'return confirm(\''.addslashes($module->confirmUninstall).'\');') : + $obj->onclickOption('uninstall', $module->options['uninstall_url'])); + + if ((Tools::getValue('module_name') == $module->name || in_array($module->name, explode('|', Tools::getValue('modules_list')))) && (int)Tools::getValue('conf') > 0) + $module->message = $this->_conf[(int)Tools::getValue('conf')]; + + if ((Tools::getValue('module_name') == $module->name || in_array($module->name, explode('|', Tools::getValue('modules_list')))) && (int)Tools::getValue('conf') > 0) + unset($obj); + } + + /** + * Display modules list + * + * @param $module + * @param $output_type (link or select) + * @param $back + * + * @return string + */ + protected $translationsTab = array(); + public function displayModuleOptions($module, $output_type = 'link', $back = null) + { + if (!isset($this->translationsTab['Disable this module'])) + { + $this->translationsTab['Disable this module'] = $this->l('Disable this module'); + $this->translationsTab['Enable this module for all shops'] = $this->l('Enable this module for all shops'); + $this->translationsTab['Disable'] = $this->l('Disable'); + $this->translationsTab['Enable'] = $this->l('Enable'); + $this->translationsTab['Reset'] = $this->l('Reset'); + $this->translationsTab['Configure'] = $this->l('Configure'); + $this->translationsTab['Delete'] = $this->l('Delete'); + $this->translationsTab['Install'] = $this->l('Install'); + $this->translationsTab['Uninstall'] = $this->l('Uninstall'); + $this->translationsTab['This action will permanently remove the module from the server. Are you sure you want to do this?'] = $this->l('This action will permanently remove the module from the server. Are you sure you want to do this?'); + } + + $modules_options = array( + 'configure-module' => array( + 'href' => self::$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name), + 'onclick' => $module->onclick_option && isset($module->onclick_option_content['configure']) ? $module->onclick_option_content['configure'] : '', + 'title' => '', + 'text' => $this->translationsTab['Configure'], + 'cond' => $module->id && isset($module->is_configurable) && $module->is_configurable, + ), + 'desactive-module' => array( + 'href' => self::$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&'.($module->active ? 'enable=0' : 'enable=1').'&tab_module='.$module->tab, + 'onclick' => $module->active && $module->onclick_option && isset($module->onclick_option_content['desactive']) ? $module->onclick_option_content['desactive'] : '' , + 'title' => Shop::isFeatureActive() ? htmlspecialchars($module->active ? $this->translationsTab['Disable this module'] : $this->translationsTab['Enable this module for all shops']) : '', + 'text' => $module->active ? $this->translationsTab['Disable'] : $this->translationsTab['Enable'], + 'cond' => $module->id, + ), + 'reset-module' => array( + 'href' => self::$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&reset&tab_module='.$module->tab, + 'onclick' => $module->onclick_option && isset($module->onclick_option_content['reset']) ? $module->onclick_option_content['reset'] : '', + 'title' => '', + 'text' => $this->translationsTab['Reset'], + 'cond' => $module->id && $module->active, + ), + 'delete-module' => array( + 'href' => self::$currentIndex.'&delete='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name), + 'onclick' => $module->onclick_option && isset($module->onclick_option_content['delete']) ? $module->onclick_option_content['delete'] : 'return confirm(\''.$this->translationsTab['This action will permanently remove the module from the server. Are you sure you want to do this?'].'\');', + 'title' => '', + 'text' => $this->translationsTab['Delete'], + 'cond' => true, + ), + ); + $return = ''; + foreach($modules_options as $option_name => $option) + { + if ($option['cond']) + { + if ($output_type == 'link') + $return .= ' + '.$option['text'].' + '; + else if ($output_type == 'select') + $return .= ''; + } + } + if ($output_type == 'select') + { + if (!$module->id) + $return = ''.$return; + else + $return = ''.$return; + $return = ''; + + } + + return $return; + } } \ No newline at end of file diff --git a/classes/helper/Helper.php b/classes/helper/Helper.php index ddb9ef106..269cf2c44 100755 --- a/classes/helper/Helper.php +++ b/classes/helper/Helper.php @@ -350,6 +350,16 @@ class HelperCore return $tpl->fetch(); } + + public function renderModulesList($modules_list) + { + $this->tpl_vars = array('modules_list' => $modules_list); + + $tpl = $this->createTemplate('helpers/modules_list/list.tpl'); + $tpl->assign($this->tpl_vars); + + return $tpl->fetch(); + } public static function renderShopList() { diff --git a/classes/module/Module.php b/classes/module/Module.php index 452491768..900d88bd3 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -122,6 +122,8 @@ abstract class ModuleCore const CACHE_FILE_MODULES_LIST = '/config/xml/modules_list.xml'; + const CACHE_FILE_TAB_MODULES_LIST = '/config/xml/tab_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'; diff --git a/config/xml/modules_list.xml b/config/xml/modules_list.xml index a1ff61374..5eac71754 100755 --- a/config/xml/modules_list.xml +++ b/config/xml/modules_list.xml @@ -102,12 +102,13 @@ + - - + + @@ -121,6 +122,7 @@ + diff --git a/controllers/admin/AdminEmailsController.php b/controllers/admin/AdminEmailsController.php index 74470c91a..788a3d3aa 100644 --- a/controllers/admin/AdminEmailsController.php +++ b/controllers/admin/AdminEmailsController.php @@ -170,9 +170,10 @@ class AdminEmailsControllerCore extends AdminController */ public function initContent() { + $this->initTabModuleList(); $this->initToolbar(); + $this->addToolBarModulesListButton(); unset($this->toolbar_btn['save']); - $back = $this->context->link->getAdminLink('AdminHome'); $this->toolbar_btn['back'] = array( diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index d1c3dfeb8..477514792 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -232,6 +232,38 @@ class AdminModulesControllerCore extends AdminController $this->smartyOutputContent('controllers/modules/list.tpl'); exit; } + + public function ajaxProcessGetTabModulesList() + { + $tab_modules_list = Tools::getValue('tab_modules_list'); + $back = Tools::getValue('back_tab_modules_list'); + if ($back) + $back .= '&tab_modules_open=1'; + $modules_list = array('installed' =>array(), 'not_installed' => array()); + if ($tab_modules_list) + { + $tab_modules_list = explode(',', $tab_modules_list); + $all_modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee); + foreach($all_modules as $module) + { + if (in_array($module->name, $tab_modules_list)) + { + $this->fillModuleData($module, 'select', $back); + if ($module->id) + $modules_list['installed'][] = $module; + else + $modules_list['not_installed'][] = $module; + } + } + } + $this->context->smarty->assign(array( + 'tab_modules_list' => $modules_list, + 'admin_module_favorites_view' => $this->context->link->getAdminLink('AdminModules').'&select=favorites' + )); + + $this->smartyOutputContent('controllers/modules/tab_modules_list.tpl'); + exit; + } public function ajaxProcessSetFilter() { @@ -265,6 +297,22 @@ class AdminModulesControllerCore extends AdminController die('OK'); } + public function ajaxProcessSaveTabModulePreferences() + { + $values = Tools::getValue('value_pref'); + $module = Tools::getValue('module_pref'); + if (Validate::isModuleName($module)) + { + Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'tab_module_preference` WHERE `id_employee` = '.(int)$this->id_employee.' AND `module` = \''.pSQL($module).'\''); + if (is_array($values) && count($values)) + foreach($values as $value) + Db::getInstance()->execute(' + INSERT INTO `'._DB_PREFIX_.'tab_module_preference` (`id_tab_module_preference`, `id_employee`, `id_tab`, `module`) + VALUES (NULL, '.(int)$this->id_employee.', '.(int)$value.', \''.pSQL($module).'\');'); + } + die('OK'); + } + /* ** Get current URL ** @@ -730,6 +778,9 @@ class AdminModulesControllerCore extends AdminController // Call appropriate module callback if (!isset($ppmReturn)) $this->postProcessCallback(); + + if ($back = Tools::getValue('back')) + Tools::redirectAdmin($back); } /** @@ -758,42 +809,6 @@ class AdminModulesControllerCore extends AdminController return $html_error; } - /* - ** Display Modules Lists - ** - */ - protected $translationsTab = array(); - public function displayModuleOptions($module) - { - if (!isset($this->translationsTab['Disable this module'])) - { - $this->translationsTab['Disable this module'] = $this->l('Disable this module'); - $this->translationsTab['Enable this module for all shops'] = $this->l('Enable this module for all shops'); - $this->translationsTab['Disable'] = $this->l('Disable'); - $this->translationsTab['Enable'] = $this->l('Enable'); - $this->translationsTab['Reset'] = $this->l('Reset'); - $this->translationsTab['Configure'] = $this->l('Configure'); - $this->translationsTab['Delete'] = $this->l('Delete'); - $this->translationsTab['This action will permanently remove the module from the server. Are you sure you want to do this?'] = $this->l('This action will permanently remove the module from the server. Are you sure you want to do this?'); - } - - $return = ''; - if ($module->id) - $return .= ' active && $module->onclick_option && isset($module->onclick_option_content['desactive']) ? 'onclick="'.$module->onclick_option_content['desactive'].'"' : '').' - href="'.self::$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&'.($module->active ? 'enable=0' : 'enable=1').'&tab_module='.$module->tab.'" '.((Shop::isFeatureActive()) ? 'title="'.htmlspecialchars($module->active ? $this->translationsTab['Disable this module'] : $this->translationsTab['Enable this module for all shops']).'"' : '').'>'.($module->active ? $this->translationsTab['Disable'] : $this->translationsTab['Enable']).''; - - if ($module->id && $module->active) - $return .= (!empty($result) ? '|' : '').' onclick_option && isset($module->onclick_option_content['reset']) ? 'onclick="'.$module->onclick_option_content['reset'].'"' : '').' href="'.self::$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&reset&tab_module='.$module->tab.'">'.$this->translationsTab['Reset'].''; - - if ($module->id && isset($module->is_configurable) && $module->is_configurable) - $return .= (!empty($result) ? '|' : '').' onclick_option && isset($module->onclick_option_content['configure']) ? 'onclick="'.$module->onclick_option_content['configure'].'"' : '').' href="'.self::$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'">'.$this->translationsTab['Configure'].''; - - $hrefDelete = self::$currentIndex.'&delete='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name); - $return .= (!empty($result) ? '|' : '').' onclick_option && isset($module->onclick_option_content['delete']) ? 'onclick="'.$module->onclick_option_content['delete'].'"' : '').' onclick="return confirm(\''.$this->translationsTab['This action will permanently remove the module from the server. Are you sure you want to do this?'].'\');" href="'.$hrefDelete.'">'.$this->translationsTab['Delete'].''; - - return $return; - } - public function initModulesList(&$modules) { foreach ($modules as $k => $module) @@ -925,7 +940,7 @@ class AdminModulesControllerCore extends AdminController // Module has not been filtered return false; } - + public function initContent() { // Adding Css @@ -951,7 +966,13 @@ class AdminModulesControllerCore extends AdminController // Retrieve Modules Preferences $modules_preferences = ''; + $tab_modules_preferences = array(); $modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'module_preference` WHERE `id_employee` = '.(int)$this->id_employee); + $tab_modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'tab_module_preference` WHERE `id_employee` = '.(int)$this->id_employee); + + foreach($tab_modules_preferences_tmp as $i => $j) + $tab_modules_preferences[$j['module']][] = $j['id_tab']; + foreach ($modules_preferences_tmp as $k => $v) { if ($v['interest'] == null) @@ -971,6 +992,13 @@ class AdminModulesControllerCore extends AdminController // Browse modules list foreach ($modules as $km => $module) { + //if we are in favorites view we only display installed modules + if (Tools::getValue('select') == 'favorites' && !$module->id) + { + unset($modules[$km]); + continue; + } + // Upgrade Module process, init check if a module could be upgraded if (Module::initUpgradeModule($module)) { @@ -1033,34 +1061,11 @@ class AdminModulesControllerCore extends AdminController unset($modules[$km]); else { - $obj = null; - if ($module->onclick_option) - $obj = new $module->name(); - - // Fill module data - $modules[$km]->logo = '../../img/questionmark.png'; - if (file_exists('../modules/'.$module->name.'/logo.gif')) - $modules[$km]->logo = 'logo.gif'; - if (file_exists('../modules/'.$module->name.'/logo.png')) - $modules[$km]->logo = 'logo.png'; - $modules[$km]->optionsHtml = $this->displayModuleOptions($module); - $modules[$km]->categoryName = (isset($this->list_modules_categories[$module->tab]['name']) ? $this->list_modules_categories[$module->tab]['name'] : $this->list_modules_categories['others']['name']); - $modules[$km]->options['install_url'] = self::$currentIndex.'&install='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name); - $modules[$km]->options['update_url'] = self::$currentIndex.'&update='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name); - $modules[$km]->options['uninstall_url'] = self::$currentIndex.'&uninstall='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name); - - $modules[$km]->options['uninstall_onclick'] = ((!$module->onclick_option) ? - ((empty($module->confirmUninstall)) ? '' : 'return confirm(\''.addslashes($module->confirmUninstall).'\');') : - $obj->onclickOption('uninstall', $modules[$km]->options['uninstall_url'])); - - if ((Tools::getValue('module_name') == $module->name || in_array($module->name, explode('|', Tools::getValue('modules_list')))) && (int)Tools::getValue('conf') > 0) - $modules[$km]->message = $this->_conf[(int)Tools::getValue('conf')]; - - if ((Tools::getValue('module_name') == $module->name || in_array($module->name, explode('|', Tools::getValue('modules_list')))) && (int)Tools::getValue('conf') > 0) + $this->fillModuleData($module); + $module->categoryName = (isset($this->list_modules_categories[$module->tab]['name']) ? $this->list_modules_categories[$module->tab]['name'] : $this->list_modules_categories['others']['name']); if (isset($modules_preferences[$modules[$km]->name])) $modules[$km]->preferences = $modules_preferences[$modules[$km]->name]; - unset($obj); } unset($object); } @@ -1109,6 +1114,7 @@ class AdminModulesControllerCore extends AdminController $tpl_vars['check_openssl'] = (extension_loaded('openssl') ? 'ok' : 'ko'); $tpl_vars['add_permission'] = $this->tabAccess['add']; + $tpl_vars['tab_modules_preferences'] = $tab_modules_preferences; if ($this->logged_on_addons) { diff --git a/controllers/admin/AdminPaymentController.php b/controllers/admin/AdminPaymentController.php index a3fea4320..928ed8897 100644 --- a/controllers/admin/AdminPaymentController.php +++ b/controllers/admin/AdminPaymentController.php @@ -222,7 +222,7 @@ class AdminPaymentControllerCore extends AdminController } $this->tpl_view_vars = array( - 'url_modules' => isset($token_modules) ? 'index.php?tab=AdminModules&token='.$token_modules.'&&filterCategory=payments_gateways' : null, + 'modules_list' => $this->renderModulesList(), 'display_restrictions' => $display_restrictions, 'lists' => $lists, 'ps_base_uri' => __PS_BASE_URI__, diff --git a/controllers/admin/AdminStatsTabController.php b/controllers/admin/AdminStatsTabController.php index 84a419299..260573c10 100644 --- a/controllers/admin/AdminStatsTabController.php +++ b/controllers/admin/AdminStatsTabController.php @@ -36,8 +36,9 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor public function initContent() { + $this->initTabModuleList(); + $this->addToolBarModulesListButton(); $this->toolbar_title = $this->l('Stats', 'AdminStatsTab'); - if ($this->display == 'view') { // Some controllers use the view action without an object diff --git a/css/admin.css b/css/admin.css index 4986af815..b3ab69eee 100644 --- a/css/admin.css +++ b/css/admin.css @@ -352,6 +352,8 @@ select optgroup option { #content { padding: 1.25em; padding-bottom: 0.5em; + position: relative; + z-index: 3000; } #news { diff --git a/install-dev/data/db_structure.sql b/install-dev/data/db_structure.sql index 572de3a2c..c4a01418a 100644 --- a/install-dev/data/db_structure.sql +++ b/install-dev/data/db_structure.sql @@ -2433,6 +2433,15 @@ CREATE TABLE `PREFIX_module_preference` ( UNIQUE KEY `employee_module` (`id_employee`, `module`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; +CREATE TABLE `PREFIX_tab_module_preference` ( + `id_tab_module_preference` int(11) NOT NULL auto_increment, + `id_employee` int(11) NOT NULL, + `id_tab` int(11) NOT NULL, + `module` varchar(255) NOT NULL, + PRIMARY KEY (`id_tab_module_preference`), + UNIQUE KEY `employee_module` (`id_employee`, `id_tab`, `module`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; + CREATE TABLE `PREFIX_carrier_tax_rules_group_shop` ( `id_carrier` int( 11 ) unsigned NOT NULL, `id_tax_rules_group` int(11) unsigned NOT NULL, diff --git a/install-dev/upgrade/sql/1.5.4.0.sql b/install-dev/upgrade/sql/1.5.4.0.sql index b758dbde7..06144b74c 100644 --- a/install-dev/upgrade/sql/1.5.4.0.sql +++ b/install-dev/upgrade/sql/1.5.4.0.sql @@ -10,3 +10,11 @@ UPDATE `PREFIX_customer` c, `PREFIX_orders` o SET c.id_lang = o.id_lang WHERE c. UPDATE `PREFIX_quick_access` SET `link` = 'index.php?controller=AdminCartRules&addcart_rule' WHERE `link` = 'index.php?tab=AdminDiscounts&adddiscount'; +CREATE TABLE `PREFIX_tab_module_preference` ( + `id_tab_module_preference` int(11) NOT NULL auto_increment, + `id_employee` int(11) NOT NULL, + `id_tab` int(11) NOT NULL, + `module` varchar(255) NOT NULL, + PRIMARY KEY (`id_tab_module_preference`), + UNIQUE KEY `employee_module` (`id_employee`, `id_tab`, `module`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; \ No newline at end of file