aboutsummaryrefslogtreecommitdiff
path: root/mod/embed/views/default/js/embed/inline.php
blob: 0672a68f874c32746ce77987b8f1a32f36334dec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
/**
 * Inline embed JavaScript for attaching the insert data to list items
 *
 * @uses $vars['items']
 */

foreach ($vars['items'] as $item) {

	// different entity types have different title attribute names.
	$title = isset($item->name) ? $item->name : $item->title;
	// don't let it be too long
	$title = elgg_get_excerpt($title);

	$icon = "<img src=\"{$item->getIcon($icon_size)}\" />" . htmlspecialchars($title, ENT_QUOTES, 'UTF-8', false);

	$embed_code = elgg_view('output/url', array(
		'href' => $item->getURL(),
		'title' => $title,
		'text' => $icon,
		'encode_text' => false,
	));
	$embed_code = json_encode($embed_code);

	echo "$('#elgg-object-{$item->getGUID()}').data('embed_code', $embed_code);";
}