You are here

function kwresearch_keyword_pages_page in Keyword Research 6

Same name and namespace in other branches
  1. 7 kwresearch.admin.inc \kwresearch_keyword_pages_page()

Generates table of pages assoicated with a keyword

Parameters

int $kid:

1 string reference to 'kwresearch_keyword_pages_page'
kwresearch_menu in ./kwresearch.module
Implementation of hook_menu().

File

./kwresearch.admin.inc, line 549
Admin include file.

Code

function kwresearch_keyword_pages_page($kid) {
  drupal_add_css(drupal_get_path('module', 'kwresearch') . '/kwresearch.css');
  drupal_set_title('Keyword pages');
  $keyword_obj = kwresearch_load_site_keyword($kid);
  $output = t('Keyword: @keyword', array(
    '@keyword' => $keyword_obj->keyword,
  ));
  $rows = array();

  //dsm($filter);
  $header = array(
    array(
      'data' => t('Page'),
      'field' => 'k.page',
    ),
    array(
      'data' => t('Nid'),
      'field' => 'pk.nid',
    ),
    array(
      'data' => t('Page priority'),
      'field' => 'pk.priority',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Operations'),
    ),
  );
  $sql = '
    SELECT pk.*
    FROM {kwresearch_page_keyword} pk
    WHERE kid = %d
  ';
  $tablesort = tablesort_sql($header);
  $sql = $sql . $tablesort;
  $result = pager_query($sql, 100, 0, NULL, $kid);
  $priorities = kwresearch_get_priority_options();
  while ($r = db_fetch_object($result)) {
    if (!$r->path && $r->nid) {
      $r->path = 'node/' . $r->nid;
    }
    $rows[] = array(
      'data' => array(
        // Cells
        l(drupal_get_path_alias($r->path), $r->path),
        l($r->nid, 'node/' . $r->nid),
        $priorities[$r->priority],
        l(t('keywords'), 'admin/content/kwresearch/page_keywords/' . $r->nid, array(
          'query' => 'destination=admin/content/kwresearch/keywords_pages',
        )),
      ),
      // Attributes for tr
      'class' => "kwresearch",
    );
  }
  if (!$rows) {
    $rows[] = array(
      array(
        'data' => t('No pages are associated with this keyword.'),
        'colspan' => count($header),
      ),
    );
  }
  $output .= theme('table', $header, $rows, array(
    'id' => 'kwresearch-site-keywords',
  ));
  $output .= theme('pager', NULL, 100, 0);
  return $output;
}