Skip to content

Commit

Permalink
Merge pull request #4 from PrestaShop/dev
Browse files Browse the repository at this point in the history
1.0.2
  • Loading branch information
MrBaiame authored Jun 7, 2018
2 parents 1ef4ea8 + 11d4a57 commit bcaaa3a
Show file tree
Hide file tree
Showing 13 changed files with 569 additions and 81 deletions.
12 changes: 12 additions & 0 deletions config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>ps_mbo</name>
<displayName><![CDATA[MBO]]></displayName>
<version><![CDATA[1.0.2]]></version>
<description><![CDATA[Discover the best PrestaShop modules to optimize your online store.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
<is_configurable>0</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>
15 changes: 14 additions & 1 deletion controllers/admin/AdminPsMboModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use PrestaShop\PrestaShop\Core\Addon\AddonListFilterStatus;
use PrestaShop\PrestaShop\Core\Addon\AddonListFilterType;
use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;


require_once(dirname(__FILE__) . '../../../classes/Addons.php');
Expand Down Expand Up @@ -59,14 +60,25 @@ public function initContent() {
$admin_webpath = str_ireplace(_PS_CORE_DIR_, '', _PS_ADMIN_DIR_);
$admin_webpath = preg_replace('/^'.preg_quote(DIRECTORY_SEPARATOR, '/').'/', '', $admin_webpath);

$container = SymfonyContainer::getInstance();
$install_url = $container->get('router')->generate('admin_module_import', [], UrlGeneratorInterface::ABSOLUTE_URL);
$notification_count_url = $container->get('router')->generate('admin_module_notification_count', [], UrlGeneratorInterface::ABSOLUTE_URL);

$parts = parse_url($install_url);
parse_str($parts['query'], $query);
$moduleControllerToken = $query['_token'];

$this->context->smarty->assign(array(
'bootstrap' => 1,
'configure_type' => $this->controller_quick_name,
'template_dir' => $this->module->template_dir,
'admin_module_controller_psmbo' => $this->module->controller_name[0],
'admin_module_ajax_url_psmbo' => $this->module->front_controller[0],
'currency_symbol' => Context::getContext()->currency->sign,
'bo_img' => __PS_BASE_URI__ . $admin_webpath . '/themes/default/img/'
'bo_img' => __PS_BASE_URI__ . $admin_webpath . '/themes/default/img/',
'install_url' => $install_url,
'module_controller_token' => $moduleControllerToken,
'notification_count_url' => $notification_count_url
));

$aJsDef = $aJs = array();
Expand All @@ -75,6 +87,7 @@ public function initContent() {
// TODO, call vue.min.js
$aJs = array(
$this->module->js_path . 'vue.js',
$this->module->js_path . 'controllers/module/dropzone.min.js',
$this->module->js_path . 'controllers/module/jquery.pstagger.js',
$this->module->js_path . 'controllers/module/module.js',
$this->module->js_path . 'controllers/module/search.js',
Expand Down
83 changes: 55 additions & 28 deletions ps_mbo.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,35 @@
exit;
}

use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShopBundle\Service\DataProvider\Admin\AddonsInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class ps_mbo extends Module
{
public $tabs = array(
array(
'name' => 'Module catalog MBO', // One name for all langs
'name' => 'Module catalog', // One name for all langs
'class_name' => 'AdminPsMboModule',
'visible' => true,
'parent_class_name' => 'AdminModulesSf',
),
array(
'name' => 'Theme catalog MBO 1', // One name for all langs
'name' => 'Theme catalog', // One name for all langs
'class_name' => 'AdminPsMboTheme',
'visible' => true,
'parent_class_name' => 'AdminParentThemes',
)
);

public function __construct()
{
public function __construct() {
$this->name = 'ps_mbo';
$this->version = '0.0.1';
$this->version = '1.0.2';
$this->author = 'PrestaShop';
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Module Back Office');
$this->description = $this->l('Get all your addons modules !');
$this->displayName = $this->l('PrestaShop Marketplace in your Back Office');
$this->description = $this->l('Discover the best PrestaShop modules to optimize your online store.');

$this->controller_name = array('AdminPsMboModule', 'AdminPsMboTheme');
$this->front_controller = array(
Expand All @@ -75,8 +78,7 @@ public function __construct()
* @param none
* @return bool
*/
public function install()
{
public function install() {
if (parent::install()
&& $this->registerHook('backOfficeHeader')
&& $this->registerHook('displayDashboardToolbarTopMenu')
Expand Down Expand Up @@ -129,6 +131,16 @@ public function fetchModulesByController($ajax = false) {
}

public function hookDisplayAdminEndContent() {
if (Tools::getIsset('controller') && Tools::getValue('controller') == 'AdminPsMboModule') {
$addonsConnect = $this->getAddonsConnectToolbar();

$this->context->smarty->assign(array(
'addons_connect' => $addonsConnect,
));

return $this->context->smarty->fetch($this->template_dir . '/include/modal_addons_connect.tpl');
}

$controller = Tools::getValue('controller');
if ($controller == 'AdminThemes') {
$this->context->smarty->assign(array(
Expand All @@ -147,14 +159,19 @@ public function hookDisplayAdminEndContent() {
return $content;
}


public function hookDisplayDashboardToolbarTopMenu() {

if (Tools::getIsset('controller') && Tools::getValue('controller') == 'AdminPsMboModule') {
$addonsConnect = $this->getAddonsConnectToolbar();

$this->context->smarty->assign(array(
'addons_connect' => $addonsConnect,
));

return $this->context->smarty->fetch($this->template_dir . '/module-toolbar.tpl');
}

if (!$this->isSymfonyContext()) {
return '<div style="width:100px; height:100px; background-color: red">HEYCOUCOU</div>';
$this->context->smarty->assign(array(
// 'admin_module_ajax_url_psmbo' => $this->front_controller[0],
'admin_module_ajax_url_psmbo' => $this->context->link->getAdminLink('AdminPsMboModule'),
'controller' => Tools::getValue('controller')
));
Expand All @@ -163,6 +180,27 @@ public function hookDisplayDashboardToolbarTopMenu() {
}
}

private function getAddonsConnectToolbar() {
$container = SymfonyContainer::getInstance();
$addonsProvider = $container->get('prestashop.core.admin.data_provider.addons_interface');
$addonsConnect = array();

$authenticated = $addonsProvider->isAddonsAuthenticated();

if ($addonsProvider->isAddonsAuthenticated()) {
$addonsEmail = $addonsProvider->getAddonsEmail();
return array(
'connected' => true,
'email' => $addonsEmail['username_addons'],
'logout_url' => $container->get('router')->generate('admin_addons_logout', [], UrlGeneratorInterface::ABSOLUTE_URL)
);
} else {
return array(
'connected' => false,
'login_url' => $container->get('router')->generate('admin_addons_login', [], UrlGeneratorInterface::ABSOLUTE_URL)
);
}
}

private function installTab() {
$tab = new Tab();
Expand Down Expand Up @@ -196,8 +234,7 @@ private function installTab() {
* @param none
* @return bool
*/
public function uninstall()
{
public function uninstall() {
// unregister hook
if (parent::uninstall()) {
return true;
Expand All @@ -214,8 +251,7 @@ public function uninstall()
* @param none
* @return none
*/
public function setMedia($aJsDef, $aJs, $aCss)
{
public function setMedia($aJsDef, $aJs, $aCss) {
Media::addJsDef($aJsDef);
$this->context->controller->addCSS($aCss);
$this->context->controller->addJS($aJs);
Expand Down Expand Up @@ -249,10 +285,6 @@ public function getModules($filter_modules_list, $tracking_source) {
$all_modules = Module::getModulesOnDisk(true);
$modules_list = array();

// TODO REMOVE THESE LINES $filter_modules_list
$filter_modules_list[] = 'export2bizrate';
$filter_modules_list[] = 'cappasity3d';

foreach ($all_modules as $module) {
$perm = true;
if ($module->id) {
Expand Down Expand Up @@ -284,9 +316,6 @@ protected function getPaymentMboModules() {
$active_list = array();
$unactive_list = array();
foreach ($modulesList as $key => $module) {
// if (in_array($module->name, $this->list_partners_modules)) {
// $modulesList[$key]->type = 'addonsPartner';
// }
if (isset($module->description_full) && trim($module->description_full) != '') {
$module->show_quick_view = true;
}
Expand Down Expand Up @@ -315,8 +344,7 @@ protected function getPaymentMboModules() {

}

public function fillModuleData(&$module, $output_type = 'link', $back = null, $install_source_tracking = false)
{
public function fillModuleData(&$module, $output_type = 'link', $back = null, $install_source_tracking = false) {
/** @var Module $obj */
$obj = null;
if ($module->onclick_option) {
Expand Down Expand Up @@ -369,8 +397,7 @@ public function fillModuleData(&$module, $output_type = 'link', $back = null, $i
* @param string|bool $install_source_tracking
* @return string|array
*/
public function displayModuleOptions($module, $output_type = 'link', $back = null, $install_source_tracking = false)
{
public function displayModuleOptions($module, $output_type = 'link', $back = null, $install_source_tracking = false) {
if (!isset($module->enable_device)) {
$module->enable_device = Context::DEVICE_COMPUTER | Context::DEVICE_TABLET | Context::DEVICE_MOBILE;
}
Expand Down
110 changes: 109 additions & 1 deletion views/css/controllers/module/module.css
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,112 @@

.link-leveltwo>.link,
.menu .main-tab .submenu a,
#nav-sidebar ul.menu li.maintab ul.submenu li a { font-size: .75rem!important; }
#nav-sidebar ul.menu li.maintab ul.submenu li a { font-size: .75rem!important; }

.bootstrap .btn {
border-width: 1px;
font-weight: 600;
white-space: nowrap;
display: inline-block;
text-align: center;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: 1px solid transparent;
padding: .375rem .838rem;
font-size: .875rem;
line-height: 1.5;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
border-radius: .063rem;
}

.bootstrap .btn.btn-primary {
color: #fff;
background-color: #25b9d7;
border-color: #25b9d7;
box-shadow: none;
text-transform: none;
margin-right: 10px;
}

.bootstrap .btn-outline-secondary {
color: #6c868e!important;
background-color: transparent;
background-image: none;
border-color: #6c868e;
margin-right: 10px;
}

.bootstrap #toolbar-nav { margin-top: 30px; }
.modal-backdrop.fade { opacity: .5!important; }
.modal.fade .modal-dialog { margin: 8rem auto!important; }
h4.modal-title {
display: inline-block;
vertical-align: top;
margin-bottom: 0;
line-height: 1.5;
font-size: 1.125rem;
font-family: Open Sans,Helvetica,Arial,sans-serif;
font-weight: 700;
color: #363a41;
margin-top: 0;
}
#module-modal-addons-connect .modal-header .close,
#module-modal-import-closing-cross {
padding: 1.875rem;
font-size: 2rem;
margin: -1.875rem -1.875rem -1.875rem auto;
float: right;
font-weight: 700;
line-height: 1;
color: #000;
text-shadow: 0 1px 0 #fff;
opacity: .5;
}

#module-addons-connect-email, #module-addons-connect-password {
padding: .375rem .4375rem;
display: block;
width: 100%;
font-size: .875rem;
line-height: 1.5;
color: #363a41;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #bbcdd2;
border-radius: 0;
box-shadow: none;
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}

.modal-content { border-radius: 0px; }

.notification-container {
line-height: 1.5rem;
height: 1.5rem;
vertical-align: middle;
cursor: pointer;
color: #6c868e;
float: right;
position: relative;
}

.notification-counter {
display: inline-block;
line-height: .875rem;
height: .875rem;
vertical-align: middle;
position: absolute;
color: #fff;
background: #cd9321;
font-size: .5625rem;
padding: 0 .25rem;
border-radius: 1rem;
top: -.063rem;
right: auto;
}

#help-container .page-wrap, #main-nav { margin-top: 30px!important; }
.pstaggerTagsWrapper { padding: 0.3rem 0.4rem!important; }
1 change: 1 addition & 0 deletions views/js/controllers/module/dropzone.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit bcaaa3a

Please sign in to comment.