本文整理汇总了PHP中Modules::set_active方法的典型用法代码示例。如果您正苦于以下问题:PHP Modules::set_active方法的具体用法?PHP Modules::set_active怎么用?PHP Modules::set_active使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Modules
的用法示例。
在下文中一共展示了Modules::set_active方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajax_dashboard
/**
* Handles AJAX requests from the dashboard
*/
public function ajax_dashboard($handler_vars)
{
Utils::check_request_method(array('POST'));
$theme_dir = Plugins::filter('admin_theme_dir', Site::get_dir('admin_theme', true));
$this->theme = Themes::create('admin', 'RawPHPEngine', $theme_dir);
switch ($handler_vars['action']) {
case 'updateModules':
$modules = array();
foreach ($_POST as $key => $module) {
// skip POST elements which are not module names
if (preg_match('/^module\\d+$/', $key)) {
list($module_id, $module_name) = explode(':', $module, 2);
// remove non-sortable modules from the list
if ($module_id != 'nosort') {
$modules[$module_id] = $module_name;
}
}
}
Modules::set_active($modules);
$ar = new AjaxResponse(200, _t('Modules updated.'));
break;
case 'addModule':
$id = Modules::add($handler_vars['module_name']);
$this->fetch_dashboard_modules();
$ar = new AjaxResponse(200, _t('Added module %s.', array($handler_vars['module_name'])));
$ar->html('modules', $this->theme->fetch('dashboard_modules'));
break;
case 'removeModule':
Modules::remove($handler_vars['moduleid']);
$this->fetch_dashboard_modules();
$ar = new AjaxResponse(200, _t('Removed module.'));
$ar->html('modules', $this->theme->fetch('dashboard_modules'));
break;
}
$ar->out();
}
示例2: ajax_dashboard
/**
* Handles ajax requests from the dashboard
*/
public function ajax_dashboard($handler_vars)
{
Utils::check_request_method(array('POST'));
$theme_dir = Plugins::filter('admin_theme_dir', Site::get_dir('admin_theme', TRUE));
$this->theme = Themes::create('admin', 'RawPHPEngine', $theme_dir);
switch ($handler_vars['action']) {
case 'updateModules':
$modules = array();
foreach ($_POST as $key => $module) {
// skip POST elements which are not module names
if (preg_match('/^module\\d+$/', $key)) {
list($module_id, $module_name) = split(':', $module, 2);
// remove non-sortable modules from the list
if ($module_id != 'nosort') {
$modules[$module_id] = $module_name;
}
}
}
Modules::set_active($modules);
echo json_encode(true);
break;
case 'addModule':
$id = Modules::add($handler_vars['module_name']);
$this->fetch_dashboard_modules();
$result = array('message' => "Added module {$handler_vars['module_name']}.", 'modules' => $this->theme->fetch('dashboard_modules'));
echo json_encode($result);
break;
case 'removeModule':
Modules::remove($handler_vars['moduleid']);
$this->fetch_dashboard_modules();
$result = array('message' => 'Removed module', 'modules' => $this->theme->fetch('dashboard_modules'));
echo json_encode($result);
break;
}
}