Elgg  Version 3.0
summary.php
Go to the documentation of this file.
1 <?php
8 $item = elgg_extract('item', $vars);
9 if (!$item instanceof ElggRiverItem) {
10  return;
11 }
12 
13 $subject = $item->getSubjectEntity();
14 if (!$subject instanceof ElggEntity) {
15  return;
16 }
17 
18 $object = $item->getObjectEntity();
19 if (!$object 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 
31 $object_link = elgg_view('output/url', [
32  'href' => $object->getURL(),
33  'text' => elgg_get_excerpt($object->getDisplayName(), 100),
34  'class' => 'elgg-river-object',
35  'is_trusted' => true,
36 ]);
37 
38 $action = $item->action_type;
39 $type = $item->type;
40 $subtype = $item->subtype;
41 
42 // if activity happened in a group
45 if ($container instanceof ElggGroup && $container->guid != elgg_get_page_owner_guid()) {
46  $group_link = elgg_view('output/url', [
47  'href' => $container->getURL(),
48  'text' => $container->getDisplayName(),
49  'is_trusted' => true,
50  ]);
51  $group_string = elgg_echo('river:ingroup', [$group_link]);
52 }
53 
54 // check summary translation keys
55 $key = false;
56 $keys = [
57  "river:{$type}:{$subtype}:{$action}",
58  "river:{$type}:{$subtype}:default",
59  "river:{$type}:{$action}",
60  "river:{$type}:default",
61 ];
62 foreach ($keys as $try_key) {
63  if (elgg_language_key_exists($try_key)) {
64  $key = $try_key;
65  break;
66  }
67 }
68 // try the old translation keys
69 if ($key === false) {
70  $deprecated_keys = [
71  "river:$action:$type:$subtype",
72  "river:$action:$type:default",
73  ];
74  foreach ($deprecated_keys as $try_key) {
75  if (elgg_language_key_exists($try_key)) {
76  $key = $try_key;
77 
78  $notice = "Please update your river language key: '{$try_key}', suggested new key 'river:{$type}:{$subtype}:{$action}'.";
79  $notice .= " See views/default/river/elements/summary";
81  break;
82  }
83  }
84 }
85 $summary = '';
86 if ($key !== false) {
88 }
89 
90 echo trim("$summary $group_string");
elgg_language_key_exists($key, $language= 'en')
Check if a given language key exists.
Definition: languages.php:96
$subtype
Definition: summary.php:40
$action
Definition: summary.php:38
if(!$entity instanceof ElggEntity) $summary
Definition: summary.php:24
if(!$item instanceof ElggRiverItem) $subject
Definition: summary.php:13
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$type
Definition: summary.php:39
if(!$object instanceof ElggEntity) $subject_link
Definition: summary.php:23
elgg echo
Translates a string.
Definition: languages.js:43
$container
Definition: summary.php:44
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:841
$group_string
Definition: summary.php:43
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
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:55
$vars['type']
Definition: save.php:11
elgg_get_excerpt($text, $num_chars=250)
Returns an excerpt.
Definition: output.php:74
getContainerEntity()
Get the container entity for this object.
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
elgg_get_page_owner_guid($guid=0)
Gets the guid of the entity that owns the current page.
Definition: pageowner.php:22
getURL()
Gets the URL for this entity.
$item
Short summary of the action that occurred.
Definition: summary.php:8
if(!$subject instanceof ElggEntity) $object
Definition: summary.php:18
getDisplayName()
Get the entity&#39;s display name.
Definition: ElggEntity.php:307
$object_link
Definition: summary.php:31
$keys
Definition: summary.php:56