node_comment_form.inc

  1. cis7 sites/all/modules/ulmus/ctools/plugins/content_types/node_context/node_comment_form.inc
  2. cle7 sites/all/modules/ulmus/ctools/plugins/content_types/node_context/node_comment_form.inc
  3. ecd7 sites/all/modules/ulmus/ctools/plugins/content_types/node_context/node_comment_form.inc
  4. elmsmedia7 sites/all/modules/ulmus/ctools/plugins/content_types/node_context/node_comment_form.inc
  5. harmony7 sites/all/modules/ulmus/ctools/plugins/content_types/node_context/node_comment_form.inc
  6. icor7 sites/all/modules/ulmus/ctools/plugins/content_types/node_context/node_comment_form.inc
  7. meedjum_blog7 sites/all/modules/ulmus/ctools/plugins/content_types/node_context/node_comment_form.inc
  8. mooc7 sites/all/modules/ulmus/ctools/plugins/content_types/node_context/node_comment_form.inc

Functions

File

sites/all/modules/ulmus/ctools/plugins/content_types/node_context/node_comment_form.inc
View source
  1. <?php
  2. if (module_exists('comment')) {
  3. /**
  4. * Plugins are described by creating a $plugin array which will be used
  5. * by the system that includes this file.
  6. */
  7. $plugin = array(
  8. 'single' => TRUE,
  9. 'title' => t('Comment form'),
  10. 'icon' => 'icon_node.png',
  11. 'description' => t('A form to add a new comment.'),
  12. 'required context' => new ctools_context_required(t('Node'), 'node'),
  13. 'category' => t('Node'),
  14. 'defaults' => array('anon_links' => FALSE),
  15. );
  16. }
  17. function ctools_node_comment_form_content_type_render($subtype, $conf, $panel_args, $context) {
  18. $node = isset($context->data) ? clone($context->data) : NULL;
  19. $block = new stdClass();
  20. $block->module = 'comments';
  21. $block->delta = $node->nid;
  22. $block->title = t('Add comment');
  23. if (empty($node)) {
  24. $block->content = t('Comment form here.');
  25. }
  26. else if ($node->comment == COMMENT_NODE_OPEN) {
  27. if (user_access('post comments')) {
  28. $comment = new stdClass();
  29. $comment->nid = $node->nid;
  30. $comment->pid = NULL;
  31. $form_state = array(
  32. 'ctools comment alter' => TRUE,
  33. 'node' => $node,
  34. 'build_info' => array(
  35. 'args' => array(
  36. $comment,
  37. ),
  38. ),
  39. );
  40. $block->content = drupal_build_form('comment_node_' . $node->type . '_form', $form_state);
  41. }
  42. else if (!empty($conf['anon_links'])) {
  43. $block->content = theme('comment_post_forbidden', array('node' => $node));
  44. }
  45. }
  46. return $block;
  47. }
  48. function ctools_node_comment_form_content_type_admin_title($subtype, $conf, $context) {
  49. return t('"@s" comment form', array('@s' => $context->identifier));
  50. }
  51. function ctools_node_comment_form_content_type_edit_form($form, &$form_state) {
  52. $form['anon_links'] = array(
  53. '#type' => 'checkbox',
  54. '#title' => t('Shows links to register or login.'),
  55. '#description' => t('If anonymous comments are not allowed, this will display the register and login links.'),
  56. '#default_value' => $form_state['conf']['anon_links'],
  57. );
  58. return $form;
  59. }
  60. function ctools_node_comment_form_content_type_edit_form_submit($form, &$form_state) {
  61. // For each part of the form defined in the 'defaults' array set when you
  62. // defined the content type, copy the value from the form into the array
  63. // of items to be saved. We don't ever want to use
  64. // $form_state['conf'] = $form_state['values'] because values contains
  65. // buttons, form id and other items we don't want stored. CTools will handle
  66. // the actual form submission.
  67. foreach (array_keys($form_state['plugin']['defaults']) as $key) {
  68. $form_state['conf'][$key] = $form_state['values'][$key];
  69. }
  70. }
  71. /**
  72. * Alter the comment form to get a little more control over it.
  73. */
  74. function ctools_form_comment_form_alter(&$form, &$form_state) {
  75. if (!empty($form_state['ctools comment alter'])) {
  76. // Force the form to post back to wherever we are.
  77. $form['#action'] = url($_GET['q'], array('fragment' => 'comment-form'));
  78. if (empty($form['#submit'])) {
  79. $form['#submit'] = array('comment_form_submit');
  80. }
  81. $form['#submit'][] = 'ctools_node_comment_form_submit';
  82. }
  83. }
  84. function ctools_node_comment_form_submit(&$form, &$form_state) {
  85. $form_state['redirect'][0] = $_GET['q'];
  86. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.