You are here

function uc_attribute_admin in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_attribute/uc_attribute.admin.inc \uc_attribute_admin()
  2. 7.3 uc_attribute/uc_attribute.admin.inc \uc_attribute_admin()
1 string reference to 'uc_attribute_admin'
uc_attribute_menu in uc_attribute/uc_attribute.module
Implementation of hook_menu().

File

uc_attribute/uc_attribute.module, line 401

Code

function uc_attribute_admin() {
  $header = array(
    array(
      'data' => t('Name'),
      'field' => 'a.name',
      'sort' => 'asc',
    ),
    t('Required'),
    array(
      'data' => t('Order'),
      'field' => 'a.ordering',
    ),
    t('Number of options'),
    t('Display type'),
    t('Operations'),
  );
  $display_types = _uc_attribute_display_types();
  $result = pager_query("SELECT a.aid, a.name, a.required, a.ordering, a.display, COUNT(ao.oid) AS options FROM {uc_attributes} AS a LEFT JOIN {uc_attribute_options} AS ao ON a.aid = ao.aid GROUP BY a.aid, a.name, a.ordering, a.required, a.display" . tablesort_sql($header), 30, 0, "SELECT COUNT(aid) FROM {uc_attributes}");
  while ($attr = db_fetch_object($result)) {
    $ops = array(
      l(t('edit'), 'admin/store/products/attributes/' . $attr->aid . '/edit'),
      l(t('options'), 'admin/store/products/attributes/' . $attr->aid . '/options'),
      l(t('delete'), 'admin/store/products/attributes/' . $attr->aid . '/delete'),
    );
    $rows[] = array(
      $attr->name,
      $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/products/attributes/add');
  return $output;
}