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