本文整理汇总了PHP中Module::getInstanceByName方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::getInstanceByName方法的具体用法?PHP Module::getInstanceByName怎么用?PHP Module::getInstanceByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module::getInstanceByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: migrate_block_info_to_cms_block
function migrate_block_info_to_cms_block()
{
//get ids cms of block information
$id_blockinfos = Db::getInstance()->getValue('SELECT id_module FROM `' . _DB_PREFIX_ . 'module` WHERE name = \'blockinfos\'');
//get ids cms of block information
$ids_cms = Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'block_cms` WHERE `id_block` = ' . (int) $id_blockinfos);
//check if block info is installed and active
if (sizeof($ids_cms)) {
//install module blockcms
if (Module::getInstanceByName('blockcms')->install()) {
//add new block in new cms block
Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'cms_block` (`id_cms_category`, `name`, `location`, `position`) VALUES( 1, \'\', 0, 0)');
$id_block = Db::getInstance()->Insert_ID();
$languages = Language::getLanguages(false);
foreach ($languages as $language) {
Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'cms_block_lang` (`id_cms_block`, `id_lang`, `name`) VALUES (' . (int) $id_block . ', ' . (int) $language['id_lang'] . ', \'Information\')');
}
//save ids cms of block information in new module cms bloc
foreach ($ids_cms as $id_cms) {
Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'cms_block_page` (`id_cms_block`, `id_cms`, `is_category`) VALUES (' . (int) $id_block . ', ' . (int) $id_cms['id_cms'] . ', 0)');
}
} else {
return true;
}
} else {
return true;
}
}
示例2: l
public function l($string, $class = null, $addslashes = false, $htmlentities = true)
{
if (!$this->module instanceof Module) {
$this->module = Module::getInstanceByName('lgconsultas');
}
return $this->module->l($string, 'lgconsultasresponses', $addslashes, $htmlentities);
}
示例3: ps_cli_load_ps_core
public static function ps_cli_load_ps_core()
{
//todo: load path
$configuration = PS_CLI_Configure::getInstance();
if (!defined('_PS_ADMIN_DIR_')) {
// define('_PS_ADMIN_DIR_', getcwd());
define('_PS_ADMIN_DIR_', $configuration->boPath);
}
if (!defined('PS_ADMIN_DIR')) {
define('PS_ADMIN_DIR', _PS_ADMIN_DIR_);
}
/*
Prestashop checks if config/settings.inc.php exists
before loading. If it does not exists, it performs
header('location'). ps-cli must check for this before
loading prestashop core
*/
if (!file_exists(_PS_ADMIN_DIR_ . '/../config/settings.inc.php')) {
echo "Prestashop seems not installed ! (no config/settings.inc.php found)\n";
die;
}
require_once _PS_ADMIN_DIR_ . '/../config/config.inc.php';
require_once _PS_ADMIN_DIR_ . '/../config/autoload.php';
require_once _PS_ADMIN_DIR_ . '/functions.php';
// Load modules
$modules = Module::getModulesOnDisk(true);
foreach ($modules as $mod) {
Module::getInstanceByName($mod);
}
$configuration->psCoreLoaded = true;
}
示例4: getModuleInstance
public function getModuleInstance()
{
if (is_null($this->module_instance)) {
$this->module_instance = Module::getInstanceByName($this->module_name);
}
return $this->module_instance;
}
示例5: initContent
public function initContent()
{
$admin_seur = new AdminSeur(false);
if (!$admin_seur->module_enabled_and_configured) {
$admin_seur->displayModuleConfigurationWarning();
$this->content = $admin_seur->content;
return parent::initContent();
}
$this->display = 'view';
$this->module_instance = Module::getInstanceByName('seur');
Context::getContext()->controller->addJqueryUI('ui.datepicker');
if (Tools::getValue('verDetalle')) {
$response = Expedition::getExpeditions($admin_seur->getExpeditionData());
$this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries($response, true));
} elseif (Tools::getValue('createPickup')) {
$error_response = Pickup::createPickup();
if (!empty($error_response)) {
$this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries(null, null, $error_response));
} else {
$this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries());
}
} elseif (Tools::getValue('submitFilter')) {
$response = Expedition::getExpeditions($admin_seur->getExpeditionData());
$this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries($response, false));
} else {
$this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries());
}
$this->content = $admin_seur->content;
$this->fields_list = $admin_seur->fields_list;
parent::initContent();
}
示例6: displayList
public function displayList()
{
global $cookie, $currentIndex;
$warnings = array();
if (!file_exists(_PS_ROOT_DIR_ . '/.htaccess')) {
$warnings[] = $this->l('In order to enable the PrestaShop Webservice, please generate the .htaccess file via the "Generators" tab (in the "Tools" tab).');
}
if (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) {
$warnings[] = $this->l('To avoid operating problems, please use an Apache server.');
}
if (function_exists('apache_get_modules')) {
$apache_modules = apache_get_modules();
if (!in_array('mod_auth_basic', $apache_modules)) {
$warnings[] = $this->l('Please activate the Apache module \'mod_auth_basic\' to allow authentication of PrestaShop webservice.');
}
if (!in_array('mod_rewrite', $apache_modules)) {
$warnings[] = $this->l('Please activate the Apache module \'mod_rewrite\' to allow using the PrestaShop webservice.');
}
} else {
$warnings[] = $this->l('We could not check if basic authentication and rewrite extensions are activated. Please manually check if they are activated in order to use the PrestaShop webservice.');
}
if (!extension_loaded('SimpleXML')) {
$warnings[] = $this->l('Please activate the PHP extension \'SimpleXML\' to allow testing of PrestaShop webservice.');
}
if (!configuration::get('PS_SSL_ENABLED')) {
$warnings[] = $this->l('If possible, it is preferable to use SSL (https) for webservice calls, as it avoids the security issues of type "man in the middle".');
}
$this->displayWarning($warnings);
foreach ($this->_list as $k => $item) {
if ($item['is_module'] && $item['class_name'] && $item['module_name'] && ($instance = Module::getInstanceByName($item['module_name'])) && !$instance->useNormalPermissionBehaviour()) {
unset($this->_list[$k]);
}
}
parent::displayList();
}
示例7: ModuleHookExec
private function ModuleHookExec($moduleName, $hook_name)
{
$output = '';
$moduleInstance = Module::getInstanceByName($moduleName);
if (Validate::isLoadedObject($moduleInstance) && $moduleInstance->id) {
$altern = 0;
$id_hook = Hook::getIdByName($hook_name);
$retro_hook_name = Hook::getRetroHookName($hook_name);
$disable_non_native_modules = (bool) Configuration::get('PS_DISABLE_NON_NATIVE_MODULE');
if ($disable_non_native_modules && Hook::$native_module && count(Hook::$native_module) && !in_array($moduleInstance->name, self::$native_module)) {
return '';
}
//check disable module
$device = (int) $this->context->getDevice();
if (Db::getInstance()->getValue('
SELECT COUNT(`id_module`) FROM ' . _DB_PREFIX_ . 'module_shop
WHERE enable_device & ' . (int) $device . ' AND id_module=' . (int) $moduleInstance->id . Shop::addSqlRestriction()) == 0) {
return '';
}
// Check permissions
$exceptions = $moduleInstance->getExceptions($id_hook);
$controller = Dispatcher::getInstance()->getController();
$controller_obj = Context::getContext()->controller;
//check if current controller is a module controller
if (isset($controller_obj->module) && Validate::isLoadedObject($controller_obj->module)) {
$controller = 'module-' . $controller_obj->module->name . '-' . $controller;
}
if (in_array($controller, $exceptions)) {
return '';
}
//retro compat of controller names
$matching_name = array('authentication' => 'auth', 'productscomparison' => 'compare');
if (isset($matching_name[$controller]) && in_array($matching_name[$controller], $exceptions)) {
return '';
}
if (Validate::isLoadedObject($this->context->employee) && !$moduleInstance->getPermission('view', $this->context->employee)) {
return '';
}
if (!isset($hook_args['cookie']) or !$hook_args['cookie']) {
$hook_args['cookie'] = $this->context->cookie;
}
if (!isset($hook_args['cart']) or !$hook_args['cart']) {
$hook_args['cart'] = $this->context->cart;
}
$hook_callable = is_callable(array($moduleInstance, 'hook' . $hook_name));
$hook_retro_callable = is_callable(array($moduleInstance, 'hook' . $retro_hook_name));
if (($hook_callable || $hook_retro_callable) && Module::preCall($moduleInstance->name)) {
$hook_args['altern'] = ++$altern;
// Call hook method
if ($hook_callable) {
$display = $moduleInstance->{'hook' . $hook_name}($hook_args);
} elseif ($hook_retro_callable) {
$display = $moduleInstance->{'hook' . $retro_hook_name}($hook_args);
}
$output .= $display;
}
}
return $output;
}
示例8: initContent
/**
* Save carrier settings to database
* This runs when in frontend changet some drop down
*/
public function initContent()
{
$DpdOrderOptions = Module::getInstanceByName('dynamicparceldistribution')->getModel('DpdOrderOptions');
$cartOptions = $this->context->cart;
$result = $DpdOrderOptions->setOrderOptions($cartOptions->id, $cartOptions->id_carrier, $cartOptions->id_address_delivery, serialize(array('delivery_option' => Tools::getValue('value'), 'delivery_label' => Tools::getValue('label'))));
die($result);
//This is need because without that return some HOOK error
}
示例9: initContent
public function initContent()
{
parent::initContent();
$hipay = Module::getInstanceByName('hipay');
if (Validate::isLoadedObject($hipay)) {
$hipay->validation();
}
}
示例10: testUninstall
public function testUninstall()
{
$module = Module::getInstanceByName(Tools::strtolower($this->getClass()));
if (!$module->id) {
$module->install();
}
$this->assertTrue($module->uninstall());
}
示例11: hookModule
function hookModule($moduleName, $hookName)
{
$dbPrefix = _DB_PREFIX_;
$module = Module::getInstanceByName($moduleName);
$moduleId = $module->id;
Db::getInstance()->execute("DELETE FROM {$dbPrefix}hook_module WHERE id_module={$moduleId}");
$module->registerHook($hookName);
echo "- module `{$moduleName}` hooked to `{$hookName}`\n";
}
示例12: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$this->module = Module::getInstanceByName(Tools::getValue('module'));
if (!$this->module->active) {
Tools::redirect('index.php');
}
$this->initContent();
}
示例13: __construct
public function __construct(stdClass $datas)
{
$this->datas = $datas;
$this->context = Context::getContext();
$this->module = Module::getInstanceByName('powatag');
$this->initLang();
$id_group = Group::getCurrent()->id;
$this->display_taxes = Group::getPriceDisplayMethod($id_group) == PS_TAX_EXC ? false : true;
}
示例14: update_module_followup
function update_module_followup()
{
Configuration::loadConfiguration();
$followup = Module::getInstanceByName('followup');
if (!$followup->id) {
return;
}
Db::getInstance()->Execute('ALTER TABLE `' . _DB_PREFIX_ . 'log_email` ADD INDEX `date_add`(`date_add`), ADD INDEX `id_cart`(`id_cart`);');
}
示例15: __construct
public function __construct()
{
$this->context = Context::getContext();
$this->client_id = Configuration::get('YA_METRIKA_ID_APPLICATION');
$this->number = Configuration::get('YA_METRIKA_NUMBER');
$this->client_secret = Configuration::get('YA_METRIKA_PASSWORD_APPLICATION');
$this->state = 'Test_1';
$this->token = Configuration::get('YA_METRIKA_TOKEN') ? Configuration::get('YA_METRIKA_TOKEN') : '';
$this->module = Module::getInstanceByName('yamodule');
}