summaryrefslogtreecommitdiff
path: root/modules/comment
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-01-30 04:14:17 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-01-30 04:14:17 +0000
commitec78589174fef03608524d39e9ba35c5584efe39 (patch)
tree28948d9c7698347b90348bbb898b6829ac6a8397 /modules/comment
parent5aebca5a7a8fbb818ef0cf9e0aff7bd21c9797c7 (diff)
downloadbrdo-ec78589174fef03608524d39e9ba35c5584efe39.tar.gz
brdo-ec78589174fef03608524d39e9ba35c5584efe39.tar.bz2
#537750 by yched: Added Field UI for comments.
Diffstat (limited to 'modules/comment')
-rw-r--r--modules/comment/comment.module60
1 files changed, 57 insertions, 3 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 97d862f73..556c234c2 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -104,9 +104,6 @@ function comment_entity_info() {
'id' => 'cid',
'bundle' => 'node_type',
),
- 'bundle keys' => array(
- 'bundle' => 'type',
- ),
'bundles' => array(),
'view modes' => array(
'full' => array(
@@ -120,6 +117,19 @@ function comment_entity_info() {
foreach (node_type_get_names() as $type => $name) {
$return['comment']['bundles']['comment_node_' . $type] = array(
'label' => $name,
+ 'admin' => array(
+ // Place the Field UI paths for comments one level below the
+ // corresponding paths for nodes, so that they appear in the same set
+ // of local tasks. Note that the paths use a different placeholder name
+ // and thus a different menu loader callback, so that Field UI page
+ // callbacks get a comment bundle name from the node type in the URL.
+ // @see comment_node_type_load()
+ // @see comment_menu_alter()
+ 'path' => 'admin/structure/types/manage/%comment_node_type/comment',
+ 'bundle argument' => 4,
+ 'real path' => 'admin/structure/types/manage/' . str_replace('_', '-', $type) . '/comment',
+ 'access arguments' => array('administer content types'),
+ ),
);
}
@@ -127,6 +137,17 @@ function comment_entity_info() {
}
/**
+ * Menu loader callback for Field UI paths.
+ *
+ * Return a comment bundle name from a node type in the URL.
+ */
+function comment_node_type_load($name) {
+ if ($type = node_type_get_type(strtr($name, array('-' => '_')))) {
+ return 'comment_node_' . $type->type;
+ }
+}
+
+/**
* Entity path callback.
*/
function comment_path($comment) {
@@ -134,6 +155,32 @@ function comment_path($comment) {
}
/**
+ * Implements hook_field_extra_fields().
+ */
+function comment_field_extra_fields() {
+ $return = array();
+
+ foreach (node_type_get_types() as $type) {
+ if (variable_get('comment_subject_field_' . $type->type, 1) == 1) {
+ $return['comment']['comment_node_' . $type->type] = array(
+ 'author' => array(
+ 'label' => t('Author'),
+ 'description' => t('Author textfield'),
+ 'weight' => -2,
+ ),
+ 'title' => array(
+ 'label' => t('Subject'),
+ 'description' => t('Subject textfield'),
+ 'weight' => -1,
+ ),
+ );
+ }
+ }
+
+ return $return;
+}
+
+/**
* Implements hook_theme().
*/
function comment_theme() {
@@ -2501,6 +2548,13 @@ function comment_ranking() {
function comment_menu_alter(&$items) {
// Add comments to the description for admin/content.
$items['admin/content']['description'] = "Administer content and comments";
+
+ // Adjust the Field UI tabs on admin/structure/types/manage/[node-type].
+ // @see comment_entity_info()
+ $items['admin/structure/types/manage/%comment_node_type/comment/fields']['title'] = 'Comment fields';
+ $items['admin/structure/types/manage/%comment_node_type/comment/fields']['weight'] = 3;
+ $items['admin/structure/types/manage/%comment_node_type/comment/display']['title'] = 'Comment display';
+ $items['admin/structure/types/manage/%comment_node_type/comment/display']['weight'] = 4;
}
/**