1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- /**
- * Form for adding and editing comments
- *
- * @package Elgg
- *
- * @uses ElggEntity $vars['entity'] The entity being commented
- * @uses ElggComment $vars['comment'] The comment being edited
- * @uses bool $vars['inline'] Show a single line version of the form?
- */
- if (!elgg_is_logged_in()) {
- return;
- }
- $river_id_input = "";
- $river_id = elgg_extract('river_id', $vars, false);
- if ($river_id){
- $river_id_input = elgg_view('input/hidden', array(
- 'name' => 'river_id',
- 'value' => $river_id
- ));
- }
- $entity_guid_input = '';
- if (isset($vars['entity'])) {
- $entity_guid_input = elgg_view('input/hidden', array(
- 'name' => 'entity_guid',
- 'value' => $vars['entity']->guid,
- ));
- }
- $comment_text = '';
- $comment_guid_input = '';
- if (isset($vars['comment']) && $vars['comment']->canEdit()) {
- $entity_guid_input = elgg_view('input/hidden', array(
- 'name' => 'comment_guid',
- 'value' => $vars['comment']->guid,
- ));
- $comment_label = elgg_echo("generic_comments:edit");
- $submit_input = elgg_view('input/submit', array('value' => elgg_echo('save')));
- $comment_text = $vars['comment']->description;
- } else {
- $comment_label = elgg_echo("generic_comments:add");
- $submit_input = elgg_view('input/submit', array('value' => elgg_echo('comment')));
- }
- $cancel_link = '';
- if (isset($vars['comment'])) {
- $cancel_link = "<a class='elgg-cancel mlm' href='#'>" . elgg_echo('cancel') . "</a>";
- }
- $inline = elgg_extract('inline', $vars, false);
- if ($inline) {
- $comment_input = elgg_view('input/text', array(
- 'name' => 'generic_comment',
- 'value' => $comment_text,
- ));
- echo $river_id_input . $comment_input . $entity_guid_input . $comment_guid_input . $submit_input;
- } else {
- $comment_input = elgg_view('input/longtext', array(
- 'name' => 'generic_comment',
- 'value' => $comment_text,
- ));
- echo <<<FORM
- <div>
- <label>$comment_label</label>
- $comment_input
- </div>
- <div class="elgg-foot">
- $comment_guid_input
- $entity_guid_input
- $submit_input $cancel_link
- <div>
- FORM;
- }
|