本文整理汇总了PHP中Tab::getInstanceFromClassName方法的典型用法代码示例。如果您正苦于以下问题:PHP Tab::getInstanceFromClassName方法的具体用法?PHP Tab::getInstanceFromClassName怎么用?PHP Tab::getInstanceFromClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tab
的用法示例。
在下文中一共展示了Tab::getInstanceFromClassName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateOptionPsMultishopFeatureActive
/**
* Enable / disable multishop menu if multishop feature is activated
*
* @param string $value
*/
public function updateOptionPsMultishopFeatureActive($value)
{
Configuration::updateValue('PS_MULTISHOP_FEATURE_ACTIVE', $value);
$tab = Tab::getInstanceFromClassName('AdminShopGroup');
$tab->active = (bool) Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE');
$tab->update();
}
示例2: __construct
public function __construct()
{
global $cookie;
parent::__construct();
$this->is_seller = $cookie->profile == (int) Configuration::get('AGILE_MS_PROFILE_ID');
Shop::$id_shop_owner = $this->is_seller ? $cookie->id_employee : 0;
if (Module::isInstalled('agilemultipleseller') and !isset($_GET['logout']) and $this->is_seller and (Tools::getValue("controller") == "" or Tools::getValue("controller") == "adminhome")) {
$tid = Tab::getIdFromClassName('AdminProducts');
$token = Tools::getAdminToken('AdminProducts' . intval($tid) . intval($cookie->id_employee));
Tools::redirectAdmin("./index.php?controller=AdminProducts&token=" . $token);
}
if (Module::isInstalled('agilesellerlistoptions')) {
require_once _PS_ROOT_DIR_ . '/modules/agilesellerlistoptions/agilesellerlistoptions.php';
$aslo_module = new AgileSellerListOptions();
$msg = $aslo_module->hookAgileAdminTop(null);
if (!empty($msg)) {
$this->displayWarning($msg);
}
}
$tab = Tab::getInstanceFromClassName('AdminShopGroup');
if (Module::isInstalled('agilemultipleshop')) {
$tab->active = 1;
} else {
$tab->active = 0;
}
$tab->update();
}
示例3: __construct
public function __construct()
{
$this->table = 'employee';
$this->className = 'Employee';
$this->lang = false;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->context = Context::getContext();
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
/*
check if there are more than one superAdmin
if it's the case then we can delete a superAdmin
*/
$super_admin = Employee::countProfile(_PS_ADMIN_PROFILE_, true);
if ($super_admin == 1) {
$super_admin_array = Employee::getEmployeesByProfile(_PS_ADMIN_PROFILE_, true);
$super_admin_id = array();
foreach ($super_admin_array as $key => $val) {
$super_admin_id[] = $val['id_employee'];
}
$this->addRowActionSkipList('delete', $super_admin_id);
}
$profiles = Profile::getProfiles($this->context->language->id);
if (!$profiles) {
$this->errors[] = Tools::displayError('No profile');
} else {
foreach ($profiles as $profile) {
$this->profiles_array[$profile['name']] = $profile['name'];
}
}
$this->fields_list = array('id_employee' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'lastname' => array('title' => $this->l('Last name'), 'width' => 'auto'), 'firstname' => array('title' => $this->l('First name'), 'width' => 130), 'email' => array('title' => $this->l('E-mail address'), 'width' => 180), 'profile' => array('title' => $this->l('Profile'), 'width' => 90, 'type' => 'select', 'list' => $this->profiles_array, 'filter_key' => 'pl!name'), 'active' => array('title' => $this->l('Can log in'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'width' => 30));
$this->fields_options = array('general' => array('title' => $this->l('Employee options'), 'fields' => array('PS_PASSWD_TIME_BACK' => array('title' => $this->l('Password regeneration'), 'desc' => $this->l('Security: minimum time to wait between two password changes'), 'cast' => 'intval', 'size' => 5, 'type' => 'text', 'suffix' => ' ' . $this->l('minutes'), 'visibility' => Shop::CONTEXT_ALL), 'PS_BO_ALLOW_EMPLOYEE_FORM_LANG' => array('title' => $this->l('Memorize language used in Admin panel forms'), 'desc' => $this->l('Allow employees to select a specific language for Admin panel forms'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array('0' => array('value' => 0, 'name' => $this->l('No')), '1' => array('value' => 1, 'name' => $this->l('Yes'))), 'visibility' => Shop::CONTEXT_ALL)), 'submit' => array()));
$path = _PS_ADMIN_DIR_ . '/themes/';
foreach (scandir($path) as $theme) {
if ($theme[0] != '.' && is_dir($path . $theme) && file_exists($path . $theme . '/css/admin.css')) {
$this->themes[] = $theme;
}
}
$home_tab = Tab::getInstanceFromClassName('adminHome');
$this->tabs_list[$home_tab->id] = array('name' => $home_tab->name[$this->context->language->id], 'id_tab' => $home_tab->id, 'children' => array(array('id_tab' => $home_tab->id, 'name' => $home_tab->name[$this->context->language->id])));
foreach (Tab::getTabs($this->context->language->id, 0) as $tab) {
if (Tab::checkTabRights($tab['id_tab'])) {
$this->tabs_list[$tab['id_tab']] = $tab;
foreach (Tab::getTabs($this->context->language->id, $tab['id_tab']) as $children) {
if (Tab::checkTabRights($children['id_tab'])) {
$this->tabs_list[$tab['id_tab']]['children'][] = $children;
}
}
}
}
parent::__construct();
// An employee can edit its own profile
if ($this->context->employee->id == Tools::getValue('id_employee')) {
$this->tabAccess['view'] = '1';
if (!$this->tabAccess['edit']) {
$this->restrict_edition = true;
}
$this->tabAccess['edit'] = '1';
}
}
示例4: upgrade_module_0_2
/**
*
* @param piwikanalyticsjs $module
* @return boolean
*/
function upgrade_module_0_2($module)
{
if ($tab = Tab::getInstanceFromClassName('PiwikAnalyticsResource')) {
$tab->delete();
}
return true;
}
示例5: updateOptionPsB2bEnable
/**
* Update PS_B2B_ENABLE and enables / disables the associated tabs
* @param $value integer Value of option
*/
public function updateOptionPsB2bEnable($value)
{
$value = (int) $value;
$tabs_class_name = array('AdminOutstanding');
if (!empty($tabs_class_name)) {
foreach ($tabs_class_name as $tab_class_name) {
$tab = Tab::getInstanceFromClassName($tab_class_name);
if (Validate::isLoadedObject($tab)) {
$tab->active = $value;
$tab->save();
}
}
}
Configuration::updateValue('PS_B2B_ENABLE', $value);
}
示例6: addAdminTab
/**
* Add admin tabs in the menu
* @param Array $tabs
* Array[
* Array[
* id_parent => 0 || void
* className => Controller to link to
* module => modulename to easily delete when uninstalling
* name => name to display
* position => position
* ]
* ]
*/
public static function addAdminTab($data)
{
// Get ID Parent
$id_parent = isset($data['id_parent']) ? (int) $data['id_parent'] : (int) Tab::getIdFromClassName($data['classNameParent']);
// Tab
$tab = Tab::getInstanceFromClassName($data['className']);
$tab->id_parent = (int) $id_parent;
$tab->class_name = $data['className'];
$tab->module = $data['module'];
$tab->position = Tab::getNewLastPosition((int) $id_parent);
$tab->active = 1;
$languages = Language::getLanguages(false);
foreach ($languages as $lang) {
$tab->name[(int) $lang['id_lang']] = $data['name'];
}
if (!$tab->save()) {
return false;
}
return $tab->id;
}
示例7: __construct
public function __construct()
{
$this->bootstrap = true;
$this->table = 'employee';
$this->className = 'Employee';
$this->lang = false;
$this->context = Context::getContext();
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->addRowActionSkipList('delete', array((int) $this->context->employee->id));
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
/*
check if there are more than one superAdmin
if it's the case then we can delete a superAdmin
*/
$super_admin = Employee::countProfile(_PS_ADMIN_PROFILE_, true);
if ($super_admin == 1) {
$super_admin_array = Employee::getEmployeesByProfile(_PS_ADMIN_PROFILE_, true);
$super_admin_id = array();
foreach ($super_admin_array as $key => $val) {
$super_admin_id[] = $val['id_employee'];
}
$this->addRowActionSkipList('delete', $super_admin_id);
}
$profiles = Profile::getProfiles($this->context->language->id);
if (!$profiles) {
$this->errors[] = Tools::displayError('No profile.');
} else {
foreach ($profiles as $profile) {
$this->profiles_array[$profile['name']] = $profile['name'];
}
}
$this->fields_list = array('id_employee' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'firstname' => array('title' => $this->l('First Name')), 'lastname' => array('title' => $this->l('Last Name')), 'email' => array('title' => $this->l('Email address')), 'profile' => array('title' => $this->l('Profile'), 'type' => 'select', 'list' => $this->profiles_array, 'filter_key' => 'pl!name', 'class' => 'fixed-width-lg'), 'active' => array('title' => $this->l('Active'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'class' => 'fixed-width-sm'));
$this->fields_options = array('general' => array('title' => $this->l('Employee options'), 'fields' => array('PS_PASSWD_TIME_BACK' => array('title' => $this->l('Password regeneration'), 'hint' => $this->l('Security: Minimum time to wait between two password changes.'), 'cast' => 'intval', 'type' => 'text', 'suffix' => ' ' . $this->l('minutes'), 'visibility' => Shop::CONTEXT_ALL), 'PS_BO_ALLOW_EMPLOYEE_FORM_LANG' => array('title' => $this->l('Memorize the language used in Admin panel forms'), 'hint' => $this->l('Allow employees to select a specific language for the Admin panel form.'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array('0' => array('value' => 0, 'name' => $this->l('No')), '1' => array('value' => 1, 'name' => $this->l('Yes'))), 'visibility' => Shop::CONTEXT_ALL)), 'submit' => array('title' => $this->l('Save'))));
$rtl = $this->context->language->is_rtl ? '_rtl' : '';
$path = _PS_ADMIN_DIR_ . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR;
foreach (scandir($path) as $theme) {
if ($theme[0] != '.' && is_dir($path . $theme) && @filemtime($path . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'admin-theme.css')) {
$this->themes[] = array('id' => $theme . '|admin-theme' . $rtl . '.css', 'name' => $theme == 'default' ? $this->l('Default') : ucfirst($theme));
if (file_exists($path . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'schemes' . $rtl)) {
foreach (scandir($path . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'schemes' . $rtl) as $css) {
if ($css[0] != '.' && preg_match('/\\.css$/', $css)) {
$name = strpos($css, 'admin-theme-') !== false ? Tools::ucfirst(preg_replace('/^admin-theme-(.*)\\.css$/', '$1', $css)) : $css;
$this->themes[] = array('id' => $theme . '|schemes' . $rtl . '/' . $css, 'name' => $name);
}
}
}
}
}
$home_tab = Tab::getInstanceFromClassName('AdminDashboard', $this->context->language->id);
$this->tabs_list[$home_tab->id] = array('name' => $home_tab->name, 'id_tab' => $home_tab->id, 'children' => array(array('id_tab' => $home_tab->id, 'name' => $home_tab->name)));
foreach (Tab::getTabs($this->context->language->id, 0) as $tab) {
if (Tab::checkTabRights($tab['id_tab'])) {
$this->tabs_list[$tab['id_tab']] = $tab;
foreach (Tab::getTabs($this->context->language->id, $tab['id_tab']) as $children) {
if (Tab::checkTabRights($children['id_tab'])) {
$this->tabs_list[$tab['id_tab']]['children'][] = $children;
}
}
}
}
parent::__construct();
// An employee can edit its own profile
if ($this->context->employee->id == Tools::getValue('id_employee')) {
$this->tabAccess['view'] = '1';
$this->restrict_edition = true;
$this->tabAccess['edit'] = '1';
}
}
示例8: dispatch
/**
* Find the controller and instantiate it
*/
public function dispatch()
{
$controller_class = '';
// Get current controller
$this->getController();
if (!$this->controller) {
$this->controller = $this->useDefaultController();
}
// Dispatch with right front controller
switch ($this->front_controller) {
// Dispatch front office controller
case self::FC_FRONT:
$controllers = Dispatcher::getControllers(array(_PS_FRONT_CONTROLLER_DIR_, _PS_OVERRIDE_DIR_ . 'controllers/front/'));
$controllers['index'] = 'IndexController';
if (isset($controllers['auth'])) {
$controllers['authentication'] = $controllers['auth'];
}
if (isset($controllers['compare'])) {
$controllers['productscomparison'] = $controllers['compare'];
}
if (isset($controllers['contact'])) {
$controllers['contactform'] = $controllers['contact'];
}
if (!isset($controllers[strtolower($this->controller)])) {
$this->controller = $this->controller_not_found;
}
$controller_class = $controllers[strtolower($this->controller)];
$params_hook_action_dispatcher = array('controller_type' => self::FC_FRONT, 'controller_class' => $controller_class, 'is_module' => 0);
break;
// Dispatch module controller for front office
// Dispatch module controller for front office
case self::FC_MODULE:
$module_name = Validate::isModuleName(Tools::getValue('module')) ? Tools::getValue('module') : '';
$module = Module::getInstanceByName($module_name);
$controller_class = 'PageNotFoundController';
if (Validate::isLoadedObject($module) && $module->active) {
$controllers = Dispatcher::getControllers(_PS_MODULE_DIR_ . $module_name . '/controllers/front/');
if (isset($controllers[strtolower($this->controller)])) {
include_once _PS_MODULE_DIR_ . $module_name . '/controllers/front/' . $this->controller . '.php';
$controller_class = $module_name . $this->controller . 'ModuleFrontController';
}
}
$params_hook_action_dispatcher = array('controller_type' => self::FC_FRONT, 'controller_class' => $controller_class, 'is_module' => 1);
break;
// Dispatch back office controller + module back office controller
// Dispatch back office controller + module back office controller
case self::FC_ADMIN:
if ($this->use_default_controller && !Tools::getValue('token') && Validate::isLoadedObject(Context::getContext()->employee) && Context::getContext()->employee->isLoggedBack()) {
Tools::redirectAdmin('index.php?controller=' . $this->controller . '&token=' . Tools::getAdminTokenLite($this->controller));
}
$tab = Tab::getInstanceFromClassName($this->controller, Configuration::get('PS_LANG_DEFAULT'));
$retrocompatibility_admin_tab = null;
if ($tab->module) {
if (file_exists(_PS_MODULE_DIR_ . $tab->module . '/' . $tab->class_name . '.php')) {
$retrocompatibility_admin_tab = _PS_MODULE_DIR_ . $tab->module . '/' . $tab->class_name . '.php';
} else {
$controllers = Dispatcher::getControllers(_PS_MODULE_DIR_ . $tab->module . '/controllers/admin/');
if (!isset($controllers[strtolower($this->controller)])) {
$this->controller = $this->controller_not_found;
$controller_class = 'AdminNotFoundController';
} else {
// Controllers in modules can be named AdminXXX.php or AdminXXXController.php
include_once _PS_MODULE_DIR_ . $tab->module . '/controllers/admin/' . $controllers[strtolower($this->controller)] . '.php';
$controller_class = $controllers[strtolower($this->controller)] . (strpos($controllers[strtolower($this->controller)], 'Controller') ? '' : 'Controller');
}
}
$params_hook_action_dispatcher = array('controller_type' => self::FC_ADMIN, 'controller_class' => $controller_class, 'is_module' => 1);
} else {
$controllers = Dispatcher::getControllers(array(_PS_ADMIN_DIR_ . '/tabs/', _PS_ADMIN_CONTROLLER_DIR_, _PS_OVERRIDE_DIR_ . 'controllers/admin/'));
if (!isset($controllers[strtolower($this->controller)])) {
// If this is a parent tab, load the first child
if (Validate::isLoadedObject($tab) && $tab->id_parent == 0 && ($tabs = Tab::getTabs(Context::getContext()->language->id, $tab->id)) && isset($tabs[0])) {
Tools::redirectAdmin(Context::getContext()->link->getAdminLink($tabs[0]['class_name']));
}
$this->controller = $this->controller_not_found;
}
$controller_class = $controllers[strtolower($this->controller)];
$params_hook_action_dispatcher = array('controller_type' => self::FC_ADMIN, 'controller_class' => $controller_class, 'is_module' => 0);
if (file_exists(_PS_ADMIN_DIR_ . '/tabs/' . $controller_class . '.php')) {
$retrocompatibility_admin_tab = _PS_ADMIN_DIR_ . '/tabs/' . $controller_class . '.php';
}
}
// @retrocompatibility with admin/tabs/ old system
if ($retrocompatibility_admin_tab) {
include_once $retrocompatibility_admin_tab;
include_once _PS_ADMIN_DIR_ . '/functions.php';
runAdminTab($this->controller, !empty($_REQUEST['ajaxMode']));
return;
}
break;
default:
throw new PrestaShopException('Bad front controller chosen');
}
// Instantiate controller
try {
// Loading controller
$controller = Controller::getController($controller_class);
//.........这里部分代码省略.........
示例9: addNewTabs
/**
* Add new translations tabs by code ISO
*
* @param array $iso_code
* @param array $files
*/
public static function addNewTabs($iso_code, $files)
{
foreach ($files as $file) {
// Check if file is a file theme
if (preg_match('#^translations\\/' . $iso_code . '\\/tabs.php#Ui', $file['filename'], $matches) && Validate::isLanguageIsoCode($iso_code)) {
// Include array width new translations tabs
$tabs = (include _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $file['filename']);
foreach ($tabs as $class_name => $translations) {
// Get instance of this tab by class name
$tab = Tab::getInstanceFromClassName($class_name);
//Check if class name exists
if (isset($tab->class_name) && !empty($tab->class_name)) {
$id_lang = Language::getIdByIso($iso_code);
$tab->name[(int) $id_lang] = pSQL($translations);
// Update this tab
$tab->update();
}
}
}
}
}
示例10: addNewTabs
/**
* Add new translations tabs by code ISO
*
* @param array $iso_code
* @param array $files
*/
public static function addNewTabs($iso_code, $files)
{
$errors = array();
foreach ($files as $file) {
// Check if file is a file theme
if (preg_match('#^translations\\/' . $iso_code . '\\/tabs.php#Ui', $file['filename'], $matches) && Validate::isLanguageIsoCode($iso_code)) {
// Include array width new translations tabs
$_TABS = array();
clearstatcache();
if (file_exists(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $file['filename'])) {
include_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $file['filename'];
}
if (count($_TABS)) {
foreach ($_TABS as $class_name => $translations) {
// Get instance of this tab by class name
$tab = Tab::getInstanceFromClassName($class_name);
//Check if class name exists
if (isset($tab->class_name) && !empty($tab->class_name)) {
$id_lang = Language::getIdByIso($iso_code);
$tab->name[(int) $id_lang] = $translations;
// Do not crash at intall
if (!isset($tab->name[Configuration::get('PS_LANG_DEFAULT')])) {
$tab->name[(int) Configuration::get('PS_LANG_DEFAULT')] = $translations;
}
if (!Validate::isGenericName($tab->name[(int) $id_lang])) {
$errors[] = sprintf(Tools::displayError('Tab "%s" is not valid'), $tab->name[(int) $id_lang]);
} else {
$tab->update();
}
}
}
}
}
}
return $errors;
}
示例11: uninstall
/**
* Uninstall the module
* @return boolean false on uninstall error
*/
public function uninstall()
{
if (parent::uninstall()) {
foreach ($this->getConfigFields(FALSE) as $key => $value) {
Configuration::deleteByName($key);
}
try {
if (method_exists('Tab', 'getInstanceFromClassName')) {
$AdminParentStats = Tab::getInstanceFromClassName('PiwikAnalytics15');
if (!isset($AdminParentStats) || !Validate::isLoadedObject($AdminParentStats)) {
$AdminParentStats = Tab::getInstanceFromClassName('AdminPiwikAnalytics');
}
if (!isset($AdminParentStats) || !Validate::isLoadedObject($AdminParentStats)) {
$AdminParentStats = Tab::getInstanceFromClassName('PiwikAnalytics');
}
} else {
if (method_exists('Tab', 'getIdFromClassName')) {
$tmpId = TabCore::getIdFromClassName('PiwikAnalytics15');
if (!isset($tmpId) || !(bool) $tmpId || (int) $tmpId < 1) {
$tmpId = Tab::getIdFromClassName('AdminPiwikAnalytics');
}
if (!isset($tmpId) || !(bool) $tmpId || (int) $tmpId < 1) {
$tmpId = Tab::getIdFromClassName('PiwikAnalytics');
}
if (!isset($tmpId) || !(bool) $tmpId || (int) $tmpId < 1) {
$AdminParentStats = new Tab($tmpId);
}
}
}
if (isset($AdminParentStats) && ($AdminParentStats instanceof Tab || $AdminParentStats instanceof TabCore)) {
$AdminParentStats->delete();
}
} catch (Exception $ex) {
}
Configuration::deleteByName(PKHelper::CPREFIX . 'TAPID');
return true;
}
return false;
}