Index: community_tags.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/community_tags/community_tags.module,v
retrieving revision 1.31
diff -u -b -r1.31 community_tags.module
--- community_tags.module       2 Nov 2006 20:24:03 -0000       1.31
+++ community_tags.module       1 Feb 2007 21:31:24 -0000
@@ -2,16 +2,6 @@
 // $Id: community_tags.module,v 1.31 2006/11/02 20:24:03 webchick Exp $

 /**
- * Implementation of hook_help().
- */
-function community_tags_help($section) {
-  switch ($section) {
-    case 'admin/modules#description':
-      return t("Allows users to 'tag' other users' content. Weighted tag lists or 'tag clouds' are generated for each piece of content to show the popularity of tags.");
-  }
-}
-
-/**
  * Implementation of hook_menu().
  */
 function community_tags_menu($may_cache) {
@@ -30,6 +20,16 @@
     }
   }

+       $items[] = array(
+    'path' => 'admin/settings/community_tags',
+    'title' => t('Community Tags settings'),
+    'description' => t('Modify the default free tagging vocabulary used by community_tags'),
+    'callback' => 'drupal_get_form',
+    'callback arguments' => 'community_tags_admin',
+    'access' => user_access('access administration pages'),
+    'type' => MENU_NORMAL_ITEM,
+   );
+
   return $items;
 }

@@ -41,7 +41,7 @@
   $node = node_load($nid);

   if (!$inline) {
-    drupal_set_title(t('Tagging %type %title:', array('%type' => node_get_name($node->type), '%title' => theme('placeholder', $node->title))));
+    drupal_set_title(t('Tagging %type %title:', array('%type' => node_get_types('name', $node->type), '%title' => theme('placeholder', $node->title))));
   }

   $output = theme('community_tags', 'node', $node->nid);
@@ -50,13 +50,13 @@
   $tags = community_tags_get_user_node_tags($user->uid, $node->nid);
   if (!count($tags)) {
     // User has not yet added tags to this node yet. Show form.
-    $output .= community_tags_form(array('nid' => $node->nid, 'vid' => $vid, 'tags' => NULL));
+    $output .= community_tags_edit(array('nid' => $node->nid, 'vid' => $vid, 'tags' => NULL));
   }
   elseif (user_access('edit own tags')) {
     // User has already tagged this node, but can edit their tags. Show form
     // with the user's tags pre-populated.
     $tags = implode(', ', $tags);
-    $output .= community_tags_form(array('nid' => $node->nid, 'vid' => $vid, 'tags' => $tags));
+    $output .= community_tags_edit(array('nid' => $node->nid, 'vid' => $vid, 'tags' => $tags));
   }
   else {
     // Sorry, no more adding tags for you!
@@ -104,23 +104,35 @@
       $vid = $node->tags ? array_shift(array_keys($node->tags)) : variable_get('community_tags_default_vocabulary', NULL);
       if (!$teaser && $node->community_tags_form && $vid) {
         // Display a tag cloud of the overall community tags for this node.
-        $node->body .= theme('community_tags', 'node', $node->nid);
+                               $node->content['tags_list'] = array(
+                                       '#value' => theme('community_tags', 'node', $node->nid),
+                                       '#weight' => 2
+                                );

         if (user_access('tag content') && $node->uid != $user->uid) {
           $tags = community_tags_get_user_node_tags($user->uid, $node->nid);
           if (!count($tags)) {
             // User has not yet added tags to this node yet. Show form.
-            $node->body .= community_tags_form(array('nid' => $node->nid, 'vid' => $vid, 'tags' => NULL));
+                                               $node->content['tags_form'] = array(
+                                                       '#value' => '<div class="community_tags">' . community_tags_edit(array('nid' => $node->nid, 'vid' => $vid, 'tags' => NULL)) . '</div>',
+                                                       '#weight' => 3
+                                                );
           }
           elseif (user_access('edit own tags')) {
             // User has already tagged this node, but can edit their tags. Show form
             // with the user's tags pre-populated.
             $tags = implode(', ', $tags);
-            $node->body .= community_tags_form(array('nid' => $node->nid, 'vid' => $vid, 'tags' => $tags));
+                                               $node->content['tags_form'] = array(
+                                                       '#value' => community_tags_edit(array('nid' => $node->nid, 'vid' => $vid, 'tags' => NULL)),
+                                                       '#weight' => 3
+                                                );
           }
           else {
             // Sorry, no more adding tags for you!
-            $node->body .= '<p>'. t('You have already tagged this post. Your tags: ') . theme('community_tags', 'user_node', $user->uid, $node->nid) .'</p>';
+                                               $node->content['tags_message'] = array(
+                                                       '#value' => '<p>'. t('You have already tagged this post. Your tags: ') . theme('community_tags', 'user_node', $user->uid, $node->nid) .'</p>',
+                                                       '#weight' => 5
+                                                );
           }
         }
       }
@@ -129,9 +141,9 @@
 }

 /**
- * Implementation of hook_settings().
+ * Admin settings menu
  */
-function community_tags_settings() {
+function community_tags_admin() {
   // Build list of available free-tagging vocabularies
   $vocabs = db_query('SELECT v.vid, v.name FROM {vocabulary} v WHERE v.tags = 1 ORDER BY v.weight, v.name');
   $options = array(0 => t('--'));
@@ -147,7 +159,7 @@
     '#description' => t('Which vocabulary should the quick tagging forms use?')
     );
   }
-  return $form;
+  return system_settings_form($form);
 }

 /**
@@ -200,7 +212,7 @@
 /**
  * Quick tag form
  */
-function community_tags_form($edit, $title = NULL) {
+function community_tags_edit_form($edit, $title = NULL) {
   $form = array();
   $form['tags'] = array(
     '#type' => 'textfield',
@@ -227,13 +239,17 @@
     '#value' => $edit['vid'],
   );

-  return drupal_get_form('community_tags_form', $form);
+       return $form;
+}
+
+function community_tags_edit($edit, $title = NULL) {
+  return drupal_get_form('community_tags_edit_form', $edit, $title);
 }

 /**
  * Validate the quick tag form.
  */
-function community_tags_form_validate($form_id, $form_values) {
+function community_tags_edit_form_validate($form_id, $form_values) {
   if ($form_values['tags'] == '') {
     form_set_error('tags', t('You must enter at least one tag.'));
   }
@@ -242,7 +258,7 @@
 /**
  * Submit callback for quick tag form.
  */
-function community_tags_form_submit($form_id, $form_values) {
+function community_tags_edit_form_submit($form_id, $form_values) {
   global $user;

   community_tags_taxonomy_node_save($form_values['nid'], array('tags' => array($form_values['vid'] => $form_values['tags'])), FALSE, $user->uid);
