function boxes_list in Boxes 7.2
Render a listing of all Boxes.
1 string reference to 'boxes_list'
- boxes_menu in ./
boxes.module - Implements hook_menu().
File
- includes/
boxes.pages.inc, line 45 - Box Functions
Code
function boxes_list() {
$rows = array();
// Build the sortable table header.
$header = array(
'title' => array(
'data' => 'Title',
'type' => 'property',
'specifier' => 'title',
'sort' => 'asc',
),
'type' => array(
'data' => 'Type',
'type' => 'entity',
'specifier' => 'bundle',
),
'operations' => array(
'data' => t('Operations'),
),
);
$filters = boxes_get_filter();
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'box')
->tableSort($header)
->pager($filters['per_page']);
if (!empty($filters['types'])) {
$query
->entityCondition('bundle', $filters['types'], 'IN');
}
$result = $query
->execute();
if (!empty($result)) {
$boxes = boxes_load_multiple(array_keys($result['box']));
}
else {
$boxes = array();
}
foreach ($boxes as $box) {
$rows[$box->bid] = array(
'title' => array(
'data' => array(
'#type' => 'link',
'#title' => $box->label,
'#href' => 'block/' . $box->delta,
),
),
'type' => check_plain($box->type),
);
$destination = drupal_get_destination();
// Build a list of all the accessible operations for the current box.
$operations = array();
$operations['edit'] = array(
'title' => t('edit'),
'href' => 'block/' . $box->delta . '/edit',
'query' => $destination,
);
$operations['delete'] = array(
'title' => t('delete'),
'href' => 'block/' . $box->delta . '/delete',
'query' => $destination,
);
// Render an unordered list of operations links.
$rows[$box->bid]['operations'] = array(
'data' => array(
'#theme' => 'links__boxes_operations',
'#links' => $operations,
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
),
);
}
$output = array(
'boxes_filter_form' => drupal_get_form('boxes_filter_form'),
'boxes_content' => array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('There are no Block Available'),
),
'pager' => array(
'#theme' => 'pager',
),
);
return $output;
}