diff -u -x tags -Nru whois-409552-1/whois_domain_status.tpl.php whois-if3/whois_domain_status.tpl.php --- whois-409552-1/whois_domain_status.tpl.php 1970-01-01 01:00:00.000000000 +0100 +++ whois-if3/whois_domain_status.tpl.php 2009-06-23 14:20:18.000000000 +0200 @@ -0,0 +1,10 @@ + $address)) ; + } + else { + echo t('The domain %domain is registered', array('%domain' => $address)); + } + + diff -u -x tags -Nru whois-409552-1/whois.module whois-if3/whois.module --- whois-409552-1/whois.module 2009-06-23 14:09:38.000000000 +0200 +++ whois-if3/whois.module 2009-06-23 14:20:18.000000000 +0200 @@ -30,6 +30,17 @@ return array('access whois'); } +function whois_theme() { + return array( + 'whois_domain_status' => array( + 'template' => 'whois_domain_status', + 'arguments' => array('address' => NULL, // The address that was looked up + 'registered' => NULL, // Boolean, weather the domain is already registered + 'result_data' => NULL), // Full result data, optionally used in template to further customise the output + ), + ); +} + /** * Implementation of hook_menu() */ @@ -66,10 +77,11 @@ '#type' => 'radios', '#title' => t('Output method'), '#default_value' => variable_get('whois_output_method', 'html'), - '#description' => t(''), + '#description' => t('The style in which the whois results are presented to the user.'), '#options' => array( 'basic' => 'Basic', 'html' => 'HTMLized', + 'html_status' => 'HTMLized status only', 'object' => 'PHP object', ), ); @@ -95,13 +107,16 @@ } function whois_whois_page() { + if (!user_access('access whois')) { + return; + } + $output = ''; $address = $_POST['address'] ? whois_parse_url($_POST['address']) : arg(1); if (isset($address)) { // Check for hourly threshold. if (flood_is_allowed('whois', variable_get('whois_hourly_threshold', 13))) { - $output .= '

' . t('Whois lookup for %address:', array('%address' => $address)) . '

'; $output .= whois_display_whois($address); } else { @@ -126,6 +141,32 @@ return drupal_get_form('whois_whois_form') . '
' . $output . '
'; } +/** + * Implementation of hook_block(). + */ +function whois_block($op = 'list', $delta = 0) { + + // listing of blocks, such as on the admin/block page + if ($op == "list") { + $block[0]["info"] = t('Whois mini form'); + return $block; + } + elseif ($op == 'view') { + + switch ($delta) { + case 0: + $block['subject'] = 'Whois'; + $block_content = drupal_get_form('whois_whois_mini_form'); + break; + } + $block['content'] = $block_content; + return $block; + } +} // end whois_block + +/** + * Implementation of hook_form(). + */ function whois_whois_form() { $form = array(); @@ -152,6 +193,27 @@ return $form; } +/** + * Implementation of hook_form(). + * + * Produce a form for the mini_form block + */ +function whois_whois_mini_form() { + $form = array(); + + $form['whois_address'] = array( + '#type' => 'textfield', + '#size' => 15, + '#required' => TRUE, + ); + $form['whois_submit'] = array( + '#type' => 'submit', + '#value' => t('Lookup'), + ); + + return $form; +} + function whois_whois_form_submit($form, &$form_state) { global $user; $address = whois_parse_url($form_state['values']['whois_address']); @@ -160,6 +222,15 @@ return; } +/* + * Wrapper around whois_whois_form_submit + */ +function whois_whois_mini_form_submit($form, &$form_state) { + whois_whois_form_submit($form, $form_state); + return; +} + + function whois_display_whois($address) { $data = ''; $result = whois_get_whois($address); @@ -167,6 +238,7 @@ $option = variable_get('whois_output_method', 'html'); switch ($option) { case 'html': + $data .= '

' . t('Whois lookup for %address:', array('%address' => $address)) . '

'; if (!empty($result['rawdata'])) { $utils = new utils; $data .= $utils->showHTML($result); @@ -174,9 +246,19 @@ else { $data .= implode($whois->Query['errstr'], "\n
"); } + break; + + case 'html_status': + if (!empty($result['rawdata'])) { + $data .= theme('whois_domain_status', $address, $result['regrinfo']['registered'] != 'no', $result); + } + else { + $data .= implode($whois->Query['errstr'], "\n
"); + } break; case 'object': + $data .= '

' . t('Whois lookup for %address:', array('%address' => $address)) . '

'; if ($whois->Query['status'] < 0) { $data .= implode($whois->Query['errstr'], "\n
"); } @@ -186,13 +268,14 @@ } break; - case 'basic': // 'basic' is the default + case 'basic': // 'basic' is the default default: + $data .= '

' . t('Whois lookup for %address:', array('%address' => $address)) . '

'; if (!empty($result['rawdata'])) { $data .= '
' . implode($result['rawdata'], "\n") . '
'; } else { - $data .= implode($whois->Query['errstr'], "\n
Query['errstr'], "\n
"); } break; }