You are here

function total_control_taxonomy_content_type_render in Total Control Admin Dashboard 6.2

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

Run-time rendering of the body of the block.

Parameters

$subtype:

$conf: Configuration as done at admin time.

$args:

$context: Context - in this case we don't have any.

Return value

An object with at least title and content members.

1 string reference to 'total_control_taxonomy_content_type_render'
taxonomy.inc in plugins/content_types/taxonomy.inc
taxonomy.inc

File

plugins/content_types/taxonomy.inc, line 64
taxonomy.inc

Code

function total_control_taxonomy_content_type_render($subtype, $conf, $panel_args, &$context) {
  if (!module_exists('taxonomy')) {
    return;
  }
  $vids = isset($conf['vids']) ? $conf['vids'] : array();
  $vocabs = taxonomy_get_vocabularies();
  $access = user_access('administer taxonomy');
  $options = array(
    'query' => array(
      'destination' => 'admin/dashboard',
    ),
  );
  $header = array(
    'page' => t('Vocabulary'),
    'options' => array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  $rows = array();
  if (!empty($vocabs)) {
    foreach ($vocabs as $vocab) {

      // compare against vocab option on pane config
      if (in_array($vocab->vid, $vids) || !array_key_exists('vids', $conf)) {
        $term_query = db_query("SELECT count(*) FROM {term_data} WHERE vid = %d", $vocab->vid);
        $terms = format_plural(db_result($term_query), '1 term', '@count terms');
        if ($access) {
          $rows[] = array(
            'data' => array(
              t($vocab->name . ': ' . $terms),
              l('List terms', 'admin/content/taxonomy/' . $vocab->vid, $options),
              l('Add terms', 'admin/content/taxonomy/' . $vocab->vid . '/add/term', $options),
            ),
          );
        }
      }
    }
  }
  if ($access) {
    $link = l(t('Taxonomy administration'), 'admin/content/taxonomy');
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('There are no vocabularies to display.'),
        'colspan' => 3,
      ),
    );
  }
  $block = new stdClass();
  $block->module = t('total_control');
  $block->title = t('Administer Taxonomy');
  $block->content = theme('total_control_admin_table', $header, $rows, $link);
  return $block;
}