Changeset 13205

Show
Ignore:
Timestamp:
03/25/08 16:43:24 (10 months ago)
Author:
pottedmeat
Message:

Refs #5602. Merge dev branch back into trunk

Location:
util/trunk/jsdoc
Files:
3 added
5 modified

Legend:

Unmodified
Added
Removed
  • util/trunk/jsdoc/INSTALL

    r10914 r13205  
    55================= 
    66 
    7 http://drupal.org/drupal-5.1 (tested on 5.1 at the time of this writing) 
     7http://drupal.org/drupal-5.7 (tested on 5.7 at the time of this writing) 
    88http://drupal.org/getting-started/5/install 
    99 
     
    1616===================== 
    1717 
     18http://drupal.org/node/70151 
    1819Drop the jsdoc folder into sites/all/modules 
    1920 
  • util/trunk/jsdoc/jsdoc.css

    r11199 r13205  
    1 /** 
    2  * GeSHi Dynamically Generated Stylesheet 
    3  * -------------------------------------- 
    4  * Dynamically generated stylesheet for javascript 
    5  * CSS class: javascript, CSS id:  
    6  * GeSHi (C) 2004 - 2007 Nigel McNie (http://qbnz.com/highlighter) 
    7  */ 
    8 .javascript .de1, .javascript .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} 
    9 .javascript  {} 
    10 .javascript .head {} 
    11 .javascript .foot {} 
    12 .javascript .imp {font-weight: bold; color: red;} 
    13 .javascript .ln-xtra {color: #cc0; background-color: #ffc;} 
    14 .javascript li {font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;} 
    15 .javascript li.li2 {font-weight: bold;} 
    16 .javascript .kw1 {color: #000066; font-weight: bold;} 
    17 .javascript .kw2 {color: #003366; font-weight: bold;} 
     1/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */ 
     2.javascript .de1, .javascript .de2 {font-weight:normal;background:transparent;color:#000; padding-left: 5px;} 
     3.javascript .kw1 {color: #a1a100;} 
     4.javascript .kw2 {color: #000; font-weight: bold;} 
    185.javascript .kw3 {color: #000066;} 
    19 .javascript .co1 {color: #009900; font-style: italic;} 
    20 .javascript .coMULTI {color: #009900; font-style: italic;} 
    21 .javascript .es0 {color: #000099; font-weight: bold;} 
     6.javascript .kw4 {color: #f63333;} 
     7.javascript .co1, .javascript .co2, .javascript .coMULTI {color: #808080;} 
     8.javascript .es0 {color: #000033; font-weight: bold;} 
    229.javascript .br0 {color: #66cc66;} 
    23 .javascript .st0 {color: #3366CC;} 
    24 .javascript .nu0 {color: #CC0000;} 
    25 .javascript .me1 {color: #006600;} 
    26 .javascript .sc0 {} 
    27 .javascript .sc1 {} 
    28 .javascript .sc2 {} 
    29 .javascript .sc3 {} 
    30 .javascript .re0 {color: #0066FF;} 
    31 /** 
    32  * GeSHi Dynamically Generated Stylesheet 
    33  * -------------------------------------- 
    34  * Dynamically generated stylesheet for javascript 
    35  * CSS class: javascript, CSS id:  
    36  * GeSHi (C) 2004 - 2007 Nigel McNie (http://qbnz.com/highlighter) 
    37  */ 
    38 .javascript .de1, .javascript .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} 
    39 .javascript  {} 
    40 .javascript .head {} 
    41 .javascript .foot {} 
    42 .javascript .imp {font-weight: bold; color: red;} 
    43 .javascript .ln-xtra {color: #cc0; background-color: #ffc;} 
    44 .javascript li {font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;} 
    45 .javascript li.li2 {font-weight: bold;} 
    46 .javascript .kw1 {color: #000066; font-weight: bold;} 
    47 .javascript .kw2 {color: #003366; font-weight: bold;} 
    48 .javascript .kw3 {color: #000066;} 
    49 .javascript .kw4 {color: #600000;} 
    50 .javascript .co1 {color: #009900; font-style: italic;} 
    51 .javascript .coMULTI {color: #009900; font-style: italic;} 
    52 .javascript .es0 {color: #000099; font-weight: bold;} 
    53 .javascript .br0 {color: #66cc66;} 
    54 .javascript .st0 {color: #3366CC;} 
    55 .javascript .nu0 {color: #CC0000;} 
    56 .javascript .me1 {color: #006600;} 
    57 .javascript .sc0 {} 
    58 .javascript .sc1 {} 
    59 .javascript .sc2 {} 
    60 .javascript .sc3 {} 
    61 .javascript .re0 {color: #0066FF;} 
    62 /** 
    63  * GeSHi Dynamically Generated Stylesheet 
    64  * -------------------------------------- 
    65  * Dynamically generated stylesheet for javascript 
    66  * CSS class: javascript, CSS id:  
    67  * GeSHi (C) 2004 - 2007 Nigel McNie (http://qbnz.com/highlighter) 
    68  */ 
    69 .javascript .de1, .javascript .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} 
    70 .javascript  {} 
    71 .javascript .head {} 
    72 .javascript .foot {} 
    73 .javascript .imp {font-weight: bold; color: red;} 
    74 .javascript .ln-xtra {color: #cc0; background-color: #ffc;} 
    75 .javascript li {font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;} 
    76 .javascript li.li2 {font-weight: bold;} 
    77 .javascript .kw1 {color: #000066; font-weight: bold;} 
    78 .javascript .kw2 {color: #003366; font-weight: bold;} 
    79 .javascript .kw3 {color: #000066;} 
    80 .javascript .co1 {color: #009900; font-style: italic;} 
    81 .javascript .coMULTI {color: #009900; font-style: italic;} 
    82 .javascript .es0 {color: #000099; font-weight: bold;} 
    83 .javascript .br0 {color: #66cc66;} 
    84 .javascript .st0 {color: #3366CC;} 
    85 .javascript .nu0 {color: #CC0000;} 
    86 .javascript .me1 {color: #006600;} 
    87 .javascript .sc0 {} 
    88 .javascript .sc1 {} 
    89 .javascript .sc2 {} 
    90 .javascript .sc3 {} 
    91 .javascript .re0 {color: #0066FF;} 
    92 /** 
    93  * GeSHi Dynamically Generated Stylesheet 
    94  * -------------------------------------- 
    95  * Dynamically generated stylesheet for javascript 
    96  * CSS class: javascript, CSS id:  
    97  * GeSHi (C) 2004 - 2007 Nigel McNie (http://qbnz.com/highlighter) 
    98  */ 
    99 .javascript .de1, .javascript .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} 
    100 .javascript  {} 
    101 .javascript .head {} 
    102 .javascript .foot {} 
    103 .javascript .imp {font-weight: bold; color: red;} 
    104 .javascript .ln-xtra {color: #cc0; background-color: #ffc;} 
    105 .javascript li {font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;} 
    106 .javascript li.li2 {font-weight: bold;} 
    107 .javascript .kw1 {color: #000066; font-weight: bold;} 
    108 .javascript .kw2 {color: #003366; font-weight: bold;} 
    109 .javascript .kw3 {color: #000066;} 
    110 .javascript .co1 {color: #009900; font-style: italic;} 
    111 .javascript .coMULTI {color: #009900; font-style: italic;} 
    112 .javascript .es0 {color: #000099; font-weight: bold;} 
    113 .javascript .br0 {color: #66cc66;} 
    114 .javascript .st0 {color: #3366CC;} 
    115 .javascript .nu0 {color: #CC0000;} 
    116 .javascript .me1 {color: #006600;} 
    117 .javascript .sc0 {} 
    118 .javascript .sc1 {} 
    119 .javascript .sc2 {} 
    120 .javascript .sc3 {} 
    121 .javascript .re0 {color: #0066FF;} 
     10.javascript .st0 {color: #ff0000;} 
     11.javascript .nu0 {color: #ff33ff;} 
     12.javascript .me0 {color: #006600;} 
     13 
     14.html4strict .de1, .html4strict .de2 {font-weight:normal;background:transparent;color:#000; padding-left: 5px;} 
     15.html4strict .kw1 {color: #a1a100;} 
     16.html4strict .kw2 {color: #000; font-weight: bold;} 
     17.html4strict .kw3 {color: #000066;} 
     18.html4strict .kw4 {color: #f63333;} 
     19.html4strict .co1, .html4strict .co2, .html4strict .coMULTI {color: #808080;} 
     20.html4strict .es0 {color: #000033; font-weight: bold;} 
     21.html4strict .br0 {color: #66cc66;} 
     22.html4strict .st0 {color: #ff0000;} 
     23.html4strict .nu0 {color: #ff33ff;} 
     24.html4strict .me0 {color: #006600;} 
  • util/trunk/jsdoc/jsdoc.install

    r11930 r13205  
    119119        updating bool NOT NULL DEFAULT 1, -- Flag for update the next go around 
    120120        returns varchar(255) NOT NULL, 
     121        return_summary longtext NOT NULL, 
    121122        source longtext NOT NULL, 
    122123        private boolean NOT NULL DEFAULT 0, 
     
    139140        parent_vid integer NOT NULL REFERENCES {node_revisions} (vid), 
    140141        parent_nid integer NOT NULL REFERENCES {node} (vid), -- node-type: jsdoc_variable 
    141         type enum('normal', 'prototype', 'instance', 'alias', 'chain', 'mixin'), -- The type of join 
     142        type enum('normal', 'cascading', 'prototype', 'instance', 'alias', 'chain', 'mixin'), -- The type of join 
    142143        subtype enum('call', 'prototype', '') DEFAULT '', -- The subtype of the join 
    143144        version integer NOT NULL REFERENCES {node} (nid), -- node-type: jsdoc_version 
     
    180181        weight integer NOT NULL, 
    181182        example longtext NOT NULL, 
     183        markedup longtext NOT NULL, 
    182184      PRIMARY KEY (vid, weight) 
    183185      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); 
  • util/trunk/jsdoc/jsdoc.module

    r11930 r13205  
    6767      'access' => false 
    6868    ); 
     69 
     70    $items[] = array( 
     71      'path' => 'jsdoc/jsonp', 
     72      'type' => MENU_CALLBACK, 
     73      'callback' => 'jsdoc_jsonp', 
     74      'access' => true 
     75    ); 
     76 
     77    $items[] = array( 
     78      'path' => 'jsdoc/jsonp', 
     79      'type' => MENU_CALLBACK, 
     80      'callback' => 'jsdoc_jsonp', 
     81      'access' => true 
     82    ); 
     83 
     84    $items[] = array( 
     85      'path' => 'jsdoc/ide', 
     86      'type' => MENU_CALLBACK, 
     87      'callback' => 'jsdoc_ide', 
     88      'access' => true 
     89    ); 
    6990  } 
    7091  else { 
    71     if (db_result(db_query("SELECT 1 FROM {jsdoc_objects} WHERE used = 0 UNION SELECT 1 FROM {jsdoc_resources} WHERE used = 0"))) { 
     92    if (db_result(db_query("SELECT 1 FROM {jsdoc_objects} WHERE used = 0 OR new = 1"))) { 
    7293      $items[] = array('path' => 'jsdoc/manage', 
    7394        'title' => t('Manage Documentation Changes'), 
     
    79100    } 
    80101 
    81     if (arg(0) == 'jsdoc' && arg(3) == 'resource') { 
    82       // jsdoc/namespace/'HEAD'/'resource'/resource 
    83  
    84       $node = jsdoc_resource_node_load(arg(1), arg(2), str_replace('__', '/', arg(4))); 
    85       $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/resource/' . arg(4), 
    86         'title' => t('View'), 
    87         'callback' => 'jsdoc_resource_node_view', 
    88         'callback arguments' => array($node), 
    89         'access' => node_access('view', $node), 
    90         'type' => MENU_CALLBACK, 
    91       ); 
    92       $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/resource/' . arg(4) . '/view', 
    93         'title' => t('View'), 
    94         'type' => MENU_DEFAULT_LOCAL_TASK, 
    95         'weight' => -10 
    96       ); 
    97       $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/resource/' . arg(4) . '/private', 
    98         'title' => t('View w/ Private'), 
    99         'callback' => 'jsdoc_resource_node_view', 
    100         'callback arguments' => array($node), 
    101         'access' => node_access('view', $node), 
    102         'weight' => -9, 
    103         'type' => MENU_LOCAL_TASK 
    104       ); 
    105       $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/resource/' . arg(4) . '/edit', 
    106         'title' => t('Edit'), 
    107         'callback' => 'jsdoc_resource_edit_redirect', 
    108         'callback arguments' => array($node), 
    109         'access' => node_access('update', $node), 
    110         'weight' => 1, 
    111         'type' => MENU_LOCAL_TASK 
    112       ); 
    113     } 
    114  
    115     if (arg(0) == 'jsdoc' && arg(3) == 'object' && arg(4)) { 
    116       // jsdoc/namespace/'HEAD'/'object'/resource/object 
    117       if (arg(5) && arg(5) != 'view' && arg(5) != 'edit' && arg(5) != 'private') { 
    118         $item = arg(4) . '/' . arg(5); 
    119         $detail = $node = jsdoc_object_node_load(arg(1), arg(2), arg(5), str_replace('__', '/', arg(4))); 
    120       } 
    121       // jsdoc/namespace/'HEAD'/'object'/object 
    122       else { 
    123         $item = arg(4); 
    124         $detail = $node = jsdoc_object_node_load(arg(1), arg(2), arg(4)); 
    125       } 
    126  
    127       if ($node->jsdoc_detail) { 
    128         $detail = $node->jsdoc_detail; 
    129       } 
    130       $items[] = array('path' => 'jsdoc/' . arg(1) . '/' . arg(2) . '/object/' . $item, 
    131         'title' => t('View'), 
    132         'callback' => 'jsdoc_object_node_view', 
    133         'callback arguments' => array($node), 
    134         'access' => node_access('view', $node), 
    135         'type' => MENU_CALLBACK 
    136       ); 
    137       $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/object/' . $item . '/view', 
    138         'title' => t('View'), 
    139         'type' => MENU_DEFAULT_LOCAL_TASK, 
    140         'weight' => -10 
    141       ); 
    142       $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/object/' . $item . '/private', 
    143         'title' => t('View w/ Private'), 
    144         'callback' => 'jsdoc_object_node_view', 
    145         'callback arguments' => array($node, null, true), 
    146         'access' => node_access('view', $node), 
    147         'weight' => -9, 
    148         'type' => MENU_LOCAL_TASK 
    149       ); 
    150       $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/object/' . $item . '/edit', 
    151         'title' => t('Edit'), 
    152         'callback' => 'jsdoc_object_edit_redirect', 
    153         'callback arguments' => array($node), 
    154         'access' => node_access('update', $node), 
    155         'weight' => 1, 
    156         'type' => MENU_LOCAL_TASK 
    157       ); 
    158       $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/object/' . $item . '/edit/' . arg(6), 
    159         'title' => t('Edit'), 
    160         'callback' => 'jsdoc_object_edit_redirect', 
    161         'callback arguments' => array($node, arg(6)), 
    162         'access' => node_access('update', $node), 
    163         'weight' => 1, 
    164         'type' => MENU_LOCAL_TASK 
    165       ); 
    166  
    167       if ($detail->jsdoc_type == 'Function') { 
    168         if ($detail->jsdoc_classlike || $detail->jsdoc_initialized) { 
    169           $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/object/' . $item . '/view/init', 
    170             'title' => t('Initialized'), 
    171             'type' => MENU_DEFAULT_LOCAL_TASK, 
    172             'weight' => -10 
    173           ); 
    174           if (!$detail->jsdoc_initialized) { 
    175             $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/object/' . $item . '/view/normal', 
    176               'title' => t('Uninitialized'), 
    177               'callback' => 'jsdoc_object_node_view', 
    178               'callback arguments' => array($node, false), 
    179               'access' => node_access('view', $node), 
    180               'type' => MENU_LOCAL_TASK 
    181             ); 
    182             $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/object/' . $item . '/private/init', 
    183               'title' => t('Initialized'), 
    184               'type' => MENU_DEFAULT_LOCAL_TASK, 
    185               'weight' => -10 
    186             ); 
    187             $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/object/' . $item . '/private/normal', 
    188               'title' => t('Uninitialized'), 
    189               'callback' => 'jsdoc_object_node_view', 
    190               'callback arguments' => array($node, false, true), 
    191               'access' => node_access('view', $node), 
    192               'type' => MENU_LOCAL_TASK 
     102    if (arg(0) == 'jsdoc' && arg(1) != 'jsonp') { 
     103      $project = false; 
     104      $version = false; 
     105      $resource = false; 
     106      $name = ''; 
     107      $path = ''; 
     108      if (arg(4)) { 
     109        // If we have 4 arguments, assume that we've been passed a resource 
     110        $project = arg(1); 
     111        $version = arg(2); 
     112        $resource = str_replace('__', '/', arg(3)); 
     113        $name = arg(4); 
     114        $path = "jsdoc/$project/$version/" . arg(3) . "/$name"; 
     115 
     116        // TODO: Remove this once search engines have stopped indexing it. 
     117        if ($resource == 'object') { 
     118          drupal_goto("jsdoc/$project/$version/$name"); 
     119        } 
     120      } 
     121      elseif (arg(3)) { 
     122        // If we have 3 arguments, assume that we don't have a resource 
     123        $project = arg(1); 
     124        $version = arg(2); 
     125        $name = arg(3); 
     126        $path = "jsdoc/$project/$version/$name"; 
     127      } 
     128      elseif (arg(2)) { 
     129        // If we have 2 arguments, assume that we don't have a resource or project 
     130        // So basically, we assume that version is more important than project 
     131        $version = arg(1); 
     132        $name = arg(2); 
     133        $path = "jsdoc/$version/$name"; 
     134      } 
     135      elseif (arg(1)) { 
     136        // Allow the user to only pass the name 
     137        $name = arg(1); 
     138        $path = "jsdoc/$name"; 
     139      } 
     140 
     141      if ($node = jsdoc_object_nodes_load($name, $project, $version, $resource)) { 
     142        if (count($node) == 1) { 
     143          $node = $node[0]; 
     144          jsdoc_current_node($node); 
     145        } 
     146        $item = array( 
     147          'path' => $path, 
     148          'title' => t('View'), 
     149          'access' => node_access('view', $node), 
     150          'type' => MENU_CALLBACK 
     151        ); 
     152        if (is_array($node)) { 
     153          $item['callback'] = 'jsdoc_variables_node_view'; 
     154          $item['callback arguments'] = array($node); 
     155        } 
     156        else { 
     157          if ($node->type == 'jsdoc_object') { 
     158            $item['callback'] = 'jsdoc_object_node_view'; 
     159            $item['callback arguments'] = array($node); 
     160          } 
     161          else { 
     162            $item['callback'] = 'jsdoc_variable_node_view'; 
     163            $item['callback arguments'] = array($node); 
     164          } 
     165        } 
     166        $items[] = $item; 
     167      } 
     168    } 
     169  } 
     170 
     171  return $items; 
     172} 
     173 
     174/** 
     175 * Impelementation of hook_block 
     176 */ 
     177function jsdoc_block($op='list', $delta=0) { 
     178  if (module_exists('search')) { 
     179    if ($op == 'list') { 
     180      $block[0]['info'] = t('JavaScript Documentation Search'); 
     181      $block[1]['info'] = t('JavaScript Namespace List'); 
     182      return $block; 
     183    } 
     184    elseif ($op == 'view') { 
     185      if ($delta == 0) { 
     186        $block['subject'] = 'Search'; 
     187        $block['content'] = preg_replace('%ignore.*endignore%s', theme('jsdoc_search', 'search'), drupal_get_form('_jsdoc_block_search')); 
     188        return $block; 
     189      } 
     190      elseif ($delta == 1) { 
     191        $namespaces = array(); 
     192 
     193        $current = jsdoc_current_node(); 
     194 
     195        if ($_GET['jsdoc_project'] || $current) { 
     196          if ($_GET['jsdoc_project']) { 
     197            $project_title = $_GET['jsdoc_project']; 
     198          } 
     199          else { 
     200            $project_title = jsdoc_get_project($current)->title; 
     201          } 
     202 
     203          foreach (jsdoc_projects() as $project) { 
     204            if ($project->title != $project_title) { 
     205              $namespaces[] = (object)array( 
     206                'title' => $project->title, 
     207                'url' => url($_GET['q'], 'jsdoc_project=' . $project->title), 
     208                'a' => l($project->title, $_GET['q'], array(), 'jsdoc_project=' . $project->title) 
     209              ); 
     210            } 
     211            else { 
     212              if ($_GET['jsdoc_project']) { 
     213                $version = jsdoc_version_node_load('HEAD', $_GET['jsdoc_project']); 
     214                $project = jsdoc_get_project($version); 
     215              } 
     216              else { 
     217                $version = jsdoc_get_version($current); 
     218                $project = jsdoc_get_project($current); 
     219              } 
     220 
     221              if (!($all_namespaces = cache_get('jsdoc_namespaces_' . $project->title, 'cache'))) { 
     222                $all_namespaces = array(); 
     223              } 
     224              else { 
     225                $all_namespaces = unserialize($all_namespaces->data); 
     226              } 
     227              if (empty($all_namespaces[$version->nid])) { 
     228                $query = db_query("SELECT n.title, n.nid, n.vid, jo.type AS jsdoc_type, jo.initialized AS jsdoc_initialized FROM {jsdoc_objects} jo JOIN {node} n ON (n.vid = jo.vid) WHERE jo.private = 0 AND jo.private_parent = 0 AND jo.version = %d 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", $version->nid, $project->title, $project->title); 
     229                while ($result = db_fetch_object($query)) { 
     230                  if (jsdoc_is_namespace($result)) { 
     231                    $all_namespaces[$version->nid][] = array($result->nid, $result->vid); 
     232                  } 
     233                } 
     234                cache_set('jsdoc_namespaces_' . $project->title, 'cache', serialize($all_namespaces)); 
     235              } 
     236 
     237              foreach ($all_namespaces[$version->nid] as $namespace) { 
     238                $namespace = _jsdoc_node_load($namespace[0], $namespace[1]); 
     239                $children = false; 
     240 
     241                if ($_GET['jsdoc_object'] == $namespace->title) { 
     242                  $variables = jsdoc_get_child_variables($namespace); 
     243                  if (!empty($variables)) { 
     244                    foreach ($variables as $child) { 
     245                      $children[$child->title] = _jsdoc_get_object_themed($child); 
     246                    } 
     247                    uksort($children, "strnatcasecmp"); 
     248                  } 
     249                } 
     250 
     251                $namespace = _jsdoc_get_object_themed($namespace); 
     252                $namespace->children = $children; 
     253                $namespace->url = url($namespace->title, $_GET['q'], 'jsdoc_project=' . $_GET['jsdoc_project'] . '&jsdoc_object=' . $namespace->title); 
     254                $namespace->a = l($namespace->title, $_GET['q'], array(), 'jsdoc_project=' . $_GET['jsdoc_project'] . '&jsdoc_object=' . $namespace->title); 
     255 
     256                $namespaces[] = $namespace; 
     257              } 
     258            } 
     259          } 
     260        } 
     261        else { 
     262          foreach (jsdoc_projects() as $project) { 
     263            $namespaces[] = (object)array( 
     264              'title' => $project->title, 
     265              'url' => url($_GET['q'], 'jsdoc_project=' . $project->title), 
     266              'a' => l($project->title, $_GET['q'], array(), 'jsdoc_project=' . $project->title) 
    193267            ); 
    194268          } 
    195269        } 
    196         else { 
    197           $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/object/' . $item . '/view/normal', 
    198             'title' => t('Uninitialized'), 
    199             'type' => MENU_DEFAULT_LOCAL_TASK, 
    200             'weight' => -10 
    201           ); 
    202           $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/object/' . $item . '/view/init', 
    203             'title' => t('Initialized'), 
    204             'callback' => 'jsdoc_object_node_view', 
    205             'callback arguments' => array($node, true), 
    206             'access' => node_access('view', $node), 
    207             'type' => MENU_LOCAL_TASK 
    208           ); 
    209           $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/object/' . $item . '/private/normal', 
    210             'title' => t('Uninitialized'), 
    211             'type' => MENU_DEFAULT_LOCAL_TASK, 
    212             'weight' => -10 
    213           ); 
    214           $items[] = array('path' => 'jsdoc/'. arg(1) . '/' . arg(2) . '/object/' . $item . '/private/init', 
    215             'title' => t('Initialized'), 
    216             'callback' => 'jsdoc_object_node_view', 
    217             'callback arguments' => array($node, true, true), 
    218             'access' => node_access('view', $node), 
    219             'type' => MENU_LOCAL_TASK 
    220           ); 
    221         } 
    222       } 
    223     } 
    224   } 
    225  
    226   return $items; 
    227 } 
    228  
    229 /** 
    230  * shutdown function to make sure we always mark the last node processed. 
    231  */ 
    232 function jsdoc_update_shutdown() { 
    233   global $last_change, $last_nid; 
    234  
    235   if ($last_change && $last_nid) { 
    236     variable_set('jsdoc_cron_last', $last_change); 
    237     variable_set('jsdoc_cron_last_nid', $last_nid); 
    238   } 
     270        //$namespaces = unserialize(cache_get('jsdoc_namespaces', 'cache')->data); 
     271        $block['subject'] = 'Objects'; 
     272        $block['content'] = theme('jsdoc_namespaces', $namespaces); 
     273        return $block; 
     274      } 
     275    } 
     276  } 
     277} 
     278 
     279function _jsdoc_block_search() { 
     280  if (module_exists('search')) { 
     281    return array( 
     282      'ignore' => array( 
     283        '#value' => 'ignore' 
     284      ), 
     285      'search' => array( 
     286        '#type' => 'textfield' 
     287      ), 
     288      'go' => array( 
     289        '#type' => 'submit', 
     290        '#value' => 'Go' 
     291      ), 
     292      'endignore' => array( 
     293        '#value' => 'endignore' 
     294      ) 
     295    ); 
     296  } 
     297} 
     298 
     299function _jsdoc_block_search_submit($form_id, $form) { 
     300  $search = $form['search']; 
     301  if (strpos($search, ' ') === false) { 
     302    $query = db_query("SELECT title FROM {node} WHERE type = 'jsdoc_object' AND title = '%s' GROUP BY BINARY title", $search); 
     303    if (db_num_rows($query) == 1) { 
     304      $object = jsdoc_object_node_load(db_result($query)); 
     305      watchdog('search', t('%keys (@type).', array('%keys' => $search, '@type' => 'JavaScript Documentation')), WATCHDOG_NOTICE, l(t('result'), $object->jsdoc_url)); 
     306      drupal_goto($object->jsdoc_url); 
     307      return; 
     308    } 
     309    else { 
     310      $query = db_query("SELECT title FROM {node} WHERE type = 'jsdoc_object' AND title LIKE '%%%s%%' GROUP BY BINARY title", $search); 
     311      if (db_num_rows($query) == 1) { 
     312        $object = jsdoc_object_node_load(db_result($query)); 
     313        watchdog('search', t('%keys (@type).', array('%keys' => $search, '@type' => 'JavaScript Documentation')), WATCHDOG_NOTICE, l(t('result'), $object->jsdoc_url)); 
     314        drupal_goto($object->jsdoc_url); 
     315        return; 
     316      } 
     317    } 
     318  } 
     319 
     320  drupal_goto('search/jsdoc/' . $search); 
    239321} 
    240322 
     
    255337  $last = variable_get('jsdoc_cron_last', 0); 
    256338  $last_nid = variable_get('jsdoc_cron_last_nid', 0); 
    257   $limit = (int)variable_get('jsdoc_cron_limit', 100); 
    258  
    259   $result = db_query_range("SELECT GREATEST(IF(c.last_comment_timestamp IS NULL, 0, c.last_comment_timestamp), n.changed) as last_change, n.nid FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE n.type IN ('jsdoc_variable', 'jsdoc_resource') AND n.status = 1 AND ((GREATEST(n.changed, c.last_comment_timestamp) = %d AND n.nid > %d) OR (n.changed > %d OR c.last_comment_timestamp > %d)) ORDER BY GREATEST(n.changed, c.last_comment_timestamp) ASC, n.nid ASC", $last, $last_nid, $last, $last, $last, 0, $limit); 
     339  $limit = (int)variable_get('search_cron_limit', 500); 
     340 
     341  $result = db_query_range("SELECT GREATEST(IF(c.last_comment_timestamp IS NULL, 0, c.last_comment_timestamp), n.changed) as last_change, n.nid FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE n.type = 'jsdoc_variable' AND n.status = 1 AND ((GREATEST(n.changed, c.last_comment_timestamp) = %d AND n.nid > %d) OR (n.changed > %d OR c.last_comment_timestamp > %d)) ORDER BY GREATEST(n.changed, c.last_comment_timestamp) ASC, n.nid ASC", $last, $last_nid, $last, $last, $last, 0, $limit); 
    260342 
    261343  while ($node = db_fetch_object($result)) { 
     
    264346    $node = _jsdoc_node_load($node->nid); 
    265347 
    266     $text = '<h1>'. str_replace('.', ' ', $node->title) .'</h1>'. $node->title . ' ' . $node->teaser . ' ' . $node->body; 
     348    $text = '<h1>'. implode(' ', _jsdoc_build_terms($node->title)) . '</h1> ' . jsdoc_get_teaser($node) . ' ' . jsdoc_get_body($node); 
    267349 
    268350    // Fetch extra data normally not visible 
     
    274356    // Update index 
    275357    search_index($node->nid, 'jsdoc_' . jsdoc_get_version($node)->title, $text); 
     358  } 
     359} 
     360 
     361/** 
     362 * shutdown function to make sure we always mark the last node processed. 
     363 */ 
     364function jsdoc_update_shutdown() { 
     365  global $last_change, $last_nid; 
     366 
     367  if ($last_change && $last_nid) { 
     368    variable_set('jsdoc_cron_last', $last_change); 
     369    variable_set('jsdoc_cron_last_nid', $last_nid); 
    276370  } 
    277371} 
     
    290384      $keys = search_query_insert($keys, 'project'); 
    291385      $version = search_query_extract($keys, 'version'); 
     386      if (empty($version)) { 
     387        $version = 'HEAD'; 
     388        // TODO: Start using "ANY" here if no version is provided. 
     389      } 
    292390      $keys = search_query_insert($keys, 'version'); 
    293391 
     
    295393      $keys = search_query_insert($keys, 'private'); 
    296394 
    297       $private_sql = ""; 
     395      $where = '1'; 
    298396      if (!$private) { 
    299         $private_sql = " AND (jo.private = 0 OR jo.private IS NULL) "; 
    300       } 
    301  
    302       $project = _jsdoc_project_get_or_create($project); 
    303       $version = _jsdoc_version_get_or_create($version, $project); 
    304  
    305       $find = do_search(str_replace('.', ' ', $keys) . ' OR ' . $keys, 'jsdoc_' . $version->title, 'LEFT JOIN {jsdoc_objects} jo ON (i.sid = jo.nid) LEFT JOIN {jsdoc_resources} jr ON (i.sid = jr.nid)', '(jo.version = ' . $version->nid . ' OR jr.version = ' . $version->nid . ')' . $private_sql); 
     397        $where = "jo.private = 0 AND jo.private_parent = 0"; 
     398      } 
     399 
     400      $find = do_search( 
     401        '(' . implode('), (', _jsdoc_build_terms($keys)) . ')', 
     402        'jsdoc_' . $version, 
     403        "INNER JOIN {node} n ON (n.nid = i.sid) INNER JOIN {node} n2 ON (n2.title = n.title AND BINARY n2.title = BINARY n.title AND n2.type = 'jsdoc_object') INNER JOIN {jsdoc_objects} jo ON (jo.vid = n2.vid) INNER JOIN {jsdoc_versions} jv ON (jv.nid = jo.version) INNER JOIN {node} n4 ON (n4.nid = jv.project)", 
     404        $where, 
     405        array(), 
     406        'i.relevance + (15 / CHAR_LENGTH(n.title)) AS score', 
     407        "INNER JOIN {node} n ON (n.nid = i.sid)" 
     408      ); 
    306409      $results = array(); 
    307410      foreach ($find as $item) { 
     
    317420          'node' => $node, 
    318421          'score' => $item->score, 
    319           'snippet' => ($node->teaser) ? search_excerpt($keys, $node->teaser) : '' 
     422          'snippet' => (jsdoc_get_teaser($node)) ? search_excerpt($keys, jsdoc_get_teaser($node)) : '' 
    320423        ); 
    321424      } 
     
    328431 */ 
    329432function jsdoc_search_validate($form_id, $form_values, $form) {