public function moveRightColumn($position) { if (_PS_VERSION_ < '1.5') { $hookRight = (int) Hook::get('rightColumn'); } else { $hookRight = (int) Hook::getIdByName('rightColumn'); } $moduleInstance = Module::getInstanceByName($this->name); if (_PS_VERSION_ < '1.5') { $moduleInfo = Hook::getModuleFromHook($hookRight, $moduleInstance->id); } else { $moduleInfo = Hook::getModulesFromHook($hookRight, $moduleInstance->id); } if (isset($moduleInfo['position']) && (int) $moduleInfo['position'] > (int) $position || isset($moduleInfo['m.position']) && (int) $moduleInfo['m.position'] > (int) $position) { return $moduleInstance->updatePosition($hookRight, 0, (int) $position); } return $moduleInstance->updatePosition($hookRight, 1, (int) $position); }
public function displayList() { global $currentIndex; $link = new Link(); $admin_dir = dirname($_SERVER['PHP_SELF']); $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1); echo ' <script type="text/javascript" src="../js/jquery/jquery.tablednd_0_5.js"></script> <script type="text/javascript"> var token = \'' . $this->token . '\'; var come_from = \'AdminModulesPositions\'; </script> <script type="text/javascript" src="../js/admin-dnd.js"></script> '; echo '<a href="' . $currentIndex . '&addToHook' . ($this->displayKey ? '&show_modules=' . $this->displayKey : '') . '&token=' . $this->token . '"><img src="../img/admin/add.gif" border="0" /> <b>' . $this->l('Transplant a module') . '</b></a><br /><br />'; // Print select list echo ' <form> ' . $this->l('Show') . ' : <select id="show_modules" onChange="autoUrl(\'show_modules\', \'' . $currentIndex . '&token=' . $this->token . '&show_modules=\')"> <option value="all">' . $this->l('All modules') . ' </option> <option>---------------</option>'; $modules = Module::getModulesInstalled(); $moduleIdList = array(); foreach ($modules as $module) { $moduleIdList[] = (int) $module['id_module']; } Module::preloadModuleNameFromId($moduleIdList); foreach ($modules as $module) { Module::getInstanceById((int) $module['id_module']); if ($tmpInstance = Module::getInstanceById((int) $module['id_module'])) { $cm[$tmpInstance->displayName] = $tmpInstance; } } ksort($cm); foreach ($cm as $module) { echo ' <option value="' . (int) $module->id . '" ' . ($this->displayKey == $module->id ? 'selected="selected" ' : '') . '>' . $module->displayName . '</option>'; } echo ' </select><br /><br /> <input type="checkbox" id="hook_position" onclick="autoUrlNoList(\'hook_position\', \'' . $currentIndex . '&token=' . $this->token . '&show_modules=' . (int) Tools::getValue('show_modules') . '&hook_position=\')" ' . (Tools::getValue('hook_position') ? 'checked="checked" ' : '') . ' /> <label class="t" for="hook_position">' . $this->l('Display non-positionable hook') . '</label> </form> <fieldset style="width:250px;float:right"><legend>' . $this->l('Live edit') . '</legend> <p>' . $this->l('By clicking here you will be redirected to the front office of your shop to move and delete modules directly.') . '</p> <br> <a href="' . $link->getPageLink('index.php') . '?live_edit&ad=' . $admin_dir . '&liveToken=' . sha1($admin_dir . _COOKIE_KEY_) . '" target="_blank" class="button">' . $this->l('Run LiveEdit') . '</a> </fieldset> '; // Print hook list echo '<form method="post" action="' . $currentIndex . '&token=' . $this->token . '">'; $irow = 0; $hooks = Hook::getHooks(!(int) Tools::getValue('hook_position')); echo '<div id="unhook_button_position_top"><input class="button floatr" type="submit" name="unhookform" value="' . $this->l('Unhook the selection') . '"/></div>'; Hook::preloadModulesFromHooks(); foreach ($hooks as $hook) { $modules = array(); if (!$this->displayKey) { $modules = Hook::getModulesFromHook($hook['id_hook']); } elseif ($res = Hook::getModuleFromHook($hook['id_hook'], $this->displayKey)) { $modules[0] = $res; } $nbModules = sizeof($modules); echo ' <a name="' . $hook['name'] . '"/> <table cellpadding="0" cellspacing="0" class="table width3 space' . ($nbModules >= 2 ? ' tableDnD' : '') . '" id="' . $hook['id_hook'] . '"> <tr class="nodrag nodrop"><th colspan="4">' . $hook['title'] . ' - <span style="color: red">' . $nbModules . '</span> ' . ($nbModules > 1 ? $this->l('modules') : $this->l('module')); if ($nbModules) { echo '<input type="checkbox" id="Ghook' . $hook['id_hook'] . '" class="floatr" style="margin-right: 2px;" onclick="hookCheckboxes(' . $hook['id_hook'] . ', 0, this)"/>'; } if (!empty($hook['description'])) { echo ' <span style="font-size:0.8em; font-weight: normal">[' . $hook['description'] . ']</span>'; } echo ' <sub style="color:grey;"><i>(' . $this->l('Technical name: ') . $hook['name'] . ')</i></sub></th></tr>'; // Print modules list if ($nbModules) { $instances = array(); foreach ($modules as $module) { $moduleIdList[] = (int) $module['id_module']; } Module::preloadModuleNameFromId($moduleIdList); foreach ($modules as $module) { if ($tmpInstance = Module::getInstanceById((int) $module['id_module'])) { $instances[$tmpInstance->getPosition($hook['id_hook'])] = $tmpInstance; } } ksort($instances); foreach ($instances as $position => $instance) { echo ' <tr id="' . $hook['id_hook'] . '_' . $instance->id . '"' . ($irow++ % 2 ? ' class="alt_row"' : '') . ' style="height: 42px;">'; if (!$this->displayKey) { echo ' <td class="positions" width="40">' . (int) $position . '</td> <td' . ($nbModules >= 2 ? ' class="dragHandle"' : '') . ' id="td_' . $hook['id_hook'] . '_' . $instance->id . '" width="40"> <a' . ($position == 1 ? ' style="display: none;"' : '') . ' href="' . $currentIndex . '&id_module=' . $instance->id . '&id_hook=' . $hook['id_hook'] . '&direction=0&token=' . $this->token . '&changePosition=' . rand() . '#' . $hook['name'] . '"><img src="../img/admin/up.gif" alt="' . $this->l('Up') . '" title="' . $this->l('Up') . '" /></a><br /> <a ' . ($position == sizeof($instances) ? ' style="display: none;"' : '') . 'href="' . $currentIndex . '&id_module=' . $instance->id . '&id_hook=' . $hook['id_hook'] . '&direction=1&token=' . $this->token . '&changePosition=' . rand() . '#' . $hook['name'] . '"><img src="../img/admin/down.gif" alt="' . $this->l('Down') . '" title="' . $this->l('Down') . '" /></a> </td> <td style="padding-left: 10px;"><label class="lab_modules_positions" for="mod' . $hook['id_hook'] . '_' . $instance->id . '"> '; } else { echo '<td style="padding-left: 10px;" colspan="3"><label class="lab_modules_positions" for="' . $hook['id_hook'] . '_' . $instance->id . '">'; } echo ' <img src="../modules/' . $instance->name . '/logo.gif" alt="' . stripslashes($instance->name) . '" /> <strong>' . stripslashes($instance->displayName) . '</strong> ' . ($instance->version ? ' v' . ((int) $instance->version == $instance->version ? sprintf('%.1f', $instance->version) : (double) $instance->version) : '') . '<br />' . $instance->description . ' </label></td> <td width="60"> <a href="' . $currentIndex . '&id_module=' . $instance->id . '&id_hook=' . $hook['id_hook'] . '&editGraft' . ($this->displayKey ? '&show_modules=' . $this->displayKey : '') . '&token=' . $this->token . '"><img src="../img/admin/edit.gif" border="0" alt="' . $this->l('Edit') . '" title="' . $this->l('Edit') . '" /></a> <a href="' . $currentIndex . '&id_module=' . $instance->id . '&id_hook=' . $hook['id_hook'] . '&deleteGraft' . ($this->displayKey ? '&show_modules=' . $this->displayKey : '') . '&token=' . $this->token . '"><img src="../img/admin/delete.gif" border="0" alt="' . $this->l('Delete') . '" title="' . $this->l('Delete') . '" /></a> <input type="checkbox" id="mod' . $hook['id_hook'] . '_' . $instance->id . '" class="hook' . $hook['id_hook'] . '" onclick="hookCheckboxes(' . $hook['id_hook'] . ', 1, this)" name="unhooks[]" value="' . $hook['id_hook'] . '_' . $instance->id . '"/> </td> </tr>'; } } else { echo '<tr><td colspan="4">' . $this->l('No module for this hook') . '</td></tr>'; } echo '</table>'; } echo '<div id="unhook_button_position_bottom"><input class="button floatr" type="submit" name="unhookform" value="' . $this->l('Unhook the selection') . '"/></div></form>'; }
public function displayList() { global $currentIndex; echo ' <script type="text/javascript" src="../js/jquery/jquery.tablednd_0_5.js"></script> <script type="text/javascript"> var token = \'' . $this->token . '\'; var come_from = \'AdminModulesPositions\'; </script> <script type="text/javascript" src="../js/admin-dnd.js"></script> '; echo '<a href="' . $currentIndex . '&addToHook' . ($this->displayKey ? '&show_modules=' . $this->displayKey : '') . '&token=' . $this->token . '"><img src="../img/admin/add.gif" border="0" /> <b>' . $this->l('Transplant a module') . '</b></a><br /><br />'; // Print select list echo ' <form> ' . $this->l('Show') . ' : <select id="show_modules" onChange="autoUrl(\'show_modules\', \'' . $currentIndex . '&token=' . $this->token . '&show_modules=\')"> <option value="all">' . $this->l('All modules') . ' </option> <option>---------------</option>'; $modules = Module::getModulesInstalled(); foreach ($modules as $module) { if ($tmpInstance = Module::getInstanceById(intval($module['id_module']))) { $cm[$tmpInstance->displayName] = $tmpInstance; } } ksort($cm); foreach ($cm as $module) { echo ' <option value="' . intval($module->id) . '" ' . ($this->displayKey == $module->id ? 'selected="selected" ' : '') . '>' . $module->displayName . '</option>'; } echo ' </select><br /><br /> <input type="checkbox" id="hook_position" onclick="autoUrlNoList(\'hook_position\', \'' . $currentIndex . '&token=' . $this->token . '&show_modules=' . intval(Tools::getValue('show_modules')) . '&hook_position=\')" ' . (Tools::getValue('hook_position') ? 'checked="checked" ' : '') . ' /> ' . $this->l('Display non-positionnable hook') . ' </form>'; // Print hook list $irow = 0; $hooks = Hook::getHooks(!intval(Tools::getValue('hook_position'))); foreach ($hooks as $hook) { $modules = array(); if (!$this->displayKey) { $modules = Hook::getModulesFromHook($hook['id_hook']); } elseif ($res = Hook::getModuleFromHook($hook['id_hook'], $this->displayKey)) { $modules[0] = $res; } $nbModules = sizeof($modules); echo ' <a name="' . $hook['name'] . '"/> <table cellpadding="0" cellspacing="0" class="table width3 space' . ($nbModules >= 2 ? ' tableDnD' : '') . '" id="' . $hook['id_hook'] . '"> <tr class="nodrag nodrop"><th colspan="4">' . $hook['title'] . ' - <span style="color: red">' . $nbModules . '</span> ' . ($nbModules > 1 ? $this->l('modules') : $this->l('module')); if (!empty($hook['description'])) { echo ' <span style="font-size:0.8em; font-weight: normal">[' . $hook['description'] . ']</span>'; } echo '</th></tr>'; // Print modules list if ($nbModules) { $instances = array(); foreach ($modules as $module) { if ($tmpInstance = Module::getInstanceById(intval($module['id_module']))) { $instances[$tmpInstance->getPosition($hook['id_hook'])] = $tmpInstance; } } ksort($instances); foreach ($instances as $position => $instance) { echo ' <tr id="' . $hook['id_hook'] . '_' . $instance->id . '"' . ($irow++ % 2 ? ' class="alt_row"' : '') . ' style="height: 42px;">'; if (!$this->displayKey) { echo ' <td class="positions" width="40">' . intval($position) . '</td> <td' . ($nbModules >= 2 ? ' class="dragHandle"' : '') . ' id="td_' . $hook['id_hook'] . '_' . $instance->id . '" width="40"> <a' . ($position == 1 ? ' style="display: none;"' : '') . ' href="' . $currentIndex . '&id_module=' . $instance->id . '&id_hook=' . $hook['id_hook'] . '&direction=0&token=' . $this->token . '&changePosition=' . rand() . '#' . $hook['name'] . '"><img src="../img/admin/up.gif" alt="' . $this->l('Up') . '" title="' . $this->l('Up') . '" /></a><br /> <a ' . ($position == sizeof($instances) ? ' style="display: none;"' : '') . 'href="' . $currentIndex . '&id_module=' . $instance->id . '&id_hook=' . $hook['id_hook'] . '&direction=1&token=' . $this->token . '&changePosition=' . rand() . '#' . $hook['name'] . '"><img src="../img/admin/down.gif" alt="' . $this->l('Down') . '" title="' . $this->l('Down') . '" /></a> </td> <td style="padding-left: 10px;"> '; } else { echo '<td style="padding-left: 10px;" colspan="3">'; } echo ' <img src="../modules/' . $instance->name . '/logo.gif" alt="' . stripslashes($instance->name) . '" /> <strong>' . stripslashes($instance->displayName) . '</strong> ' . ($instance->version ? ' v' . (intval($instance->version) == $instance->version ? sprintf('%.1f', $instance->version) : floatval($instance->version)) : '') . '<br />' . $instance->description . ' </td> <td width="40"> <a href="' . $currentIndex . '&id_module=' . $instance->id . '&id_hook=' . $hook['id_hook'] . '&editGraft' . ($this->displayKey ? '&show_modules=' . $this->displayKey : '') . '&token=' . $this->token . '"><img src="../img/admin/edit.gif" border="0" alt="' . $this->l('Edit') . '" title="' . $this->l('Edit') . '" /></a> <a href="' . $currentIndex . '&id_module=' . $instance->id . '&id_hook=' . $hook['id_hook'] . '&deleteGraft' . ($this->displayKey ? '&show_modules=' . $this->displayKey : '') . '&token=' . $this->token . '"><img src="../img/admin/delete.gif" border="0" alt="' . $this->l('Delete') . '" title="' . $this->l('Delete') . '" /></a> </td> </tr>'; } } else { echo '<tr><td colspan="4">' . $this->l('No module for this hook') . '</td></tr>'; } echo '</table>'; } }
/** * Hooks methods */ public function hookHeader() { if ($this->useMobile()) { $id_hook = (int) Configuration::get('PS_MOBILE_HOOK_HEADER_ID'); if ($id_hook > 0) { $module = Hook::getModuleFromHook($id_hook, $this->id); if (!$module) { $this->registerHook('displayMobileHeader'); } } } if (isset($this->context->cart) && $this->context->cart->id) { $this->context->smarty->assign('id_cart', (int) $this->context->cart->id); } /* Added for PrestaBox */ if (method_exists($this->context->controller, 'addCSS')) { $this->context->controller->addCSS(_MODULE_DIR_ . $this->name . '/css/paypal.css'); } else { Tools::addCSS(_MODULE_DIR_ . $this->name . '/css/paypal.css'); } return '<script type="text/javascript">' . $this->fetchTemplate('paypal.js') . '</script>'; }