public function PurgePurgerBundleUI::get_form_list_type in Purge 7.2
Generates a list of items of a specific type.
Parameters
string $item_type:
Return value
array $form
1 call to PurgePurgerBundleUI::get_form_list_type()
- PurgePurgerBundleUI::get_form_list in includes/
purge_ui.class.inc - Generates a list form.
File
- includes/
purge_ui.class.inc, line 108 - Provides administrative interface for the Purge module.
Class
- PurgePurgerBundleUI
- Generates UI elements for the Purge UI module.
Code
public function get_form_list_type($item_type) {
// fieldset for each type
$form = array(
'#type' => 'fieldset',
'#title' => $this->type[$item_type]->name,
);
$form['description'] = array(
'#type' => 'item',
'#markup' => $this->type[$item_type]->description,
);
// Add link
if (in_array(PURGE_ACCESS_FULL, $this->type[$item_type]->access)) {
$form['add'] = array(
'#type' => 'item',
'#title' => l(t('Add @type', array(
'@type' => $this->type[$item_type]->name,
)), "admin/config/system/purge/add/{$item_type}"),
);
}
$table_options = array();
// Generate the table form.
foreach ($this->{$item_type} as $item_name => $item) {
$actions = array();
// Skip all system items.
if (!in_array(PURGE_ACCESS_SYSTEM, $item->access)) {
// Check if we'll only show an edit option.
if (in_array(PURGE_ACCESS_FULL, $item->access) || in_array(PURGE_ACCESS_ENABLE, $item->access)) {
$actions[] = l(t('Edit'), "admin/config/system/purge/edit/{$item_type}/{$item_name}");
}
elseif (in_array(PURGE_ACCESS_VIEW, $item->access)) {
$actions[] = l(t('View'), "admin/config/system/purge/view/{$item_type}/{$item_name}");
}
// Enable/disable cations.
if (in_array(PURGE_ACCESS_FULL, $item->access) || in_array(PURGE_ACCESS_ENABLE, $item->access)) {
if ($item->enabled == 1) {
$actions[] = l(t('Disable'), "admin/config/system/purge/disable/{$item_type}/{$item_name}");
}
else {
$actions[] = l(t('Enable'), "admin/config/system/purge/enable/{$item_type}/{$item_name}");
}
}
// Clone
if (in_array(PURGE_ACCESS_FULL, $item->access) || in_array(PURGE_ACCESS_CLONE, $item->access)) {
$actions[] = l(t('Clone'), "admin/config/system/purge/clone/{$item_type}/{$item_name}");
}
if (in_array(PURGE_ACCESS_FULL, $item->access)) {
$actions[] = l(t('Delete'), "admin/config/system/purge/delete/{$item_type}/{$item_name}");
}
// Get the curent status.
if ($item->enabled == 1) {
$status = t('Enabled');
}
else {
$status = t('Disabled');
}
$table_options[$item_name] = array(
'name' => $item->name,
'description' => $item->description,
'status' => $status,
'actions' => implode(' | ', $actions),
);
}
}
$form['items'] = array(
'#type' => 'tableselect',
'#header' => array(
'name' => t('Name'),
'description' => t('Description'),
'status' => t('Status'),
'actions' => t('Actions'),
),
'#options' => $table_options,
);
return $form;
}