本文整理汇总了PHP中ModuleManager::set_module_state方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleManager::set_module_state方法的具体用法?PHP ModuleManager::set_module_state怎么用?PHP ModuleManager::set_module_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleManager
的用法示例。
在下文中一共展示了ModuleManager::set_module_state方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: body
public function body()
{
ob_start();
//create default module form
print '<div class="title">Select modules to disable</div>';
print 'Selected modules will be marked as not installed but uninstall methods will not be called. Any database tables and other modifications made by modules\' install methods will not be reverted.<br><br>';
print 'To uninstall module please use Modules Administration in Application.';
print '<hr/><br/>';
$form = new HTML_QuickForm('modulesform', 'post', $_SERVER['PHP_SELF'] . '?' . http_build_query($_GET), '', null, true);
$states = array(ModuleManager::MODULE_ENABLED => 'Active', ModuleManager::MODULE_DISABLED => 'Inactive');
$modules = DB::GetAssoc('SELECT * FROM modules ORDER BY state, name');
foreach ($modules as $m) {
$name = $m['name'];
$state = isset($m['state']) ? $m['state'] : ModuleManager::MODULE_ENABLED;
if ($state == ModuleManager::MODULE_NOT_FOUND) {
$state = ModuleManager::MODULE_DISABLED;
}
$form->addElement('select', $name, $name, $states);
$form->setDefaults(array($name => $state));
}
$form->addElement('button', 'submit_button', 'Save', array('class' => 'button', 'onclick' => 'if(confirm("Are you sure?")) document.modulesform.submit();'));
//validation or display
if ($form->validate()) {
//uninstall
$vals = $form->exportValues();
foreach ($vals as $k => $v) {
if (isset($modules[$k]['state']) && $modules[$k]['state'] != $v) {
ModuleManager::set_module_state($k, $v);
}
}
}
$form->display();
return ob_get_clean();
}