/[drupal]/contributions/modules/api/api.module
ViewVC logotype

Diff of /contributions/modules/api/api.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.88.2.42, Thu Oct 15 06:42:35 2009 UTC revision 1.88.2.43, Sun Oct 18 23:07:51 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: api.module,v 1.88.2.41 2009/10/15 05:52:59 drumm Exp $  // $Id: api.module,v 1.88.2.42 2009/10/15 06:42:35 drumm Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 146  function api_menu() { Line 146  function api_menu() {
146    $items['api/search'] = array(    $items['api/search'] = array(
147      'title' => 'API Search',      'title' => 'API Search',
148      'page callback' => 'drupal_get_form',      'page callback' => 'drupal_get_form',
149      'page arguments' => array('api_search_form', $default_branch->branch_name),      'page arguments' => array('api_search_form', $default_branch),
150      'access callback' => $access_callback,      'access callback' => $access_callback,
151      'access arguments' => $access_arguments,      'access arguments' => $access_arguments,
152      'type' => MENU_CALLBACK,      'type' => MENU_CALLBACK,
# Line 227  function api_menu() { Line 227  function api_menu() {
227    // Part 2: Object provided, default branch.    // Part 2: Object provided, default branch.
228    $items['api/function/%api_object'] = array(    $items['api/function/%api_object'] = array(
229      'title' => 'Function',      'title' => 'Function',
230      'load arguments' => array('function', $default_branch->branch_name),      'load arguments' => array('function', $default_branch),
231      'page callback' => 'api_page_function',      'page callback' => 'api_page_function',
232      'page arguments' => array($default_branch, 2),      'page arguments' => array($default_branch, 2),
233      'access callback' => $access_callback,      'access callback' => $access_callback,
# Line 236  function api_menu() { Line 236  function api_menu() {
236    );    );
237    $items['api/constant/%api_object'] = array(    $items['api/constant/%api_object'] = array(
238      'title' => 'Constant',      'title' => 'Constant',
239      'load arguments' => array('constant', $default_branch->branch_name),      'load arguments' => array('constant', $default_branch),
240      'page callback' => 'api_page_constant',      'page callback' => 'api_page_constant',
241      'page arguments' => array($default_branch, 2),      'page arguments' => array($default_branch, 2),
242      'access callback' => $access_callback,      'access callback' => $access_callback,
# Line 245  function api_menu() { Line 245  function api_menu() {
245    );    );
246    $items['api/global/%api_object'] = array(    $items['api/global/%api_object'] = array(
247      'title' => 'Global',      'title' => 'Global',
248      'load arguments' => array('global', $default_branch->branch_name),      'load arguments' => array('global', $default_branch),
249      'page callback' => 'api_page_global',      'page callback' => 'api_page_global',
250      'page arguments' => array($default_branch, 2),      'page arguments' => array($default_branch, 2),
251      'access callback' => $access_callback,      'access callback' => $access_callback,
# Line 255  function api_menu() { Line 255  function api_menu() {
255    
256    $items['api/' . $default_branch->project . '/%api_filename'] = array(    $items['api/' . $default_branch->project . '/%api_filename'] = array(
257      'title' => 'File',      'title' => 'File',
258      'load arguments' => array($default_branch->branch_name),      'load arguments' => array($default_branch),
259      'page callback' => 'api_page_file',      'page callback' => 'api_page_file',
260      'page arguments' => array($default_branch, 2),      'page arguments' => array($default_branch, 2),
261      'access callback' => $access_callback,      'access callback' => $access_callback,
# Line 265  function api_menu() { Line 265  function api_menu() {
265    
266    $items['api/group/%api_object'] = array(    $items['api/group/%api_object'] = array(
267      'title' => 'Topic',      'title' => 'Topic',
268      'load arguments' => array('group', $default_branch->branch_name),      'load arguments' => array('group', $default_branch),
269      'page callback' => 'api_page_group',      'page callback' => 'api_page_group',
270      'page arguments' => array($default_branch, 2),      'page arguments' => array($default_branch, 2),
271      'access callback' => $access_callback,      'access callback' => $access_callback,
# Line 280  function api_menu() { Line 280  function api_menu() {
280      'access arguments' => $access_arguments,      'access arguments' => $access_arguments,
281      'type' => MENU_CALLBACK,      'type' => MENU_CALLBACK,
282    );    );
   $items['api/suggest/%/%'] = array(  
     'page callback' => 'api_suggest',  
     'page arguments' => array(2, 3),  
     'access callback' => $access_callback,  
     'access arguments' => $access_arguments,  
     'type' => MENU_CALLBACK,  
   );  
283    
284    foreach ($branches as $branch) {    foreach ($branches as $branch) {
285        $items['api/suggest/' . $branch->branch_name . '/%'] = array(
286          'page callback' => 'api_suggest',
287          'page arguments' => array($branch, 3),
288          'access callback' => $access_callback,
289          'access arguments' => $access_arguments,
290          'type' => MENU_CALLBACK,
291        );
292      $items['api/autocomplete/' . $branch->branch_name] = array(      $items['api/autocomplete/' . $branch->branch_name] = array(
293        'page callback' => 'api_autocomplete',        'page callback' => 'api_autocomplete',
294        'page arguments' => array($branch->branch_name),        'page arguments' => array($branch),
295        'access callback' => $access_callback,        'access callback' => $access_callback,
296        'access arguments' => $access_arguments,        'access arguments' => $access_arguments,
297        'type' => MENU_CALLBACK,        'type' => MENU_CALLBACK,
# Line 350  function api_menu() { Line 350  function api_menu() {
350      // Part 4: Object provided, specific branch.      // Part 4: Object provided, specific branch.
351      $items['api/function/%api_object/'. $branch->branch_name] = array(      $items['api/function/%api_object/'. $branch->branch_name] = array(
352        'title' => $branch->title,        'title' => $branch->title,
353        'load arguments' => array('function', $branch->branch_name),        'load arguments' => array('function', $branch),
354        'page callback' => 'api_page_function',        'page callback' => 'api_page_function',
355        'page arguments' => array($branch, 2),        'page arguments' => array($branch, 2),
356        'access callback' => $access_callback,        'access callback' => $access_callback,
# Line 360  function api_menu() { Line 360  function api_menu() {
360    
361      $items['api/constant/%api_object/'. $branch->branch_name] = array(      $items['api/constant/%api_object/'. $branch->branch_name] = array(
362        'title' => $branch->title,        'title' => $branch->title,
363        'load arguments' => array('constant', $branch->branch_name),        'load arguments' => array('constant', $branch),
364        'page callback' => 'api_page_constant',        'page callback' => 'api_page_constant',
365        'page arguments' => array($branch, 2),        'page arguments' => array($branch, 2),
366        'access callback' => $access_callback,        'access callback' => $access_callback,
# Line 369  function api_menu() { Line 369  function api_menu() {
369      );      );
370      $items['api/global/%api_object/'. $branch->branch_name] = array(      $items['api/global/%api_object/'. $branch->branch_name] = array(
371        'title' => $branch->title,        'title' => $branch->title,
372        'load arguments' => array('global', $branch->branch_name),        'load arguments' => array('global', $branch),
373        'page callback' => 'api_page_global',        'page callback' => 'api_page_global',
374        'page arguments' => array($branch, 2),        'page arguments' => array($branch, 2),
375        'access callback' => $access_callback,        'access callback' => $access_callback,
# Line 379  function api_menu() { Line 379  function api_menu() {
379    
380      $items['api/' . $branch->project . '/%api_filename/'. $branch->branch_name] = array(      $items['api/' . $branch->project . '/%api_filename/'. $branch->branch_name] = array(
381        'title' => $branch->title,        'title' => $branch->title,
382        'load arguments' => array($branch->branch_name),        'load arguments' => array($branch),
383        'page callback' => 'api_page_file',        'page callback' => 'api_page_file',
384        'page arguments' => array($branch, 2),        'page arguments' => array($branch, 2),
385        'access callback' => $access_callback,        'access callback' => $access_callback,
# Line 388  function api_menu() { Line 388  function api_menu() {
388      );      );
389      $items['api/' . $branch->project . '/%api_filename/'. $branch->branch_name .'/documentation'] = array(      $items['api/' . $branch->project . '/%api_filename/'. $branch->branch_name .'/documentation'] = array(
390        'title' => 'View documentation',        'title' => 'View documentation',
391        'load arguments' => array($branch->branch_name),        'load arguments' => array($branch),
392        'type' => MENU_DEFAULT_LOCAL_TASK,        'type' => MENU_DEFAULT_LOCAL_TASK,
393        'weight' => -10,        'weight' => -10,
394      );      );
395      $items['api/' . $branch->project . '/%api_filename/'. $branch->branch_name .'/source'] = array(      $items['api/' . $branch->project . '/%api_filename/'. $branch->branch_name .'/source'] = array(
396        'title' => 'View source',        'title' => 'View source',
397        'load arguments' => array($branch->branch_name),        'load arguments' => array($branch),
398        'page callback' => 'api_page_file_source',        'page callback' => 'api_page_file_source',
399        'page arguments' => array($branch, 2),        'page arguments' => array($branch, 2),
400        'access callback' => $access_callback,        'access callback' => $access_callback,
# Line 404  function api_menu() { Line 404  function api_menu() {
404    
405      $items['api/group/%api_object/'. $branch->branch_name] = array(      $items['api/group/%api_object/'. $branch->branch_name] = array(
406        'title' => $branch->title,        'title' => $branch->title,
407        'load arguments' => array('group', $branch->branch_name),        'load arguments' => array('group', $branch),
408        'page callback' => 'api_page_group',        'page callback' => 'api_page_group',
409        'page arguments' => array($branch, 2),        'page arguments' => array($branch, 2),
410        'access callback' => $access_callback,        'access callback' => $access_callback,
# Line 423  function api_menu() { Line 423  function api_menu() {
423      // Function dumps for IDEs and code editors.      // Function dumps for IDEs and code editors.
424      $items['api/function_dump/'. $branch->branch_name] = array(      $items['api/function_dump/'. $branch->branch_name] = array(
425        'page callback' => 'api_page_function_dump',        'page callback' => 'api_page_function_dump',
426        'page arguments' => array($branch->branch_name),        'page arguments' => array($branch),
427        'access callback' => $access_callback,        'access callback' => $access_callback,
428        'access arguments' => $access_arguments,        'access arguments' => $access_arguments,
429        'type' => MENU_CALLBACK,        'type' => MENU_CALLBACK,
# Line 441  function api_menu() { Line 441  function api_menu() {
441    return $items;    return $items;
442  }  }
443    
444  function api_filename_load($file_name, $branch_name = NULL) {  function api_filename_load($file_name, $branch = NULL) {
445    return api_object_load(str_replace('--', '/', $file_name), 'file', $branch_name);    return api_object_load(str_replace('--', '/', $file_name), 'file', $branch);
446  }  }
447    
448  /**  /**
449   * Load an object from its name, type and branch.   * Load an object from its name, type and branch.
450   */   */
451  function api_object_load($object_name, $object_type, $branch_name = NULL) {  function api_object_load($object_name, $object_type, $branch = NULL) {
452    static $cache;    static $cache;
453    
454    if (is_null($branch_name)) {    if (is_null($branch)) {
455      $branches = api_get_branches();      $branches = api_get_branches();
456      $branch_name = $branches[variable_get('api_default_branch', NULL)]->branch_name;      $branch = $branches[variable_get('api_default_branch', NULL)];
457    }    }
458    
459    $key = $object_name .':'. $object_type .':'. $branch_name;    $key = $object_name .':'. $object_type .':'. $branch->branch_id;
460    if (!isset($cache[$key])) {    if (!isset($cache[$key])) {
461      // Prepare the query      // Prepare the query
462      $tables = array('{api_documentation} ad');      $tables = array('{api_documentation} ad');
463      $fields = array('ad.*');      $fields = array('ad.*');
464      $where = "WHERE ad.object_name = '%s' AND ad.object_type = '%s' AND ad.branch_name = '%s'";      $where = "WHERE ad.object_name = '%s' AND ad.object_type = '%s' AND ad.branch_id = %d";
465      $arguments = array($object_name, $object_type, $branch_name);      $arguments = array($object_name, $object_type, $branch->branch_id);
466    
467      if ($object_type == 'function') {      if ($object_type == 'function') {
468        $tables[] = 'LEFT JOIN {api_function} af ON (af.did = ad.did)';        $tables[] = 'LEFT JOIN {api_function} af ON (af.did = ad.did)';
# Line 614  function api_init() { Line 614  function api_init() {
614    // If we happen to be on an API node page, redirect.    // If we happen to be on an API node page, redirect.
615    if (($node = menu_get_object()) && $node->type == 'api') {    if (($node = menu_get_object()) && $node->type == 'api') {
616      $documentation = db_fetch_object(db_query('SELECT * FROM {api_documentation} WHERE did = %d', $node->nid));      $documentation = db_fetch_object(db_query('SELECT * FROM {api_documentation} WHERE did = %d', $node->nid));
617      drupal_goto("api/$documentation->object_type/$documentation->object_name/$documentation->branch_name");      drupal_goto('api/' . $documentation->object_type . '/' . $documentation->object_name . '/' . $documentation->branch_name);
618    }    }
619  }  }
620    
# Line 646  function api_block($op, $delta = NULL, $ Line 646  function api_block($op, $delta = NULL, $
646            if (user_access('access API reference') && !empty($branch)) {            if (user_access('access API reference') && !empty($branch)) {
647              return array(              return array(
648                'subject' => t('Search @branch', array('@branch' => $branch->title)),                'subject' => t('Search @branch', array('@branch' => $branch->title)),
649                'content' => drupal_get_form('api_search_form', $branch->branch_name),                'content' => drupal_get_form('api_search_form', $branch),
650              );              );
651            }            }
652            return;            return;
# Line 756  function api_save_branch($branch) { Line 756  function api_save_branch($branch) {
756    
757    // Reweight all branches.    // Reweight all branches.
758    $branches = api_get_branches(TRUE);    $branches = api_get_branches(TRUE);
759    uksort($branches, 'version_compare');    usort($branches, 'api_branch_sort');
760    $weight = 0;    $weight = 0;
761    foreach ($branches as $branch) {    foreach ($branches as $branch) {
762      $branch->weight = $weight;      $branch->weight = $weight;
763      $weight += 1;      $weight += 1;
764      drupal_write_record('api_branch', $branch, 'branch_name');      drupal_write_record('api_branch', $branch, 'branch_id');
765    }    }
766    
767    menu_rebuild();    menu_rebuild();
768  }  }
769    
770    function api_branch_sort($a, $b) {
771      return version_compare($a->branch_name, $b->branch_name);
772    }
773    
774  function api_get_active_branch() {  function api_get_active_branch() {
775    static $branch_id;    static $branch;
776    
777    if (!isset($branch_id)) {    if (!isset($branch)) {
778      if (arg(0) == 'api') {      if (arg(0) == 'api') {
779        if (in_array(arg(1), array('function_dump', 'functions', 'constants', 'globals', 'files', 'groups', 'search'))) {        if (in_array(arg(1), array('function_dump', 'functions', 'constants', 'globals', 'files', 'groups', 'search'))) {
780          $possible_branch = arg(2);          $possible_branch = arg(2);
# Line 784  function api_get_active_branch() { Line 788  function api_get_active_branch() {
788        }        }
789      }      }
790    
791        $branches = api_get_branches();
792      if (isset($possible_branch)) {      if (isset($possible_branch)) {
793        $branch_id = db_result(db_query("SELECT branch_id FROM {api_branch} WHERE branch_name = '%s'", $args[$end]));        foreach ($branches as $b) {
794            if ($b->branch_name === $possible_branch) {
795              $branch = $b;
796            }
797          }
798      }      }
799      if (empty($branch_id)) {      if (!isset($branch)) {
800        $branch_id = variable_get('api_default_branch', NULL);        $branch = $branches[variable_get('api_default_branch', NULL)];
801      }      }
802    }    }
803    
804    $branches = api_get_branches();    return $branch;
   return $branches[$branch_id];  
805  }  }
806    
807  function api_search_form($form_state, $branch_name) {  function api_search_form($form_state, $branch) {
808    drupal_add_js(array('apiAutoCompletePath' => base_path() . variable_get('api_autocomplete_path_' . $branch_name, url('api/autocomplete/' . $branch_name))), 'setting');    drupal_add_js(array('apiAutoCompletePath' => base_path() . variable_get('api_autocomplete_path_' . $branch->branch_name, url('api/autocomplete/' . $branch->branch_name))), 'setting');
809    $form = array(    $form = array(
810      '#token' => FALSE,      '#token' => FALSE,
811    );    );
812    
813    $form['branch_name'] = array(    $form['#branch'] = $branch;
     '#type' => 'value',  
     '#value' => $branch_name,  
   );  
814    $form['search'] = array(    $form['search'] = array(
815      '#title' => t('Function, file, or topic'),      '#title' => t('Function, file, or topic'),
816      '#type' => 'textfield',      '#type' => 'textfield',
# Line 821  function api_search_form($form_state, $b Line 826  function api_search_form($form_state, $b
826  }  }
827    
828  function api_search_form_submit($form, &$form_state) {  function api_search_form_submit($form, &$form_state) {
829    $form_state['redirect'] = 'api/search/'. $form_state['values']['branch_name'] .'/'. $form_state['values']['search'];    $form_state['redirect'] = 'api/search/'. $form['#branch']->branch .'/'. $form_state['values']['search'];
830  }  }
831    
832  function api_search_redirect() {  function api_search_redirect() {
# Line 847  function api_search_listing($branch) { Line 852  function api_search_listing($branch) {
852    $search_text = implode('/', $search_text);    $search_text = implode('/', $search_text);
853    drupal_set_title(t('Search for %search', array('%search' => $search_text)));    drupal_set_title(t('Search for %search', array('%search' => $search_text)));
854    
855    $count = db_result(db_query("SELECT count(*) FROM {api_documentation} WHERE branch_name = '%s' AND title = '%s'", $branch->branch_name, $search_text));    $count = db_result(db_query("SELECT count(*) FROM {api_documentation} WHERE branch_id = %d AND title = '%s'", $branch->branch_id, $search_text));
856    if ($count == 1) {    if ($count == 1) {
857      // Exact match.      // Exact match.
858      $item = db_fetch_object(db_query("SELECT * FROM {api_documentation} WHERE branch_name = '%s' AND title = '%s'", $branch->branch_name, $search_text));      $item = db_fetch_object(db_query("SELECT * FROM {api_documentation} WHERE branch_id = %d AND title = '%s'", $branch->branch_id, $search_text));
859      drupal_goto(api_url($branch, $item));      drupal_goto(api_url($branch, $item));
860    }    }
861    else {    else {
862      // Wildcard search.      // Wildcard search.
863      $result = pager_query("SELECT * FROM {api_documentation} WHERE branch_name = '%s' AND object_name LIKE '%%%s%%' ORDER BY title", 50, 0, NULL, $branch->branch_name, $search_text);      $result = pager_query("SELECT * FROM {api_documentation} WHERE branch_id = %d AND object_name LIKE '%%%s%%' ORDER BY title", 50, 0, NULL, $branch->branch_id, $search_text);
864      return api_render_listing($result, $branch, t('No search results found.')) . theme('pager', NULL, 50, 0);      return api_render_listing($result, $branch, t('No search results found.')) . theme('pager', NULL, 50, 0);
865    }    }
866  }  }
# Line 863  function api_search_listing($branch) { Line 868  function api_search_listing($branch) {
868  /**  /**
869   * Prepare a listing of documentation objects for a branch.   * Prepare a listing of documentation objects for a branch.
870   *   *
871   * @param $branch_name   * @param $branch
872   *   A branch name.   *   A branch.
873   */   */
874  function api_autocomplete($branch_name, $page = TRUE) {  function api_autocomplete($branch, $page = TRUE) {
875    $result = db_query("SELECT title, object_type FROM {api_documentation} WHERE branch_name = '%s' AND object_type <> 'mainpage' ORDER BY LENGTH(title)", $branch_name);    $result = db_query("SELECT title, object_type FROM {api_documentation} WHERE branch_id = %d AND object_type <> 'mainpage' ORDER BY LENGTH(title)", $branch->branch_id);
876    while ($object = db_fetch_object($result)) {    while ($object = db_fetch_object($result)) {
877      $objects[] = $object->title;      $objects[] = $object->title;
878    }    }
# Line 930  EOD; Line 935  EOD;
935   * Prepare a listing of potential documentation matches for a branch for   * Prepare a listing of potential documentation matches for a branch for
936   * OpenSearch.   * OpenSearch.
937   *   *
938   * @param $branch_name   * @param $branch
939   *   A branch name.   *   A branch.
940   * @param ...   * @param ...
941   *   The string to search for.   *   The string to search for.
942   *   *
943   * @see http://www.opensearch.org/Specifications/OpenSearch/Extensions/Suggestions/1.0   * @see http://www.opensearch.org/Specifications/OpenSearch/Extensions/Suggestions/1.0
944   */   */
945  function api_suggest($branch_name) {  function api_suggest($branch) {
946    $matches = array();    $matches = array();
947    $search = func_get_args();    $search = func_get_args();
948    array_shift($search);    array_shift($search);
949    $result = _api_fuzzy_search($branch_name, implode('/', $search), 10);    $result = db_query_range("SELECT title FROM {api_documentation} WHERE title LIKE '%%%s%%' AND branch_id = %d ORDER BY LENGTH(title)", implode('/', str_replace('_', '\_', $search)), $branch->branch_id, 0, 10);
950    while ($r = db_fetch_object($result)) {    while ($r = db_fetch_object($result)) {
951      $matches[] = $r->title;      $matches[] = $r->title;
952    }    }
# Line 949  function api_suggest($branch_name) { Line 954  function api_suggest($branch_name) {
954  }  }
955    
956  /**  /**
  * Search the database and return the query result handle.  
  *  
  * @param $branch_name  
  *   A branch name.  
  * @param $search  
  *   The string to search for.  
  * @param $limit  
  *   Maximum number of search results to provide.  
  */  
 function _api_fuzzy_search($branch_name, $search, $limit = 10) {  
   // Escape underscore to produce more accurate results.  
   $search = str_replace('_', '\_', $search);  
   return db_query_range("SELECT title FROM {api_documentation} WHERE title LIKE '%%%s%%' AND branch_name = '%s' ORDER BY LENGTH(title)", $search, $branch_name, 0, $limit);  
 }  
   
 /**  
957   * Menu callback; displays the main documentation page.   * Menu callback; displays the main documentation page.
958   */   */
959  function api_page_branch($branch) {  function api_page_branch($branch) {
960    $result = db_query("SELECT documentation FROM {api_documentation} WHERE object_name = '%s' AND branch_name = '%s' AND object_type = 'mainpage'", $branch->branch_name, $branch->branch_name);    $result = db_query("SELECT documentation FROM {api_documentation} WHERE object_name = '%s' AND branch_id = %d AND object_type = 'mainpage'", $branch->branch_id, $branch->branch_id);
961    if ($docs = db_fetch_object($result)) {    if ($docs = db_fetch_object($result)) {
962      return api_link_documentation($docs->documentation, $branch);      return api_link_documentation($docs->documentation, $branch);
963    }    }
964    else {    else {
965      return theme('api_branch_default_page', $branch->branch_name);      return theme('api_branch_default_page', $branch);
966    }    }
967  }  }
968    
# Line 981  function api_page_branch($branch) { Line 970  function api_page_branch($branch) {
970   * Menu callback; displays an object listing.   * Menu callback; displays an object listing.
971   */   */
972  function api_page_listing($branch, $object_type) {  function api_page_listing($branch, $object_type) {
973    $result = pager_query("SELECT * FROM {api_documentation} WHERE branch_name = '%s' AND object_type = '%s' ORDER BY title", 50, 0, NULL, $branch->branch_name, $object_type);    $result = pager_query("SELECT * FROM {api_documentation} WHERE branch_id = %d AND object_type = '%s' ORDER BY title", 50, 0, NULL, $branch->branch_id, $object_type);
974    return api_render_listing($result, $branch) . theme('pager', NULL, 50, 0);    return api_render_listing($result, $branch) . theme('pager', NULL, 50, 0);
975  }  }
976    
# Line 1025  function api_render_listing($result, $br Line 1014  function api_render_listing($result, $br
1014  /**  /**
1015   * Menu callback; produces a textual listing of all functions for use in IDEs.   * Menu callback; produces a textual listing of all functions for use in IDEs.
1016   */   */
1017  function api_page_function_dump($branch_name) {  function api_page_function_dump($branch) {
1018    $result = db_query("SELECT d.title, d.summary, f.signature FROM {api_documentation} d INNER JOIN {api_function} f ON d.did = f.did WHERE d.branch_name = '%s' AND d.object_type = 'function'", $branch_name);    $result = db_query("SELECT d.title, d.summary, f.signature FROM {api_documentation} d INNER JOIN {api_function} f ON d.did = f.did WHERE d.branch_id = %d AND d.object_type = 'function'", $branch->branch_id);
1019    while ($object = db_fetch_object($result)) {    while ($object = db_fetch_object($result)) {
1020      print($object->signature);      print($object->signature);
1021      print(' ### '. $object->summary ."\n");      print(' ### '. $object->summary ."\n");
# Line 1047  function api_page_function($branch, $fun Line 1036  function api_page_function($branch, $fun
1036    $last_signature = '';    $last_signature = '';
1037    $signatures = array();    $signatures = array();
1038    $n = 0;    $n = 0;
1039    $result = db_query("SELECT d.branch_name, f.signature FROM {api_documentation} d INNER JOIN {api_function} f ON f.did = d.did INNER JOIN {api_branch} b ON d.branch_name = b.branch_name WHERE d.object_type = 'function' AND d.title = '%s' ORDER BY b.weight", $function->title);    $result = db_query("SELECT d.branch_name, f.signature FROM {api_documentation} d INNER JOIN {api_function} f ON f.did = d.did INNER JOIN {api_branch} b ON d.branch_id = b.branch_id WHERE d.object_type = 'function' AND d.title = '%s' ORDER BY b.weight", $function->title);
1040    while ($signature = db_fetch_object($result)) {    while ($signature = db_fetch_object($result)) {
1041      if ($signature->signature == $last_signature) {      if ($signature->signature == $last_signature) {
1042        // Collapse unchanged signatures to one line.        // Collapse unchanged signatures to one line.
# Line 1138  function api_page_function($branch, $fun Line 1127  function api_page_function($branch, $fun
1127    $call_count = db_result(db_query("SELECT count(*) FROM {api_reference_storage} r INNER JOIN {api_documentation} d ON r.from_did = d.did AND d.object_type = 'function' WHERE r.to_did = %d", $function->did));    $call_count = db_result(db_query("SELECT count(*) FROM {api_reference_storage} r INNER JOIN {api_documentation} d ON r.from_did = d.did AND d.object_type = 'function' WHERE r.to_did = %d", $function->did));
1128    $call = '';    $call = '';
1129    if ($call_count > 0) {    if ($call_count > 0) {
1130      $result = db_query("SELECT d.object_name, d.title, d.summary, d.file_name, d.branch_name, d.object_type FROM {api_reference_storage} r INNER JOIN {api_documentation} d ON r.from_did = d.did AND d.object_type = 'function' WHERE r.to_did = %d ORDER BY d.title", $function->did);      $result = db_query("SELECT d.object_name, d.title, d.summary, d.file_name, d.object_type FROM {api_reference_storage} r INNER JOIN {api_documentation} d ON r.from_did = d.did AND d.object_type = 'function' WHERE r.to_did = %d ORDER BY d.title", $function->did);
1131      $call_functions = array();      $call_functions = array();
1132      while ($object = db_fetch_object($result)) {      while ($object = db_fetch_object($result)) {
1133        $call_functions[] = array(        $call_functions[] = array(
# Line 1193  function api_page_file($branch, $file) { Line 1182  function api_page_file($branch, $file) {
1182    drupal_set_title($file->title);    drupal_set_title($file->title);
1183    
1184    $documentation = api_link_documentation($file->documentation, $branch);    $documentation = api_link_documentation($file->documentation, $branch);
1185    $result = db_query("SELECT title, object_name, summary, object_type, branch_name FROM {api_documentation} WHERE file_name = '%s' AND branch_name = '%s' AND object_type IN ('constant', 'global', 'function') ORDER BY title", $file->object_name, $file->branch_name);    $result = db_query("SELECT title, object_name, summary, object_type FROM {api_documentation} WHERE file_name = '%s' AND branch_id = %d AND object_type IN ('constant', 'global', 'function') ORDER BY title", $file->object_name, $file->branch_id);
1186    $rows = array(    $rows = array(
1187      'constant' => array(),      'constant' => array(),
1188      'global' => array(),      'global' => array(),
# Line 1276  function api_page_group($branch, $group) Line 1265  function api_page_group($branch, $group)
1265      'global' => array(),      'global' => array(),
1266      'function' => array(),      'function' => array(),
1267    );    );
1268    $result = db_query("SELECT d.object_name, d.title, d.summary, d.file_name, d.object_type, d.branch_name FROM {api_reference_storage} r INNER JOIN {api_documentation} d ON r.from_did = d.did AND d.object_type IN ('constant', 'global', 'function') WHERE r.to_did = %d ORDER BY d.object_name", $group->did);    $result = db_query("SELECT d.object_name, d.title, d.summary, d.file_name, d.object_type FROM {api_reference_storage} r INNER JOIN {api_documentation} d ON r.from_did = d.did AND d.object_type IN ('constant', 'global', 'function') WHERE r.to_did = %d ORDER BY d.object_name", $group->did);
1269    while ($object = db_fetch_object($result)) {    while ($object = db_fetch_object($result)) {
1270      $rows[$object->object_type][] = array(      $rows[$object->object_type][] = array(
1271        l($object->title, api_url($branch, $object)),        l($object->title, api_url($branch, $object)),
# Line 1462  function api_link_name($name, $branch, $ Line 1451  function api_link_name($name, $branch, $
1451    static $local_objects, $php_functions;    static $local_objects, $php_functions;
1452    
1453    if (is_null($local_objects)) {    if (is_null($local_objects)) {
1454      $result = db_query("SELECT object_name, title, object_type, summary, branch_name FROM {api_documentation} WHERE branch_name = '%s'", $branch->branch_name);      $result = db_query("SELECT object_name, title, object_type, summary FROM {api_documentation} WHERE branch_id = %d", $branch->branch_id);
1455      $local_objects = array(      $local_objects = array(
1456        'function' => array(),        'function' => array(),
1457        'file' => array(),        'file' => array(),
# Line 1479  function api_link_name($name, $branch, $ Line 1468  function api_link_name($name, $branch, $
1468    }    }
1469    
1470    if (is_null($php_functions)) {    if (is_null($php_functions)) {
1471        //todo
1472      $result = db_query("SELECT object_name, summary FROM {api_documentation} WHERE branch_name = 'php' AND object_type = 'function'");      $result = db_query("SELECT object_name, summary FROM {api_documentation} WHERE branch_name = 'php' AND object_type = 'function'");
1473      $php_functions = array();      $php_functions = array();
1474      while ($function = db_fetch_object($result)) {      while ($function = db_fetch_object($result)) {

Legend:
Removed from v.1.88.2.42  
changed lines
  Added in v.1.88.2.43

  ViewVC Help
Powered by ViewVC 1.1.2