function panels_page_list_page in Panels 6.2
Same name and namespace in other branches
- 5.2 panels_page/panels_page.admin.inc \panels_page_list_page()
Provide a list of panels, with links to edit or delete them.
TODO Since we've already got the views dependency, should we just do this as a view?
1 string reference to 'panels_page_list_page'
- panels_page_admin_static_menu_items in panels_page/
panels_page.menu.inc - Define and return all the static administrative pages for hook_menu().
File
- panels_page/
panels_page.admin.inc, line 16 - panels_page.admin.inc
Code
function panels_page_list_page() {
panels_page_load_include('read');
panels_load_include('plugins');
$layouts = panels_get_layouts();
$items = array();
$sorts = array();
$header = array(
array(
'data' => t('Page title'),
'field' => 'title',
),
array(
'data' => t('Name'),
'field' => 'name',
'sort' => 'asc',
),
array(
'data' => t('Type'),
'field' => 'type',
),
t('Layout'),
array(
'data' => t('URL'),
'field' => 'url',
),
t('Operations'),
);
// Load all panel pages and their primary displays.
$panel_pages = panels_page_load_all();
$dids = array();
foreach ($panel_pages as $panel_page) {
if (empty($panel_page->display)) {
$dids[] = $panel_page->did;
}
}
$displays = panels_load_displays($dids);
foreach ($panel_pages as $panel_page) {
$ops = array();
if (empty($panel_page->disabled)) {
$ops[] = l(t('Edit'), "admin/panels/panel-page/{$panel_page->name}/edit");
$ops[] = l(t('Export'), "admin/panels/panel-page/{$panel_page->name}/edit/export");
}
if ($panel_page->type != t('Default')) {
$text = $panel_page->type == t('Overridden') ? t('Revert') : t('Delete');
$ops[] = l($text, "admin/panels/panel-page/{$panel_page->name}/delete");
}
else {
if (empty($panel_page->disabled)) {
$ops[] = l(t('Disable'), "admin/panels/panel-page/disable/{$panel_page->name}", array(
'query' => drupal_get_destination(),
));
}
else {
$ops[] = l(t('Enable'), "admin/panels/panel-page/enable/{$panel_page->name}", array(
'query' => drupal_get_destination(),
));
}
}
$path = empty($panel_page->disabled) && strpos($panel_page->path, '%') === FALSE ? l($panel_page->path, $panel_page->path) : check_plain($panel_page->path);
$item = array();
$item[] = check_plain(panels_page_get_title($panel_page));
$item[] = check_plain($panel_page->name);
// this is safe as it's always programmatic
$item[] = $panel_page->type;
if ($panel_page->type == t('Default')) {
$panel_page->display =& $panel_page->primary;
}
else {
$panel_page->display = $displays[$panel_page->did];
}
$item[] = check_plain($layouts[$panel_page->display->layout]['title']);
$item[] = $path;
$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_page->type . $item[0];
break;
case 'url':
$sorts[] = $panel_page->path;
break;
}
}
if (!empty($ts['sort']) && 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;
}