You are here

function kwresearch_analyzer_form_elements in Keyword Research 6

Same name and namespace in other branches
  1. 7 includes/contentanalysis.inc \kwresearch_analyzer_form_elements()

Implementation of hook_analyzer_form_elements() via custom define callback

hook to add any analyzier specific form elements to the content analyzer form. callback is defined in hook_contentanalysis_analyzers ['form elements callback']

Parameters

$form_state: Array defined by form_api

$analysis: Array analysis formated array defined in conentanalysis

$node: Node object

1 string reference to 'kwresearch_analyzer_form_elements'
kwresearch_contentanalysis_analyzers in includes/contentanalysis.inc
Implentation of hook_contentanalysis_analyzers() register contentanalysisexample with contentanalysis analyzers registry

File

includes/contentanalysis.inc, line 36
Contains Content Analysis integration functions

Code

function kwresearch_analyzer_form_elements($form_state, $analysis = '', $node = NULL) {

  //dsm($form_state);

  //dsm($node);
  drupal_add_css(drupal_get_path('module', 'kwresearch') . '/kwresearch.css');
  drupal_add_js(drupal_get_path('module', 'kwresearch') . '/kwresearch.js');
  $site_kw = array();
  $sql = '
    SELECT * FROM {kwresearch_keyword}
    WHERE priority > 0
  ';
  $res = db_query($sql);
  while ($r = db_fetch_object($res)) {
    $site_kw[$r->keyword] = array(
      'priority' => (int) $r->priority,
      'value' => (int) $r->value,
    );
  }
  $page_kw = array();
  if ($node->nid) {
    $sql = '
      SELECT p.*, k.keyword
      FROM {kwresearch_page_keyword} p
      JOIN {kwresearch_keyword} k ON k.kid = p.kid
      WHERE nid = %d
    ';
    $res = db_query($sql, $nid);
    while ($r = db_fetch_object($res)) {
      $page_kw[$r->keyword] = array(
        'priority' => (int) $r->priority,
      );
    }
  }
  $site_priority_options = kwresearch_get_priority_options();
  $page_priority_options = kwresearch_get_priority_options();
  drupal_add_js(array(
    'kwresearch' => array(
      'form' => 'node_edit',
      'analyze_callback' => base_path() . 'kwresearch/analyze_js',
      'toggle_site_keyword_callback' => base_path() . 'kwresearch/toggle_site_keyword_js',
      'toggle_page_keyword_callback' => base_path() . 'kwresearch/toggle_page_keyword_js',
      'module_path' => base_path() . drupal_get_path('module', 'kwresearch'),
      'keyword_tag_vocabulary' => variable_get('kwresearch_keyword_tag_vocabulary', ''),
      'keyword_sync_vocabulary' => variable_get('kwresearch_keyword_sync_vocabulary', ''),
      'enable_site_keyword_tool' => user_access('kwresearch admin site keywords'),
      'enable_page_keyword_tool' => user_access('kwresearch admin page keywords'),
      'site_keywords_data' => $site_kw,
      'page_keywords_data' => $page_kw,
      'site_priority_options' => $site_priority_options,
      'page_priority_options' => $page_priority_options,
    ),
  ), 'setting');

  //return $form;
}