class UserBadgeUIController in User Badges 7.4
Custom controller for the administrator UI
Hierarchy
- class \EntityDefaultUIController
- class \UserBadgeUIController
Expanded class hierarchy of UserBadgeUIController
1 string reference to 'UserBadgeUIController'
- user_badges_entity_info in ./
user_badges.module - Implements hook_entity_info().
File
- ./
user_badges.module, line 1318 - Hooks and other stuff related to user badge.
View source
class UserBadgeUIController extends EntityDefaultUIController {
/**
* Override the menu hook for default ui controller.
*/
public function hook_menu() {
$items = parent::hook_menu();
$items[$this->path]['description'] = t('Manage User Badge');
$items[$this->path]['title'] = t('User Badges');
return $items;
}
/**
* Admin form for searching and doing bulk operations.
*/
public function overviewForm($form, &$form_state) {
$form['pager'] = array(
'#theme' => 'pager',
);
$header = array(
'name' => array(
'data' => t('Name'),
'field' => 'name',
),
'weight' => array(
'data' => t('Weight'),
'field' => 'weight',
),
'operations' => array(
'data' => t('Operations'),
'field' => 'operations',
),
);
$items = array();
$search_term = !empty($_GET['search']) ? $_GET['search'] : NULL;
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'user_badge');
if (!empty($search_term)) {
$query
->propertyCondition('name', '%' . $search_term . '%', 'like');
}
// Check for sort order and sort key.
if (!empty($_GET['sort']) && !empty($_GET['order'])) {
$sort = strtoupper($_GET['sort']);
$order = strtolower($_GET['order']);
$order = str_replace(' ', '_', $order);
if ($order != 'operations') {
$query
->propertyOrderBy($order, $sort);
}
}
$query
->pager(10);
$result = $query
->execute();
$user_badge_results = !empty($result['user_badge']) ? $result['user_badge'] : array();
$user_badge_array = !empty($user_badge_results) ? user_badge_load_multiple(array_keys($user_badge_results)) : array();
foreach ($user_badge_array as $bid => $user_badge) {
$items['bid-' . $bid] = array(
'name' => l($user_badge->name, 'user-badge/' . $user_badge->bid),
'weight' => $user_badge->weight,
'operations' => l(t('View'), 'user-badge/' . $user_badge->bid) . ' ' . l(t('Edit'), USER_BADGES_ADMIN_USER_BADGES_MANAGE_URI . $bid, array(
'query' => array(
'destination' => USER_BADGES_ADMIN_USER_BADGES_URI,
),
)) . ' ' . l(t('Delete'), USER_BADGES_ADMIN_USER_BADGES_MANAGE_URI . $bid . '/delete', array(
'attributes' => array(
'class' => array(
'user_badge_delete-' . $user_badge->bid,
),
),
'query' => array(
'destination' => USER_BADGES_ADMIN_USER_BADGES_URI,
),
)),
);
}
$form['search'] = array(
'#type' => 'fieldset',
'#title' => t('Basic Search'),
'#collapsible' => TRUE,
'#collapsed' => !empty($search_term) ? FALSE : TRUE,
);
$form['search']['search_text'] = array(
'#type' => 'textfield',
'#title' => t('Search Term'),
'#default_value' => !empty($search_term) ? $search_term : '',
);
$form['search']['search_submit'] = array(
'#type' => 'submit',
'#value' => t('Search'),
);
$form['bulk_operations'] = array(
'#type' => 'fieldset',
'#title' => t('Bulk Operations'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['bulk_operations']['operations'] = array(
'#type' => 'select',
'#options' => array(
0 => t('Select a bulk operation'),
'delete' => t('Delete selected user badge'),
),
);
$form['bulk_operations']['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
$form['entities'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $items,
'#attributes' => array(
'class' => array(
'entity-sort-table',
),
),
'#empty' => t('There are no user badge.'),
);
return $form;
}
/**
* Form Submit method.
*/
public function overviewFormSubmit($form, &$form_state) {
$values = $form_state['values'];
$bids = array();
if (!empty($values['entities'])) {
foreach ($values['entities'] as $index => $value) {
if (!empty($value)) {
$bids[] = str_replace('bid-', '', $value);
}
}
switch ($values['operations']) {
case 'delete':
drupal_goto('admin/content/user_badge/bulk/delete/' . implode('|', $bids));
break;
}
}
if (!empty($values['search_text'])) {
drupal_goto('admin/content/user_badge', array(
'query' => array(
'search' => $values['search_text'],
),
));
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityDefaultUIController:: |
protected | property | ||
EntityDefaultUIController:: |
protected | property | ||
EntityDefaultUIController:: |
protected | property | ||
EntityDefaultUIController:: |
public | property | Defines the number of entries to show per page in overview table. | |
EntityDefaultUIController:: |
public | function | Applies an operation to the given entity. | |
EntityDefaultUIController:: |
public | function | Entity submit builder invoked via entity_ui_form_submit_build_entity(). | |
EntityDefaultUIController:: |
public | function | Provides definitions for implementing hook_forms(). | |
EntityDefaultUIController:: |
protected | function | Returns the operation count for calculating colspans. | |
EntityDefaultUIController:: |
public | function | Builds the operation form. | |
EntityDefaultUIController:: |
public | function | Operation form submit callback. | 1 |
EntityDefaultUIController:: |
public | function | Operation form validation callback. | |
EntityDefaultUIController:: |
public | function | Overview form validation callback. | |
EntityDefaultUIController:: |
public | function | Generates the render array for a overview table for arbitrary entities matching the given conditions. | |
EntityDefaultUIController:: |
protected | function | Generates the table headers for the overview table. | |
EntityDefaultUIController:: |
protected | function | Generates the row for the passed entity and may be overridden in order to customize the rows. | |
EntityDefaultUIController:: |
public | function | ||
UserBadgeUIController:: |
public | function |
Override the menu hook for default ui controller. Overrides EntityDefaultUIController:: |
|
UserBadgeUIController:: |
public | function |
Admin form for searching and doing bulk operations. Overrides EntityDefaultUIController:: |
|
UserBadgeUIController:: |
public | function |
Form Submit method. Overrides EntityDefaultUIController:: |