function uc_attribute_admin in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_attribute/uc_attribute.module \uc_attribute_admin()
- 7.3 uc_attribute/uc_attribute.admin.inc \uc_attribute_admin()
Displays a paged list and overview of existing product attributes.
1 string reference to 'uc_attribute_admin'
- uc_attribute_menu in uc_attribute/
uc_attribute.module - Implements hook_menu().
File
- uc_attribute/
uc_attribute.admin.inc, line 11 - Attribute administration menu items.
Code
function uc_attribute_admin() {
$header = array(
array(
'data' => t('Name'),
'field' => 'name',
'sort' => 'asc',
),
array(
'data' => t('Label'),
'field' => 'label',
),
t('Required'),
array(
'data' => t('List position'),
'field' => 'ordering',
),
t('Number of options'),
t('Display type'),
t('Operations'),
);
$display_types = _uc_attribute_display_types();
$rows = array();
$result = pager_query("SELECT aid, name, label, required, ordering, display FROM {uc_attributes}" . tablesort_sql($header), 30, 0);
while ($attr = db_fetch_object($result)) {
$attr->options = db_result(db_query('SELECT COUNT(*) FROM {uc_attribute_options} WHERE aid = %d', $attr->aid));
if (empty($attr->label)) {
$attr->label = $attr->name;
}
$ops = array(
l(t('edit'), 'admin/store/attributes/' . $attr->aid . '/edit'),
l(t('options'), 'admin/store/attributes/' . $attr->aid . '/options'),
l(t('delete'), 'admin/store/attributes/' . $attr->aid . '/delete'),
);
$rows[] = array(
check_plain($attr->name),
check_plain($attr->label),
$attr->required == 1 ? t('Yes') : t('No'),
array(
'data' => $attr->ordering,
'align' => 'center',
),
array(
'data' => $attr->options,
'align' => 'center',
),
$display_types[$attr->display],
implode(' ', $ops),
);
}
if (count($rows) == 0) {
$rows[] = array(
array(
'data' => t('No product attributes have been added yet.'),
'colspan' => '6',
),
);
}
$output = theme('table', $header, $rows) . theme('pager', NULL, 30) . l(t('Add an attribute'), 'admin/store/attributes/add');
return $output;
}