Changeset 12056

Show
Ignore:
Timestamp:
01/16/08 15:08:09 (12 months ago)
Author:
pottedmeat
Message:

Refs #5602.

  • Split out UI into themed functions
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • util/dev/jsdoc/jsdoc.module

    r11930 r12056  
    10111011  $node = node_prepare($node, $teaser); 
    10121012  if (!$teaser) { 
    1013      
     1013    // Add link to the jsdoc page 
    10141014  } 
    10151015  return $node; 
     
    11131113  $query = db_query("SELECT nid FROM {node} WHERE type = 'jsdoc_object' AND title = '%s'", $node->title); 
    11141114  while ($object = db_fetch_object($query)) { 
    1115     jsdoc_object_delete($object); 
     1115    node_delete($object->nid); 
    11161116  } 
    11171117} 
     
    12861286} 
    12871287 
     1288/** 
     1289 * 
     1290 */ 
    12881291function jsdoc_get_parents(&$node) { 
    1289   if (isset($node->jsdoc_parents) || !$node->jsdoc_used) return; 
     1292  if (isset($node->jsdoc_parents)) return $node->jsdoc_parents; 
    12901293 
    12911294  $node->jsdoc_parents = array(); 
    12921295 
    1293   if ($node->type == "jsdoc_object" || ($node->type == "jsdoc_variable" && $node->jsdoc_detail)) { 
     1296  if ($node->type == "jsdoc_object" || ($node->type == "jsdoc_variable" && jsdoc_get_variable_object($node))) { 
    12941297    if ($node->type == "jsdoc_variable") { 
    1295       $detail = $node->jsdoc_detail; 
     1298      $detail = jsdoc_get_variable_object($node); 
    12961299    } 
    12971300    else { 
     
    13201323    $node->jsdoc_parents = $detail->jsdoc_parents; 
    13211324  } 
    1322   elseif ($node->type == "jsdoc_variable") { 
     1325  elseif ($node->type == 'jsdoc_variable') { 
    13231326    $node->jsdoc_parents = array(); 
    1324     if ($node->jsdoc_detail) { 
    1325       $query = db_query("SELECT %d AS vid", $node->jsdoc_detail->vid); 
     1327    if (jsdoc_get_variable_object($node)) { 
     1328      $query = db_query("SELECT %d AS vid", jsdoc_get_variable_object($node)->vid); 
    13261329    } 
    13271330    else { 
     
    13401343 
    13411344  return $node->jsdoc_parents; 
     1345} 
     1346 
     1347function jsdoc_get_classlike(&$node) { 
     1348  if (isset($node->jsdoc_classlike)) { 
     1349    return $node->jsdoc_classlike; 
     1350  } 
     1351 
     1352  if ($node->type == 'jsdoc_variable') { 
     1353    $classlikes = array(); 
     1354    $query = db_query("SELECT j.classlike FROM {jsdoc_objects} j JOIN {node_revisions} nr ON (nr.vid = j.vid) WHERE nr.title = '%s' AND BINARY nr.title = '%s' AND j.version = %d", $node->title, $node->title, jsdoc_get_version($node)->nid); 
     1355    while ($result = db_fetch_object($query)) { 
     1356      $classlikes[] = $result->classlike; 
     1357    } 
     1358    $classlikes = array_unique($classlikes); 
     1359    if (count($classlikes) == 1) { 
     1360      return $node->jsdoc_classlike = $classlikes[0]; 
     1361    } 
     1362  } 
     1363 
     1364  return $node->jsdoc_classlike = false; 
     1365} 
     1366 
     1367function jsdoc_get_teaser(&$node) { 
     1368  if ($node->type == 'jsdoc_variable' && !$node->teaser) { 
     1369    return $node->teaser = _jsdoc_resolve_variable($node)->teaser; 
     1370  } 
     1371 
     1372  return $node->teaser; 
     1373} 
     1374 
     1375function jsdoc_get_body(&$node) { 
     1376  if ($node->type == 'jsdoc_variable' && !$node->body) { 
     1377    return $node->body = _jsdoc_resolve_variable($node)->body; 
     1378  } 
     1379 
     1380  return $node->body; 
     1381} 
     1382 
     1383function jsdoc_get_format(&$node) { 
     1384  if ($node->type == 'jsdoc_variable' && !$node->format) { 
     1385    return $node->format = _jsdoc_resolve_variable($node)->format; 
     1386  } 
     1387 
     1388  return $node->format; 
     1389} 
     1390 
     1391function jsdoc_get_full_url(&$node) { 
     1392  if ($node->type == 'jsdoc_variable' && !$node->jsdoc_full_url) { 
     1393    return $node->jsdoc_full_url = _jsdoc_resolve_variable($node)->full_url; 
     1394  } 
     1395 
     1396  return $node->jsdoc_full_url; 
     1397} 
     1398 
     1399function jsdoc_get_variable_object(&$node) { 
     1400  if ($node->type == 'jsdoc_variable') { 
     1401    return _jsdoc_resolve_variable($node)->object; 
     1402  } 
     1403 
     1404  return $node; 
     1405} 
     1406 
     1407function jsdoc_get_type(&$node) { 
     1408  if (isset($node->jsdoc_type)) { 
     1409    return $node->jsdoc_type; 
     1410  } 
     1411 
     1412  if ($node->type == 'jsdoc_variable') { 
     1413    $types = array(); 
     1414    $query = db_query("SELECT j.type FROM {jsdoc_objects} j JOIN {node_revisions} nr ON (nr.vid = j.vid) WHERE nr.title = '%s' AND BINARY nr.title = '%s' AND j.version = %d", $node->title, $node->title, jsdoc_get_version($node)->nid); 
     1415    while ($result = db_fetch_object($query)) { 
     1416      if ($result->type) { 
     1417        $types[] = $result->type; 
     1418      } 
     1419    } 
     1420    $types = array_unique($types); 
     1421    if (count($types) == 1) { 
     1422      return $node->jsdoc_type = $types[0]; 
     1423    } 
     1424    elseif (count($types) > 1) { 
     1425      return $node->jsdoc_type = 'mixed'; 
     1426    } 
     1427  } 
     1428 
     1429  return ''; 
    13421430} 
    13431431 
     
    14351523  $node->jsdoc_version = $additions->jsdoc_version; 
    14361524  $additions->jsdoc_url = 'jsdoc/' . jsdoc_get_project($node)->title . '/HEAD/resource/' . str_replace('/', '__', $node->title); 
    1437   $additions->jsdoc_formatted = array(); 
     1525  $additions->jsdoc_anchor = l($node->title, $additions->jsdoc_url); 
    14381526  return $additions; 
    14391527} 
     
    14451533  // An object might have a "default" disambiguation package. 
    14461534  $additions = db_fetch_object(db_query("SELECT version AS jsdoc_version, resource_nid AS jsdoc_resource, resource_vid AS jsdoc_resource_vid, private AS jsdoc_private FROM {jsdoc_variables} WHERE vid = %d", $node->vid)); 
    1447   if ($additions->jsdoc_resource_vid == -1) { 
    1448     $additions->jsdoc_disambiguation = -1; 
    1449   } 
    1450   elseif ($additions->jsdoc_resource) { 
    1451     $additions->jsdoc_disambiguation = _jsdoc_node_load($additions->jsdoc_resource, $additions->jsdoc_resource_vid); 
    1452   } 
    1453   unset($additions->jsdoc_resource); 
    1454   unset($additions->jsdoc_resource_vid); 
    1455  
    14561535  $node->jsdoc_version = $additions->jsdoc_version; 
    1457   $version = jsdoc_get_version($node); 
    1458  
    1459   $additions->jsdoc_disambiguations = array(); 
    1460   $additions->jsdoc_url = 'jsdoc/' . jsdoc_get_project($version)->title . '/' . $version->title . '/object/' . $node->title; 
    1461  
    1462   $additions->teaser = ''; 
    1463   $additions->body = ''; 
    1464   if ($additions->jsdoc_disambiguation == -1) { 
    1465     $additions->teaser = $node->teaser; 
    1466     $additions->body = $node->body; 
    1467   } 
    1468  
    1469   $types = array(); 
    1470   $classlikes = array(); 
    1471  
    1472   $query = db_query("SELECT n.teaser, n.body, j.nid, MAX(j.vid) AS vid, j.resource_nid, MAX(j.resource_vid) AS resource_vid, j.classlike, j.type, j.private FROM {jsdoc_objects} j JOIN {node_revisions} n ON (j.vid = n.vid) WHERE n.title = '%s' AND BINARY n.title = '%s' AND j.used != -1 AND j.new = 0 AND j.version = %d GROUP BY n.nid", $node->title, $node->title, $version->nid); 
    1473  
    1474   while ($result = db_fetch_object($query)) { 
    1475     if (db_num_rows($query) == 1 || ($additions->jsdoc_disambiguation && $additions->jsdoc_disambiguation->vid == $result->resource_vid)) { 
    1476       $additions->jsdoc_detail = _jsdoc_node_load($result->nid, $result->vid); 
    1477       $sumdesc = db_fetch_object(db_query("SELECT j.type, j.classlike, n.teaser, n.body, n.format, n2.title AS resource FROM {jsdoc_objects} j JOIN {node_revisions} n ON (n.vid = j.vid) JOIN {node_revisions} n2 ON (n2.vid = j.resource_vid) WHERE j.vid = %d", $additions->jsdoc_detail->vid)); 
    1478       if ($additions->jsdoc_disambiguation != -1) { 
    1479         $additions->teaser = $sumdesc->teaser; 
    1480         $additions->format = $sumdesc->format; 
    1481         $additions->body = $sumdesc->body; 
    1482       } 
    1483       $additions->jsdoc_type = $sumdesc->type; 
    1484       $additions->jsdoc_classlike = $sumdesc->classlike; 
    1485       $additions->jsdoc_full_url = 'jsdoc/' . jsdoc_get_project($node)->title . '/' . $version->title . '/object/' . str_replace('/', '__', $sumdesc->resource) . '/' . $node->title; 
    1486       $additions->jsdoc_url = 'jsdoc/' . jsdoc_get_project($node)->title . '/' . $version->title . '/object/' . $node->title; 
    1487     } 
    1488     else { 
    1489       if (!$node->jsdoc_disambiguation) { 
    1490         $types[] = $result->type; 
    1491         $classlikes[] = $result->classlike; 
    1492         if ($result->teaser && !$node->teaser && !$additions->teaser) { 
    1493           $additions->teaser = $result->teaser; 
    1494         } 
    1495         if ($result->body && !$node->body && !$additions->body) { 
    1496           $additions->body = $result->body; 
    1497         } 
    1498       } 
    1499       $additions->jsdoc_disambiguations[] = _jsdoc_node_load($result->nid, $result->vid);       
    1500     } 
    1501   } 
    1502  
    1503   if (!empty($types)) { 
    1504     $types = array_unique($types); 
    1505     if (count($types) == 1) { 
    1506       $additions->jsdoc_type = $types[0]; 
    1507     } 
    1508     else { 
    1509       $additions->jsdoc_type = 'mixed'; 
    1510     } 
    1511   } 
    1512  
    1513   if (!empty($classlikes)) { 
    1514     $additions->jsdoc_classlike = false; 
    1515  
    1516     $classlikes = array_unique($classlikes); 
    1517     if (count($types) == 1) { 
    1518       $additions->jsdoc_classlike = $classlikes[0]; 
    1519     } 
    1520   } 
    1521  
    1522   if ($additions->jsdoc_detail || count($additions->jsdoc_disambiguations)) { 
    1523     $additions->jsdoc_used = 1; 
    1524   } 
    1525   else { 
    1526     $additions->jsdoc_used = 0; 
    1527     $node->jsdoc_renames = array(); 
    1528     // Check for what the deleted items have been renamed to 
    1529     $query = db_query("SELECT nr.nid, nr.vid FROM {node_revisions} nr JOIN {jsdoc_objects} jo ON (jo.vid = nr.vid) WHERE nr.title = '%s' AND BINARY nr.title = '%s' AND jo.version = %d", $node->title, $node->title, $version->nid); 
    1530     while ($object = db_fetch_object($query)) { 
    1531       $renames_query = db_query("SELECT nr.title FROM {jsdoc_objects} jo JOIN {node_revisions} nr ON (nr.nid = jo.nid) WHERE jo.nid = %d AND nr.vid != %d AND jo.version = %d GROUP BY nr.nid", $object->nid, $object->vid, $version->nid); 
    1532       while ($rename = db_fetch_object($renames_query)) { 
    1533         if ($rename->title == $node->title) continue; 
    1534         if (!$node->jsdoc_renames[$rename->title]) { 
    1535           $node->jsdoc_renames[$rename->title] = jsdoc_object_node_load(jsdoc_get_project($rename), jsdoc_get_version($rename), $rename->title); 
    1536         } 
    1537       } 
    1538     } 
    1539   } 
    1540  
    1541   if(arg(0) == 'node' && arg(2) == 'edit') { 
    1542     unset($additions->teaser); 
    1543     unset($additions->body); 
    1544   } 
    1545  
    1546   $additions->jsdoc_title = $node->title; 
    1547  
    1548   $additions->jsdoc_formatted = _jsdoc_format_type($additions->jsdoc_type, $additions->jsdoc_classlike); 
     1536  $additions->jsdoc_url = 'jsdoc/' . jsdoc_get_project($node)->title . '/' . jsdoc_get_version($node)->title . '/object/' . $node->title; 
    15491537 
    15501538  return $additions; 
     
    24572445 */ 
    24582446function jsdoc_object_node_view($node, $initialized = null, $allow_private = false) { 
     2447  // Test for the basics 
    24592448  if (!$node) { 
    24602449    return drupal_not_found(); 
     
    24632452    return drupal_not_found(); 
    24642453  } 
     2454 
     2455  drupal_add_js('misc/collapse.js'); 
     2456 
     2457  $used = $node->jsdoc_used; 
     2458  $title = $node->title; 
     2459  $teaser = $node->teaser; 
     2460  $body = $node->body; 
     2461  $format = $node->format; 
     2462  $object_type = $node->jsdoc_type; 
     2463  $classlike = false; 
     2464  $full_url = $node->jsdoc_url; 
     2465 
     2466  $resources = array(); 
     2467 
     2468  $variables = array(); 
     2469  $source = ''; 
     2470  $signature = ''; 
     2471  $parameters = array(); 
     2472 
     2473  if ($node->type == 'jsdoc_object') { 
     2474    $object = $node; 
     2475  } 
     2476  elseif ($node->type == 'jsdoc_variable') { 
     2477    $resource = jsdoc_get_resource($node); 
     2478    $version = jsdoc_get_version($node); 
     2479 
     2480    $teaser = jsdoc_get_teaser($node); 
     2481    $body = jsdoc_get_body($node); 
     2482    $format = jsdoc_get_format($node); 
     2483    $object_type = jsdoc_get_format($node); 
     2484    $classlike = jsdoc_get_classlike($node); 
     2485    $full_url = jsdoc_get_full_url($node); 
     2486    $object = jsdoc_get_variable_object($node); 
     2487 
     2488    if ($object || count($resources)) { 
     2489      $used = 1; 
     2490    } 
     2491    else { 
     2492      $used = 0; 
     2493      $renames = array(); 
     2494      // Check for what the deleted items have been renamed to 
     2495      $query = db_query("SELECT nr.nid, nr.vid FROM {node_revisions} nr JOIN {jsdoc_objects} jo ON (jo.vid = nr.vid) WHERE nr.title = '%s' AND BINARY nr.title = '%s' AND jo.version = %d", $node->title, $node->title, $version->nid); 
     2496      while ($object = db_fetch_object($query)) { 
     2497        $renames_query = db_query("SELECT nr.title FROM {jsdoc_objects} jo JOIN {node_revisions} nr ON (nr.nid = jo.nid) WHERE jo.nid = %d AND nr.vid != %d AND jo.version = %d GROUP BY nr.nid", $object->nid, $object->vid, $version->nid); 
     2498        while ($rename = db_fetch_object($renames_query)) { 
     2499          if ($rename->title == $node->title) continue; 
     2500          if (!$renamed[$rename->title]) { 
     2501            $renames[$rename->title] = jsdoc_object_node_load(jsdoc_get_project($rename), jsdoc_get_version($rename), $rename->title); 
     2502          } 
     2503        } 
     2504      } 
     2505    } 
     2506  } 
     2507 
     2508  drupal_set_title($title); 
     2509 
     2510  $parents = jsdoc_get_parents($node); 
     2511  if ($node->type == 'jsdoc_variable' && $parents['all']) { 
     2512    $parent = $parents['all'][0]; 
     2513  } 
     2514 
     2515  $display = _jsdoc_theme_clone($node); 
     2516  $display->used = $used; 
     2517  $display->teaser = $teaser; 
     2518  $display->body = $body; 
     2519  $display->format = $format; 
     2520  $display->object_type = $object_type ? $object_type : 'Object'; 
     2521  $display->classlike = $classlike; 
     2522  $display->full_url = $full_url; 
     2523  $display->formatted = _jsdoc_format_type($display->object_type, $classlike);; 
     2524 
     2525  $display = _jsdoc_theme_clone($node); 
     2526  if (!empty($resources)) { 
     2527    $display->multiple = count($resources) != 1; 
     2528    $display_resources = array(); 
     2529    foreach ($resources as $resource_value) { 
     2530      $display_resources[] = (object)array( 
     2531        'anchor' => $resource_value->jsdoc_anchor 
     2532      ); 
     2533    } 
     2534    $display->resources = $display_resources; 
     2535    $resources_output = theme('jsdoc_object_resources', $display); 
     2536  } 
     2537 
     2538  if ($object) { 
     2539  } 
     2540  else { 
     2541    if ($display->object_type == 'Function') { 
     2542      theme('jsdoc_function', $display); 
     2543    } 
     2544    else { 
     2545      theme('jsdoc_object', $display); 
     2546    } 
     2547  } 
     2548 
     2549  $classes = array(); 
     2550  $functions = array(); 
     2551  $fields = array(); 
     2552  jsdoc_load_children($node); 
     2553  foreach ($node->jsdoc_variables as $variable_name => $variable) { 
     2554    if (jsdoc_get_type($variable) == 'Function') { 
     2555      if (jsdoc_get_classlike($variable)) { 
     2556        $addto = &$classes; 
     2557      } 
     2558      else { 
     2559        $addto = &$functions; 
     2560      } 
     2561    } 
     2562    else { 
     2563      $addto = &$fields; 
     2564    } 
     2565 
     2566    $display = drupal_clone($variable); 
     2567    $formatted_type = _jsdoc_format_type(jsdoc_get_type($variable), jsdoc_get_classlike($variable)); 
     2568    $display->object_type = $formatted_type['type']; 
     2569    if (jsdoc_get_type($variable) && jsdoc_get_type($variable) != 'mixed') { 
     2570      $display->object_type_link = l($formatted_type['type'], jsdoc_object_node_load(jsdoc_get_project($object), jsdoc_get_version($object), jsdoc_get_type($variable))->jsdoc_url) . $formatted_type['separator']; 
     2571    } 
     2572    $display->title_link = l($variable->title, $variable->jsdoc_url); 
     2573    jsdoc_get_teaser($display); 
     2574    $addto[] = _jsdoc_theme_clone($display); 
     2575  } 
     2576 
     2577  $node = node_prepare($node); 
     2578  $node->content['teaser'] = array( 
     2579    '#value' => $node->teaser, 
     2580    '#weight' => -1 
     2581  ); 
     2582  if ($resources_output) { 
     2583    $node->content['jsdoc_resources'] = array( 
     2584      '#value' => $resources_output, 
     2585      '#weight' => 1 
     2586    ); 
     2587  } 
     2588 
     2589  $parent = jsdoc_object_node_load(jsdoc_get_project($node), jsdoc_get_version($node), $parent); 
     2590  $formatted_type = _jsdoc_format_type($parent->title, jsdoc_get_classlike($parent)); 
     2591  $parent->object_type = $formatted_type['type']; 
     2592  $parent->object_type_link = l($formatted_type['type'], $parent->jsdoc_url); 
     2593  $node->content['jsdoc_parent'] = array( 
     2594    '#value' => theme('jsdoc_parent', $parent), 
     2595    '#weight' => 1.5 
     2596  ); 
     2597 
     2598  $display = _jsdoc_theme_clone($node); 
     2599  $formatted_type = _jsdoc_format_type(jsdoc_get_type($node), jsdoc_get_classlike($node)); 
     2600  $display->object_type = $formatted_type['type']; 
     2601  $display->object_type_link = l($formatted_type['type'], jsdoc_object_node_load(jsdoc_get_project($node), jsdoc_get_version($node), $formatted_type['type'])->jsdoc_url) . $formatted_type['separator']; 
     2602  $node->content['jsdoc_type'] = array( 
     2603    '#value' => theme('jsdoc_object_type', $display), 
     2604    '#weight' => 2 
     2605  ); 
     2606 
     2607  $node->content['jsdoc_fields'] = array( 
     2608    '#value' => theme('jsdoc_field_list', $fields), 
     2609    '#weight' => 3 
     2610  ); 
     2611 
     2612  $node->content['jsdoc_functions'] = array( 
     2613    '#value' => theme('jsdoc_function_list', $functions), 
     2614    '#weight' => 4 
     2615  ); 
     2616 
     2617  $node->content['jsdoc_classes'] = array( 
     2618    '#value' => theme('jsdoc_class_list', $classes), 
     2619    '#weight' => 5 
     2620  ); 
     2621 
     2622  return drupal_render_form('jsdoc_object_form', $node->content); 
     2623 
     2624  /* Reimplement 
    24652625  if ($node->type == 'jsdoc_variable' && !$node->jsdoc_detail && empty($node->jsdoc_disambiguations) && !count($node->jsdoc_renames)) { 
    24662626    return drupal_not_found();     
     
    24782638  drupal_set_title(check_plain($node->title)); 
    24792639  return node_show($node, 0); 
     2640  */ 
    24802641} 
    24812642 
     
    31523313// ========================= 
    31533314 
     3315function _jsdoc_theme_clone($node) { 
     3316  $clone = drupal_clone($node); 
     3317  foreach ($clone as $key => $value) { 
     3318    if (substr($key, 0, 6) == 'jsdoc_') { 
     3319      unset($clone->$key); 
     3320    } 
     3321  } 
     3322  return $clone; 
     3323} 
     3324 
    31543325function _jsdoc_node_load($param = array(), $revision = NULL, $reset = NULL) { 
    31553326  static $nodes; 
     
    31833354    } 
    31843355  } 
    3185    
     3356 
    31863357  $highlighter =& new GeSHi($text, 'javascript'); 
    31873358  $highlighter->enable_classes(); 
     
    32213392} 
    32223393 
     3394function _jsdoc_resolve_variable(&$node) { 
     3395  if (isset($node->jsdoc_resolved)) { 
     3396    return $node->jsdoc_resolved; 
     3397  } 
     3398 
     3399  $resource = jsdoc_get_resource($node); 
     3400  $version = jsdoc_get_version($node); 
     3401 
     3402  $used = $node->jsdoc_used; 
     3403  $title = $node->title; 
     3404  $teaser = $node->teaser; 
     3405  $body = $node->body; 
     3406  $format = $node->format; 
     3407  $object_type = $node->jsdoc_type; 
     3408  $classlike = false; 
     3409  $full_url = $node->jsdoc_url; 
     3410 
     3411  $query = db_query("SELECT n.teaser, n.body, n.format, j.nid, MAX(j.vid) AS vid, j.resource_nid, MAX(j.resource_vid) AS resource_vid, j.classlike, j.type, j.private FROM {jsdoc_objects} j JOIN {node_revisions} n ON (j.vid = n.vid) WHERE n.title = '%s' AND BINARY n.title = '%s' AND j.used != -1 AND j.new = 0 AND j.version = %d GROUP BY n.nid", $node->title, $node->title, $version->nid); 
     3412  while ($result = db_fetch_object($query)) { 
     3413    // If there's only one object for a given variable, or if a resource is chosen, use this as the object 
     3414    $resources[] = _jsdoc_node_load($result->resource_nid, $result->resource_vid); 
     3415    if (db_num_rows($query) == 1 || ($resource && $resource->vid == $result->resource_vid)) { 
     3416      $object = _jsdoc_node_load($result->nid, $result->vid); 
     3417      $sumdesc = db_fetch_object(db_query("SELECT j.type, j.classlike, n.teaser, n.body, n.format, n2.title AS resource FROM {jsdoc_objects} j JOIN {node_revisions} n ON (n.vid = j.vid) JOIN {node_revisions} n2 ON (n2.vid = j.resource_vid) WHERE j.vid = %d", $result->vid)); 
     3418      if ($sumdesc->teaser && !$teaser) { 
     3419        $teaser = $sumdesc->teaser; 
     3420      } 
     3421      if ($sumdesc->body && !$body) { 
     3422        $body = $sumdesc->body; 
     3423      } 
     3424      if ($sumdesc->format && !$format) { 
     3425        $format = $sumdesc->format; 
     3426      } 
     3427      if ($sumdesc->type && !$object_type) { 
     3428        $object_type = $sumdesc->type; 
     3429      } 
     3430      $classlike = $sumdesc->classlike; 
     3431      $full_url = str_replace('/object/', '/object/' . str_replace('/', '__', $sumdesc->resource) . '/', $full_url); 
     3432    } 
     3433    else { 
     3434      if ($result->teaser && !$teaser) { 
     3435        $teaser = $result->teaser; 
     3436      } 
     3437      if ($result->body && !$body) { 
     3438        $body = $result->body; 
     3439      } 
     3440      $format = $result->format; 
     3441      if ($result->type) { 
     3442        if (!$object_type) { 
     3443          $object_type = $result->type; 
     3444        } 
     3445        elseif ($object_type != $result->type) { 
     3446          $object_type = 'mixed'; 
     3447        } 
     3448      } 
     3449      if ($result->classlike) { 
     3450        $classlike = true; 
     3451      } 
     3452    } 
     3453  } 
     3454 
     3455  return $node->jsdoc_resolved = (object)array( 
     3456    'teaser' => $teaser, 
     3457    'body' => $body, 
     3458    'format' => $format, 
     3459    'object_type' => $object_type, 
     3460    'classlike' => $classlike, 
     3461    'full_url' => $full_url 
     3462  ); 
     3463} 
     3464 
    32233465function _jsdoc_markup_text($text, $version, $format = false){ 
    32243466  if (!$format) { 
     
    32403482  drupal_add_css(drupal_get_path('module', 'jsdoc') . '/jsdoc.css'); 
    32413483} 
     3484 
     3485// Theme functions 
     3486// =============== 
     3487 
     3488/** 
     3489 * Theme the list of resources that this object might appear in. 
     3490 */ 
     3491function theme_jsdoc_object_resources($node) { 
     3492  $output = '<div class="jsdoc_object_resources">'; 
     3493  $output .= '<fieldset class="collapsible collapsed">'; 
     3494  $output .= '<legend><a href="#">Appears in Resource'; 
     3495  if ($node->multiple) { 
     3496    $output .= 's'; 
     3497  } 
     3498  $output .= '</a></legend>'; 
     3499  $output .= '<div class="fieldset-wrapper">'; 
     3500  foreach ($node->resources as $resource) { 
     3501    $output .= '<div class="form-item">'; 
     3502    $output .= $resource->anchor; 
     3503    $output .= '</div>'; 
     3504  } 
     3505  $output .= '</div>'; 
     3506  $output .= '</fieldset>'; 
     3507 
     3508  return $output; 
     3509} 
     3510 
     3511/** 
     3512 * Theme the object type block. 
     3513 */ 
     3514function theme_jsdoc_object_type($node) { 
     3515  return '<div class="form-item"><label>Object Type:</label>' . $node->object_type_link . '</div>'; 
     3516} 
     3517 
     3518function theme_jsdoc_function($node) { 
     3519  return 'Function'; 
     3520} 
     3521 
     3522function theme_jsdoc_object($node) { 
     3523  return 'Object'; 
     3524} 
     3525 
     3526function theme_jsdoc_parent($node) { 
     3527  return '<div class="form-item"><label>Parent Object:</label>' . $node->object_type_link . '</div>'; 
     3528} 
     3529 
     3530/** 
     3531 * Theme a list of nodes that are classlike 
     3532 */ 
     3533function theme_jsdoc_class_list($nodes) { 
     3534  return theme_jsdoc_field_list($nodes, 'Classes'); 
     3535} 
     3536 
     3537/** 
     3538 * Theme a list of nodes that are functions 
     3539 */ 
     3540function theme_jsdoc_function_list($nodes) { 
     3541  return theme_jsdoc_field_list($nodes, 'Functions'); 
     3542} 
     3543 
     3544/** 
     3545 * Theme a list of nodes that aren't classes or functions 
     3546 */ 
     3547function theme_jsdoc_field_list($nodes, $title = 'Fields') { 
     3548  if (!empty($nodes)) { 
     3549    $output = '<div class="jsdoc_field_list">'; 
     3550    $output .= '<fieldset class="collapsible">'; 
     3551    $output .= '<legend><a href="#">' . $title . '</a></legend>'; 
     3552    $output .= '<div class="fieldset-wrapper">'; 
     3553    foreach ($nodes as $node) { 
     3554      $output .= '<div class="form-item">'; 
     3555      $output .= $node->object_type_link . $node->title_link; 
     3556      if ($node->teaser) { 
     3557        $output .= ': ' . $node->teaser; 
     3558      } 
     3559      $output .= '</div>'; 
     3560    } 
     3561    $output .= '</div>'; 
     3562    $output .= '</fieldset>'; 
     3563 
     3564    return $output; 
     3565  } 
     3566} 
     3567 
     3568/** 
     3569 * Theme all fields for a given object (should only be used if UI is being seriously tweaked). 
     3570 */ 
     3571function theme_jsdoc_any_list($nodes) { 
     3572   
     3573}