Index: taxonomy.module =================================================================== retrieving revision 1.106 diff -u -r1.106 taxonomy.module --- taxonomy.module 6 Mar 2004 16:17:48 -0000 1.106 +++ taxonomy.module 6 Mar 2004 18:14:25 -0000 @@ -26,6 +26,7 @@ if (user_access("administer taxonomy")) { menu("admin/taxonomy", t("taxonomy"), "taxonomy_admin", 3); menu("admin/taxonomy/add/vocabulary", t("create new vocabulary"), "taxonomy_admin"); + menu("admin/taxonomy/orphans", t("orphan nodes"), "taxonomy_admin_orphan", 5); menu("admin/taxonomy/help", t("help"), "taxonomy_admin", 9); } if (user_access("access content")) { @@ -830,6 +831,32 @@ print theme("page", $output); } +/** + * This function is designed to display any nodes that have no associated taxonomy term and that can have + * terms (nodes such as book pages and project issues cannot have terms). It is a rather expensive function + * to call (especially for large sites), but it shouldn't see much use. + */ +function taxonomy_admin_orphan() { + + $result = db_query("SELECT DISTINCT n.nid FROM {node} AS n LEFT JOIN {term_node} AS t ON n.nid = t.nid WHERE t.nid IS NULL"); + + // This while statement will get all of the nodes with nids returned from above. + while ($nodeId = db_fetch_object($result)) { + $nodes[$nodeId->nid] = node_load(array("nid" => $nodeId->nid)); + } + + if ($nodes) { + $output .= "

Nodes Without Taxonomy Terms

"; + $header = array(t("title"), array("data" => t("operations"), "colspan" => 3)); + foreach ($nodes as $node) { + $rows[] = array(l($node->title, "node/view/$node->nid"), l(t("view node"), "node/view/$node->nid"), l(t("edit node"), "admin/node/edit/$node->nid"), l(t("delete node"), "admin/node/delete/$node->nid")); + } + $output .= theme("table", $header, $rows, array("summary" => "Table of nodes that have no associated taxonomy terms.")); + } + + print theme("page", $output); +} + function taxonomy_help($section = "admin/help#taxonomy") { $output = "";