function sweaver_plugin_config_plugins in Sweaver 7
Same name and namespace in other branches
- 6 sweaver.admin.inc \sweaver_plugin_config_plugins()
Plugins form.
1 string reference to 'sweaver_plugin_config_plugins'
- _sweaver_menu in ./
sweaver.registry.inc - Menu items.
File
- ./
sweaver.admin.inc, line 11 - Administrative functions for sweaver plugins.
Code
function sweaver_plugin_config_plugins() {
$form = array();
$weight = 100;
$form['#tree'] = TRUE;
$form['#plugins'] = array();
$form['#theme'] = 'sweaver_plugin_config_plugins';
$plugins_order = variable_get('sweaver_plugins_weight', array());
cache_clear_all('plugins:sweaver:plugins', 'cache');
cache_clear_all('sweaver_plugins', 'cache');
drupal_add_css(drupal_get_path('module', 'sweaver') . '/sweaver_plugin.admin.css');
$sweaver = Sweaver::get_instance();
foreach ($sweaver
->get_plugins_registry(FALSE) as $plugin_name => $plugin) {
$sweaver_plugin = $sweaver
->get_plugin($plugin_name, FALSE);
$default_weight = isset($plugins_order[$plugin_name]) ? $plugins_order[$plugin_name] : $weight++;
$form['#plugins'][$plugin_name] = $default_weight;
// Status - editor can not be disabled.
$status = variable_get('sweaver_plugin_status_' . $plugin_name, FALSE);
if ($plugin_name == 'sweaver_plugin_editor') {
$form[$plugin_name]['status'] = array(
'#type' => 'checkbox',
'#value' => 1,
'#access' => FALSE,
);
}
else {
$missing = array();
$can_be_enabled = TRUE;
$dependencies = $sweaver_plugin
->sweaver_dependencies();
if (!empty($dependencies)) {
foreach ($dependencies as $module) {
if (!module_exists($module)) {
$can_be_enabled = FALSE;
$missing[] = $module;
}
}
}
$form[$plugin_name]['status'] = array(
'#type' => 'checkbox',
'#default_value' => $status,
);
if (!$can_be_enabled) {
$form[$plugin_name]['status']['#disabled'] = TRUE;
$form[$plugin_name]['status']['#value'] = 0;
$form[$plugin_name]['status']['#description'] = t('Following modules or plugins are disabled or missing: @module', array(
'@module' => implode(', ', $missing),
));
}
}
// Markup.
$form[$plugin_name]['name'] = array(
'#markup' => isset($plugin['tab']) ? $plugin['tab'] : drupal_ucfirst($plugin_name),
);
$form[$plugin_name]['weight'] = array(
'#type' => 'weight',
'#delta' => 50,
'#attributes' => array(
'class' => array(
'plugin-weight',
),
),
'#default_value' => $default_weight,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
return $form;
}