| 1 |
<?php |
<?php |
| 2 |
// $Id: api.module,v 1.88.2.39 2009/10/04 23:10:34 drumm Exp $ |
// $Id: api.module,v 1.88.2.40 2009/10/08 06:07:46 drumm Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 73 |
static $branches; |
static $branches; |
| 74 |
|
|
| 75 |
if (!isset($branches) || $_reset) { |
if (!isset($branches) || $_reset) { |
| 76 |
$result = db_query('SELECT branch_name, title, directories, excluded_directories FROM {api_branch} ORDER BY weight'); |
$result = db_query('SELECT branch_id, project, branch_name, title, directories, excluded_directories FROM {api_branch} ORDER BY weight'); |
| 77 |
$branches = array(); |
$branches = array(); |
| 78 |
while ($branch = db_fetch_object($result)) { |
while ($branch = db_fetch_object($result)) { |
| 79 |
$branches[$branch->branch_name] = $branch; |
$branches[$branch->branch_id] = $branch; |
| 80 |
} |
} |
| 81 |
} |
} |
| 82 |
|
|
| 93 |
$access_arguments = array('access API reference'); |
$access_arguments = array('access API reference'); |
| 94 |
|
|
| 95 |
$branches = api_get_branches(); |
$branches = api_get_branches(); |
| 96 |
$default_branch = variable_get('api_default_branch', NULL); |
$default_branch = $branches[variable_get('api_default_branch', NULL)]; |
| 97 |
// Part 1: No object, Default branch |
// Part 1: No object, Default branch |
| 98 |
$items['api'] = array( |
$items['api'] = array( |
| 99 |
'title' => 'API reference', |
'title' => 'API reference', |
| 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), |
'page arguments' => array('api_search_form', $default_branch->branch_name), |
| 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, |
| 189 |
'type' => MENU_LOCAL_TASK, |
'type' => MENU_LOCAL_TASK, |
| 190 |
); |
); |
| 191 |
$items['admin/settings/api/branches/%'] = array( |
$items['admin/settings/api/branches/%'] = array( |
| 192 |
'title' => 'Edit @branch', |
'title' => 'Edit branch', |
|
'title arguments' => array('@branch' => 4), |
|
| 193 |
'access callback' => 'user_access', |
'access callback' => 'user_access', |
| 194 |
'access arguments' => array('administer API reference'), |
'access arguments' => array('administer API reference'), |
| 195 |
'page callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 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), |
'load arguments' => array('function', $default_branch->branch_name), |
| 231 |
'page callback' => 'api_page_function', |
'page callback' => 'api_page_function', |
| 232 |
'page arguments' => array(2), |
'page arguments' => array($default_branch, 2), |
| 233 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 234 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 235 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 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), |
'load arguments' => array('constant', $default_branch->branch_name), |
| 240 |
'page callback' => 'api_page_constant', |
'page callback' => 'api_page_constant', |
| 241 |
'page arguments' => array(2), |
'page arguments' => array($default_branch, 2), |
| 242 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 243 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 244 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 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), |
'load arguments' => array('global', $default_branch->branch_name), |
| 249 |
'page callback' => 'api_page_global', |
'page callback' => 'api_page_global', |
| 250 |
'page arguments' => array(2), |
'page arguments' => array($default_branch, 2), |
| 251 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 252 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 253 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 255 |
|
|
| 256 |
$items['api/' . variable_get('api_default_project', 'drupal') . '/%api_filename'] = array( |
$items['api/' . variable_get('api_default_project', 'drupal') . '/%api_filename'] = array( |
| 257 |
'title' => 'File', |
'title' => 'File', |
| 258 |
'load arguments' => array($default_branch), |
'load arguments' => array($default_branch->branch_name), |
| 259 |
'page callback' => 'api_page_file', |
'page callback' => 'api_page_file', |
| 260 |
'page arguments' => array(2), |
'page arguments' => array($default_branch, 2), |
| 261 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 262 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 263 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 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), |
'load arguments' => array('group', $default_branch->branch_name), |
| 269 |
'page callback' => 'api_page_group', |
'page callback' => 'api_page_group', |
| 270 |
'page arguments' => array(2), |
'page arguments' => array($default_branch, 2), |
| 271 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 272 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 273 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 301 |
$items['api/'. $branch->branch_name] = array( |
$items['api/'. $branch->branch_name] = array( |
| 302 |
'title' => $branch->title, |
'title' => $branch->title, |
| 303 |
'page callback' => 'api_page_branch', |
'page callback' => 'api_page_branch', |
| 304 |
'page arguments' => array($branch->branch_name), |
'page arguments' => array($branch), |
| 305 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 306 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 307 |
'type' => ($branch->branch_name == $default_branch) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
'type' => ($branch->branch_id == $default_branch->branch_id) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
| 308 |
); |
); |
| 309 |
$items['api/functions/'. $branch->branch_name] = array( |
$items['api/functions/'. $branch->branch_name] = array( |
| 310 |
'title' => $branch->title, |
'title' => $branch->title, |
| 311 |
'page callback' => 'api_page_listing', |
'page callback' => 'api_page_listing', |
| 312 |
'page arguments' => array($branch->branch_name, 'function'), |
'page arguments' => array($branch, 'function'), |
| 313 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 314 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 315 |
'type' => ($branch->branch_name == $default_branch) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
'type' => ($branch->branch_id == $default_branch->branch_id) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
| 316 |
); |
); |
| 317 |
$items['api/constants/'. $branch->branch_name] = array( |
$items['api/constants/'. $branch->branch_name] = array( |
| 318 |
'title' => $branch->title, |
'title' => $branch->title, |
| 319 |
'page callback' => 'api_page_listing', |
'page callback' => 'api_page_listing', |
| 320 |
'page arguments' => array($branch->branch_name, 'constant'), |
'page arguments' => array($branch, 'constant'), |
| 321 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 322 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 323 |
'type' => ($branch->branch_name == $default_branch) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
'type' => ($branch->branch_id == $default_branch->branch_id) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
| 324 |
); |
); |
| 325 |
$items['api/globals/'. $branch->branch_name] = array( |
$items['api/globals/'. $branch->branch_name] = array( |
| 326 |
'title' => $branch->title, |
'title' => $branch->title, |
| 327 |
'page callback' => 'api_page_listing', |
'page callback' => 'api_page_listing', |
| 328 |
'page arguments' => array($branch->branch_name, 'global'), |
'page arguments' => array($branch, 'global'), |
| 329 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 330 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 331 |
'type' => ($branch->branch_name == $default_branch) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
'type' => ($branch->branch_id == $default_branch->branch_id) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
| 332 |
); |
); |
| 333 |
$items['api/files/'. $branch->branch_name] = array( |
$items['api/files/'. $branch->branch_name] = array( |
| 334 |
'title' => $branch->title, |
'title' => $branch->title, |
| 335 |
'page callback' => 'api_page_listing', |
'page callback' => 'api_page_listing', |
| 336 |
'page arguments' => array($branch->branch_name, 'file'), |
'page arguments' => array($branch, 'file'), |
| 337 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 338 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 339 |
'type' => ($branch->branch_name == $default_branch) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
'type' => ($branch->branch_id == $default_branch->branch_id) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
| 340 |
); |
); |
| 341 |
$items['api/groups/'. $branch->branch_name] = array( |
$items['api/groups/'. $branch->branch_name] = array( |
| 342 |
'title' => $branch->title, |
'title' => $branch->title, |
| 343 |
'page callback' => 'api_page_listing', |
'page callback' => 'api_page_listing', |
| 344 |
'page arguments' => array($branch->branch_name, 'group'), |
'page arguments' => array($branch, 'group'), |
| 345 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 346 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 347 |
'type' => ($branch->branch_name == $default_branch) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
'type' => ($branch->branch_id == $default_branch->branch_id) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
| 348 |
); |
); |
| 349 |
|
|
| 350 |
// Part 4: Object provided, specific branch. |
// Part 4: Object provided, specific branch. |
| 352 |
'title' => $branch->title, |
'title' => $branch->title, |
| 353 |
'load arguments' => array('function', $branch->branch_name), |
'load arguments' => array('function', $branch->branch_name), |
| 354 |
'page callback' => 'api_page_function', |
'page callback' => 'api_page_function', |
| 355 |
'page arguments' => array(2), |
'page arguments' => array($branch, 2), |
| 356 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 357 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 358 |
'type' => ($branch->branch_name == $default_branch) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
'type' => ($branch->branch_id == $default_branch->branch_id) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
| 359 |
); |
); |
| 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->branch_name), |
| 364 |
'page callback' => 'api_page_constant', |
'page callback' => 'api_page_constant', |
| 365 |
'page arguments' => array(2), |
'page arguments' => array($branch, 2), |
| 366 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 367 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 368 |
'type' => ($branch->branch_name == $default_branch) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
'type' => ($branch->branch_id == $default_branch->branch_id) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
| 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->branch_name), |
| 373 |
'page callback' => 'api_page_global', |
'page callback' => 'api_page_global', |
| 374 |
'page arguments' => array(2), |
'page arguments' => array($branch, 2), |
| 375 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 376 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 377 |
'type' => ($branch->branch_name == $default_branch) ? 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/' . variable_get('api_default_project', 'drupal') . '/%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', |
| 384 |
'page arguments' => array(2), |
'page arguments' => array($branch, 2), |
| 385 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 386 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 387 |
'type' => ($branch->branch_name == $default_branch) ? 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/' . variable_get('api_default_project', 'drupal') . '/%api_filename/'. $branch->branch_name .'/documentation'] = array( |
| 390 |
'title' => 'View documentation', |
'title' => 'View documentation', |
| 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', |
| 399 |
'page arguments' => array(2), |
'page arguments' => array($branch, 2), |
| 400 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 401 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 402 |
'type' => MENU_LOCAL_TASK, |
'type' => MENU_LOCAL_TASK, |
| 406 |
'title' => $branch->title, |
'title' => $branch->title, |
| 407 |
'load arguments' => array('group', $branch->branch_name), |
'load arguments' => array('group', $branch->branch_name), |
| 408 |
'page callback' => 'api_page_group', |
'page callback' => 'api_page_group', |
| 409 |
'page arguments' => array(2), |
'page arguments' => array($branch, 2), |
| 410 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 411 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 412 |
'type' => ($branch->branch_name == $default_branch) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
'type' => ($branch->branch_id == $default_branch->branch_id) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, |
| 413 |
); |
); |
| 414 |
$items['api/search/'. $branch->branch_name .'/%menu_tail'] = array( |
$items['api/search/'. $branch->branch_name .'/%menu_tail'] = array( |
| 415 |
'title' => $branch->title, |
'title' => $branch->title, |
| 416 |
'page callback' => 'api_search_listing', |
'page callback' => 'api_search_listing', |
| 417 |
'page arguments' => array($branch->branch_name, 3), |
'page arguments' => array($branch, 3), |
| 418 |
'access callback' => $access_callback, |
'access callback' => $access_callback, |
| 419 |
'access arguments' => $access_arguments, |
'access arguments' => $access_arguments, |
| 420 |
'type' => MENU_LOCAL_TASK, |
'type' => MENU_LOCAL_TASK, |
| 452 |
static $cache; |
static $cache; |
| 453 |
|
|
| 454 |
if (is_null($branch_name)) { |
if (is_null($branch_name)) { |
| 455 |
$branch_name = variable_get('api_default_branch', NULL); |
$branches = api_get_branches(); |
| 456 |
|
$branch_name = $branches[variable_get('api_default_branch', NULL)]->branch_name; |
| 457 |
} |
} |
| 458 |
|
|
| 459 |
$key = $object_name .':'. $object_type .':'. $branch_name; |
$key = $object_name .':'. $object_type .':'. $branch_name; |
| 600 |
drupal_add_js(drupal_get_path('module', 'api') . '/api.js'); |
drupal_add_js(drupal_get_path('module', 'api') . '/api.js'); |
| 601 |
|
|
| 602 |
// Add OpenSearch autodiscovery links. |
// Add OpenSearch autodiscovery links. |
| 603 |
foreach (array_keys(api_get_branches()) as $branch_name) { |
foreach (api_get_branches() as $branch) { |
| 604 |
$title = t('Drupal API @branch', array('@branch' => $branch_name)); |
$title = t('Drupal API @branch', array('@branch' => $branch->branch_name)); |
| 605 |
$url = url('api/opensearch/'. $branch_name, array('absolute' => TRUE)); |
$url = url('api/opensearch/'. $branch->branch_name, array('absolute' => TRUE)); |
| 606 |
drupal_set_html_head('<link rel="search" type="application/opensearchdescription+xml" href="'. $url .'" title="'. $title .'" />'); |
drupal_set_html_head('<link rel="search" type="application/opensearchdescription+xml" href="'. $url .'" title="'. $title .'" />'); |
| 607 |
} |
} |
| 608 |
|
|
| 634 |
); |
); |
| 635 |
|
|
| 636 |
case 'view': |
case 'view': |
|
$branches = api_get_branches(); |
|
| 637 |
$branch = api_get_active_branch(); |
$branch = api_get_active_branch(); |
| 638 |
|
|
| 639 |
switch ($delta) { |
switch ($delta) { |
| 640 |
case 'api-search': |
case 'api-search': |
| 641 |
if (user_access('access API reference') && isset($branches[$branch])) { |
if (user_access('access API reference') && !empty($branch)) { |
| 642 |
return array( |
return array( |
| 643 |
'subject' => t('Search @branch', array('@branch' => $branches[$branch]->title)), |
'subject' => t('Search @branch', array('@branch' => $branch->title)), |
| 644 |
'content' => drupal_get_form('api_search_form', $branches[$branch]->branch_name), |
'content' => drupal_get_form('api_search_form', $branch->branch_name), |
| 645 |
); |
); |
| 646 |
} |
} |
| 647 |
return; |
return; |
| 648 |
|
|
| 649 |
case 'navigation': |
case 'navigation': |
| 650 |
if (user_access('access API reference') && isset($branches[$branch])) { |
if (user_access('access API reference') && !empty($branch)) { |
| 651 |
// We forgo the menu system because we want to link to non-default |
// We forgo the menu system because we want to link to non-default |
| 652 |
// local tasks; as of Drupal 5.x, this seems impossible. |
// local tasks; as of Drupal 5.x, this seems impossible. |
| 653 |
if ($branch == variable_get('api_default_branch', NULL)) { |
if ($branch->branch_id == variable_get('api_default_branch', NULL)) { |
| 654 |
$suffix = ''; |
$suffix = ''; |
| 655 |
} |
} |
| 656 |
else { |
else { |
| 657 |
$suffix = '/'. $branch; |
$suffix = '/'. $branch->branch_name; |
| 658 |
} |
} |
| 659 |
|
|
| 660 |
$links = array(); |
$links = array(); |
| 661 |
$links[] = l($branches[$branch]->title, 'api'. $suffix); |
$links[] = l($branch->title, 'api'. $suffix); |
| 662 |
$links[] = l(t('Constants'), 'api/constants'. $suffix); |
$links[] = l(t('Constants'), 'api/constants'. $suffix); |
| 663 |
$links[] = l(t('Files'), 'api/files'. $suffix); |
$links[] = l(t('Files'), 'api/files'. $suffix); |
| 664 |
$links[] = l(t('Functions'), 'api/functions'. $suffix); |
$links[] = l(t('Functions'), 'api/functions'. $suffix); |
| 738 |
* @param $old_branch_name |
* @param $old_branch_name |
| 739 |
* To replace a branch, provide the old branch name. |
* To replace a branch, provide the old branch name. |
| 740 |
*/ |
*/ |
| 741 |
function api_save_branch($branch, $old_branch_name = NULL) { |
function api_save_branch($branch) { |
| 742 |
if (empty($old_branch_name)) { |
if (empty($branch->branch_id)) { |
| 743 |
drupal_write_record('api_branch', $branch); |
drupal_write_record('api_branch', $branch); |
| 744 |
if (is_null(variable_get('api_default_branch', NULL))) { |
if (is_null(variable_get('api_default_branch', NULL))) { |
| 745 |
variable_set('api_default_branch', $branch->branch_name); |
variable_set('api_default_branch', db_last_insert_id('api_branch', 'branch_id')); |
| 746 |
} |
} |
| 747 |
} |
} |
| 748 |
else { |
else { |
| 749 |
if ($branch->branch_name !== $old_branch_name) { |
drupal_write_record('api_branch', $branch, 'branch_id'); |
|
db_query("UPDATE {api_branch} SET branch_name = '%s' WHERE branch_name = '%s'", $branch->branch_name, $old_branch_name); |
|
|
db_query("UPDATE {api_documentation} SET branch_name = '%s' WHERE branch_name = '%s'", $branch->branch_name, $old_branch_name); |
|
|
db_query("UPDATE {api_file} f INNER JOIN {api_documentation} d ON d.did = f.did SET f.modified = 52 WHERE d.branch_name = '%s'", $branch->branch_name); |
|
|
if (variable_get('api_default_branch', NULL) === $old_branch_name) { |
|
|
variable_set('api_default_branch', $branch->branch_name); |
|
|
} |
|
|
} |
|
|
drupal_write_record('api_branch', $branch, 'branch_name'); |
|
| 750 |
} |
} |
| 751 |
|
|
| 752 |
// Reweight all branches. |
// Reweight all branches. |
| 763 |
} |
} |
| 764 |
|
|
| 765 |
function api_get_active_branch() { |
function api_get_active_branch() { |
| 766 |
static $branch; |
static $branch_id; |
| 767 |
|
|
| 768 |
if (!isset($branch)) { |
if (!isset($branch_id)) { |
| 769 |
if (arg(0) == 'api') { |
if (arg(0) == 'api') { |
| 770 |
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'))) { |
| 771 |
$possible_branch = arg(2); |
$possible_branch = arg(2); |
| 772 |
} |
} |
| 773 |
elseif (in_array(arg(1), array('function', 'constant', 'global', 'group'))) { |
elseif (in_array(arg(1), array('function', 'file', 'constant', 'global', 'group'))) { |
| 774 |
$possible_branch = arg(3); |
$possible_branch = arg(3); |
| 775 |
} |
} |
|
elseif (arg(1) == 'file') { |
|
|
// Starting at arg(2), we have a variable number of directories. The |
|
|
// possible branch name is either in the last, or, if we are on a |
|
|
// secondary local task, second to last argument. |
|
|
$current = arg(3); |
|
|
$i = 4; |
|
|
while (!is_null(arg($i))) { |
|
|
$last = $current; |
|
|
$current = arg($i); |
|
|
$i += 1; |
|
|
} |
|
|
|
|
|
if (in_array($current, array('documentation', 'source'))) { |
|
|
$possible_branch = $last; |
|
|
} |
|
|
else { |
|
|
$possible_branch = $current; |
|
|
} |
|
|
} |
|
| 776 |
else { |
else { |
| 777 |
// Maybe we are on one of the branch home pages. |
// Maybe we are on one of the branch home pages. |
| 778 |
$possible_branch = arg(1); |
$possible_branch = arg(1); |
| 780 |
} |
} |
| 781 |
|
|
| 782 |
if (isset($possible_branch)) { |
if (isset($possible_branch)) { |
| 783 |
$branches = api_get_branches(); |
$branch_id = db_result(db_query("SELECT branch_id FROM {api_branch} WHERE branch_name = '%s'", $args[$end])); |
|
if (isset($branches[$possible_branch])) { |
|
|
$branch = $possible_branch; |
|
|
} |
|
| 784 |
} |
} |
| 785 |
if (!isset($branch)) { |
if (empty($branch_id)) { |
| 786 |
$branch = variable_get('api_default_branch', NULL); |
$branch_id = variable_get('api_default_branch', NULL); |
| 787 |
} |
} |
| 788 |
} |
} |
| 789 |
|
|
| 790 |
return $branch; |
$branches = api_get_branches(); |
| 791 |
|
return $branches[$branch_id]; |
| 792 |
} |
} |
| 793 |
|
|
| 794 |
function api_search_form($form_state, $branch_name) { |
function api_search_form($form_state, $branch_name) { |
| 828 |
else { |
else { |
| 829 |
$tail = implode('/', $args); |
$tail = implode('/', $args); |
| 830 |
} |
} |
| 831 |
$_REQUEST['destination'] = 'api/search/'. variable_get('api_default_branch', NULL) .'/'. $tail; |
$branches = api_get_branches(); |
| 832 |
|
$_REQUEST['destination'] = 'api/search/'. $branches[variable_get('api_default_branch', NULL)]->branch_name .'/'. $tail; |
| 833 |
drupal_goto(); |
drupal_goto(); |
| 834 |
} |
} |
| 835 |
|
|
| 836 |
/** |
/** |
| 837 |
* Menu callback; perform a global search for documentation. |
* Menu callback; perform a global search for documentation. |
| 838 |
*/ |
*/ |
| 839 |
function api_search_listing($branch_name) { |
function api_search_listing($branch) { |
| 840 |
$search_text = func_get_args(); |
$search_text = func_get_args(); |
| 841 |
array_shift($search_text); |
array_shift($search_text); |
| 842 |
$search_text = implode('/', $search_text); |
$search_text = implode('/', $search_text); |
| 843 |
drupal_set_title(t('Search for %search', array('%search' => $search_text))); |
drupal_set_title(t('Search for %search', array('%search' => $search_text))); |
| 844 |
|
|
| 845 |
$count = db_result(db_query("SELECT count(*) FROM {api_documentation} WHERE branch_name = '%s' AND title = '%s'", $branch_name, $search_text)); |
$count = db_result(db_query("SELECT count(*) FROM {api_documentation} WHERE branch_name = '%s' AND title = '%s'", $branch->branch_name, $search_text)); |
| 846 |
if ($count == 1) { |
if ($count == 1) { |
| 847 |
// Exact match. |
// Exact match. |
| 848 |
$item = db_fetch_object(db_query("SELECT * FROM {api_documentation} WHERE branch_name = '%s' AND title = '%s'", $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)); |
| 849 |
drupal_goto(api_url($item)); |
drupal_goto(api_url($item)); |
| 850 |
} |
} |
| 851 |
else { |
else { |
| 852 |
// Wildcard search. |
// Wildcard search. |
| 853 |
$result = pager_query("SELECT * FROM {api_documentation} WHERE branch_name = '%s' AND object_name LIKE '%%%s%%' ORDER BY title", 50, 0, NULL, $branch_name, $search_text); |
$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); |
| 854 |
return api_render_listing($result, 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); |
| 855 |
} |
} |
| 856 |
} |
} |
| 857 |
|
|
| 884 |
* @see https://developer.mozilla.org/en/Creating_OpenSearch_plugins_for_Firefox |
* @see https://developer.mozilla.org/en/Creating_OpenSearch_plugins_for_Firefox |
| 885 |
*/ |
*/ |
| 886 |
function api_opensearch($branch_name) { |
function api_opensearch($branch_name) { |
| 887 |
$valid = api_get_branches(); |
if (!db_result(db_query("SELECT 1 FROM {api_branch} WHERE branch_name = '%s'", $branch_name))) { |
|
if (!isset($valid[$branch_name])) { |
|
| 888 |
return drupal_not_found(); |
return drupal_not_found(); |
| 889 |
} |
} |
| 890 |
|
|
| 962 |
/** |
/** |
| 963 |
* Menu callback; displays the main documentation page. |
* Menu callback; displays the main documentation page. |
| 964 |
*/ |
*/ |
| 965 |
function api_page_branch($branch_name) { |
function api_page_branch($branch) { |
| 966 |
$result = db_query("SELECT documentation FROM {api_documentation} WHERE object_name = '%s' AND branch_name = '%s' AND object_type = 'mainpage'", $branch_name, $branch_name); |
$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); |
| 967 |
if ($branch = db_fetch_object($result)) { |
if ($docs = db_fetch_object($result)) { |
| 968 |
return api_link_documentation($branch->documentation, $branch_name); |
return api_link_documentation($docs->documentation, $branch); |
| 969 |
} |
} |
| 970 |
else { |
else { |
| 971 |
return theme('api_branch_default_page', $branch_name); |
return theme('api_branch_default_page', $branch->branch_name); |
| 972 |
} |
} |
| 973 |
} |
} |
| 974 |
|
|
| 975 |
/** |
/** |
| 976 |
* Menu callback; displays an object listing. |
* Menu callback; displays an object listing. |
| 977 |
*/ |
*/ |
| 978 |
function api_page_listing($branch_name, $object_type) { |
function api_page_listing($branch, $object_type) { |
| 979 |
$result = pager_query("SELECT * FROM {api_documentation} WHERE branch_name = '%s' AND object_type = '%s' ORDER BY title", 50, 0, NULL, $branch_name, $object_type); |
$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); |
| 980 |
return api_render_listing($result) . theme('pager', NULL, 50, 0); |
return api_render_listing($result, $branch) . theme('pager', NULL, 50, 0); |
| 981 |
} |
} |
| 982 |
|
|
| 983 |
/** |
/** |
| 988 |
* @param $empty_message |
* @param $empty_message |
| 989 |
* An optional string to display instead of an empty table. |
* An optional string to display instead of an empty table. |
| 990 |
*/ |
*/ |
| 991 |
function api_render_listing($result, $empty_message = NULL) { |
function api_render_listing($result, $branch, $empty_message = NULL) { |
| 992 |
$headers = array( |
$headers = array( |
| 993 |
t('Name'), |
t('Name'), |
| 994 |
t('Location'), |
t('Location'), |
| 1000 |
$rows[] = array( |
$rows[] = array( |
| 1001 |
l($object->title, api_url($object)), |
l($object->title, api_url($object)), |
| 1002 |
'<small>'. api_file_link($object) .'</small>', |
'<small>'. api_file_link($object) .'</small>', |
| 1003 |
api_link_documentation($object->summary, $object->branch_name), |
api_link_documentation($object->summary, $branch), |
| 1004 |
); |
); |
| 1005 |
} |
} |
| 1006 |
|
|
| 1031 |
/** |
/** |
| 1032 |
* Menu callback; displays documentation for a function. |
* Menu callback; displays documentation for a function. |
| 1033 |
*/ |
*/ |
| 1034 |
function api_page_function($function) { |
function api_page_function($branch, $function) { |
| 1035 |
drupal_set_title($function->title); |
drupal_set_title($function->title); |
| 1036 |
drupal_set_breadcrumb(array( |
drupal_set_breadcrumb(array( |
| 1037 |
l(t('Home'), ''), |
l(t('Home'), ''), |
| 1124 |
); |
); |
| 1125 |
} |
} |
| 1126 |
|
|
| 1127 |
$documentation = api_link_documentation($function->documentation, $function->branch_name); |
$documentation = api_link_documentation($function->documentation, $branch); |
| 1128 |
$parameters = api_link_documentation($function->parameters, $function->branch_name); |
$parameters = api_link_documentation($function->parameters, $branch); |
| 1129 |
$return = api_link_documentation($function->return_value, $function->branch_name); |
$return = api_link_documentation($function->return_value, $branch); |
| 1130 |
$code = api_link_code($function->code, $function->branch_name); |
$code = api_link_code($function->code, $branch); |
| 1131 |
$related_topics = api_related_topics($function->did, $function->branch_name); |
$related_topics = api_related_topics($function->did, $branch); |
| 1132 |
|
|
| 1133 |
$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)); |
| 1134 |
$call = ''; |
$call = ''; |
| 1139 |
$call_functions[] = array( |
$call_functions[] = array( |
| 1140 |
'function' => l($object->title, api_url($object)), |
'function' => l($object->title, api_url($object)), |
| 1141 |
'file' => api_file_link($object), |
'file' => api_file_link($object), |
| 1142 |
'description' => api_link_documentation($object->summary, $object->branch_name), |
'description' => api_link_documentation($object->summary, $branch), |
| 1143 |
); |
); |
| 1144 |
} |
} |
| 1145 |
$call_title = format_plural($call_count, '1 function calls @name()', '@count functions call @name()', array('@name' => $function->title)); |
$call_title = format_plural($call_count, '1 function calls @name()', '@count functions call @name()', array('@name' => $function->title)); |
| 1154 |
/** |
/** |
| 1155 |
* Menu callback; displays documentation for a constant. |
* Menu callback; displays documentation for a constant. |
| 1156 |
*/ |
*/ |
| 1157 |
function api_page_constant($constant) { |
function api_page_constant($branch, $constant) { |
| 1158 |
drupal_set_title($constant->title); |
drupal_set_title($constant->title); |
| 1159 |
|
|
| 1160 |
$documentation = api_link_documentation($constant->documentation, $constant->branch_name); |
$documentation = api_link_documentation($constant->documentation, $branch); |
| 1161 |
$code = api_link_code($constant->code, $constant->branch_name); |
$code = api_link_code($constant->code, $branch); |
| 1162 |
$related_topics = api_related_topics($constant->did, $constant->branch_name); |
$related_topics = api_related_topics($constant->did, $branch); |
| 1163 |
|
|
| 1164 |
$output = theme('api_constant_page', $constant, $documentation, $code, $related_topics); |
$output = theme('api_constant_page', $constant, $documentation, $code, $related_topics); |
| 1165 |
$output .= _api_add_comments($constant); |
$output .= _api_add_comments($constant); |
| 1169 |
/** |
/** |
| 1170 |
* Menu callback; displays documentation for a global. |
* Menu callback; displays documentation for a global. |
| 1171 |
*/ |
*/ |
| 1172 |
function api_page_global($global) { |
function api_page_global($branch, $global) { |
| 1173 |
drupal_set_title($global->title); |
drupal_set_title($global->title); |
| 1174 |
|
|
| 1175 |
$documentation = api_link_documentation($global->documentation, $global->branch_name); |
$documentation = api_link_documentation($global->documentation, $branch); |
| 1176 |
$related_topics = api_related_topics($global->did, $global->branch_name); |
$related_topics = api_related_topics($global->did, $branch); |
| 1177 |
$code = api_link_code($global->code, $global->branch_name); |
$code = api_link_code($global->code, $branch); |
| 1178 |
|
|
| 1179 |
$output = theme('api_global_page', $global, $documentation, $code, $related_topics); |
$output = theme('api_global_page', $global, $documentation, $code, $related_topics); |
| 1180 |
$output .= _api_add_comments($global); |
$output .= _api_add_comments($global); |
| 1184 |
/** |
/** |
| 1185 |
* Menu callback; displays documentation for a file. |
* Menu callback; displays documentation for a file. |
| 1186 |
*/ |
*/ |
| 1187 |
function api_page_file($file) { |
function api_page_file($branch, $file) { |
| 1188 |
drupal_set_title($file->title); |
drupal_set_title($file->title); |
| 1189 |
|
|
| 1190 |
$documentation = api_link_documentation($file->documentation, $file->branch_name); |
$documentation = api_link_documentation($file->documentation, $branch); |
| 1191 |
$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, 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); |
| 1192 |
$rows = array( |
$rows = array( |
| 1193 |
'constant' => array(), |
'constant' => array(), |
| 1197 |
while ($object = db_fetch_object($result)) { |
while ($object = db_fetch_object($result)) { |
| 1198 |
$rows[$object->object_type][] = array( |
$rows[$object->object_type][] = array( |
| 1199 |
l($object->title, api_url($object)), |
l($object->title, api_url($object)), |
| 1200 |
api_link_documentation($object->summary, $file->branch_name), |
api_link_documentation($object->summary, $branch), |
| 1201 |
); |
); |
| 1202 |
} |
} |
| 1203 |
$header = array( |
$header = array( |
| 1252 |
/** |
/** |
| 1253 |
* Menu callback; displays source code for a file. |
* Menu callback; displays source code for a file. |
| 1254 |
*/ |
*/ |
| 1255 |
function api_page_file_source($file) { |
function api_page_file_source($branch, $file) { |
| 1256 |
drupal_set_title($file->title); |
drupal_set_title($file->title); |
| 1257 |
|
|
| 1258 |
return api_link_code($file->code, $file->branch_name); |
return api_link_code($file->code, $branch); |
| 1259 |
} |
} |
| 1260 |
|
|
| 1261 |
/** |
/** |
| 1262 |
* Menu callback; displays documentation for a group. |
* Menu callback; displays documentation for a group. |
| 1263 |
*/ |
*/ |
| 1264 |
function api_page_group($group) { |
function api_page_group($branch, $group) { |
| 1265 |
drupal_set_title($group->title); |
drupal_set_title($group->title); |
| 1266 |
|
|
| 1267 |
$documentation = api_link_documentation($group->documentation, $group->branch_name); |
$documentation = api_link_documentation($group->documentation, $branch); |
| 1268 |
|
|
| 1269 |
$rows = array( |
$rows = array( |
| 1270 |
'constant' => array(), |
'constant' => array(), |
| 1276 |
$rows[$object->object_type][] = array( |
$rows[$object->object_type][] = array( |
| 1277 |
l($object->title, api_url($object)), |
l($object->title, api_url($object)), |
| 1278 |
'<small>'. api_file_link($object) .'</small>', |
'<small>'. api_file_link($object) .'</small>', |
| 1279 |
api_link_documentation($object->summary, $object->branch_name), |
api_link_documentation($object->summary, $branch), |
| 1280 |
); |
); |
| 1281 |
} |
} |
| 1282 |
$header = array( |
$header = array( |
| 1302 |
return $output; |
return $output; |
| 1303 |
} |
} |
| 1304 |
|
|
| 1305 |
function api_related_topics($did, $branch_name) { |
function api_related_topics($did, $branch) { |
| 1306 |
$header = array( |
$header = array( |
| 1307 |
t('Name'), |
t('Name'), |
| 1308 |
t('Description'), |
t('Description'), |
| 1310 |
$topics = array(); |
$topics = array(); |
| 1311 |
$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", $did); |
$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", $did); |
| 1312 |
while ($group = db_fetch_object($result)) { |
while ($group = db_fetch_object($result)) { |
| 1313 |
$topics[l($group->title, 'api/group/'. $group->object_name .'/'. $branch_name)] = api_link_documentation($group->summary, $branch_name); |
$topics[l($group->title, 'api/group/'. $group->object_name .'/'. $branch->branch_name)] = api_link_documentation($group->summary, $branch); |
| 1314 |
} |
} |
| 1315 |
if (count($topics) > 0) { |
if (count($topics) > 0) { |
| 1316 |
return theme('api_related_topics', $topics); |
return theme('api_related_topics', $topics); |
| 1330 |
/** |
/** |
| 1331 |
* Turn function names into links. |
* Turn function names into links. |
| 1332 |
*/ |
*/ |
| 1333 |
function api_link_code($code, $branch_name) { |
function api_link_code($code, $branch) { |
| 1334 |
return _api_link_documentation($code, $branch_name, array('code function')); |
return _api_link_documentation($code, $branch, array('code function')); |
| 1335 |
} |
} |
| 1336 |
|
|
| 1337 |
function api_link_documentation($documentation, $branch_name) { |
function api_link_documentation($documentation, $branch) { |
| 1338 |
return _filter_url(api_filter_documentation($documentation, $branch_name), NULL); |
return _filter_url(api_filter_documentation($documentation, $branch), NULL); |
| 1339 |
} |
} |
| 1340 |
|
|
| 1341 |
/** |
/** |
| 1342 |
* Turn function and file names into links. This is done on output because the |
* Turn function and file names into links. This is done on output because the |
| 1343 |
* identifiers which are linked frequently change. |
* identifiers which are linked frequently change. |
| 1344 |
*/ |
*/ |
| 1345 |
function api_filter_documentation($text, $branch_name) { |
function api_filter_documentation($text, $branch) { |
| 1346 |
// Remove escaping from \@. |
// Remove escaping from \@. |
| 1347 |
return preg_replace('!\\\@!', '@', _api_link_documentation($text, $branch_name, array('tags', 'link', 'function', 'file'))); |
return preg_replace('!\\\@!', '@', _api_link_documentation($text, $branch, array('tags', 'link', 'function', 'file'))); |
| 1348 |
} |
} |
| 1349 |
|
|
| 1350 |
function _api_link_documentation($documentation, $branch_name, $stages = array()) { |
function _api_link_documentation($documentation, $branch, $stages = array()) { |
| 1351 |
$patterns = array( |
$patterns = array( |
| 1352 |
// Find HTML tags, which will not be filtered. |
// Find HTML tags, which will not be filtered. |
| 1353 |
'tags' => '/(<[^>]+?>)/', |
'tags' => '/(<[^>]+?>)/', |
| 1398 |
$callback = NULL; |
$callback = NULL; |
| 1399 |
} |
} |
| 1400 |
|
|
| 1401 |
return api_split($patterns[$stage], $documentation, $callback_match, array($branch_name, $prepend, $append), $callback, array($branch_name, $stages)); |
return api_split($patterns[$stage], $documentation, $callback_match, array($branch, $prepend, $append), $callback, array($branch, $stages)); |
| 1402 |
} |
} |
| 1403 |
|
|
| 1404 |
/** |
/** |
| 1453 |
/** |
/** |
| 1454 |
* Link an object name to its documentation. |
* Link an object name to its documentation. |
| 1455 |
*/ |
*/ |
| 1456 |
function api_link_name($name, $branch_name, $prepend = '', $append = '', $text = NULL, $is_link = FALSE) { |
function api_link_name($name, $branch, $prepend = '', $append = '', $text = NULL, $is_link = FALSE) { |
| 1457 |
static $local_objects, $php_functions; |
static $local_objects, $php_functions; |
| 1458 |
|
|
| 1459 |
if (is_null($local_objects)) { |
if (is_null($local_objects)) { |
| 1460 |
$result = db_query("SELECT object_name, title, object_type, summary, branch_name FROM {api_documentation} WHERE branch_name = '%s'", $branch_name); |
$result = db_query("SELECT object_name, title, object_type, summary, branch_name FROM {api_documentation} WHERE branch_name = '%s'", $branch->branch_name); |
| 1461 |
$local_objects = array( |
$local_objects = array( |
| 1462 |
'function' => array(), |
'function' => array(), |
| 1463 |
'file' => array(), |
'file' => array(), |
| 1486 |
} |
} |
| 1487 |
|
|
| 1488 |
if ($is_link && array_key_exists($name, $local_objects['group'])) { |
if ($is_link && array_key_exists($name, $local_objects['group'])) { |
| 1489 |
return $prepend . l($text, 'api/group/'. $local_objects['group'][$name]->object_name .'/'. $branch_name) . $append; |
return $prepend . l($text, 'api/group/'. $local_objects['group'][$name]->object_name .'/'. $branch->branch_name) . $append; |
| 1490 |
} |
} |
| 1491 |
elseif (array_key_exists($name, $local_objects['function'])) { |
elseif (array_key_exists($name, $local_objects['function'])) { |
| 1492 |
return $prepend . l($text, 'api/function/'. $local_objects['function'][$name]->object_name .'/'. $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; |
| 1493 |
} |
} |
| 1494 |
elseif (array_key_exists($name, $local_objects['file'])) { |
elseif (array_key_exists($name, $local_objects['file'])) { |
| 1495 |
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($local_objects['file'][$name]), array('attributes' => array('title' => $local_objects['file'][$name]->summary, 'class' => 'local'))); |
| 1496 |
} |
} |
| 1497 |
elseif (array_key_exists($name, $local_objects['constant'])) { |
elseif (array_key_exists($name, $local_objects['constant'])) { |
| 1498 |
return l($text, 'api/constant/'. $local_objects['constant'][$name]->object_name .'/'. $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'))); |
| 1499 |
} |
} |
| 1500 |
elseif (array_key_exists($name, $local_objects['global'])) { |
elseif (array_key_exists($name, $local_objects['global'])) { |
| 1501 |
return l($text, 'api/global/'. $local_objects['global'][$name]->object_name .'/'. $branch_name, array('attributes' => array('title' => $local_objects['global'][$name]->summary, 'class' => 'local'))); |
return l($text, 'api/global/'. $local_objects['global'][$name]->object_name .'/'. $branch->branch_name, array('attributes' => array('title' => $local_objects['global'][$name]->summary, 'class' => 'local'))); |
| 1502 |
} |
} |
| 1503 |
elseif (array_key_exists($name, $php_functions)) { |
elseif (array_key_exists($name, $php_functions)) { |
| 1504 |
$link = strtr(variable_get('api_php_funcpath', 'http://php.net/!function'), array('!function' => $name)); |
$link = strtr(variable_get('api_php_funcpath', 'http://php.net/!function'), array('!function' => $name)); |
| 1509 |
} |
} |
| 1510 |
} |
} |
| 1511 |
|
|
| 1512 |
function api_link_link($name, $branch_name, $prepend = '', $append = '') { |
function api_link_link($name, $branch, $prepend = '', $append = '') { |
| 1513 |
$words = preg_split('/\s+/', $name); |
$words = preg_split('/\s+/', $name); |
| 1514 |
$name = array_shift($words); |
$name = array_shift($words); |
| 1515 |
return api_link_name($name, $branch_name, $prepend, $append, implode(' ', $words), TRUE); |
return api_link_name($name, $branch, $prepend, $append, implode(' ', $words), TRUE); |
| 1516 |
} |
} |