Index: yahoo_terms.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/yahoo_terms/yahoo_terms.module,v retrieving revision 1.1 diff -u -p -r1.1 yahoo_terms.module --- yahoo_terms.module 17 Apr 2007 19:14:17 -0000 1.1 +++ yahoo_terms.module 25 Sep 2007 02:27:49 -0000 @@ -166,7 +166,7 @@ function _yahoo_terms_create_vocabulary_ /** * The settings form */ -function yahoo_terms_settings() { +function yahoo_terms_admin_settings() { $form['yahoo_terms_appid'] = array( '#title' => t('Yahoo Application ID'), '#description' => t('An Application ID is a string that uniquely identifies your application. @@ -206,7 +206,7 @@ function yahoo_terms_settings() { '#required' => TRUE, '#default_value' => variable_get('yahoo_terms_vocab', ''), ); - return $form; + return system_settings_form($form); } /** @@ -233,14 +233,96 @@ function yahoo_terms_link($type, $node = */ function yahoo_terms_menu() { $items = array(); - $items[] = array('path' => 'yahoo_terms', 'title' => t('Extraction...'), - 'callback' => '_yahoo_terms_process_node', 'access' => user_access(YAHOO_TERMS_USE), - 'type' => MENU_CALLBACK); - $items[] = array('path' => 'yahoo_terms/batch', 'title' => t('Yahoo Terms batch processing'), - 'callback' => 'yahoo_terms_batch', 'access' => user_access(YAHOO_TERMS_USE) && user_access('administer nodes')); + $items[] = array( + 'path' => 'yahoo_terms', + 'title' => t('Extraction...'), + 'callback' => '_yahoo_terms_process_node', + 'access' => user_access(YAHOO_TERMS_USE), + 'type' => MENU_CALLBACK + ); + $items[] = array( + 'path' => 'yahoo_terms/batch', + 'title' => t('Yahoo Terms batch processing'), + 'callback' => 'yahoo_terms_batch', + 'access' => user_access(YAHOO_TERMS_USE) && user_access('administer nodes') + ); + $items[] = array( + 'path' => 'admin/settings/yahoo_terms', + 'title' => t('Yahoo Terms'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('yahoo_terms_admin_settings'), + 'access' => user_access('administer nodes'), + ); + $items[] = array( + 'path' => 'admin/settings/yahoo_terms/yahoo_devel', + 'callback' => 'yahoo_terms_devel_page', + 'access' => user_access('administer nodes'), + 'type' => MENU_CALLBACK, + ); return $items; } +function yahoo_terms_devel_page() { + $page = ""; + $page .= drupal_get_form('yahoo_terms_devel_form'); + if(isset($_REQUEST['yahoo_result'])) { + $page .= "

Results

"; + $results = unserialize($_REQUEST['yahoo_result']); + $out = ''; + foreach($results as $result) { + $out .= "
  • $result
  • "; + } + $out = ""; + $page .= "
    $out
    "; + } + return $page; +} + +/** + *Allows someone to send a raw request + *to yahoo terms. + */ +function yahoo_terms_devel_form() { + $form = array(); + $form['#multistep'] = true; + $form['#redirect'] = false; + $form['yahoo_terms_max'] = array( + '#type' => 'textfield', + '#title' => t('Maximum term results'), + '#default_value' => -1 + ); + $form['yahoo_terms_request'] = array( + '#type' => 'textfield', + '#title' => t('Yahoo! Terms Request'), + '#request' => true, + '#default_value' => $_POST['yahoo_term_request'] + ); + $form['yahoo_terms_context'] = array( + '#type' => 'textarea', + '#title' => t('Context'), + '#default_value' => $_POST['yahoo_terms_context'] + ); + $form['yahoo_terms_blacklist'] = array( + '#type' => 'textarea', + '#title' => t('Blacklist'), + '#default_value' => $_POST['yahoo_terms_blacklist'] + ); + $form['send'] = array( + '#type' => 'submit', + '#value' => t('Submit Request') + ); + return $form; +} + +function yahoo_terms_devel_form_submit($form_id, $form_values) { + $terms = $form_values['yahoo_terms_request']; + $blacklist = explode("\n", $form_values['yahoo_terms_blacklist']); + $result = yahoo_terms_text_get_keywords($form_values['yahoo_terms_context'], $terms, $form_values['yahoo_terms_max'], $blacklist); + drupal_set_message(t('Found %term_count terms.', array('%term_count' => count($result)))); + $_REQUEST['yahoo_result'] = serialize($result); + return; +} + /** * Do the term assigning to the given node in the argument *