Changeset 12569

Show
Ignore:
Timestamp:
02/20/08 15:02:44 (11 months ago)
Author:
pottedmeat
Message:

Refs #5602. Clean up the title theme function

Files:
1 modified

Legend:

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

    r12567 r12569  
    22342234  } 
    22352235 
    2236   drupal_set_title(theme('jsdoc_object_title', $node)); 
     2236  drupal_set_title(theme('jsdoc_object_title', _jsdoc_get_title_themed($node))); 
    22372237 
    22382238  return drupal_render_form('jsdoc_variable_form', $form); 
     
    22532253  drupal_add_js('misc/collapse.js'); 
    22542254 
    2255   drupal_set_title(theme('jsdoc_object_title', $node)); 
     2255  drupal_set_title(theme('jsdoc_object_title', _jsdoc_get_title_themed($node))); 
    22562256 
    22572257  $form = node_prepare($node, false)->content; 
     
    24382438} 
    24392439 
     2440function _jsdoc_get_title_themed($node) { 
     2441  $themed = (object)array( 
     2442    'title' => $node->title, 
     2443    'crumbs' => array() 
     2444  ); 
     2445 
     2446  if ($type = jsdoc_get_type($node)) { 
     2447    $type = jsdoc_object_node_load($type, jsdoc_get_project($node), jsdoc_get_version($node), jsdoc_get_all_provide_nids($node, array(3, 4))); 
     2448    $themed->type = (object)array( 
     2449      'title' => $type->title, 
     2450      'url' => $type->jsdoc_url 
     2451    ); 
     2452    if ($type->jsdoc_url) { 
     2453      $themed->type->a = l($type->title, $type->jsdoc_url); 
     2454    } 
     2455    else { 
     2456      $themed->type->a = $type->title; 
     2457    } 
     2458  } 
     2459 
     2460  $parts = explode('.', $node->title); 
     2461  $title_text = ""; 
     2462  $end = array_pop($parts); 
     2463  foreach ($parts as $part) { 
     2464    if (!empty($title_text)) { 
     2465      $title_text .= '.'; 
     2466    } 
     2467    $title_text .= $part; 
     2468 
     2469    $obj = jsdoc_object_node_load($title_text, jsdoc_get_project($node), jsdoc_get_version($node)); 
     2470    if ($obj) { 
     2471      $themed->crumbs[] = l($part, $obj->jsdoc_url); 
     2472    } 
     2473    else { 
     2474      $themed->crumbs[] = $part; 
     2475    } 
     2476  } 
     2477  $themed->crumbs[] = $end; 
     2478 
     2479  return $themed;   
     2480} 
     2481 
    24402482function _jsdoc_get_object_themed($node, $title=null) { 
    24412483  if (is_null($title)) { 
     
    30543096  } 
    30553097 
    3056   $signature = 'function ('; 
     3098  $signature = '('; 
    30573099 
    30583100  if ($parameters) { 
     
    35013543 * Theme the object type block. 
    35023544 */ 
    3503 function theme_jsdoc_object_title($node) { 
    3504   $parts = explode('.', $node->title); 
    3505   $title_text = ""; 
    3506   $end = array_pop($parts); 
    3507   $title = ""; 
    3508   $last_part = ""; 
    3509   foreach ($parts as $part) { 
    3510     if (!empty($title_text)) { 
    3511       $title_text .= '.'; 
    3512     } 
    3513     $title_text .= $part; 
    3514  
    3515     $obj = jsdoc_object_node_load($title_text, jsdoc_get_project($node), jsdoc_get_version($node)); 
    3516     if (!empty($title)) { 
    3517       $title .= '.'; 
    3518     } 
    3519     if ($obj) { 
    3520       $title .= l($part, $obj->jsdoc_url); 
    3521     } 
    3522     else { 
    3523       $title .= $part; 
    3524     } 
    3525   } 
    3526   if (!empty($title)) { 
    3527     $title .= '.'; 
    3528   } 
    3529  
    3530   $title .= $end; 
    3531  
    3532   /* 
    3533   if (jsdoc_get_type($node)) { 
    3534     $type_node = jsdoc_object_node_load(jsdoc_get_type($node), jsdoc_get_project($node), jsdoc_get_version($node)); 
    3535     if ($type_node) { 
    3536       $title .= ': ' . l(jsdoc_get_type($node), $type_node->jsdoc_url); 
    3537     } 
    3538   } 
    3539   */ 
    3540    
    3541   return $title; 
     3545function theme_jsdoc_object_title($title) { 
     3546  $output = implode('.', $title->crumbs); 
     3547  if ($title->type) { 
     3548    $output .= ': ' . $title->type->a; 
     3549  } 
     3550  return $output; 
    35423551} 
    35433552 
     
    35893598  $output .= '<div class="fieldset-wrapper">'; 
    35903599 
    3591   $statics = array(); 
    3592   $functions = array(); 
    3593   $constructors = array(); 
    3594   $objects = array(); 
    35953600  foreach($children as $child){ 
     3601     
    35963602    if($child->type){ 
    35973603      if($child->type->title=="Constructor") $constructors[]=$child; 
     
    36033609    } 
    36043610  } 
    3605    
     3611 
    36063612  $types = array("Statics"=>$statics, "Constructors"=>$constructors, "Properties"=>$objects, "Functions"=>$functions); 
    36073613  foreach($types as $key=>$arr){ 
     
    36143620        $output .= ': <small>' . $child->type->a . '</small> '; 
    36153621      } 
    3616       if($child->parameters){ 
    3617                   $output .= '('; 
    3618                   foreach ($child->parameters as $i => $param){ 
    3619                         if($i){ 
    3620                           $output .= ', '; 
    3621                         } 
    3622                     if($param->types){ 
    3623                           $output .= '/* '; 
    3624                           foreach ($param->types as $j => $type){ 
    3625                                 if($j) { 
    3626                                   $output .= '|'; 
    3627                                 } 
    3628                                 $output .= $type->a ; 
    3629                           } 
    3630                           if($param->repeating){ 
    3631                                 $output .= '...'; 
    3632                           } 
    3633                           if($param->optional){ 
    3634                                 $output .= '?'; 
    3635                           } 
    3636                           $output .= ' */ '; 
    3637                         } 
    3638                         $output .= $param->name; 
    3639           } 
    3640                   $output .= ') '; 
     3622      if($child->signature){ 
     3623        $output .= $child->signature; 
    36413624      } 
    36423625          else if($key=="Functions"){ 
     
    37053688  $output .= '<div class="fieldset-wrapper">'; 
    37063689  $output .= '<div class="form-item">'; 
    3707   $output .= $function->signature; 
     3690  $output .= 'function ' . $function->signature; 
    37083691  $output .= '</div>'; 
    37093692  $output .= '</div>';