function bean_list in Bean (for Drupal 7) 7
1 string reference to 'bean_list'
- bean_menu in ./
bean.module - Implements hook_menu().
File
- includes/
bean.pages.inc, line 66 - Bean Functions
Code
function bean_list() {
$rows = array();
// Build the sortable table header.
$header = array(
'label' => array(
'data' => 'Label',
'type' => 'property',
'specifier' => 'label',
'sort' => 'asc',
),
'type' => array(
'data' => 'Type',
'type' => 'entity',
'specifier' => 'bundle',
),
'operations' => array(
'data' => t('Operations'),
),
);
$filters = bean_get_filter();
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'bean')
->tableSort($header)
->pager($filters['per_page']);
if (!empty($filters['types'])) {
$query
->entityCondition('bundle', $filters['types'], 'IN');
}
$result = $query
->execute();
if (!empty($result)) {
$beans = bean_load_multiple(array_keys($result['bean']));
}
else {
$beans = array();
}
foreach ($beans as $bean) {
$rows[$bean->bid] = array(
'label' => array(
'data' => array(
'#type' => 'link',
'#title' => $bean->label,
'#href' => 'block/' . $bean->delta,
),
),
'type' => check_plain($bean->type),
);
$destination = drupal_get_destination();
// Build a list of all the accessible operations for the current bean.
$operations = array();
if (entity_access('update', 'bean', $bean)) {
$operations['edit'] = array(
'title' => t('edit'),
'href' => 'block/' . $bean->delta . '/edit',
'query' => $destination,
);
}
if (entity_access('delete', 'bean', $bean)) {
$operations['delete'] = array(
'title' => t('delete'),
'href' => 'block/' . $bean->delta . '/delete',
'query' => $destination,
);
}
// Render an unordered list of operations links.
$rows[$bean->bid]['operations'] = array(
'data' => array(
'#theme' => 'links__bean_operations',
'#links' => $operations,
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
),
);
}
$output = array(
'bean_filter_form' => drupal_get_form('bean_filter_form'),
'bean_content' => array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('There are no Block Available'),
),
'pager' => array(
'#theme' => 'pager',
),
);
return $output;
}