Elgg  Version 3.0
save.php
Go to the documentation of this file.
1 <?php
12 if (!elgg_is_logged_in()) {
13  return;
14 }
15 
16 elgg_require_js('elgg/comments');
17 
18 $entity = elgg_extract('entity', $vars);
19 /* @var ElggEntity $entity */
20 
21 $comment = elgg_extract('comment', $vars);
22 /* @var ElggComment $comment */
23 
24 $inline = (bool) elgg_extract('inline', $vars, false);
25 
26 if ($entity) {
27  echo elgg_view('input/hidden', [
28  'name' => 'entity_guid',
29  'value' => $entity->guid,
30  ]);
31 }
32 
34 $footer = '';
35 if ($comment && $comment->canEdit()) {
36  echo elgg_view('input/hidden', [
37  'name' => 'comment_guid',
38  'value' => $comment->guid,
39  ]);
40  $comment_label = elgg_echo("generic_comments:edit");
41  $footer .= elgg_view('input/submit', ['value' => elgg_echo('save')]);
42  $comment_text = $comment->description;
43 } else {
44  $comment_label = elgg_echo("generic_comments:add");
45  $footer .= elgg_view('input/submit', ['value' => elgg_echo('comment')]);
46 }
47 
48 if ($inline) {
49  $form = elgg_view('input/text', [
50  'name' => 'generic_comment',
51  'value' => $comment_text,
52  'required' => true,
53  ]);
54 
55  $form .= $footer;
56  echo elgg_format_element('div', [
57  'class' => 'elgg-level',
58  ], $form);
59 } else {
61  '#type' => 'longtext',
62  '#label' => $comment_label,
63  'name' => 'generic_comment',
64  'value' => $comment_text,
65  'required' => true,
66  'editor_type' => 'simple',
67  ]);
68 
69  if ($comment) {
70  $footer .= elgg_view('input/button', [
71  'value' => elgg_echo('cancel'),
72  'class' => 'elgg-button-cancel mlm',
73  'href' => $entity ? $entity->getURL() : '#',
74  ]);
75  }
76 
78 }
$comment_text
Definition: save.php:11
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:48
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1395
$inline
Definition: save.php:24
$footer
Definition: save.php:87
$comment
Definition: save.php:43
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_set_form_footer($footer= '')
Sets form footer and defers its rendering until the form view and extensions have been rendered...
Definition: views.php:1331
elgg_require_js($name)
Request that Elgg load an AMD module onto the page.
Definition: elgglib.php:168
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
elgg echo
Translates a string.
Definition: languages.js:43
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
$entity
Definition: save.php:18
$vars['type']
Definition: save.php:11
$form
List all unvalidated users in the admin area.
Definition: unvalidated.php:9
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246