function panels_mini_list_page in Panels 6.2
Same name and namespace in other branches
- 5.2 panels_mini/panels_mini.module \panels_mini_list_page()
Provide a list of mini panels, with links to edit or delete them.
1 string reference to 'panels_mini_list_page'
- _panels_mini_menu in panels_mini/
panels_mini.admin.inc - Implementation of hook_menu().
File
- panels_mini/
panels_mini.admin.inc, line 137 - Administrative items for the panels mini module.
Code
function panels_mini_list_page() {
panels_load_include('plugins');
$layouts = panels_get_layouts();
$items = array();
$sorts = array();
$header = array(
array(
'data' => t('Title'),
'field' => 'title',
),
array(
'data' => t('Name'),
'field' => 'name',
'sort' => 'asc',
),
array(
'data' => t('Type'),
'field' => 'type',
),
t('Layout'),
t('Operations'),
);
// Load all mini panels and their displays.
$panel_minis = panels_mini_load_all();
$dids = array();
foreach ($panel_minis as $panel_mini) {
if (empty($panel_mini->display)) {
$dids[] = $panel_mini->did;
}
}
$displays = panels_load_displays($dids);
if (empty($displays)) {
return t('There are currently no mini panels.');
}
foreach ($panel_minis as $panel_mini) {
$ops = array();
if (empty($panel_mini->disabled)) {
$ops[] = l(t('Edit'), "admin/panels/panel-mini/{$panel_mini->name}/edit-general");
$ops[] = l(t('Export'), "admin/panels/panel-mini/{$panel_mini->name}/export");
}
if ($panel_mini->type != t('Default')) {
$text = $panel_mini->type == t('Overridden') ? t('Revert') : t('Delete');
$ops[] = l($text, "admin/panels/panel-mini/{$panel_mini->name}/delete");
}
else {
if (empty($panel_mini->disabled)) {
$ops[] = l(t('Disable'), "admin/panels/panel-mini/disable/{$panel_mini->name}", array(
'query' => drupal_get_destination(),
));
}
else {
$ops[] = l(t('Enable'), "admin/panels/panel-mini/enable/{$panel_mini->name}", array(
'query' => drupal_get_destination(),
));
}
}
$item = array();
$item[] = check_plain($panel_mini->title);
$item[] = check_plain($panel_mini->name);
// this is safe as it's always programmatic
$item[] = $panel_mini->type;
if (empty($panel_mini->display)) {
$panel_mini->display = $displays[$panel_mini->did];
}
$item[] = check_plain($layouts[$panel_mini->display->layout]['title']);
$item[] = implode(' | ', $ops);
$items[] = $item;
$ts = tablesort_init($header);
switch ($ts['sql']) {
case 'title':
$sorts[] = $item[0];
break;
case 'name':
default:
$sorts[] = $item[1];
break;
case 'type':
$sorts[] = $panel_mini->type . $item[0];
break;
}
}
if (drupal_strtolower($ts['sort']) == 'desc') {
arsort($sorts);
}
else {
asort($sorts);
}
$i = array();
foreach ($sorts as $id => $title) {
$i[] = $items[$id];
}
$output = theme('table', $header, $i);
return $output;
}