Changeset 12664

Show
Ignore:
Timestamp:
02/23/08 17:26:59 (11 months ago)
Author:
pottedmeat
Message:

Refs #5602. Check in slightly more advanced namespace block

Files:
1 modified

Legend:

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

    r12657 r12664  
    8484  else { 
    8585    if (db_result(db_query("SELECT 1 FROM {jsdoc_objects} WHERE used = 0"))) { 
     86      $query = db_query("SELECT COUNT(*) FROM {jsdoc_objects} WHERE used = 0"); 
    8687      $items[] = array('path' => 'jsdoc/manage', 
    87         'title' => t('Manage Documentation Changes'), 
     88        'title' => t('Manage Documentation Changes: ' . db_result($query) . ' left'), 
    8889        'callback' => 'drupal_get_form', 
    8990        'callback arguments' => array('jsdoc_manage'), 
     
    135136        if (count($node) == 1) { 
    136137          $node = $node[0]; 
     138          jsdoc_current_node($node); 
    137139        } 
    138140        $item = array( 
     
    181183      } 
    182184      elseif ($delta == 1) { 
    183         $namespaces = unserialize(cache_get('jsdoc_namespaces', 'cache')->data); 
     185        $namespaces = array(); 
     186 
     187        $current = jsdoc_current_node(); 
     188 
     189        if ($_GET['jsdoc_project'] || $current) { 
     190          if ($current) { 
     191            $project_title = jsdoc_get_project($current)->title; 
     192          } 
     193          else { 
     194            $project_title = $_GET['jsdoc_project']; 
     195          } 
     196 
     197          foreach (jsdoc_projects() as $project) { 
     198            if ($project->title != $project_title) { 
     199              $namespaces[] = (object)array( 
     200                'title' => $project->title, 
     201                'url' => url($_GET['q'], 'jsdoc_project=' . $project->title), 
     202                'a' => l($project->title, $_GET['q'], array(), 'jsdoc_project=' . $project->title) 
     203              ); 
     204            } 
     205            else { 
     206              if ($_GET['jsdoc_project']) { 
     207                $version = jsdoc_version_node_load('HEAD', $_GET['jsdoc_project']); 
     208                $project = jsdoc_get_project($version); 
     209              } 
     210              else { 
     211                $version = jsdoc_get_version($current); 
     212                $project = jsdoc_get_project($current); 
     213              } 
     214              $all_namespaces = unserialize(cache_get('jsdoc_namespaces_' . $project->title, 'cache')->data); 
     215 
     216              foreach ($all_namespaces[$version->nid] as $namespace) { 
     217                $namespace = _jsdoc_node_load($namespace[0], $namespace[1]); 
     218                $children = false; 
     219 
     220                if ($_GET['jsdoc_object'] == $namespace->title) { 
     221                  $variables = jsdoc_get_child_variables($namespace); 
     222                  if (!empty($variables)) { 
     223                    foreach ($variables as $child) { 
     224                      $children[$child->title] = _jsdoc_get_object_themed($child); 
     225                    } 
     226                    uksort($children, "strnatcasecmp"); 
     227                  } 
     228                } 
     229 
     230                $namespace = _jsdoc_get_object_themed($namespace); 
     231                $namespace->children = $children; 
     232                $namespace->url = url($namespace->title, $_GET['q'], 'jsdoc_project=' . $_GET['jsdoc_project'] . '&jsdoc_object=' . $namespace->title); 
     233                $namespace->a = l($namespace->title, $_GET['q'], array(), 'jsdoc_project=' . $_GET['jsdoc_project'] . '&jsdoc_object=' . $namespace->title); 
     234 
     235                $namespaces[] = $namespace; 
     236              } 
     237            } 
     238          } 
     239        } 
     240        else { 
     241          foreach (jsdoc_projects() as $project) { 
     242            $namespaces[] = (object)array( 
     243              'title' => $project->title, 
     244              'url' => url($_GET['q'], 'jsdoc_project=' . $project->title), 
     245              'a' => l($project->title, $_GET['q'], array(), 'jsdoc_project=' . $project->title) 
     246            ); 
     247          } 
     248        } 
     249        //$namespaces = unserialize(cache_get('jsdoc_namespaces', 'cache')->data); 
    184250        $block['subject'] = 'Objects'; 
    185251        $block['content'] = theme('jsdoc_namespaces', $namespaces); 
     
    317383        $where, 
    318384        array(), 
    319         'i.relevance + (10 / CHAR_LENGTH(n.title)) AS score', 
     385        'i.relevance + (15 / CHAR_LENGTH(n.title)) AS score', 
    320386        "INNER JOIN {node} n ON (n.nid = i.sid)" 
    321387      ); 
     
    438504      _jsdoc_init(); 
    439505 
    440       $namespaces = array(); 
    441506      foreach (jsdoc_projects() as $project) { 
    442         $query = db_query("SELECT n.title, jo.type AS jsdoc_type, jo.initialized AS jsdoc_intialized FROM {jsdoc_objects} jo JOIN {node} n ON (n.vid = jo.vid) WHERE jo.private = 0 AND jo.private_parent = 0 AND (n.title = '%s' OR n.title LIKE '%s.%%') AND (jo.type = 'Object' OR (jo.type = 'Function' AND jo.initialized = 1)) GROUP BY BINARY n.title ORDER BY n.title", $project->title, $project->title); 
     507        $namespaces = array(); 
     508        $query = db_query("SELECT n.title, n.nid, n.vid, jo.version AS jsdoc_version, jo.type AS jsdoc_type, jo.initialized AS jsdoc_intialized FROM {jsdoc_objects} jo JOIN {node} n ON (n.vid = jo.vid) WHERE jo.private = 0 AND jo.private_parent = 0 AND (n.title = '%s' OR n.title LIKE '%s.%%') AND (jo.type = 'Object' OR (jo.type = 'Function' AND jo.initialized = 1)) GROUP BY BINARY n.title ORDER BY n.title", $project->title, $project->title); 
    443509        while ($result = db_fetch_object($query)) { 
    444510          if (jsdoc_is_namespace($result)) { 
    445             $namespaces[] = $result->title; 
     511            $namespaces[$result->jsdoc_version][] = array($result->nid, $result->vid); 
    446512          } 
    447513        } 
    448       } 
    449       cache_set('jsdoc_namespaces', 'cache', serialize($namespaces)); 
     514        cache_set('jsdoc_namespaces_' . $project->title, 'cache', serialize($namespaces)); 
     515      } 
    450516 
    451517      // Build an array of ctimes from our cache table 
     
    777843        foreach ($vids as $vid => $props) { 
    778844          if ($props['delete']) { 
    779             if ($type == 'resources') { 
    780               db_query("UPDATE {jsdoc_resources} SET used = -1 WHERE vid = %d", $vid); 
    781             } 
    782             elseif ($type == 'objects') { 
     845            if ($type == 'objects') { 
     846              $node = _jsdoc_node_load($nid, $vid); 
    783847              db_query("UPDATE {jsdoc_objects} SET used = -1 WHERE nid = %d AND vid = %d", $nid, $vid); 
     848              $node->status = 0; 
     849              node_save($node); 
    784850            } 
    785851          } 
     
    30203086} 
    30213087 
     3088function jsdoc_current_node($node=null) { 
     3089  static $current; 
     3090  if (is_null($node)) { 
     3091    return $current; 
     3092  } 
     3093  $current = $node; 
     3094} 
     3095 
    30223096function jsdoc_get_resources(&$node, $environments) { 
    30233097  if (isset($node->jsdoc_resources)) { 
     
    38563930  $output = '<ul>'; 
    38573931  foreach ($namespaces as $namespace) { 
    3858     $output .= "<li>$namespace</li>"; 
     3932    $output .= "<li>{$namespace->a}"; 
     3933    if (!empty($namespace->children)) { 
     3934      $output .= '<ul>'; 
     3935      foreach ($namespace->children as $child) { 
     3936        $output .= "<li>{$child->a}</li>"; 
     3937      } 
     3938      $output .= '</ul>'; 
     3939    } 
     3940    $output .= "</li>"; 
    38593941  } 
    38603942  $output .= '</ul>';