Changeset 12664
- Timestamp:
- 02/23/08 17:26:59 (11 months ago)
- Files:
-
- 1 modified
-
util/branches/dev/jsdoc/jsdoc.module (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
util/branches/dev/jsdoc/jsdoc.module
r12657 r12664 84 84 else { 85 85 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"); 86 87 $items[] = array('path' => 'jsdoc/manage', 87 'title' => t('Manage Documentation Changes '),88 'title' => t('Manage Documentation Changes: ' . db_result($query) . ' left'), 88 89 'callback' => 'drupal_get_form', 89 90 'callback arguments' => array('jsdoc_manage'), … … 135 136 if (count($node) == 1) { 136 137 $node = $node[0]; 138 jsdoc_current_node($node); 137 139 } 138 140 $item = array( … … 181 183 } 182 184 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); 184 250 $block['subject'] = 'Objects'; 185 251 $block['content'] = theme('jsdoc_namespaces', $namespaces); … … 317 383 $where, 318 384 array(), 319 'i.relevance + (1 0/ CHAR_LENGTH(n.title)) AS score',385 'i.relevance + (15 / CHAR_LENGTH(n.title)) AS score', 320 386 "INNER JOIN {node} n ON (n.nid = i.sid)" 321 387 ); … … 438 504 _jsdoc_init(); 439 505 440 $namespaces = array();441 506 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); 443 509 while ($result = db_fetch_object($query)) { 444 510 if (jsdoc_is_namespace($result)) { 445 $namespaces[ ] = $result->title;511 $namespaces[$result->jsdoc_version][] = array($result->nid, $result->vid); 446 512 } 447 513 } 448 }449 cache_set('jsdoc_namespaces', 'cache', serialize($namespaces));514 cache_set('jsdoc_namespaces_' . $project->title, 'cache', serialize($namespaces)); 515 } 450 516 451 517 // Build an array of ctimes from our cache table … … 777 843 foreach ($vids as $vid => $props) { 778 844 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); 783 847 db_query("UPDATE {jsdoc_objects} SET used = -1 WHERE nid = %d AND vid = %d", $nid, $vid); 848 $node->status = 0; 849 node_save($node); 784 850 } 785 851 } … … 3020 3086 } 3021 3087 3088 function jsdoc_current_node($node=null) { 3089 static $current; 3090 if (is_null($node)) { 3091 return $current; 3092 } 3093 $current = $node; 3094 } 3095 3022 3096 function jsdoc_get_resources(&$node, $environments) { 3023 3097 if (isset($node->jsdoc_resources)) { … … 3856 3930 $output = '<ul>'; 3857 3931 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>"; 3859 3941 } 3860 3942 $output .= '</ul>';