save.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * Discussion topic reply form body
  4. *
  5. * @uses $vars['topic'] A discussion topic object
  6. * @uses $vars['entity'] A discussion reply object
  7. * @uses $vars['inline'] Display a shortened form?
  8. */
  9. $topic = elgg_extract('topic', $vars);
  10. $topic_guid_input = '';
  11. if (isset($vars['topic'])) {
  12. $topic_guid_input = elgg_view('input/hidden', array(
  13. 'name' => 'topic_guid',
  14. 'value' => $vars['topic']->getGUID(),
  15. ));
  16. }
  17. $inline = elgg_extract('inline', $vars, false);
  18. $reply = elgg_extract('entity', $vars);
  19. $value = '';
  20. $reply_guid_input = '';
  21. if ($reply && $reply->canEdit()) {
  22. $value = $reply->description;
  23. $reply_guid_input = elgg_view('input/hidden', array(
  24. 'name' => 'guid',
  25. 'value' => $reply->guid
  26. ));
  27. $reply_label = elgg_echo("discussion:reply:edit");
  28. $submit_text = elgg_echo('save');
  29. } else {
  30. $reply_label = elgg_echo("reply:this");
  31. $submit_text = elgg_echo('reply');
  32. }
  33. $cancel_button = '';
  34. if ($reply) {
  35. $cancel_button = elgg_view('input/button', array(
  36. 'value' => elgg_echo('cancel'),
  37. 'class' => 'elgg-button-cancel mlm',
  38. 'href' => $entity ? $entity->getURL() : '#',
  39. ));
  40. }
  41. $submit_input = elgg_view('input/submit', array('value' => $submit_text));
  42. if ($inline) {
  43. $description_input = elgg_view('input/text', array(
  44. 'name' => 'description',
  45. 'value' => $value
  46. ));
  47. echo <<<FORM
  48. $description_input
  49. $topic_guid_input
  50. $reply_guid_input
  51. $submit_input
  52. FORM;
  53. } else {
  54. $description_input = elgg_view('input/longtext', array(
  55. 'name' => 'description',
  56. 'value' => $value
  57. ));
  58. echo <<<FORM
  59. <div>
  60. <label>$reply_label</label>
  61. $description_input
  62. </div>
  63. <div class="foot">
  64. $reply_guid_input
  65. $topic_guid_input
  66. $submit_input $cancel_button
  67. </div>
  68. FORM;
  69. }