comment_reply_form.inc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * @file
  4. * Ctools content-type plugin to provide a comment-reply form (replying either
  5. * to a node or to another comment).
  6. */
  7. // Only provide the plugin in the comment module is enabled.
  8. if (module_exists('comment')) {
  9. $plugin = array(
  10. 'single' => TRUE,
  11. 'title' => t('Comment Reply Form'),
  12. 'icon' => 'icon_comment.png',
  13. 'description' => t('A form to add a new comment reply.'),
  14. 'required context' => array(
  15. new ctools_context_required(t('Node'), 'node'),
  16. new ctools_context_optional(t('Comment'), 'comment'),
  17. ),
  18. 'category' => t('Comment'),
  19. 'render callback' => 'ctools_comment_reply_form_content_type_render',
  20. 'defaults' => array('anon_links' => false),
  21. );
  22. }
  23. function ctools_comment_reply_form_content_type_render($subtype, $conf, $panel_args, $context) {
  24. $comment = ($context[1]->identifier == t('No context')) ? NULL : clone $context[1]->data;
  25. $block = new stdClass();
  26. $block->module = 'comments';
  27. if ($comment) $block->delta = $comment->cid;
  28. $block->title = t('Add comment');
  29. $node = $context[0]->data;
  30. module_load_include('inc', 'comment', 'comment.pages');
  31. $block->content = comment_reply($node, ($comment ? $comment->cid : NULL));
  32. return $block;
  33. }
  34. function ctools_comment_reply_form_content_type_admin_title($subtype, $conf, $context) {
  35. return t('"@s" comment form', array('@s' => $context[0]->identifier));
  36. }
  37. function ctools_comment_reply_form_content_type_edit_form($form, &$form_state) {
  38. return $form;
  39. }
  40. function ctools_comment_reply_form_content_type_edit_form_submit($form, &$form_state) {
  41. }