Elgg  Version 4.3
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 $type = $target->getType();
24 $subtype = $target->getSubtype() ? $target->getSubtype() : 'default';
25 
26 $key = false;
27 $keys = [
28  "river:$type:$subtype:comment",
29  "river:$type:default:comment",
30 ];
31 foreach ($keys as $try_key) {
32  if (elgg_language_key_exists($try_key)) {
33  $key = $try_key;
34  break;
35  }
36 }
37 
38 if ($key !== false) {
39  $subject_link = elgg_view_entity_url($subject, ['class' => 'elgg-river-subject']);
40  $target_link = elgg_view_url($comment->getURL(), $target->getDisplayName(), ['class' => 'elgg-river-target']);
41 
42  $vars['summary'] = elgg_echo($key, [$subject_link, $target_link]);
43 }
44 
46 if (elgg_substr($message, -3) === '...') {
47  $message .= elgg_view_url($comment->getURL(), elgg_echo('read_more'), ['class' => 'mls']);
48 }
49 
50 $vars['message'] = $message;
51 
52 echo elgg_view('river/elements/layout', $vars);
elgg_language_key_exists($key, $language= 'en')
Check if a given language key exists.
Definition: languages.php:46
$item
Post comment river view.
Definition: create.php:6
if(elgg_substr($message,-3)=== '...') $vars['message']
Definition: create.php:50
$key
Definition: create.php:26
if(!$subject instanceof ElggEntity||!$target instanceof ElggEntity) $type
Definition: create.php:23
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
foreach($keys as $try_key) if($key!==false) $message
Definition: create.php:45
$target
Definition: create.php:17
if(!$object instanceof ElggEntity) $subject_link
Definition: summary.php:23
if(!$item instanceof ElggRiverItem) $comment
Definition: create.php:11
$keys
Definition: create.php:27
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:547
elgg_substr()
Wrapper function for mb_substr().
Definition: mb_wrapper.php:219
$subtype
Definition: create.php:24
elgg_view_url(string $href, string $text=null, array $options=[])
Helper function for outputting urls.
Definition: views.php:1513
elgg_get_excerpt($text, $num_chars=250)
Returns an excerpt.
Definition: output.php:72
elgg echo
Translates a string.
Definition: deprecated.js:530
if(!$comment instanceof ElggComment) $subject
Definition: create.php:16
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:179
elgg_view_entity_url(\ElggEntity $entity, array $options=[])
Helper function for outputting a link to an entity.
Definition: views.php:1530