本文整理汇总了PHP中Modules::disable方法的典型用法代码示例。如果您正苦于以下问题:PHP Modules::disable方法的具体用法?PHP Modules::disable怎么用?PHP Modules::disable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Modules
的用法示例。
在下文中一共展示了Modules::disable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
function indexAction()
{
$modules_table = new Modules("nuts");
$request = new Bolts_Request($this->getRequest());
if ($request->has("id") and $request->has("perform")) {
switch ($request->perform) {
case "enable":
if (!$modules_table->isEnabled($request->id)) {
if ($modules_table->enable($request->id)) {
if (!is_null($modules_table->success)) {
$this->view->success = $modules_table->success;
} else {
$this->view->success = "Module \"" . $request->id . "\" enabled.";
}
}
} else {
$this->view->notice = "Module \"" . $request->id . "\" is already enabled.";
}
break;
case "disable":
if ($modules_table->isEnabled($request->id)) {
if ($modules_table->disable($request->id)) {
if (!is_null($modules_table->success)) {
$this->view->success = $modules_table->success;
} else {
$this->view->success = "Module \"" . $request->id . "\" disabled.";
}
}
} else {
$this->view->notice = "Module \"" . $request->id . "\" is already disabled.";
}
break;
case "install":
if (!$modules_table->exists($request->id)) {
if ($modules_table->install($request->id)) {
if (!is_null($modules_table->success)) {
$this->view->success = $modules_table->success;
} else {
$this->view->success = "Module \"" . $request->id . "\" installed.";
}
}
} else {
$this->view->notice = "Module \"" . $request->id . "\" is already installed.";
}
break;
case "uninstall":
if ($modules_table->exists($request->id)) {
if ($modules_table->disable($request->id)) {
if ($modules_table->uninstall($request->id)) {
if (!is_null($modules_table->success)) {
$this->view->success = $modules_table->success;
} else {
$this->view->success = "Module \"" . $request->id . "\" disabled and uninstalled.";
}
}
}
} else {
$this->view->notice = "Module \"" . $request->id . "\" is not installed.";
}
break;
}
if (count($modules_table->errors) > 0) {
$this->view->errors = $modules_table->errors;
}
if (!is_null($modules_table->notice)) {
$this->view->notice = $modules_table->notice;
}
}
$basepath = Zend_Registry::get('basepath');
$module_dir = $basepath . "/nuts";
$o_module_dir = dir($module_dir);
$available_modules = array();
while (false !== ($entry = $o_module_dir->read())) {
if (substr($entry, 0, 1) != ".") {
if ($entry != "default") {
$full_dir = $module_dir . "/" . $entry;
if (file_exists($full_dir . "/module.ini") and !$modules_table->exists($entry)) {
$tmp_module = $modules_table->parseIni($entry);
$tmp_module['id'] = $entry;
$tmp_module['available'] = true;
$available_modules[] = $tmp_module;
}
}
}
}
$o_module_dir->close();
$tmp_modules = array();
$modules = $modules_table->fetchAll(null, "id");
if (count($modules) > 0) {
$tmp_modules = array();
foreach ($modules as $module) {
$module = $module->toArray();
try {
$config = $modules_table->parseIni($module['id']);
foreach ($config as $key => $val) {
$module[$key] = $val;
}
$module['available'] = false;
$tmp_modules[] = $module;
} catch (Exception $e) {
//.........这里部分代码省略.........
示例2: modules
/**
* Module List and management controller
*
*
* @access public
* @author Blair Jersyer
* @copyright name date
* @param string $page
* @param string $arg2
* @since 3.0.1
*/
function modules($page = 'list', $arg2 = null)
{
if ($page === 'list') {
$this->events->add_filter('gui_page_title', function ($title) {
return '<section class="content-header"><h1>' . strip_tags($title) . ' <a class="btn btn-primary btn-sm pull-right" href="' . site_url(array('dashboard', 'modules', 'install_zip')) . '">' . __('Upload a zip file') . '</a></h1></section>';
});
$this->events->add_action('displays_dashboard_errors', function () {
if (isset($_GET['extra'])) {
echo tendoo_error(__('An error occured during module installation. There was a file conflict during module installation process.<br>This file seems to be already installed : ' . $_GET['extra']));
}
});
$this->gui->set_title(sprintf(__('Module List — %s'), get('core_signature')));
$this->load->view('dashboard/modules/list');
} else {
if ($page === 'install_zip') {
$this->events->add_filter('gui_page_title', function ($title) {
return '<section class="content-header"><h1>' . strip_tags($title) . ' <a class="btn btn-primary btn-sm pull-right" href="' . site_url(array('dashboard', 'modules')) . '">' . __('Back to modules list') . '</a></h1></section>';
});
if (isset($_FILES['extension_zip'])) {
$notice = Modules::install('extension_zip');
// it means that module has been installed
if (is_array($notice)) {
// redirecting
redirect(array('dashboard', 'modules', 'list?highlight=' . $notice['namespace'] . '¬ice=' . $notice['msg'] . (isset($notice['extra']) ? '&extra=' . $notice['extra'] : '') . '#module-' . $notice['namespace']));
} else {
$this->notice->push_notice($this->lang->line($notice));
}
}
$this->gui->set_title(sprintf(__('Add a new extension — %s'), get('core_signature')));
$this->load->view('dashboard/modules/install');
} else {
if ($page === 'enable') {
/**
* Module should be enabled before trigger this action
**/
Modules::enable($arg2);
// Enabling recently active module
Modules::init('unique', $arg2);
// Run the action
$this->events->do_action('do_enable_module', $arg2);
redirect(array('dashboard', 'modules?notice=' . $this->events->apply_filters('module_activation_status', 'module-enabled')));
} else {
if ($page === 'disable') {
$this->events->add_action('do_disable_module', function ($arg2) {
Modules::disable($arg2);
});
//
$this->events->do_action('do_disable_module', $arg2);
redirect(array('dashboard', 'modules?notice=' . $this->events->apply_filters('module_disabling_status', 'module-disabled')));
} else {
if ($page === 'remove') {
$this->events->add_action('do_remove_module', function ($arg2) {
Modules::uninstall($arg2);
redirect(array('dashboard', 'modules?notice=module-removed'));
});
$this->events->do_action('do_remove_module', $arg2);
} else {
if ($page === 'extract') {
$this->events->add_action('do_extract_module', function ($arg2) {
Modules::extract($arg2);
});
$this->events->do_action('do_extract_module', $arg2);
}
}
}
}
}
}
}
示例3: Modules
<td>Статус</td>
<td>Включить</td>
<td>Отключить</td>
</tr>
</thead>
<tbody>
<?php
$class = new Modules();
if (isset($_GET['enable'])) {
$class->enable($_GET['enable']);
$class->save();
echo "<div class='alert alert-success'>Модуль включён</div>";
}
if (isset($_GET['disable'])) {
$class->disable($_GET['disable']);
$class->save();
echo "<div class='alert alert-success'>Модуль отключён</div>";
}
$mods = $class->getModules();
$skip = array('.', '..', '.htaccess', '.conf');
$files = scandir(MODS_ROOT);
foreach ($files as $file) {
if (!in_array($file, $skip)) {
$status = in_array($file, $mods) ? "Включён" : "Отключён";
echo "<tr><td> <b><font size=3>" . $file . "</font></b> </td><td> <b>" . $status . "</b> </td><td> [<a href='?enable=" . $file . "'>Включить</a>] </td><td> [<a href='?disable=" . $file . "'>Отключить</a>] </td></tr>";
}
}
?>
</tbody>