Elgg  Version 1.11
save.php
Go to the documentation of this file.
1 <?php
13 if (!elgg_is_logged_in()) {
14  return;
15 }
16 
17 $entity = elgg_extract('entity', $vars);
18 /* @var ElggEntity $entity */
19 
20 $comment = elgg_extract('comment', $vars);
21 /* @var ElggComment $comment */
22 
23 $inline = elgg_extract('inline', $vars, false);
24 $is_edit_page = elgg_extract('is_edit_page', $vars, false);
25 
27 if ($entity) {
28  $entity_guid_input = elgg_view('input/hidden', array(
29  'name' => 'entity_guid',
30  'value' => $entity->guid,
31  ));
32 }
33 
36 if ($comment && $comment->canEdit()) {
37  $entity_guid_input = elgg_view('input/hidden', array(
38  'name' => 'comment_guid',
39  'value' => $comment->guid,
40  ));
41  $comment_label = elgg_echo("generic_comments:edit");
42  $submit_input = elgg_view('input/submit', array('value' => elgg_echo('save')));
43  $comment_text = $comment->description;
44 } else {
45  $comment_label = elgg_echo("generic_comments:add");
46  $submit_input = elgg_view('input/submit', array('value' => elgg_echo('comment')));
47 }
48 
50 if ($comment) {
51  $cancel_button = elgg_view('input/button', array(
52  'value' => elgg_echo('cancel'),
53  'class' => 'elgg-button-cancel mlm',
54  'href' => $entity ? $entity->getURL() : '#',
55  ));
56 }
57 
58 if ($inline) {
59  $comment_input = elgg_view('input/text', array(
60  'name' => 'generic_comment',
61  'value' => $comment_text,
62  ));
63 
65 } else {
66 
67  $comment_input = elgg_view('input/longtext', array(
68  'name' => 'generic_comment',
69  'value' => $comment_text,
70  ));
71 
72  $is_edit_page_input = elgg_view('input/hidden', array(
73  'name' => 'is_edit_page',
74  'value' => (int)$is_edit_page,
75  ));
76 
77  echo <<<FORM
78 <div>
79  <label>$comment_label</label>
80  $comment_input
81 </div>
82 <div class="elgg-foot">
87 </div>
88 FORM;
89 }
$comment_text
Definition: save.php:11
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:51
$is_edit_page
Definition: save.php:12
$cancel_button
Definition: save.php:49
$inline
Definition: save.php:23
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1246
fieldset div
Definition: admin.php:470
$comment
Definition: save.php:57
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$comment_guid_input
Definition: save.php:35
elgg echo
Translates a string.
Definition: languages.js:43
$entity_guid_input
Definition: save.php:26
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
$vars['type']
Definition: save.php:11
label
Definition: admin.php:460
$submit_input
Definition: save.php:46
if(!elgg_is_logged_in()) $entity
Definition: save.php:17
$is_edit_page_input
Definition: save.php:72