function page_manager_list_pages_form_submit in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 page_manager/page_manager.admin.inc \page_manager_list_pages_form_submit()
Accept submission from the page manager sort/filter form and apply it to the list of pages.
File
- page_manager/
page_manager.admin.inc, line 316 - Administrative functions for the page manager.
Code
function page_manager_list_pages_form_submit(&$form, &$form_state) {
// Filter and re-sort the pages.
// This is a copy.
$rows = $form_state['pages']['rows'];
$sorts = array();
foreach ($rows as $name => $data) {
// Filter
if ($form_state['values']['type'] != 'all' && $form_state['values']['type'] != $data['data']['type']['data']) {
continue;
}
if ($form_state['values']['storage'] != 'all' && $form_state['values']['storage'] != $data['data']['storage']['data']) {
continue;
}
if ($form_state['values']['disabled'] != 'all' && $form_state['values']['disabled'] != $form_state['pages']['disabled'][$name]) {
continue;
}
if ($form_state['values']['search'] && strpos($data['data']['name']['data'], $form_state['values']['search']) === FALSE && strpos($data['data']['path']['data'], $form_state['values']['search']) === FALSE && strpos($data['data']['title']['data'], $form_state['values']['search']) === FALSE) {
continue;
}
// Set up sorting
switch ($form_state['values']['order']) {
case 'disabled':
$sorts[$name] = !$form_state['pages']['disabled'][$name] . $data['data']['title']['data'];
break;
case 'title':
$sorts[$name] = $data['data']['title']['data'];
break;
case 'name':
$sorts[$name] = $data['data']['name']['data'];
break;
case 'path':
$sorts[$name] = $data['data']['path']['data'];
break;
case 'type':
$sorts[$name] = $data['data']['type']['data'];
break;
case 'storage':
$sorts[$name] = $data['data']['storage']['data'];
break;
}
}
// Now actually sort
if ($form_state['values']['sort'] == 'desc') {
arsort($sorts);
}
else {
asort($sorts);
}
// Nuke the original.
$form_state['pages']['rows'] = array();
// And restore.
foreach ($sorts as $name => $title) {
$form_state['pages']['rows'][$name] = $rows[$name];
}
}