? comments_hack_hack_hack.patch
Index: api.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/api/api.install,v
retrieving revision 1.11.2.1
diff -u -p -r1.11.2.1 api.install
--- api.install 28 Jan 2009 20:52:26 -0000 1.11.2.1
+++ api.install 13 Apr 2009 00:09:38 -0000
@@ -16,7 +16,7 @@ function api_schema() {
);
$schema['api_documentation'] = array(
'fields' => array(
- 'did' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
+ 'did' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'object_name' => array('type' => 'varchar', 'length' => '127', 'not null' => TRUE, 'default' => ''),
'branch_name' => array('type' => 'varchar', 'length' => '31', 'not null' => TRUE, 'default' => ''),
'object_type' => array('type' => 'varchar', 'length' => '31', 'not null' => TRUE, 'default' => ''),
@@ -73,6 +73,7 @@ function api_schema() {
function api_install() {
drupal_install_schema('api');
+ variable_set('comment_preview_api', COMMENT_PREVIEW_OPTIONAL);
}
function api_update_1() {
Index: api.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/api/api.module,v
retrieving revision 1.88.2.4
diff -u -p -r1.88.2.4 api.module
--- api.module 29 Jan 2009 06:00:05 -0000 1.88.2.4
+++ api.module 13 Apr 2009 00:09:38 -0000
@@ -574,6 +574,10 @@ function api_theme() {
function api_init() {
drupal_add_css(drupal_get_path('module', 'api') .'/api.css');
drupal_add_js(drupal_get_path('module', 'api') .'/api.js');
+ if (($node = menu_get_object()) && $node->type == 'api') {
+ $documentation = db_fetch_object(db_query('SELECT * FROM {api_documentation} WHERE did = %d', $node->nid));
+ drupal_goto("api/$documentation->object_type/$documentation->object_name/$documentation->branch_name");
+ }
}
function api_block($op, $delta = NULL, $edit = array()) {
@@ -988,7 +992,10 @@ function api_page_function($function) {
$call = theme('api_expandable', '
'. api_show_l('▸ '. $call_title) .'
', ''. api_hide_l('▾ '. $call_title) .'
'. theme('api_functions', $call_functions));
}
- return theme('api_function_page', $function, $signatures, $documentation, $parameters, $return, $related_topics, $call, $code);
+ $output = theme('api_function_page', $function, $signatures, $documentation, $parameters, $return, $related_topics, $call, $code);
+ $output .= comment_render(node_load($function->did));
+ $output .= comment_form_box(array('nid' => $function->did, 'type' => 'api'), t('Post new comment'));
+ return $output;
}
/**
Index: parser.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/api/parser.inc,v
retrieving revision 1.41.2.1
diff -u -p -r1.41.2.1 parser.inc
--- parser.inc 28 Jan 2009 21:35:50 -0000 1.41.2.1
+++ parser.inc 13 Apr 2009 00:09:38 -0000
@@ -429,8 +429,13 @@ function api_save_documentation($docbloc
db_query("UPDATE {api_documentation} SET title = '%s', file_name = '%s', summary = '%s', documentation = '%s', code = '%s' WHERE did = %d", $docblock['title'], $docblock['file_name'], $docblock['summary'], $docblock['documentation'], $docblock['code'], $did);
}
else {
- db_query("INSERT INTO {api_documentation} (object_name, branch_name, object_type, title, file_name, summary, documentation, code) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $docblock['object_name'], $docblock['branch_name'], $docblock['object_type'], $docblock['title'], $docblock['file_name'], $docblock['summary'], $docblock['documentation'], $docblock['code']);
- $did = db_last_insert_id('api_documentation', 'did');
+ $node = new stdClass();
+ $node->type = 'api';
+ $node->uid = 0;
+ $node->comment = COMMENT_NODE_READ_WRITE;
+ node_save($node);
+ $did = $node->nid;
+ db_query("INSERT INTO {api_documentation} (did, object_name, branch_name, object_type, title, file_name, summary, documentation, code) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $did, $docblock['object_name'], $docblock['branch_name'], $docblock['object_type'], $docblock['title'], $docblock['file_name'], $docblock['summary'], $docblock['documentation'], $docblock['code']);
}
switch ($docblock['object_type']) {
@@ -760,12 +765,12 @@ function api_update_branch($branch) {
$files = array();
$result = db_query("SELECT f.did, f.modified, d.object_name FROM {api_documentation} d INNER JOIN {api_file} f ON d.did = f.did WHERE d.branch_name = '%s' AND d.object_type = 'file'", $branch->branch_name);
while ($file = db_fetch_object($result)) {
- $files[$file->object_name] = $file;
+ $files[$file->object_name] = $file;
}
foreach (api_scan_directories($branch->directory) as $path => $file_name) {
preg_match('!\.([a-z]*)$!', $file_name, $matches);
- if (isset($parse_functions[$matches[1]])) {
+ if (isset($matches[1]) && isset($parse_functions[$matches[1]])) {
if (isset($files[$file_name])) {
$parse = (filemtime($path) > $files[$file_name]->modified);
unset($files[$file_name]); // All remaining files will be removed.