Passed
Push — master ( f13f78...5c1b24 )
by Ismayil
04:22
created

views/default/export/entity.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Elgg Entity export.
4
 * Displays an entity using the current view.
5
 *
6
 * @package Elgg
7
 * @subpackage Core
8
 * @deprecated 1.9
9
 */
10
11
$entity = $vars['entity'];
12
if (!$entity) {
13
	throw new InvalidParameterException("No entity found, it either doesn't exist or you don't have access to it.");
14
}
15
$options = [
16
	'guid' => $entity->guid,
17
	'limit' => 0
18
];
19
$metadata = elgg_get_metadata($options);
20
$annotations = elgg_get_annotations($options);
21
$relationships = get_entity_relationships($entity->guid);
22
23
$exportable_values = $entity->getExportableValues();
24
?>
25
<div>
26
<?php // do not change localization string since this is deprecated view ?>
27
<h2><?php echo elgg_echo('Entity'); ?></h2>
28
	<?php
29
	foreach ($entity as $k => $v) {
30
		if ((in_array($k, $exportable_values)) || (elgg_is_admin_logged_in())) {
31
?>
32
		<p class="margin-none"><b><?php echo $k; ?>: </b><?php echo strip_tags($v); ?></p>
33
<?php
34
		}
35
	}
36
	?>
37
</div>
38
39
<?php if ($metadata) { ?>
40
<div id="metadata" class="mtm">
41
<h2><?php echo elgg_echo('metadata'); ?></h2>
42
	<?php
43
	foreach ($metadata as $m) {
44
?>
45
<p class="margin-none"><b><?php echo $m->name; ?>: </b><?php echo $m->value; ?></p>
46
<?php
47
	}
48
	?>
49
50
</div>
51
<?php } ?>
52
53
<?php if ($annotations) { ?>
54
<div id="annotations" class="mtm">
55
<h2><?php echo elgg_echo('annotations'); ?></h2>
56
	<?php
57
	foreach ($annotations as $a) {
58
?>
59
<table>
60
	<p class="margin-none"><b><?php echo $a->name; ?>: </b><?php echo $a->value; ?></p>
61
</table>
62
<?php
63
	}
64
	?>
65
</div>
66
<?php } ?>
67
68
<?php if ($relationships) { ?>
0 ignored issues
show
Bug Best Practice introduced by
The expression $relationships of type ElggRelationship[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
69
<div id="relationship" class="mtm">
70
<h2><?php echo elgg_echo('relationships'); ?></h2>
71
	<?php
72
	foreach ($relationships as $r) {
73
?>
74
<table>
75
	<p class="margin-none"><b><?php echo $r->relationship; ?>: </b><?php echo $r->guid_two; ?></p>
76
</table>
77
<?php
78
	}
79
	?>
80
</div>
81
<?php }
82