/[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.41, Thu Oct 15 05:52:59 2009 UTC revision 1.88.2.42, Thu Oct 15 06:42:35 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: api.module,v 1.88.2.40 2009/10/08 06:07:46 drumm Exp $  // $Id: api.module,v 1.88.2.41 2009/10/15 05:52:59 drumm Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 253  function api_menu() { Line 253  function api_menu() {
253      'type' => MENU_CALLBACK,      'type' => MENU_CALLBACK,
254    );    );
255    
256    $items['api/' . variable_get('api_default_project', 'drupal') . '/%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->branch_name),
259      'page callback' => 'api_page_file',      'page callback' => 'api_page_file',
# Line 377  function api_menu() { Line 377  function api_menu() {
377        'type' => ($branch->branch_id == $default_branch->branch_id) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,        'type' => ($branch->branch_id == $default_branch->branch_id) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
378      );      );
379    
380      $items['api/' . variable_get('api_default_project', 'drupal') . '/%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->branch_name),
383        'page callback' => 'api_page_file',        'page callback' => 'api_page_file',
# Line 386  function api_menu() { Line 386  function api_menu() {
386        'access arguments' => $access_arguments,        'access arguments' => $access_arguments,
387        'type' => ($branch->branch_id == $default_branch->branch_id) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,        'type' => ($branch->branch_id == $default_branch->branch_id) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
388      );      );
389      $items['api/' . variable_get('api_default_project', 'drupal') . '/%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->branch_name),
392        'type' => MENU_DEFAULT_LOCAL_TASK,        'type' => MENU_DEFAULT_LOCAL_TASK,
393        'weight' => -10,        'weight' => -10,
394      );      );
395      $items['api/' . variable_get('api_default_project', 'drupal') . '/%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->branch_name),
398        'page callback' => 'api_page_file_source',        'page callback' => 'api_page_file_source',
# Line 501  function api_theme() { Line 501  function api_theme() {
501      ),      ),
502      'api_defined' => array(      'api_defined' => array(
503        'arguments' => array(        'arguments' => array(
504            'branch' => NULL,
505          'object' => NULL,          'object' => NULL,
506        ),        ),
507        'template' => 'templates/api-defined',        'template' => 'templates/api-defined',
# Line 519  function api_theme() { Line 520  function api_theme() {
520      ),      ),
521      'api_function_page' => array(      'api_function_page' => array(
522        'arguments' => array(        'arguments' => array(
523            'branch' => NULL,
524          'function' => NULL,          'function' => NULL,
525          'signatures' => NULL,          'signatures' => NULL,
526          'documentation' => NULL,          'documentation' => NULL,
# Line 532  function api_theme() { Line 534  function api_theme() {
534      ),      ),
535      'api_constant_page' => array(      'api_constant_page' => array(
536        'arguments' => array(        'arguments' => array(
537            'branch' => NULL,
538          'constant' => NULL,          'constant' => NULL,
539          'documentation' => NULL,          'documentation' => NULL,
540          'code' => NULL,          'code' => NULL,
# Line 541  function api_theme() { Line 544  function api_theme() {
544      ),      ),
545      'api_global_page' => array(      'api_global_page' => array(
546        'arguments' => array(        'arguments' => array(
547            'branch' => NULL,
548          'global' => NULL,          'global' => NULL,
549          'documentation' => NULL,          'documentation' => NULL,
550          'code' => NULL,          'code' => NULL,
# Line 560  function api_theme() { Line 564  function api_theme() {
564      ),      ),
565      'api_group_page' => array(      'api_group_page' => array(
566        'arguments' => array(        'arguments' => array(
567            'branch' => NULL,
568          'group' => NULL,          'group' => NULL,
569          'documentation' => NULL,          'documentation' => NULL,
570          'constants' => NULL,          'constants' => NULL,
# Line 578  function api_theme() { Line 583  function api_theme() {
583  }  }
584    
585  function api_preprocess_api_function_page(&$variables) {  function api_preprocess_api_function_page(&$variables) {
586    $variables['defined'] = theme('api_defined', $variables['function']);    $variables['defined'] = theme('api_defined', $variables['branch'], $variables['function']);
587  }  }
588    
589  function api_preprocess_api_constant_page(&$variables) {  function api_preprocess_api_constant_page(&$variables) {
590    $variables['defined'] = theme('api_defined', $variables['constant']);    $variables['defined'] = theme('api_defined', $variables['branch'], $variables['constant']);
591  }  }
592    
593  function api_preprocess_api_global_page(&$variables) {  function api_preprocess_api_global_page(&$variables) {
594    $variables['defined'] = theme('api_defined', $variables['global']);    $variables['defined'] = theme('api_defined', $variables['branch'], $variables['global']);
595  }  }
596    
597  function api_preprocess_api_group_page(&$variables) {  function api_preprocess_api_group_page(&$variables) {
598    $variables['defined'] = theme('api_defined', $variables['group']);    $variables['defined'] = theme('api_defined', $variables['branch'], $variables['group']);
599  }  }
600    
601  function api_init() {  function api_init() {
# Line 702  function api_filter($op, $delta = 0, $fo Line 707  function api_filter($op, $delta = 0, $fo
707   * @return   * @return
708   *   A URL string.   *   A URL string.
709   */   */
710  function api_url($object, $file = FALSE) {  function api_url($branch, $object, $file = FALSE) {
711    // api_default_project is a placeholder for when we have real project    // api_default_project is a placeholder for when we have real project
712    // support.    // support.
713    if ($file) {    if ($file) {
714      return 'api/' . variable_get('api_default_project', 'drupal') . '/' . str_replace('/', '--', $object->file_name) . '/' . $object->branch_name;      return 'api/' . $branch->project . '/' . str_replace('/', '--', $object->file_name) . '/' . $object->branch_name;
715    }    }
716    elseif ($object->object_type === 'file') {    elseif ($object->object_type === 'file') {
717      return 'api/' . variable_get('api_default_project', 'drupal') . '/' . str_replace('/', '--', $object->object_name) . '/' . $object->branch_name;      return 'api/' . $branch->project . '/' . str_replace('/', '--', $object->object_name) . '/' . $object->branch_name;
718    }    }
719    else {    else {
720      return 'api/' . $object->object_type . '/' . $object->object_name . '/' . $object->branch_name;      return 'api/' . $object->object_type . '/' . $object->object_name . '/' . $object->branch_name;
# Line 846  function api_search_listing($branch) { Line 851  function api_search_listing($branch) {
851    if ($count == 1) {    if ($count == 1) {
852      // Exact match.      // Exact match.
853      $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_name = '%s' AND title = '%s'", $branch->branch_name, $search_text));
854      drupal_goto(api_url($item));      drupal_goto(api_url($branch, $item));
855    }    }
856    else {    else {
857      // Wildcard search.      // Wildcard search.
# Line 998  function api_render_listing($result, $br Line 1003  function api_render_listing($result, $br
1003    $rows = array();    $rows = array();
1004    while ($object = db_fetch_object($result)) {    while ($object = db_fetch_object($result)) {
1005      $rows[] = array(      $rows[] = array(
1006        l($object->title, api_url($object)),        l($object->title, api_url($branch, $object)),
1007        '<small>'. api_file_link($object) .'</small>',        '<small>'. api_file_link($branch, $object) .'</small>',
1008        api_link_documentation($object->summary, $branch),        api_link_documentation($object->summary, $branch),
1009      );      );
1010    }    }
# Line 1036  function api_page_function($branch, $fun Line 1041  function api_page_function($branch, $fun
1041    drupal_set_breadcrumb(array(    drupal_set_breadcrumb(array(
1042      l(t('Home'), ''),      l(t('Home'), ''),
1043      l(t('API reference'), 'api'),      l(t('API reference'), 'api'),
1044      l(basename($function->file_name), api_url($function, TRUE)),      l(basename($function->file_name), api_url($branch, $function, TRUE)),
1045    ));    ));
1046    
1047    $last_signature = '';    $last_signature = '';
# Line 1137  function api_page_function($branch, $fun Line 1142  function api_page_function($branch, $fun
1142      $call_functions = array();      $call_functions = array();
1143      while ($object = db_fetch_object($result)) {      while ($object = db_fetch_object($result)) {
1144        $call_functions[] = array(        $call_functions[] = array(
1145          'function' => l($object->title, api_url($object)),          'function' => l($object->title, api_url($branch, $object)),
1146          'file' => api_file_link($object),          'file' => api_file_link($branch, $object),
1147          'description' => api_link_documentation($object->summary, $branch),          'description' => api_link_documentation($object->summary, $branch),
1148        );        );
1149      }      }
# Line 1146  function api_page_function($branch, $fun Line 1151  function api_page_function($branch, $fun
1151      $call = theme('api_expandable', '<h3>'. api_show_l('▸ '. $call_title) .'</h3>', '<h3>'. api_hide_l('▾ '. $call_title) .'</h3>'. theme('api_functions', $call_functions));      $call = theme('api_expandable', '<h3>'. api_show_l('▸ '. $call_title) .'</h3>', '<h3>'. api_hide_l('▾ '. $call_title) .'</h3>'. theme('api_functions', $call_functions));
1152    }    }
1153    
1154    $output = theme('api_function_page', $function, $signatures, $documentation, $parameters, $return, $related_topics, $call, $code);    $output = theme('api_function_page', $branch, $function, $signatures, $documentation, $parameters, $return, $related_topics, $call, $code);
1155    $output .= _api_add_comments($function);    $output .= _api_add_comments($function);
1156    return $output;    return $output;
1157  }  }
# Line 1161  function api_page_constant($branch, $con Line 1166  function api_page_constant($branch, $con
1166    $code = api_link_code($constant->code, $branch);    $code = api_link_code($constant->code, $branch);
1167    $related_topics = api_related_topics($constant->did, $branch);    $related_topics = api_related_topics($constant->did, $branch);
1168    
1169    $output = theme('api_constant_page', $constant, $documentation, $code, $related_topics);    $output = theme('api_constant_page', $branch, $constant, $documentation, $code, $related_topics);
1170    $output .= _api_add_comments($constant);    $output .= _api_add_comments($constant);
1171    return $output;    return $output;
1172  }  }
# Line 1176  function api_page_global($branch, $globa Line 1181  function api_page_global($branch, $globa
1181    $related_topics = api_related_topics($global->did, $branch);    $related_topics = api_related_topics($global->did, $branch);
1182    $code = api_link_code($global->code, $branch);    $code = api_link_code($global->code, $branch);
1183    
1184    $output = theme('api_global_page', $global, $documentation, $code, $related_topics);    $output = theme('api_global_page', $branch, $global, $documentation, $code, $related_topics);
1185    $output .= _api_add_comments($global);    $output .= _api_add_comments($global);
1186    return $output;    return $output;
1187  }  }
# Line 1196  function api_page_file($branch, $file) { Line 1201  function api_page_file($branch, $file) {
1201    );    );
1202    while ($object = db_fetch_object($result)) {    while ($object = db_fetch_object($result)) {
1203      $rows[$object->object_type][] = array(      $rows[$object->object_type][] = array(
1204        l($object->title, api_url($object)),        l($object->title, api_url($branch, $object)),
1205        api_link_documentation($object->summary, $branch),        api_link_documentation($object->summary, $branch),
1206      );      );
1207    }    }
# Line 1274  function api_page_group($branch, $group) Line 1279  function api_page_group($branch, $group)
1279    $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, 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);
1280    while ($object = db_fetch_object($result)) {    while ($object = db_fetch_object($result)) {
1281      $rows[$object->object_type][] = array(      $rows[$object->object_type][] = array(
1282        l($object->title, api_url($object)),        l($object->title, api_url($branch, $object)),
1283        '<small>'. api_file_link($object) .'</small>',        '<small>'. api_file_link($branch, $object) .'</small>',
1284        api_link_documentation($object->summary, $branch),        api_link_documentation($object->summary, $branch),
1285      );      );
1286    }    }
# Line 1297  function api_page_group($branch, $group) Line 1302  function api_page_group($branch, $group)
1302      $functions = theme('table', $header, $rows['function']);      $functions = theme('table', $header, $rows['function']);
1303    }    }
1304    
1305    $output = theme('api_group_page', $group, $documentation, $constants, $globals, $functions);    $output = theme('api_group_page', $branch, $group, $documentation, $constants, $globals, $functions);
1306    $output .= _api_add_comments($group);    $output .= _api_add_comments($group);
1307    return $output;    return $output;
1308  }  }
# Line 1318  function api_related_topics($did, $branc Line 1323  function api_related_topics($did, $branc
1323    return '';    return '';
1324  }  }
1325    
1326  function api_file_link($object) {  function api_file_link($branch, $object) {
1327    return dirname($object->file_name) .'/'. l(basename($object->file_name), api_url($object, TRUE));    return dirname($object->file_name) .'/'. l(basename($object->file_name), api_url($branch, $object, TRUE));
1328  }  }
1329    
1330  function api_cron() {  function api_cron() {
# Line 1492  function api_link_name($name, $branch, $ Line 1497  function api_link_name($name, $branch, $
1497      return $prepend . l($text, 'api/function/'. $local_objects['function'][$name]->object_name .'/'. $branch->branch_name, array('attributes' => array('title' => $local_objects['function'][$name]->summary, 'class' => 'local'))) . $append;      return $prepend . l($text, 'api/function/'. $local_objects['function'][$name]->object_name .'/'. $branch->branch_name, array('attributes' => array('title' => $local_objects['function'][$name]->summary, 'class' => 'local'))) . $append;
1498    }    }
1499    elseif (array_key_exists($name, $local_objects['file'])) {    elseif (array_key_exists($name, $local_objects['file'])) {
1500      return l($text, api_url($local_objects['file'][$name]), array('attributes' => array('title' => $local_objects['file'][$name]->summary, 'class' => 'local')));      return l($text, api_url($branch, $local_objects['file'][$name]), array('attributes' => array('title' => $local_objects['file'][$name]->summary, 'class' => 'local')));
1501    }    }
1502    elseif (array_key_exists($name, $local_objects['constant'])) {    elseif (array_key_exists($name, $local_objects['constant'])) {
1503      return l($text, 'api/constant/'. $local_objects['constant'][$name]->object_name .'/'. $branch->branch_name, array('attributes' => array('title' => $local_objects['constant'][$name]->summary, 'class' => 'local')));      return l($text, 'api/constant/'. $local_objects['constant'][$name]->object_name .'/'. $branch->branch_name, array('attributes' => array('title' => $local_objects['constant'][$name]->summary, 'class' => 'local')));

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

  ViewVC Help
Powered by ViewVC 1.1.2