Elgg  Version 6.1
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 
45 $message = elgg_get_excerpt((string) $comment->description);
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);
$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_get_excerpt(string $text, int $num_chars=250)
Returns an excerpt.
Definition: output.php:83
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:256
foreach($keys as $try_key) if($key!==false) $message
Definition: create.php:45
$target
Definition: create.php:17
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
elgg_language_key_exists(string $key, string $language= 'en')
Check if a given language key exists.
Definition: languages.php:44
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_substr()
Wrapper function for mb_substr().
Definition: mb_wrapper.php:195
$subtype
Definition: create.php:24
elgg_view_url(string $href, string $text=null, array $options=[])
Helper function for outputting urls.
Definition: views.php:1427
if(!$comment instanceof ElggComment) $subject
Definition: create.php:16
elgg_view_entity_url(\ElggEntity $entity, array $options=[])
Helper function for outputting a link to an entity.
Definition: views.php:1444