本文整理汇总了PHP中Module::getModulesOnDisk方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::getModulesOnDisk方法的具体用法?PHP Module::getModulesOnDisk怎么用?PHP Module::getModulesOnDisk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module::getModulesOnDisk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOptionFields
protected function getOptionFields()
{
$forms = array();
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$carriers = Carrier::getCarriers($this->context->language->id, true);
$modules = Module::getModulesOnDisk(true);
$forms = array('payment' => array('title' => $this->l('Average bank fees per payment method'), 'id' => 'payment'), 'carriers' => array('title' => $this->l('Average shipping fees per shipping method'), 'id' => 'carriers'), 'other' => array('title' => $this->l('Other settings'), 'id' => 'other'), 'expenses' => array('title' => $this->l('Other expenses (monthly)'), 'id' => 'expenses'));
foreach ($forms as &$form) {
$form['icon'] = 'tab-preferences';
$form['fields'] = array();
$form['submit'] = array('title' => $this->l('Save'));
}
foreach ($modules as $module) {
if ($module->tab == 'payments_gateways' && $module->id) {
$forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed in %1$s with %2$s.'), $currency->iso_code, $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
$forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed in %1$s with %2$s. It will be applied on the total paid with taxes.'), $currency->iso_code, $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
if (Currency::isMultiCurrencyActivated()) {
$forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed with a foreign currency with %s.'), $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
$forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed with a foreign currency with %s. It will be applied on the total paid with taxes.'), $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
}
}
}
foreach ($carriers as $carrier) {
$forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('%% of what you charged the customer for domestic delivery with %s.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
$forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP_OVERSEAS'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('%% of what you charged the customer for overseas delivery with %s.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
}
$forms['other']['fields']['CONF_AVERAGE_PRODUCT_MARGIN'] = array('title' => $this->l('Average gross margin (Selling price / Buying price)'), 'desc' => $this->l('Only used if you do not specify your buying price for each product.'), 'validation' => 'isPercentage', 'cast' => 'intval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
$forms['other']['fields']['CONF_ORDER_FIXED'] = array('title' => $this->l('Other fee per order'), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
$expense_types = array('hosting' => $this->l('Hosting'), 'tools' => $this->l('Tools (E-mailing, etc.)'), 'acounting' => $this->l('Accounting'), 'development' => $this->l('Development'), 'marketing' => $this->l('Marketing (Adwords, etc.)'), 'others' => $this->l('Others'));
foreach ($expense_types as $expense_type => $expense_label) {
$forms['expenses']['fields']['CONF_MONTHLY_' . strtoupper($expense_type)] = array('title' => $expense_label, 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
}
return $forms;
}
示例2: __construct
public function __construct()
{
/* Get all modules then select only payment ones*/
$modules = Module::getModulesOnDisk();
foreach ($modules as $module) {
if ($module->tab == 'Payment') {
if ($module->id) {
$module->country = array();
$countries = DB::getInstance()->ExecuteS('SELECT id_country FROM ' . _DB_PREFIX_ . 'module_country WHERE id_module = ' . intval($module->id));
foreach ($countries as $country) {
$module->country[] = $country['id_country'];
}
$module->currency = array();
$currencies = DB::getInstance()->ExecuteS('SELECT id_currency FROM ' . _DB_PREFIX_ . 'module_currency WHERE id_module = ' . intval($module->id));
foreach ($currencies as $currency) {
$module->currency[] = $currency['id_currency'];
}
$module->group = array();
$groups = DB::getInstance()->ExecuteS('SELECT id_group FROM ' . _DB_PREFIX_ . 'module_group WHERE id_module = ' . intval($module->id));
foreach ($groups as $group) {
$module->group[] = $group['id_group'];
}
} else {
$module->country = NULL;
$module->currency = NULL;
$module->group = NULL;
}
$this->paymentModules[] = $module;
}
}
parent::__construct();
}
示例3: getOptionFields
protected function getOptionFields()
{
$forms = array();
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$carriers = Carrier::getCarriers($this->context->language->id, true);
$modules = Module::getModulesOnDisk(true);
$forms = array('payment' => array('title' => $this->l('Average bank fees per payment method'), 'id' => 'payment'), 'carriers' => array('title' => $this->l('Average shipping fees per shipping method'), 'id' => 'carriers'), 'other' => array('title' => $this->l('Other settings'), 'id' => 'other'));
foreach ($forms as &$form) {
$form['icon'] = 'tab-preferences';
$form['fields'] = array();
$form['submit'] = array('title' => $this->l('Save'));
}
foreach ($modules as $module) {
if (isset($module->tab) && $module->tab == 'payments_gateways' && $module->id) {
$moduleClass = Module::getInstanceByName($module->name);
if (!$moduleClass->isEnabledForShopContext()) {
continue;
}
$forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed in %1$s with %2$s.'), $currency->iso_code, $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
$forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed in %1$s with %2$s. It will be applied on the total paid with taxes.'), $currency->iso_code, $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
if (Currency::isMultiCurrencyActivated()) {
$forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed with a foreign currency with %s.'), $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
$forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed with a foreign currency with %s. It will be applied on the total paid with taxes.'), $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
}
}
}
foreach ($carriers as $carrier) {
$forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('For the carrier named %s, indicate the domestic delivery costs in percentage of the price charged to customers.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
$forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP_OVERSEAS'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('For the carrier named %s, indicate the overseas delivery costs in percentage of the price charged to customers.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
}
$forms['carriers']['description'] = $this->l('Method: Indicate the percentage of your carrier margin. For example, if you charge $10 of shipping fees to your customer for each shipment, but you really pay $4 to this carrier, then you should indicate "40" in the percentage field.');
$forms['other']['fields']['CONF_AVERAGE_PRODUCT_MARGIN'] = array('title' => $this->l('Average gross margin'), 'desc' => $this->l('You should calculate this percentage as follows: ((total sales revenue) - (cost of goods sold)) / (total sales revenue) * 100. This value is only used to calculate the Dashboard approximate gross margin, if you do not specify the wholesale price for each product.'), 'validation' => 'isPercentage', 'cast' => 'intval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
$forms['other']['fields']['CONF_ORDER_FIXED'] = array('title' => $this->l('Other fees per order'), 'desc' => $this->l('You should calculate this value by making the sum of all of your additional costs per order.'), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
return $forms;
}
示例4: 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;
}
示例5: getImportModulesOnDisk
public static function getImportModulesOnDisk()
{
$modules = Module::getModulesOnDisk(true);
foreach ($modules as $key => $module) {
if (get_parent_class($module) != 'ImportModule') {
unset($modules[$key]);
}
}
return $modules;
}
示例6: ajaxProcessGetModuleQuickView
public function ajaxProcessGetModuleQuickView()
{
$modules = Module::getModulesOnDisk();
foreach ($modules as $module) {
if ($module->name == Tools::getValue('module')) {
break;
}
}
$this->context->smarty->assign(array('displayName' => $module->displayName, 'image' => $module->image, 'nb_rates' => (int) $module->nb_rates[0], 'avg_rate' => (int) $module->avg_rate[0], 'badges' => $module->badges, 'compatibility' => $module->compatibility, 'description_full' => $module->description_full, 'additional_description' => $module->additional_description, 'url' => $module->url));
$this->smartyOutputContent('controllers/modules/quickview.tpl');
die(1);
}
示例7: __construct
public function __construct()
{
$this->bootstrap = true;
parent::__construct();
$shop_id = Context::getContext()->shop->id;
/* Get all modules then select only payment ones */
$modules = Module::getModulesOnDisk(true);
foreach ($modules as $module) {
if ($module->tab == 'payments_gateways') {
if ($module->id) {
if (!get_class($module) == 'SimpleXMLElement') {
$module->country = array();
}
$countries = DB::getInstance()->executeS('
SELECT id_country
FROM ' . _DB_PREFIX_ . 'module_country
WHERE id_module = ' . (int) $module->id . ' AND `id_shop`=' . (int) $shop_id);
foreach ($countries as $country) {
$module->country[] = $country['id_country'];
}
if (!get_class($module) == 'SimpleXMLElement') {
$module->currency = array();
}
$currencies = DB::getInstance()->executeS('
SELECT id_currency
FROM ' . _DB_PREFIX_ . 'module_currency
WHERE id_module = ' . (int) $module->id . ' AND `id_shop`=' . (int) $shop_id);
foreach ($currencies as $currency) {
$module->currency[] = $currency['id_currency'];
}
if (!get_class($module) == 'SimpleXMLElement') {
$module->group = array();
}
$groups = DB::getInstance()->executeS('
SELECT id_group
FROM ' . _DB_PREFIX_ . 'module_group
WHERE id_module = ' . (int) $module->id . ' AND `id_shop`=' . (int) $shop_id);
foreach ($groups as $group) {
$module->group[] = $group['id_group'];
}
} else {
$module->country = null;
$module->currency = null;
$module->group = null;
}
$this->payment_modules[] = $module;
}
}
}
示例8: ajaxProcessGetModuleQuickView
public function ajaxProcessGetModuleQuickView()
{
$modules = Module::getModulesOnDisk();
foreach ($modules as $module) {
if ($module->name == Tools::getValue('module')) {
break;
}
}
$url = $module->url;
if (isset($module->type) && ($module->type == 'addonsPartner' || $module->type == 'addonsNative')) {
$url = $this->context->link->getAdminLink('AdminModules') . '&install=' . urlencode($module->name) . '&tab_module=' . $module->tab . '&module_name=' . $module->name . '&anchor=' . ucfirst($module->name);
}
$this->context->smarty->assign(array('displayName' => $module->displayName, 'image' => $module->image, 'nb_rates' => (int) $module->nb_rates[0], 'avg_rate' => (int) $module->avg_rate[0], 'badges' => $module->badges, 'compatibility' => $module->compatibility, 'description_full' => $module->description_full, 'additional_description' => $module->additional_description, 'is_addons_partner' => isset($module->type) && ($module->type == 'addonsPartner' || $module->type == 'addonsNative'), 'url' => $url));
$this->smartyOutputContent('controllers/modules/quickview.tpl');
die(1);
}
示例9: searchModule
public function searchModule()
{
$this->_list['modules'] = array();
$all_modules = Module::getModulesOnDisk(true, true, Context::getContext()->employee->id);
foreach ($all_modules as $module) {
if (stripos($module->name, $this->query) !== false || stripos($module->displayName, $this->query) !== false || stripos($module->description, $this->query) !== false) {
$module->linkto = 'index.php?tab=AdminModules&tab_module=' . $module->tab . '&module_name=' . $module->name . '&anchor=' . ucfirst($module->name) . '&token=' . Tools::getAdminTokenLite('AdminModules');
$this->_list['modules'][] = $module;
}
}
if (!is_numeric(trim($this->query)) && !Validate::isEmail($this->query)) {
$iso_lang = Tools::strtolower(Context::getContext()->language->iso_code);
$iso_country = Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')));
if (($json_content = Tools::file_get_contents('https://api.addons.prestashop.com/' . _PS_VERSION_ . '/search/' . urlencode($this->query) . '/' . $iso_country . '/' . $iso_lang . '/')) != false) {
$this->_list['addons'] = Tools::jsonDecode($json_content, true);
}
}
}
示例10: upgrade_all_modules_database
public static function upgrade_all_modules_database()
{
//reload modules from disk and perform upgrades
$modules = Module::getModulesOnDisk();
foreach ($modules as $module) {
if (Module::initUpgradeModule($module)) {
if (!class_exists($module->name)) {
if (!file_exists(_PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php')) {
echo "Could not find {$module->name}.php file\n";
continue;
}
require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php';
}
if ($object = new $module->name()) {
$object->runUpgradeModule();
if (count($errors_module_list = $object->getErrors())) {
$upgradeErrors[] = 'name: ' . $module->displayName . 'message: ' . $errors_module_list;
}
unset($object);
} else {
echo "error, could not create object from {$module->name}\n";
}
}
Language::updateModulesTranslations(array($module->name));
}
if (empty($upgradeErrors)) {
return true;
} else {
foreach ($upgradeErrors as $error) {
echo $error['name'] . ': ' . $error['message'] . "\n";
}
return false;
}
}
示例11: getModulesToUpdate
public static function getModulesToUpdate()
{
$context = Context::getContext();
$logged_on_addons = false;
if (isset($context->cookie->username_addons) && isset($context->cookie->password_addons) && !empty($context->cookie->username_addons) && !empty($context->cookie->password_addons)) {
$logged_on_addons = true;
}
$modules = Module::getModulesOnDisk(true, $logged_on_addons, $context->employee->id);
$upgrade_available = 0;
foreach ($modules as $km => $module) {
if ($module->installed && isset($module->version_addons) && $module->version_addons) {
// SimpleXMLElement
++$upgrade_available;
}
}
return $upgrade_available;
}
示例12: initContent
public function initContent()
{
// Adding Css
$this->addCSS(__PS_BASE_URI__ . str_replace(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR, '', _PS_ADMIN_DIR_) . '/themes/' . $this->bo_theme . '/css/modules.css', 'all');
// If we are on a module configuration, no need to load all modules
if (Tools::getValue('configure') != '') {
return true;
}
// Init
$smarty = $this->context->smarty;
$autocompleteList = 'var moduleList = [';
$nameCountryDefault = Country::getNameById($this->context->language->id, Configuration::get('PS_COUNTRY_DEFAULT'));
$categoryFiltered = array();
$filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_' . (int) $this->id_employee));
if (count($filterCategories) > 0) {
foreach ($filterCategories as $fc) {
if (!empty($fc)) {
$categoryFiltered[$fc] = 1;
}
}
}
foreach ($this->list_modules_categories as $k => $v) {
$this->list_modules_categories[$k]['nb'] = 0;
}
// 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) {
unset($v['interest']);
}
if ($v['favorite'] == null) {
unset($v['favorite']);
}
$modules_preferences[$v['module']] = $v;
}
// Retrieve Modules List
$modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee);
$this->initModulesList($modules);
$this->nb_modules_total = count($modules);
$module_errors = array();
$module_success = array();
// 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)) {
// When the XML cache file is up-to-date, the module may not be loaded yet
if (!class_exists($module->name)) {
if (!file_exists(_PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php')) {
continue;
}
require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php';
}
if ($object = new $module->name()) {
$object->runUpgradeModule();
if (count($errors_module_list = $object->getErrors())) {
$module_errors[] = array('name' => $module->name, 'message' => $errors_module_list);
} else {
if (count($conf_module_list = $object->getConfirmations())) {
$module_success[] = array('name' => $module->name, 'message' => $conf_module_list);
}
}
unset($object);
}
} elseif (Module::getUpgradeStatus($module->name)) {
// When the XML cache file is up-to-date, the module may not be loaded yet
if (!class_exists($module->name)) {
if (file_exists(_PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php')) {
require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php';
$object = new $module->name();
$module_success[] = array('name' => $module->name, 'message' => array(0 => $this->l('Current version:') . $object->version, 1 => $this->l('No file upgrades applied (none exist).')));
} else {
continue;
}
}
unset($object);
}
// Make modules stats
$this->makeModulesStats($module);
// Assign warnings
if ($module->active && isset($module->warning) && !empty($module->warning)) {
$this->warnings[] = sprintf($this->l('%1$s: %2$s'), $module->displayName, $module->warning);
}
// AutoComplete array
$autocompleteList .= Tools::jsonEncode(array('displayName' => (string) $module->displayName, 'desc' => (string) $module->description, 'name' => (string) $module->name, 'author' => (string) $module->author, 'image' => isset($module->image) ? (string) $module->image : '', 'option' => '')) . ', ';
// Apply filter
if ($this->isModuleFiltered($module) && Tools::getValue('select') != 'favorites') {
unset($modules[$km]);
} else {
$this->fillModuleData($module);
//.........这里部分代码省略.........
示例13: searchModule
public function searchModule()
{
$this->_list['modules'] = array();
$all_modules = Module::getModulesOnDisk(true, true, Context::getContext()->employee->id);
foreach ($all_modules as $module) {
if (stripos($module->name, $this->query) !== false || stripos($module->displayName, $this->query) !== false || stripos($module->description, $this->query) !== false) {
$module->linkto = 'index.php?tab=AdminModules&tab_module=' . $module->tab . '&module_name=' . $module->name . '&anchor=anchor' . ucfirst($module->name) . '&token=' . Tools::getAdminTokenLite('AdminModules');
$this->_list['modules'][] = $module;
}
}
}
示例14: getModuleControllers
/**
* Get list of all available Module Front controllers
*
* @return array
*/
public static function getModuleControllers($type = 'all', $module = null)
{
$modules_controllers = array();
if (is_null($module)) {
$modules = Module::getModulesOnDisk(true);
} elseif (!is_array($module)) {
$modules = array(Module::getInstanceByName($module));
} else {
$modules = array();
foreach ($module as $_mod) {
$modules[] = Module::getInstanceByName($_mod);
}
}
foreach ($modules as $mod) {
foreach (Dispatcher::getControllersInDirectory(_PS_MODULE_DIR_ . $mod->name . '/controllers/') as $controller) {
if ($type == 'admin') {
if (strpos($controller, 'Admin') !== false) {
$modules_controllers[$mod->name][] = $controller;
}
} elseif ($type == 'front') {
if (strpos($controller, 'Admin') === false) {
$modules_controllers[$mod->name][] = $controller;
}
} else {
$modules_controllers[$mod->name][] = $controller;
}
}
}
return $modules_controllers;
}
示例15: __construct
public function __construct()
{
$this->bootstrap = true;
parent::__construct();
$id_shop = Context::getContext()->shop->id;
/* Get all modules then select only payment ones */
$modules = Module::getModulesOnDisk(true);
$moduleManagerBuilder = ModuleManagerBuilder::getInstance();
$moduleRepository = $moduleManagerBuilder->buildRepository();
foreach ($modules as $module) {
$addonModule = $moduleRepository->getModule($module->name);
if ($addonModule->attributes->get('parent_class') == 'PaymentModule') {
if ($module->id) {
if (!get_class($module) == 'SimpleXMLElement') {
$module->country = array();
}
$sql = new DbQuery();
$sql->select('`id_country`');
$sql->from('module_country');
$sql->where('`id_module` = ' . (int) $module->id);
$sql->where('`id_shop` = ' . (int) $id_shop);
$countries = Db::getInstance()->executeS($sql);
foreach ($countries as $country) {
$module->country[] = $country['id_country'];
}
if (!get_class($module) == 'SimpleXMLElement') {
$module->currency = array();
}
$sql = new DbQuery();
$sql->select('`id_currency`');
$sql->from('module_currency');
$sql->where('`id_module` = ' . (int) $module->id);
$sql->where('`id_shop` = ' . (int) $id_shop);
$currencies = Db::getInstance()->executeS($sql);
foreach ($currencies as $currency) {
$module->currency[] = $currency['id_currency'];
}
if (!get_class($module) == 'SimpleXMLElement') {
$module->group = array();
}
$sql = new DbQuery();
$sql->select('`id_group`');
$sql->from('module_group');
$sql->where('`id_module` = ' . (int) $module->id);
$sql->where('`id_shop` = ' . (int) $id_shop);
$groups = Db::getInstance()->executeS($sql);
foreach ($groups as $group) {
$module->group[] = $group['id_group'];
}
if (!get_class($module) == 'SimpleXMLElement') {
$module->reference = array();
}
$sql = new DbQuery();
$sql->select('`id_reference`');
$sql->from('module_carrier');
$sql->where('`id_module` = ' . (int) $module->id);
$sql->where('`id_shop` = ' . (int) $id_shop);
$carriers = Db::getInstance()->executeS($sql);
foreach ($carriers as $carrier) {
$module->reference[] = $carrier['id_reference'];
}
} else {
$module->country = null;
$module->currency = null;
$module->group = null;
}
$this->payment_modules[] = $module;
}
}
}