Refactor comments
Fit comments to new bootstrap theme, simplify commenting and remove comment subjects. Disable comments on group content type. Change-Id: I6751e543e5a42a3fa4d7e60a4b4935af50576389
This commit is contained in:
parent
f7cd9f453f
commit
5992731e3e
@ -151,6 +151,7 @@ dependencies[] = groups_directory
|
||||
dependencies[] = groups_footer
|
||||
dependencies[] = groups_homepage
|
||||
dependencies[] = groups_common
|
||||
dependencies[] = groups_comment
|
||||
dependencies[] = groups_auth
|
||||
dependencies[] = groups_oauth2
|
||||
dependencies[] = groups_oauth2_picture
|
||||
|
@ -191,6 +191,16 @@ function groups_update_7108() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable groups_comment module.
|
||||
*/
|
||||
function groups_update_7109() {
|
||||
if ((!module_exists('groups_comment')) && (!module_exists('groups_comment'))) {
|
||||
module_enable(array('groups_comment'));
|
||||
drupal_flush_all_caches();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add markdown filter with permissions.
|
||||
*/
|
||||
|
@ -278,6 +278,7 @@ function groups_demo_create_group($title, $location, $attributes = null) {
|
||||
$group->created = time() - 604800;
|
||||
$group->status = 1;
|
||||
$group->field_group_location[LANGUAGE_NONE][0] = $location;
|
||||
$group->comment = 0; // disable comments
|
||||
if (isset($attributes)) {
|
||||
$attr = array();
|
||||
foreach ($attributes as $attribute) {
|
||||
|
7
modules/groups/groups_comment/groups_comment.info
Normal file
7
modules/groups/groups_comment/groups_comment.info
Normal file
@ -0,0 +1,7 @@
|
||||
name = Groups Comment
|
||||
description = Alter default comment system.
|
||||
core = 7.x
|
||||
package = groups
|
||||
version = 7.x-1.0
|
||||
project = groups_comment
|
||||
dependencies[] = groups_common
|
45
modules/groups/groups_comment/groups_comment.module
Normal file
45
modules/groups/groups_comment/groups_comment.module
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_FORM_ID_form_alter().
|
||||
*
|
||||
* Override comment form.
|
||||
*/
|
||||
function groups_comment_form_comment_form_alter(&$form, &$form_state) {
|
||||
global $user;
|
||||
|
||||
// Display the user's picture.
|
||||
$wrapper = entity_metadata_wrapper('user', $user);
|
||||
$path = empty($user->picture) ? variable_get('user_picture_default') : $wrapper->value()->picture->uri;
|
||||
$form['user_picture'] = array(
|
||||
'#theme' => 'image_style',
|
||||
'#style_name' => '50x50_avatar',
|
||||
'#path' => $path,
|
||||
'#prefix' => '<div class="user-picture">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => -20,
|
||||
);
|
||||
// hide subject field
|
||||
$form['subject']['#access'] = False;
|
||||
$form['author']['#access'] = False;
|
||||
$form['comment_body'][LANGUAGE_NONE][0]['#placeholder'] = t('Write a comment...');
|
||||
$form['comment_body'][LANGUAGE_NONE][0]['#resizable'] = False;
|
||||
$form['comment_body'][LANGUAGE_NONE][0]['#rows'] = 3;
|
||||
$form['comment_body'][LANGUAGE_NONE][0]['#title_display'] = 'invisible';
|
||||
// remove preview button
|
||||
unset($form['actions']['preview']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_text_format_alter.
|
||||
*
|
||||
* Set default text format to markdown for the group/body field.
|
||||
*/
|
||||
function groups_comment_text_format_alter(&$element) {
|
||||
if (($element['#bundle'] == 'comment_node_post') && ($element['#field_name'] == 'comment_body')) {
|
||||
// set default value to markdown
|
||||
$element['format']['format']['#default_value'] = 'markdown';
|
||||
// hide text format filter
|
||||
$element['format']['#access'] = FALSE;
|
||||
}
|
||||
}
|
18
modules/groups/groups_common/groups_common.api.php
Normal file
18
modules/groups/groups_common/groups_common.api.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* This file contains API documentation for the Groups Common module. Note that
|
||||
* all of this code is merely for example purposes, it is never executed when
|
||||
* using the Groups Common module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Alter the format settings of an element.
|
||||
*
|
||||
* @param &$element
|
||||
* The form element to process.
|
||||
* @return
|
||||
* None.
|
||||
*/
|
||||
function hook_text_format_alter(&$element) {
|
||||
}
|
@ -36,3 +36,32 @@ function groups_common_commons_utility_links_alter(&$links) {
|
||||
$links['signup']['title'] = t('Sign in');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_element_info_alter()
|
||||
*
|
||||
* Override filter_process_format.
|
||||
*
|
||||
* @see _groups_common_filter_process_format()
|
||||
*/
|
||||
function groups_common_element_info_alter(&$type) {
|
||||
if (isset($type['text_format']['#process'])) {
|
||||
foreach ($type['text_format']['#process'] as &$callback) {
|
||||
if ($callback === 'filter_process_format') {
|
||||
$callback = '_groups_common_filter_process_format';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to for text_format_alter hooks.
|
||||
*/
|
||||
function _groups_common_filter_process_format($element) {
|
||||
$element = filter_process_format($element);
|
||||
foreach (module_implements('text_format_alter') as $module) {
|
||||
$function = $module . '_text_format_alter';
|
||||
$function($element);
|
||||
}
|
||||
return $element;
|
||||
}
|
@ -12,6 +12,7 @@ dependencies[] = geocoder
|
||||
dependencies[] = geofield
|
||||
dependencies[] = list
|
||||
dependencies[] = options
|
||||
dependencies[] = groups_common
|
||||
features[features_api][] = api:2
|
||||
features[field_base][] = field_geofield
|
||||
features[field_base][] = field_group_location
|
||||
|
@ -32,4 +32,22 @@ function groups_groups_update_7302() {
|
||||
$wrapper->field_group_status->set('0');
|
||||
$wrapper->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable commenting on existing group nodes.
|
||||
*/
|
||||
function groups_groups_update_7303() {
|
||||
$query = new EntityFieldQuery();
|
||||
$query->entityCondition('entity_type', 'node')
|
||||
->entityCondition('bundle', 'group');
|
||||
$result = $query->execute();
|
||||
if (isset($result['node'])) {
|
||||
$nids = array_keys($result['node']);
|
||||
$nodes = node_load_multiple($nids, NULL, TRUE);
|
||||
foreach ($nodes as $node) {
|
||||
$node->comment = 0;
|
||||
node_save($node);
|
||||
}
|
||||
}
|
||||
}
|
@ -130,36 +130,17 @@ function groups_groups_theme() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_element_info_alter()
|
||||
* Implements hook_text_format_alter.
|
||||
*
|
||||
* Override filter_process_format.
|
||||
*
|
||||
* @see _groups_groups_set_default_format()
|
||||
* Set default text format to markdown for the group/body field.
|
||||
*/
|
||||
function groups_groups_element_info_alter(&$type) {
|
||||
if (isset($type['text_format']['#process'])) {
|
||||
foreach ($type['text_format']['#process'] as &$callback) {
|
||||
if ($callback === 'filter_process_format') {
|
||||
$callback = '_groups_groups_set_default_format';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to set body text format of group content type
|
||||
* to markdown, and hide text filter form elements.
|
||||
*/
|
||||
function _groups_groups_set_default_format($element) {
|
||||
// set body filter default to 'markdown'
|
||||
$element = filter_process_format($element);
|
||||
function groups_groups_text_format_alter(&$element) {
|
||||
if (($element['#bundle'] == 'group') && ($element['#field_name'] == 'body')) {
|
||||
// set default value to markdown
|
||||
$element['format']['format']['#default_value'] = 'markdown';
|
||||
// hide text format filter
|
||||
$element['format']['#access'] = FALSE;
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,44 @@
|
||||
#comments {
|
||||
h2 {
|
||||
margin-left: -68px;
|
||||
color: #2A4E68;
|
||||
font-weight: 300;
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.comment {
|
||||
h3 {
|
||||
margin-bottom: 0px;
|
||||
margin-top: 0px;
|
||||
a {
|
||||
color: #2A4E68;
|
||||
font-weight: 300;
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
.user-picture img {
|
||||
width: 50px;
|
||||
}
|
||||
ul {
|
||||
margin-top: 1em;
|
||||
margin-left: 0px;
|
||||
margin-bottom: 1em;
|
||||
a {
|
||||
color: #2A4E68;
|
||||
}
|
||||
}
|
||||
/* hide the like button */
|
||||
.rate-widget {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.page-comment .comment-form {
|
||||
margin-left: 68px;
|
||||
.user-picture {
|
||||
margin-left: -68px;
|
||||
position: absolute;
|
||||
float: left;
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
@import 'partials/social_icons';
|
||||
@import 'partials/group_node_form';
|
||||
@import 'partials/group';
|
||||
@import 'partials/comment';
|
||||
|
||||
/* Custom override */
|
||||
|
||||
|
@ -145,8 +145,6 @@ function openstack_bootstrap_preprocess_node(&$variables, $hook) {
|
||||
'!date' => $variables['date'],
|
||||
'@interval' => format_interval(REQUEST_TIME - $node->created),
|
||||
);
|
||||
// $node_user = user_load($node->uid);
|
||||
// $placeholders['!user'] = format_username($node_user);
|
||||
if (!empty($node->{OG_AUDIENCE_FIELD}) && $wrapper->{OG_AUDIENCE_FIELD}->count() == 1) {
|
||||
$placeholders['!group'] = l($wrapper->{OG_AUDIENCE_FIELD}->get(0)->label(), 'node/' . $wrapper->{OG_AUDIENCE_FIELD}->get(0)->getIdentifier());
|
||||
if ($use_timeago_date_format == TRUE) {
|
||||
@ -169,4 +167,4 @@ function openstack_bootstrap_preprocess_node(&$variables, $hook) {
|
||||
// overwrites the original submitted variable, so we are passing submitted_ now.
|
||||
// @see templates/node.tpl.php
|
||||
$variables['submitted_'] = $variables['submitted'];
|
||||
}
|
||||
}
|
||||
|
83
themes/openstack_bootstrap/templates/comment.tpl.php
Normal file
83
themes/openstack_bootstrap/templates/comment.tpl.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation for comments.
|
||||
*
|
||||
* Available variables:
|
||||
* - $author: Comment author. Can be link or plain text.
|
||||
* - $content: An array of comment items. Use render($content) to print them all, or
|
||||
* print a subset such as render($content['field_example']). Use
|
||||
* hide($content['field_example']) to temporarily suppress the printing of a
|
||||
* given element.
|
||||
* - $created: Formatted date and time for when the comment was created.
|
||||
* Preprocess functions can reformat it by calling format_date() with the
|
||||
* desired parameters on the $comment->created variable.
|
||||
* - $changed: Formatted date and time for when the comment was last changed.
|
||||
* Preprocess functions can reformat it by calling format_date() with the
|
||||
* desired parameters on the $comment->changed variable.
|
||||
* - $new: New comment marker.
|
||||
* - $permalink: Comment permalink.
|
||||
* - $submitted: Submission information created from $author and $created during
|
||||
* template_preprocess_comment().
|
||||
* - $picture: Authors picture.
|
||||
* - $signature: Authors signature.
|
||||
* - $status: Comment status. Possible values are:
|
||||
* comment-unpublished, comment-published or comment-preview.
|
||||
* - $title: Linked title.
|
||||
* - $classes: String of classes that can be used to style contextually through
|
||||
* CSS. It can be manipulated through the variable $classes_array from
|
||||
* preprocess functions. The default values can be one or more of the following:
|
||||
* - comment: The current template type, i.e., "theming hook".
|
||||
* - comment-by-anonymous: Comment by an unregistered user.
|
||||
* - comment-by-node-author: Comment by the author of the parent node.
|
||||
* - comment-preview: When previewing a new or edited comment.
|
||||
* The following applies only to viewers who are registered users:
|
||||
* - comment-unpublished: An unpublished comment visible only to administrators.
|
||||
* - comment-by-viewer: Comment by the user currently viewing the page.
|
||||
* - comment-new: New comment since last the visit.
|
||||
* - $title_prefix (array): An array containing additional output populated by
|
||||
* modules, intended to be displayed in front of the main title tag that
|
||||
* appears in the template.
|
||||
* - $title_suffix (array): An array containing additional output populated by
|
||||
* modules, intended to be displayed after the main title tag that appears in
|
||||
* the template.
|
||||
*
|
||||
* These two variables are provided for context:
|
||||
* - $comment: Full comment object.
|
||||
* - $node: Node object the comments are attached to.
|
||||
*
|
||||
* Other variables:
|
||||
* - $classes_array: Array of html class attribute values. It is flattened
|
||||
* into a string within the variable $classes.
|
||||
*
|
||||
* @see template_preprocess()
|
||||
* @see template_preprocess_comment()
|
||||
* @see template_process()
|
||||
* @see theme_comment()
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
|
||||
hide($content['report_link']);
|
||||
?>
|
||||
<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
|
||||
<?php print $picture; ?>
|
||||
<!-- <h3 class="comment-title"><?php print $title; ?></h3> -->
|
||||
<div class="author-datetime submitted">
|
||||
<?php print $submitted; ?>
|
||||
<?php if ($new): ?>
|
||||
<span class="new"><?php print $new ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="content"<?php print $content_attributes; ?>>
|
||||
<?php
|
||||
// We hide the comments and links now so that we can render them later.
|
||||
hide($content['links']);
|
||||
print render($content);
|
||||
?>
|
||||
</div>
|
||||
<?php print render($content['links']) ?>
|
||||
<?php print render($content['report_link']); ?>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user