Elgg  Version 3.0
create.php
Go to the documentation of this file.
1 <?php
6 $item = elgg_extract('item', $vars);
7 if (!$item instanceof ElggRiverItem) {
8  return;
9 }
10 
11 $comment = $item->getObjectEntity();
12 if (!$comment instanceof ElggComment) {
13  return;
14 }
15 
16 $subject = $item->getSubjectEntity();
17 $target = $item->getTargetEntity();
18 
19 if (!$subject instanceof ElggEntity || !$target instanceof ElggEntity) {
20  return;
21 }
22 
23 $subject_link = elgg_view('output/url', [
24  'href' => $subject->getURL(),
25  'text' => $subject->getDisplayName(),
26  'class' => 'elgg-river-subject',
27  'is_trusted' => true,
28 ]);
29 
30 $target_link = elgg_view('output/url', [
31  'href' => $comment->getURL(),
32  'text' => $target->getDisplayName(),
33  'class' => 'elgg-river-target',
34  'is_trusted' => true,
35 ]);
36 
37 $type = $target->getType();
38 $subtype = $target->getSubtype() ? $target->getSubtype() : 'default';
39 
40 $key = false;
41 $keys = [
42  "river:$type:$subtype:comment",
43  "river:$type:default:comment",
44 ];
45 foreach ($keys as $try_key) {
46  if (elgg_language_key_exists($try_key)) {
47  $key = $try_key;
48  break;
49  }
50 }
51 // try the old translation keys
52 if ($key === false) {
53  $deprecated_keys = [
54  "river:comment:$type:$subtype",
55  "river:comment:$type:default",
56  ];
57  foreach ($deprecated_keys as $try_key) {
58  if (elgg_language_key_exists($try_key)) {
59  $key = $try_key;
60 
61  $notice = "Please update your river language key: '{$try_key}', suggested new key 'river:$type:$subtype:comment'.";
62  $notice .= " See views/default/river/object/comment/create";
64  break;
65  }
66  }
67 }
68 
69 if ($key !== false) {
70  $vars['summary'] = elgg_echo($key, [$subject_link, $target_link]);
71 }
72 
74 if (substr($message, -3) === '...') {
75  $message .= elgg_view('output/url', [
76  'text' => elgg_echo('read_more'),
77  'href' => $comment->getURL(),
78  'is_trusted' => true,
79  'class' => 'mls',
80  ]);
81 }
82 
83 $vars['message'] = $message;
84 
85 echo elgg_view('river/elements/layout', $vars);
elgg_language_key_exists($key, $language= 'en')
Check if a given language key exists.
Definition: languages.php:96
$item
Post comment river view.
Definition: create.php:6
$key
Definition: create.php:40
if(substr($message,-3)=== '...') $vars['message']
Definition: create.php:83
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$target
Definition: create.php:17
foreach($keys as $try_key) if($key===false) if($key!==false) $message
Definition: create.php:73
$target_link
Definition: create.php:30
elgg echo
Translates a string.
Definition: languages.js:43
if(!$subject instanceof ElggEntity||!$target instanceof ElggEntity) $subject_link
Definition: create.php:23
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:841
if(!$item instanceof ElggRiverItem) $comment
Definition: create.php:11
$keys
Definition: create.php:41
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
$type
Definition: create.php:37
$subtype
Definition: create.php:38
getDisplayName()
{}
Definition: ElggObject.php:38
elgg_get_excerpt($text, $num_chars=250)
Returns an excerpt.
Definition: output.php:74
if(!$comment instanceof ElggComment) $subject
Definition: create.php:16
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
getURL()
Gets the URL for this entity.