You are here

function total_control_taxonomy_content_type_render in Total Control Admin Dashboard 7.2

Same name and namespace in other branches
  1. 6.2 plugins/content_types/taxonomy.inc \total_control_taxonomy_content_type_render()
  2. 6 plugins/content_types/taxonomy.inc \total_control_taxonomy_content_type_render()

Run-time rendering of the body of the block.

File

plugins/content_types/taxonomy.inc, line 41

Code

function total_control_taxonomy_content_type_render($subtype, $conf, $panel_args, &$context) {
  if (!module_exists('taxonomy')) {
    return;
  }
  $block = new stdClass();
  $block->module = t('total_control');
  $block->title = t('Manage Taxonomy');
  $vids = isset($conf['vids']) ? $conf['vids'] : array();
  $vocabs = taxonomy_get_vocabularies();
  $options = array(
    'query' => array(
      'destination' => 'admin/dashboard',
    ),
  );
  $header = array(
    array(
      'data' => t('Vocabulary'),
    ),
    array(
      'data' => t('Operations'),
      'colspan' => 3,
    ),
  );
  $rows = array();
  if (!empty($vocabs)) {
    foreach ($vocabs as $vocab) {
      if (in_array($vocab->vid, $vids) || !array_key_exists('vids', $conf)) {
        $term_count = db_query("SELECT count(*) FROM {taxonomy_term_data} WHERE vid = :vid", array(
          ':vid' => $vocab->vid,
        ))
          ->fetchField();
        if (user_access('administer taxonomy') || user_access('edit terms in ' . $vocab->vid)) {
          $terms = format_plural($term_count, '1 categories', '@count categories');
          $rows[] = array(
            'data' => array(
              t($vocab->name . ': ' . $terms),
              l(t('Configure'), 'admin/structure/taxonomy/' . $vocab->machine_name . '/edit', $options),
              l(t('Manage categories'), 'admin/structure/taxonomy/' . $vocab->machine_name, $options),
              l(t('Add new category'), 'admin/structure/taxonomy/' . $vocab->machine_name . '/add', $options),
            ),
          );
        }
      }
    }
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('There are no vocabularies to display.'),
        'colspan' => 4,
      ),
    );
  }
  $link = '';
  if (user_access('administer taxonomy')) {
    $link = l(t('Taxonomy administration'), 'admin/structure/taxonomy');
  }
  $block->content = theme('total_control_admin_table', array(
    'header' => $header,
    'rows' => $rows,
    'link' => $link,
  ));
  return $block;
}