當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Hook::getModulesFromHook方法代碼示例

本文整理匯總了PHP中Hook::getModulesFromHook方法的典型用法代碼示例。如果您正苦於以下問題:PHP Hook::getModulesFromHook方法的具體用法?PHP Hook::getModulesFromHook怎麽用?PHP Hook::getModulesFromHook使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Hook的用法示例。


在下文中一共展示了Hook::getModulesFromHook方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: renderForm

    public function renderForm($data)
    {
        $helper = $this->getFormHelper();
        $id_shop = Context::getContext()->shop->id;
        if (isset($data['params']['hookmodule'])) {
            $hid = Hook::getIdByName($data['params']['hookmodule']);
            if ($hid) {
                $hms = Hook::getModulesFromHook($hid);
                foreach ($hms as $hm) {
                    if ($data['params']['loadmodule'] == $hm['name']) {
                        $id_module = $hm['id_module'];
                        $module = Module::getInstanceById($id_module);
                        if (Validate::isLoadedObject($module)) {
                            !$module->unregisterHook((int) $hid, array($id_shop));
                        }
                    }
                }
            }
        }
        $modules = Module::getModulesInstalled(0);
        $output = array();
        $hooks = array('displayHome', 'displayLeftColumn', 'displayRightColumn', 'displayTop', 'displayHeaderRight', 'displaySlideshow', 'topNavigation', 'displayMainmenu', 'displayPromoteTop', 'displayRightColumn', 'displayLeftColumn', 'displayHome', 'displayFooter', 'displayBottom', 'displayContentBottom', 'displayFootNav', 'displayFooterTop', 'displayMapLocal', 'displayFooterBottom');
        foreach ($hooks as $hook) {
            $output[] = array('name' => $hook, 'id' => $hook);
        }
        $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.')), 'input' => array(array('type' => 'select', 'label' => $this->l('Select A Module'), 'name' => 'loadmodule', 'options' => array('query' => $modules, 'id' => 'name', 'name' => 'name'), 'default' => '1', 'desc' => $this->l('Select A Module is used as widget. the hook of this module was unhooked.')), array('type' => 'select', 'label' => $this->l('Select A Hook'), 'name' => 'hookmodule', 'options' => array('query' => $output, 'id' => 'name', 'name' => 'name'), 'default' => '1', 'desc' => $this->l('Select A hook is used to render module\'s content. the hook of this module was unhooked. 
						You could not rollback it\'s position. So you need asign it in position management of prestashop.'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
        $default_lang = (int) Configuration::get('PS_LANG_DEFAULT');
        $a = $this->getConfigFieldsValues($data);
        $helper->tpl_vars = array('fields_value' => $a, 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang);
        return $helper->generateForm($this->fields_form);
    }
開發者ID:vuduykhuong1412,項目名稱:GitHub,代碼行數:32,代碼來源:module.php

示例2: execHookTaxManagerFactory

 /**
  * Check for a tax manager able to handle this type of address in the module list
  *
  * @param Address $address
  * @param string $type
  *
  * @return TaxManager
  */
 public static function execHookTaxManagerFactory(Address $address, $type)
 {
     $modules_infos = Hook::getModulesFromHook(Hook::getIdByName('taxManager'));
     $tax_manager = false;
     foreach ($modules_infos as $module_infos) {
         $module_instance = Module::getInstanceByName($module_infos['name']);
         if (is_callable(array($module_instance, 'hookTaxManager'))) {
             $tax_manager = $module_instance->hookTaxManager(array('address' => $address, 'params' => $type));
         }
         if ($tax_manager) {
             break;
         }
     }
     return $tax_manager;
 }
開發者ID:IngenioContenidoDigital,項目名稱:americana,代碼行數:23,代碼來源:TaxManagerFactory.php

示例3: execHookStockManagerFactory

 /**
  *  Looks for a StockManager in the modules list.
  *
  *  @return StockManagerInterface
  */
 public static function execHookStockManagerFactory()
 {
     $modules_infos = Hook::getModulesFromHook(Hook::getIdByName('stockManager'));
     $stock_manager = false;
     foreach ($modules_infos as $module_infos) {
         $module_instance = Module::getInstanceByName($module_infos['name']);
         if (is_callable(array($module_instance, 'hookStockManager'))) {
             $stock_manager = $module_instance->hookStockManager();
         }
         if ($stock_manager) {
             break;
         }
     }
     return $stock_manager;
 }
開發者ID:IngenioContenidoDigital,項目名稱:americana,代碼行數:20,代碼來源:StockManagerFactory.php

示例4: moveRightColumn

 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);
 }
開發者ID:Evil1991,項目名稱:PrestaShop-1.4,代碼行數:18,代碼來源:paypal_tools.php

示例5: upgrade_module_1_4

function upgrade_module_1_4($object, $install = false)
{
    // First uninstall old override
    try {
        $object->uninstallOldOverrides();
    } catch (Exception $e) {
        $object->add_error(sprintf(Tools::displayError('Unable to uninstall old override: %s'), $e->getMessage()));
        //$this->uninstallOverrides(); remove this line because if module a install an override, then module b install same override, this line will remove override of module a (if you find a bug related to this line please don't forget what i say before)
        return false;
    }
    // Install overrides
    try {
        $object->installOverrides();
    } catch (Exception $e) {
        $object->add_error(sprintf(Tools::displayError('Unable to install override: %s'), $e->getMessage()));
        //$this->uninstallOverrides(); remove this line because if module a install an override, then module b install same override, this line will remove override of module a (if you find a bug related to this line please don't forget what i say before)
        return false;
    }
    if (!Hook::getIdByName('actionBeforeAddOrder')) {
        $hook = new Hook();
        $hook->name = 'actionBeforeAddOrder';
        $hook->title = 'New orders before order is added';
        $hook->description = 'Custom hook for PaymentModule ValidateOrder function';
        $hook->position = true;
        $hook->live_edit = false;
        $hook->add();
    }
    $id_new_hook = Hook::getIdByName('actionBeforeAddOrder');
    $id_old_hook = Hook::getIdByName('actionValidateOrder');
    $mod_new_hook = Hook::getModulesFromHook($id_new_hook, $object->id);
    $mod_old_hook = Hook::getModulesFromHook($id_old_hook, $object->id);
    if (empty($mod_new_hook)) {
        $object->registerHook('actionBeforeAddOrder');
    }
    if (!empty($mod_old_hook)) {
        $object->unregisterHook('actionValidateOrder');
    }
    return true;
}
開發者ID:,項目名稱:,代碼行數:39,代碼來源:

示例6: upgrade_module_1_5

function upgrade_module_1_5($object, $install = false)
{
    // Install overrides
    try {
        $object->installOverrides();
    } catch (Exception $e) {
        Tools::displayError(sprintf(Tools::displayError('Unable to install override: %s'), $e->getMessage()));
        //$this->uninstallOverrides(); remove this line because if module a install an override, then module b install same override, this line will remove override of module a (if you find a bug related to this line please don't forget what i say before)
        return false;
    }
    $classindex = realpath(dirname(__FILE__) . '/../..') . '/cache/class_index.php';
    unset($classindex);
    if (version_compare(_PS_VERSION_, '1.6', '>=')) {
        PrestashopAutoload::getInstance()->generateIndex();
    } else {
        Autoload::getInstance()->generateIndex();
    }
    if (!Hook::getIdByName('actionBeforeAddOrder')) {
        $hook = new Hook();
        $hook->name = 'actionBeforeAddOrder';
        $hook->title = 'Execute actions before order is added to database';
        $hook->description = 'Custom hook for Order Add function';
        $hook->position = true;
        $hook->live_edit = false;
        $hook->add();
    }
    if (!Hook::getIdByName('actionBeforeAddOrderInvoice')) {
        $hook2 = new Hook();
        $hook2->name = 'actionBeforeAddOrderInvoice';
        $hook2->title = 'Execute actions before invoice is added to database';
        $hook2->description = 'Custom hook for Order setLastInvoiceNumber function';
        $hook2->position = true;
        $hook2->live_edit = false;
        $hook2->add();
    }
    if (!Hook::getIdByName('actionBeforeAddDeliveryNumber')) {
        $hook3 = new Hook();
        $hook3->name = 'actionBeforeAddDeliveryNumber';
        $hook3->title = 'Execute actions before delivery number is added to database';
        $hook3->description = 'Custom hook for Order setDeliveryNumber function';
        $hook3->position = true;
        $hook3->live_edit = false;
        $hook3->add();
    }
    $id_new_hook = Hook::getIdByName('actionBeforeAddOrder');
    $id_new_hook2 = Hook::getIdByName('actionBeforeAddOrderInvoice');
    $id_new_hook3 = Hook::getIdByName('actionBeforeAddDeliveryNumber');
    $id_old_hook = Hook::getIdByName('actionValidateOrder');
    $mod_new_hook = Hook::getModulesFromHook($id_new_hook, $object->id);
    $mod_new_hook2 = Hook::getModulesFromHook($id_new_hook2, $object->id);
    $mod_new_hook3 = Hook::getModulesFromHook($id_new_hook3, $object->id);
    $mod_old_hook = Hook::getModulesFromHook($id_old_hook, $object->id);
    if (empty($mod_new_hook)) {
        $object->registerHook('actionBeforeAddOrder');
    }
    if (empty($mod_new_hook2)) {
        $object->registerHook('actionBeforeAddOrderInvoice');
    }
    if (empty($mod_new_hook3)) {
        $object->registerHook('actionBeforeAddDeliveryNumber');
    }
    if (!empty($mod_old_hook)) {
        $object->unregisterHook('actionValidateOrder');
    }
    return true;
}
開發者ID:,項目名稱:,代碼行數:66,代碼來源:

示例7: initMain

 public function initMain()
 {
     // Init toolbar
     $this->initToolbarTitle();
     $admin_dir = basename(_PS_ADMIN_DIR_);
     $modules = Module::getModulesInstalled();
     $assoc_modules_id = array();
     foreach ($modules as $module) {
         if ($tmp_instance = Module::getInstanceById((int) $module['id_module'])) {
             // We want to be able to sort modules by display name
             $module_instances[$tmp_instance->displayName] = $tmp_instance;
             // But we also want to associate hooks to modules using the modules IDs
             $assoc_modules_id[(int) $module['id_module']] = $tmp_instance->displayName;
         }
     }
     ksort($module_instances);
     $hooks = Hook::getHooks(!(int) Tools::getValue('hook_position'));
     foreach ($hooks as $key => $hook) {
         // Get all modules for this hook or only the filtered module
         $hooks[$key]['modules'] = Hook::getModulesFromHook($hook['id_hook'], $this->display_key);
         $hooks[$key]['module_count'] = count($hooks[$key]['modules']);
         // If modules were found, link to the previously created Module instances
         if (is_array($hooks[$key]['modules']) && !empty($hooks[$key]['modules'])) {
             foreach ($hooks[$key]['modules'] as $module_key => $module) {
                 if (isset($assoc_modules_id[$module['id_module']])) {
                     $hooks[$key]['modules'][$module_key]['instance'] = $module_instances[$assoc_modules_id[$module['id_module']]];
                 }
             }
         }
     }
     $this->addJqueryPlugin('tablednd');
     $this->toolbar_btn['save'] = array('href' => self::$currentIndex . '&addToHook' . ($this->display_key ? '&show_modules=' . $this->display_key : '') . '&token=' . $this->token, 'desc' => $this->l('Transplant a module'));
     $live_edit_params = array('live_edit' => true, 'ad' => $admin_dir, 'liveToken' => $this->token, 'id_employee' => (int) $this->context->employee->id, 'id_shop' => (int) $this->context->shop->id);
     $this->context->smarty->assign(array('show_toolbar' => true, 'toolbar_btn' => $this->toolbar_btn, 'title' => $this->toolbar_title, 'toolbar_scroll' => 'false', 'token' => $this->token, 'url_show_modules' => self::$currentIndex . '&token=' . $this->token . '&show_modules=', 'modules' => $module_instances, 'url_show_invisible' => self::$currentIndex . '&token=' . $this->token . '&show_modules=' . (int) Tools::getValue('show_modules') . '&hook_position=', 'hook_position' => Tools::getValue('hook_position'), 'live_edit' => Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP, 'url_live_edit' => $this->getLiveEditUrl($live_edit_params), 'display_key' => $this->display_key, 'hooks' => $hooks, 'url_submit' => self::$currentIndex . '&token=' . $this->token, 'can_move' => Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP ? false : true));
     return $this->createTemplate('list_modules.tpl')->fetch();
 }
開發者ID:rongandat,項目名稱:vatfairfoot,代碼行數:36,代碼來源:AdminModulesPositionsController.php

示例8: hookHeader

    /**
     * Hooks methods
     */
    public function hookHeader()
    {
        if ($this->useMobile()) {
            $id_hook = (int) Configuration::get('PS_MOBILE_HOOK_HEADER_ID');
            if ($id_hook > 0) {
                $module = Hook::getModulesFromHook($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 . '/views/css/paypal.css');
        } else {
            Tools::addCSS(_MODULE_DIR_ . $this->name . '/views/css/paypal.css');
        }
        $smarty = $this->context->smarty;
        $smarty->assign(array('ssl_enabled' => Configuration::get('PS_SSL_ENABLED'), 'PAYPAL_SANDBOX' => Configuration::get('PAYPAL_SANDBOX'), 'PayPal_in_context_checkout' => Configuration::get('PAYPAL_IN_CONTEXT_CHECKOUT'), 'PayPal_in_context_checkout_merchant_id' => Configuration::get('PAYPAL_IN_CONTEXT_CHECKOUT_M_ID')));
        $process = '<script type="text/javascript">' . $this->fetchTemplate('views/js/paypal.js') . '</script>';
        if (Configuration::get('PAYPAL_IN_CONTEXT_CHECKOUT')) {
            $process .= '<script async src="//www.paypalobjects.com/api/checkout.js"></script>';
        }
        if ((method_exists($smarty, 'getTemplateVars') && ($smarty->getTemplateVars('page_name') == 'authentication' || $smarty->getTemplateVars('page_name') == 'order-opc') || isset($smarty->_tpl_vars) && ($smarty->_tpl_vars['page_name'] == 'authentication' || $smarty->_tpl_vars['page_name'] == 'order-opc')) && (int) Configuration::get('PAYPAL_LOGIN') == 1) {
            $this->context->smarty->assign(array('paypal_locale' => $this->getLocale(), 'PAYPAL_LOGIN_CLIENT_ID' => Configuration::get('PAYPAL_LOGIN_CLIENT_ID'), 'PAYPAL_LOGIN_TPL' => Configuration::get('PAYPAL_LOGIN_TPL'), 'PAYPAL_RETURN_LINK' => PayPalLogin::getReturnLink()));
            $process .= '
				<script src="https://www.paypalobjects.com/js/external/api.js"></script>
				<script>' . $this->fetchTemplate('views/js/paypal_login.js') . '</script>';
        }
        return $process;
    }
開發者ID:ramsam5,項目名稱:paypal,代碼行數:37,代碼來源:paypal.php

示例9: renderList

    /**
     * render list of modules following positions in the layout editor.
     */
    public function renderList()
    {
        $filePath = _PS_ALL_THEMES_DIR_ . $this->theme_name . '';
        $showed = true;
        $xml = simplexml_load_file($filePath . '/config.xml');
        if (isset($xml->theme_key)) {
            $this->themeKey = trim((string) $xml->theme_key);
        }
        if ($this->themeKey) {
            $this->initToolbarTitle();
            $this->initToolbar();
            $hookspos = $this->hookspos;
            foreach ($hookspos as $hook) {
                if (Hook::getIdByName($hook)) {
                } else {
                    $new_hook = new Hook();
                    $new_hook->name = pSQL($hook);
                    $new_hook->title = pSQL($hook);
                    $new_hook->add();
                    $id_hook = $new_hook->id;
                }
            }
            Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('
				UPDATE `' . _DB_PREFIX_ . 'hook` SET position=1, live_edit=1
						WHERE name in ("' . implode('","', $hookspos) . '")  ');
            $modules = Module::getModulesInstalled(0);
            $assoc_modules_id = array();
            $assoc_modules_id = $module_instances = array();
            foreach ($modules as $module) {
                if ($tmp_instance = Module::getInstanceById((int) $module['id_module'])) {
                    // We want to be able to sort modules by display name
                    $module_instances[$tmp_instance->displayName] = $tmp_instance;
                    // But we also want to associate hooks to modules using the modules IDs
                    $assoc_modules_id[(int) $module['id_module']] = $tmp_instance->displayName;
                }
            }
            $hooks = Hook::getHooks(!(int) Tools::getValue('hook_position'));
            $hookModules = array();
            $hookedModules = array();
            foreach ($hooks as $key => $hook) {
                // $key = $hook['name'];
                $k = $hook['name'];
                $k = Tools::strtolower(Tools::substr($k, 0, 1)) . Tools::substr($k, 1);
                if (in_array($k, $hookspos)) {
                    // Get all modules for this hook or only the filtered module
                    $hookModules[$k]['modules'] = Hook::getModulesFromHook($hook['id_hook'], $this->display_key);
                    $hookModules[$k]['module_count'] = count($hookModules[$k]['modules']);
                    if (is_array($hookModules[$k]['modules']) && !empty($hookModules[$k]['modules'])) {
                        foreach ($hookModules[$k]['modules'] as $module_key => $module) {
                            if (isset($assoc_modules_id[$module['id_module']])) {
                                $hookedModules[] = $module['id_module'];
                                $hookModules[$k]['modules'][$module_key]['instance'] = $module_instances[$assoc_modules_id[$module['id_module']]];
                            }
                        }
                    }
                }
            }
            //		  	echo '<pre>'.print_r($hookedModules,1); die;
            $instances = array();
            foreach ($modules as $module) {
                if ($tmp_instance = Module::getInstanceById($module['id_module'])) {
                    if (!in_array($module['id_module'], $hookedModules)) {
                        foreach ($hookspos as $hk) {
                            $retro_hook_name = Hook::getRetroHookName($hk);
                            $hook_callable = is_callable(array($tmp_instance, 'hook' . $hk));
                            $hook_retro_callable = is_callable(array($tmp_instance, 'hook' . $retro_hook_name));
                            if ($hook_retro_callable || $hook_callable) {
                                $instances[$tmp_instance->displayName] = $tmp_instance;
                                break;
                            }
                        }
                        //	echo '<pre>'.print_r( $instances, 1 ); die;
                    }
                }
            }
            ksort($instances);
            $modules = $instances;
            $tpl = $this->createTemplate('panel.tpl');
            $this->context->controller->addCss(__PS_BASE_URI__ . str_replace("//", "/", 'modules/leotempcp') . '/assets/admin/style.css', 'all');
            $this->context->controller->addJs(__PS_BASE_URI__ . str_replace("//", "/", 'modules/leotempcp') . '/assets/admin/jquery-ui-1.10.3.custom.min.js', 'all');
            $tpl->assign(array('showed' => $showed, 'toolbar' => $this->context->smarty->fetch('toolbar.tpl'), 'modules' => $modules, 'hookspos' => $hookspos, 'URI' => __PS_BASE_URI__ . 'modules/', 'hookModules' => $hookModules, 'noModuleConfig' => $this->l('No Configuration For This Module'), 'currentURL' => 'index.php?tab=AdminLeotempcpPanel&token=' . Tools::getAdminTokenLite('AdminLeotempcpPanel') . '', 'moduleEditURL' => 'index.php?controller=adminmodules&token=' . Tools::getAdminTokenLite('AdminModules') . '&tab_module=Home'));
            return $tpl->fetch();
        } else {
            $tpl = $this->createTemplate('error.tpl');
            $tpl->assign(array('showed' => false, 'themeURL' => 'index.php?controller=AdminThemes&token=' . Tools::getAdminTokenLite('AdminThemes')));
            return $tpl->fetch();
        }
    }
開發者ID:ekachandrasetiawan,項目名稱:BeltcareCom,代碼行數:91,代碼來源:AdminLeotempcpPanel.php

示例10: displayList

    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') . '&nbsp;</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" ' : '') . ' />&nbsp;' . $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 '&nbsp;<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>';
        }
    }
開發者ID:sealence,項目名稱:local,代碼行數:93,代碼來源:AdminModulesPositions.php

示例11: registerModulesBackwardCompatHook

 public function registerModulesBackwardCompatHook()
 {
     $return = true;
     $module_to_check = array('bankwire', 'cheque', 'paypal', 'adyen', 'hipay', 'cashondelivery', 'sofortbanking', 'pigmbhpaymill', 'ogone', 'moneybookers', 'syspay');
     $display_payment_eu_hook_id = (int) Hook::getIdByName('displayPaymentEu');
     $already_hooked_modules_ids = array_keys(Hook::getModulesFromHook($display_payment_eu_hook_id));
     foreach ($module_to_check as $module_name) {
         if (($module = Module::getInstanceByName($module_name)) !== false && Module::isInstalled($module_name) && $module->active && !in_array($module->id, $already_hooked_modules_ids) && !$module->isRegisteredInHook('displayPaymentEu')) {
             $return &= $module->registerHook('displayPaymentEu');
         }
     }
     return $return;
 }
開發者ID:Luca01,項目名稱:advancedeucompliance,代碼行數:13,代碼來源:advancedeucompliance.php

示例12: displayList

    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') . '&nbsp;</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" ' : '') . ' />&nbsp;<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 '&nbsp;<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 . '">
						';
//.........這裏部分代碼省略.........
開發者ID:nicolasjeol,項目名稱:hec-ecommerce,代碼行數:101,代碼來源:AdminModulesPositions.php

示例13: hookHeader

 /**
  * Hooks methods
  */
 public function hookHeader()
 {
     if ($this->useMobile()) {
         $id_hook = (int) Configuration::get('PS_MOBILE_HOOK_HEADER_ID');
         if ($id_hook > 0) {
             $module = Hook::getModulesFromHook($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('js/paypal.js') . '</script>';
 }
開發者ID:ventsiwad,項目名稱:presta_addons,代碼行數:25,代碼來源:paypal.php

示例14:

    $hook3->description = 'Custom hook for Order setDeliveryNumber function';
    $hook3->position = true;
    $hook3->live_edit = false;
    if (!$hook3->add()) {
        $errors[] = 'Unable to add hook actionBeforeAddDeliveryNumber';
        $return &= false;
    }
}
$id_new_hook = Hook::getIdByName('actionBeforeAddOrder');
$id_new_hook2 = Hook::getIdByName('actionBeforeAddOrderInvoice');
$id_new_hook3 = Hook::getIdByName('actionBeforeAddDeliveryNumber');
$id_old_hook = Hook::getIdByName('actionValidateOrder');
$mod_new_hook = Hook::getModulesFromHook($id_new_hook, $object->id);
$mod_new_hook2 = Hook::getModulesFromHook($id_new_hook2, $object->id);
$mod_new_hook3 = Hook::getModulesFromHook($id_new_hook3, $object->id);
$mod_old_hook = Hook::getModulesFromHook($id_old_hook, $object->id);
if (empty($mod_new_hook)) {
    $return &= $object->registerHook('actionBeforeAddOrder');
}
if (empty($mod_new_hook2)) {
    $return &= $object->registerHook('actionBeforeAddOrderInvoice');
}
if (empty($mod_new_hook3)) {
    $return &= $object->registerHook('actionBeforeAddDeliveryNumber');
}
if (!empty($mod_old_hook)) {
    $return &= $object->unregisterHook('actionValidateOrder');
}
if (!$return) {
    print_r($errors);
    die;
開發者ID:TheTypoMaster,項目名稱:neotienda,代碼行數:31,代碼來源:setmodhook.php


注:本文中的Hook::getModulesFromHook方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。