diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-04-15 19:50:04 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-04-15 19:50:04 +0000 |
commit | 2de4c1c643d3c23e814bc9f765ffa3e0eabdd696 (patch) | |
tree | 852ae736da509bf40636f9ba2a0e574d5c51286b /modules | |
parent | 86ddee8dc586e57456c9bc8fc97fe1c15b4b1c4e (diff) | |
download | brdo-2de4c1c643d3c23e814bc9f765ffa3e0eabdd696.tar.gz brdo-2de4c1c643d3c23e814bc9f765ffa3e0eabdd696.tar.bz2 |
- Node API improvements by Moshe:
"implemented pieces of kjartan's original nodeAPI patch. the mingling
of other modules into node.module logic decreases (a good thing). for
example, the string "taxonomy" now appears nowhere in node.module
- moved the saving of taxonomy terms when submitting a node out of
node.module and into taxonomy.module
- moved the deletion of comments while deleting a node out of
node.module and into comment.module
- improved usability of node forms by including node type in the title
of the box and page"
Diffstat (limited to 'modules')
-rw-r--r-- | modules/comment.module | 5 | ||||
-rw-r--r-- | modules/comment/comment.module | 5 | ||||
-rw-r--r-- | modules/node.module | 45 | ||||
-rw-r--r-- | modules/node/node.module | 45 | ||||
-rw-r--r-- | modules/taxonomy.module | 32 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 32 |
6 files changed, 84 insertions, 80 deletions
diff --git a/modules/comment.module b/modules/comment.module index f3f53577a..8ada37458 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -1466,7 +1466,10 @@ function comment_nodeapi(&$node, $op, $arg = 0) { $node->comment = variable_get("comment_$node->type", 2); } break; + case "delete": + db_query("DELETE FROM comments WHERE nid = '$node->nid'"); + break; } } -?> +?>
\ No newline at end of file diff --git a/modules/comment/comment.module b/modules/comment/comment.module index f3f53577a..8ada37458 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1466,7 +1466,10 @@ function comment_nodeapi(&$node, $op, $arg = 0) { $node->comment = variable_get("comment_$node->type", 2); } break; + case "delete": + db_query("DELETE FROM comments WHERE nid = '$node->nid'"); + break; } } -?> +?>
\ No newline at end of file diff --git a/modules/node.module b/modules/node.module index 84588cdf9..846b9dfff 100644 --- a/modules/node.module +++ b/modules/node.module @@ -1180,7 +1180,7 @@ function node_preview($node, $error = NULL) { } /* - ** Exctract a teaser: + ** Extract a teaser: */ $node->teaser = node_teaser($node->body); @@ -1197,7 +1197,7 @@ function node_preview($node, $error = NULL) { } /* - ** Display a prenode of the node: + ** Display a preview of the node: */ if ($view->teaser && $view->teaser != $view->body) { @@ -1245,17 +1245,8 @@ function node_submit($node) { if (node_access("update", $node)) { $nid = node_save($node); - - /* - ** Update terms of the node - */ - - if (function_exists("taxonomy_node_save")) { - taxonomy_node_save($nid, $node->taxonomy); - } - watchdog("special", "$node->type: updated '$node->title'", l("view post", "node/view/$node->nid")); - $output = t("The node has been updated."); + $output = t("The %name has been updated.", array ("%name" => module_invoke($node->type, "node", "name"))); } } else { @@ -1275,15 +1266,6 @@ function node_submit($node) { throttle("node", variable_get("max_node_rate", 900)); $nid = node_save($node); - - /* - ** Insert terms of the node - */ - - if (function_exists("taxonomy_node_save")) { - taxonomy_node_save($nid, $node->taxonomy); - } - watchdog("special", "$node->type: added '$node->title'", l("view post", "node/view/$nid")); $output = t("Thanks for your submission."); } @@ -1326,17 +1308,10 @@ function node_delete($edit) { if ($edit["confirm"]) { /* - ** Delete the specified node and its comments: + ** Delete the specified node: */ db_query("DELETE FROM node WHERE nid = '$node->nid'"); - db_query("DELETE FROM comments WHERE nid = '$node->nid'"); - - /* - ** Delete any taxonomy terms - */ - - module_invoke("taxonomy", "node_delete", $node->nid); /* ** Call the node specific callback (if any): @@ -1381,26 +1356,26 @@ function node_page() { } theme("header"); - + $name = module_invoke(arg(2), "node", "name"); switch ($op) { case "add": - theme("box", t("Create new post"), node_add(arg(2))); + theme("box", t("Create new $name"), node_add(arg(2))); break; case "edit": - theme("box", t("Edit post"), node_edit(arg(2))); + theme("box", t("Edit $name"), node_edit(arg(2))); break; case "view": print node_show(arg(2), arg(3)); break; case t("Preview"): $edit = node_validate($edit, $error); - theme("box", t("Preview post"), node_preview($edit, $error)); + theme("box", t("Preview $name"), node_preview($edit, $error)); break; case t("Submit"): - theme("box", t("Submit post"), node_submit($edit)); + theme("box", t("Submit $name"), node_submit($edit)); break; case t("Delete"): - theme("box", t("Delete post"), node_delete($edit)); + theme("box", t("Delete $name"), node_delete($edit)); break; default: $result = pager_query("SELECT nid, type FROM node WHERE promote = '1' AND status = '1' ORDER BY static DESC, created DESC", variable_get("default_nodes_main", 10)); diff --git a/modules/node/node.module b/modules/node/node.module index 84588cdf9..846b9dfff 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1180,7 +1180,7 @@ function node_preview($node, $error = NULL) { } /* - ** Exctract a teaser: + ** Extract a teaser: */ $node->teaser = node_teaser($node->body); @@ -1197,7 +1197,7 @@ function node_preview($node, $error = NULL) { } /* - ** Display a prenode of the node: + ** Display a preview of the node: */ if ($view->teaser && $view->teaser != $view->body) { @@ -1245,17 +1245,8 @@ function node_submit($node) { if (node_access("update", $node)) { $nid = node_save($node); - - /* - ** Update terms of the node - */ - - if (function_exists("taxonomy_node_save")) { - taxonomy_node_save($nid, $node->taxonomy); - } - watchdog("special", "$node->type: updated '$node->title'", l("view post", "node/view/$node->nid")); - $output = t("The node has been updated."); + $output = t("The %name has been updated.", array ("%name" => module_invoke($node->type, "node", "name"))); } } else { @@ -1275,15 +1266,6 @@ function node_submit($node) { throttle("node", variable_get("max_node_rate", 900)); $nid = node_save($node); - - /* - ** Insert terms of the node - */ - - if (function_exists("taxonomy_node_save")) { - taxonomy_node_save($nid, $node->taxonomy); - } - watchdog("special", "$node->type: added '$node->title'", l("view post", "node/view/$nid")); $output = t("Thanks for your submission."); } @@ -1326,17 +1308,10 @@ function node_delete($edit) { if ($edit["confirm"]) { /* - ** Delete the specified node and its comments: + ** Delete the specified node: */ db_query("DELETE FROM node WHERE nid = '$node->nid'"); - db_query("DELETE FROM comments WHERE nid = '$node->nid'"); - - /* - ** Delete any taxonomy terms - */ - - module_invoke("taxonomy", "node_delete", $node->nid); /* ** Call the node specific callback (if any): @@ -1381,26 +1356,26 @@ function node_page() { } theme("header"); - + $name = module_invoke(arg(2), "node", "name"); switch ($op) { case "add": - theme("box", t("Create new post"), node_add(arg(2))); + theme("box", t("Create new $name"), node_add(arg(2))); break; case "edit": - theme("box", t("Edit post"), node_edit(arg(2))); + theme("box", t("Edit $name"), node_edit(arg(2))); break; case "view": print node_show(arg(2), arg(3)); break; case t("Preview"): $edit = node_validate($edit, $error); - theme("box", t("Preview post"), node_preview($edit, $error)); + theme("box", t("Preview $name"), node_preview($edit, $error)); break; case t("Submit"): - theme("box", t("Submit post"), node_submit($edit)); + theme("box", t("Submit $name"), node_submit($edit)); break; case t("Delete"): - theme("box", t("Delete post"), node_delete($edit)); + theme("box", t("Delete $name"), node_delete($edit)); break; default: $result = pager_query("SELECT nid, type FROM node WHERE promote = '1' AND status = '1' ORDER BY static DESC, created DESC", variable_get("default_nodes_main", 10)); diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 10c1f3317..256e0364b 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -36,6 +36,15 @@ function taxonomy_link($type, $node = NULL) { menu("admin/taxonomy/help", "help", "taxonomy_admin", NULL, 9); } else if ($type == "taxonomy terms" && $node != NULL) { + + if ($node->taxonomy) { + foreach ($node->taxonomy as $tid) { + $term = taxonomy_get_term($tid); + $links[] = l($term->name, "taxonomy/page/or/$term->tid", $term->description ? array("title" => $term->description) : array()); + } + } + else { + /* ** Themes can print taxonomy links with: ** @@ -44,12 +53,12 @@ function taxonomy_link($type, $node = NULL) { ** } */ - $links = array(); + $links = array(); + foreach (taxonomy_node_get_terms($node->nid) as $term) { + $links[] = l($term->name, "taxonomy/page/or/$term->tid", $term->description ? array("title" => $term->description) : array()); + } - foreach (taxonomy_node_get_terms($node->nid) as $term) { - $links[] = l($term->name, "taxonomy/page/or/$term->tid", $term->description ? array("title" => $term->description) : array()); } - return $links; } } @@ -676,6 +685,21 @@ function taxonomy_render_nodes($result) { print pager_display_default(NULL, variable_get("default_nodes_main", 10), 0); } +function taxonomy_nodeapi($node, $op, $arg = 0) { + + switch ($op) { + case "insert": + taxonomy_node_save($node->nid, $node->taxonomy); + break; + case "update": + taxonomy_node_save($node->nid, $node->taxonomy); + break; + case "delete": + taxonomy_node_delete($node->nid); + break; + } +} + function taxonomy_page() { diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 10c1f3317..256e0364b 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -36,6 +36,15 @@ function taxonomy_link($type, $node = NULL) { menu("admin/taxonomy/help", "help", "taxonomy_admin", NULL, 9); } else if ($type == "taxonomy terms" && $node != NULL) { + + if ($node->taxonomy) { + foreach ($node->taxonomy as $tid) { + $term = taxonomy_get_term($tid); + $links[] = l($term->name, "taxonomy/page/or/$term->tid", $term->description ? array("title" => $term->description) : array()); + } + } + else { + /* ** Themes can print taxonomy links with: ** @@ -44,12 +53,12 @@ function taxonomy_link($type, $node = NULL) { ** } */ - $links = array(); + $links = array(); + foreach (taxonomy_node_get_terms($node->nid) as $term) { + $links[] = l($term->name, "taxonomy/page/or/$term->tid", $term->description ? array("title" => $term->description) : array()); + } - foreach (taxonomy_node_get_terms($node->nid) as $term) { - $links[] = l($term->name, "taxonomy/page/or/$term->tid", $term->description ? array("title" => $term->description) : array()); } - return $links; } } @@ -676,6 +685,21 @@ function taxonomy_render_nodes($result) { print pager_display_default(NULL, variable_get("default_nodes_main", 10), 0); } +function taxonomy_nodeapi($node, $op, $arg = 0) { + + switch ($op) { + case "insert": + taxonomy_node_save($node->nid, $node->taxonomy); + break; + case "update": + taxonomy_node_save($node->nid, $node->taxonomy); + break; + case "delete": + taxonomy_node_delete($node->nid); + break; + } +} + function taxonomy_page() { |