save.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Form for adding and editing comments
  4. *
  5. * @package Elgg
  6. *
  7. * @uses ElggEntity $vars['entity'] The entity being commented
  8. * @uses ElggComment $vars['comment'] The comment being edited
  9. * @uses bool $vars['inline'] Show a single line version of the form?
  10. */
  11. if (!elgg_is_logged_in()) {
  12. return;
  13. }
  14. $river_id_input = "";
  15. $river_id = elgg_extract('river_id', $vars, false);
  16. if ($river_id){
  17. $river_id_input = elgg_view('input/hidden', array(
  18. 'name' => 'river_id',
  19. 'value' => $river_id
  20. ));
  21. }
  22. $entity_guid_input = '';
  23. if (isset($vars['entity'])) {
  24. $entity_guid_input = elgg_view('input/hidden', array(
  25. 'name' => 'entity_guid',
  26. 'value' => $vars['entity']->guid,
  27. ));
  28. }
  29. $comment_text = '';
  30. $comment_guid_input = '';
  31. if (isset($vars['comment']) && $vars['comment']->canEdit()) {
  32. $entity_guid_input = elgg_view('input/hidden', array(
  33. 'name' => 'comment_guid',
  34. 'value' => $vars['comment']->guid,
  35. ));
  36. $comment_label = elgg_echo("generic_comments:edit");
  37. $submit_input = elgg_view('input/submit', array('value' => elgg_echo('save')));
  38. $comment_text = $vars['comment']->description;
  39. } else {
  40. $comment_label = elgg_echo("generic_comments:add");
  41. $submit_input = elgg_view('input/submit', array('value' => elgg_echo('comment')));
  42. }
  43. $cancel_link = '';
  44. if (isset($vars['comment'])) {
  45. $cancel_link = "<a class='elgg-cancel mlm' href='#'>" . elgg_echo('cancel') . "</a>";
  46. }
  47. $inline = elgg_extract('inline', $vars, false);
  48. if ($inline) {
  49. $comment_input = elgg_view('input/text', array(
  50. 'name' => 'generic_comment',
  51. 'value' => $comment_text,
  52. ));
  53. echo $river_id_input . $comment_input . $entity_guid_input . $comment_guid_input . $submit_input;
  54. } else {
  55. $comment_input = elgg_view('input/longtext', array(
  56. 'name' => 'generic_comment',
  57. 'value' => $comment_text,
  58. ));
  59. echo <<<FORM
  60. <div>
  61. <label>$comment_label</label>
  62. $comment_input
  63. </div>
  64. <div class="elgg-foot">
  65. $comment_guid_input
  66. $entity_guid_input
  67. $submit_input $cancel_link
  68. <div>
  69. FORM;
  70. }