api_page_function

Versions
5
api_page_function($branch_name, $object_name)
6
api_page_function($function)

Menu callback; displays documentation for a function.

Code

contributions/api/api.module, line 667

<?php
function api_page_function($branch_name, $object_name) {
  drupal_add_css(drupal_get_path('module', 'api') .'/api.css');

  $result = db_query("SELECT d.did, d.title, d.file_name, d.documentation, d.code, f.signature, f.start_line, f.parameters, f.return FROM {api_documentation} d INNER JOIN {api_function} f ON d.did = f.did WHERE d.object_name = '%s' AND d.branch_name = '%s' AND d.object_type = 'function'", $object_name, $branch_name);
  if ($function = db_fetch_object($result)) {
    $output = '';

    $output .= '<h3>'. t('Definition') .'</h3>';
    $output .= '<p><small>'. $function->signature .'</small><br />';
    $output .= l($function->file_name, 'api/file/'. $function->file_name .'/'. $branch_name) .', '. t('line') .' '. $function->start_line .'</p>';

    if (!empty($function->documentation)) {
      $output .= '<h3>'. t('Description') .'</h3>';
      $output .= api_link_documentation($function->documentation, $branch_name);
    }

    if (!empty($function->parameters)) {
      $output .= '<h3>'. t('Parameters') .'</h3>';
      $output .= api_link_documentation($function->parameters, $branch_name);
    }

    if (!empty($function->return)) {
      $output .= '<h3>'. t('Return value') .'</h3>';
      $output .= api_link_documentation($function->return, $branch_name);
    }

    $headers = array(array('data' => t('Name'), 'field' => 'd.title'), t('Description'));
    $rows = array();
    $result = db_query("SELECT d.object_name, d.title, d.summary FROM {api_reference_storage} r INNER JOIN {api_documentation} d ON r.to_did = d.did AND d.object_type = 'group' WHERE r.from_did = %d". tablesort_sql($headers), $function->did);
    while ($group = db_fetch_object($result)) {
      $rows[] = array(
        l($group->title, 'api/group/'. $group->object_name .'/'. $branch_name),
        api_link_documentation($group->summary, $branch_name));
    }
    if (count($rows) > 0) {
      $output .= '<h3>'. t('Related topics') .'</h3>';
      $output .= theme('table', $headers, $rows);
    }

    if (!empty($function->code)) {
      $output .= '<h3>'. t('Code') .'</h3>';
      $output .= api_link_code($function->code, $branch_name);
    }

    drupal_set_title($function->title);
    return $output;
  }
  else {
    drupal_not_found();
  }
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.