You are here

function total_control_taxonomy_content_type_render in Total Control Admin Dashboard 6

Same name and namespace in other branches
  1. 6.2 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()

File

plugins/content_types/taxonomy.inc, line 29

Code

function total_control_taxonomy_content_type_render($subtype, $conf, $panel_args, &$context) {
  $block = new stdClass();
  $block->module = t('total_control');
  $vids = isset($conf['vids']) ? $conf['vids'] : array();
  $vocabs = taxonomy_get_vocabularies();
  $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');
        $rows[$vocab->vid] = $vocab->name . ': ' . $terms;
        if (user_access('administer taxonomy')) {
          $rows[$vocab->vid] .= ' | ' . l('list terms', 'admin/content/taxonomy/' . $vocab->vid);
          $rows[$vocab->vid] .= ' | ' . l('add term', 'admin/content/taxonomy/' . $vocab->vid . '/add/term');
        }

        // if access
      }

      // if vocab
    }

    // foreach
  }
  $pane = total_control_taxonomy_ctools_content_types();
  if ($rows) {
    $output = theme('item_list', $rows);
  }
  else {
    $output = t('You have no vocabularies yet. ');
    if (user_access('administer taxonomy')) {
      $output .= '<div class="add-vocab">' . l(t('Add vocabulary'), 'admin/content/taxonomy/add/vocabulary') . '</div>';
    }
  }

  // assemble content
  $content = '<div class="total-control-content-overview">';
  $content .= '  <h2 class="title">' . $pane['title'] . '</h2>';
  $content .= '  <div class="content">';
  $content .= $output;
  $content .= '  </div>';
  $content .= '</div>';
  $block->content = $content;
  return $block;
}