Elgg /
Elgg
| 1 | <?php |
||||
| 2 | /** |
||||
| 3 | * Elgg bookmark view |
||||
| 4 | * |
||||
| 5 | * @package ElggBookmarks |
||||
| 6 | */ |
||||
| 7 | |||||
| 8 | $full = elgg_extract('full_view', $vars, false); |
||||
| 9 | $bookmark = elgg_extract('entity', $vars, false); |
||||
| 10 | |||||
| 11 | if (! $bookmark instanceof ElggObject) { |
||||
| 12 | return; |
||||
| 13 | } |
||||
| 14 | |||||
| 15 | $owner = $bookmark->getOwnerEntity(); |
||||
| 16 | $owner_icon = elgg_view_entity_icon($owner, 'small'); |
||||
| 17 | |||||
| 18 | $link = elgg_view('output/url', [ |
||||
| 19 | 'href' => $bookmark->address, |
||||
| 20 | 'icon' => 'push-pin-alt', |
||||
| 21 | ]); |
||||
| 22 | |||||
| 23 | if (elgg_in_context('gallery')) { |
||||
| 24 | $owner_link = elgg_view('output/url', [ |
||||
| 25 | 'href' => $owner->getURL(), |
||||
| 26 | 'text' => $owner->getDisplayName(), |
||||
| 27 | ]); |
||||
| 28 | $date = elgg_view_friendly_time($bookmark->time_created); |
||||
| 29 | |||||
| 30 | echo <<<HTML |
||||
| 31 | <div class="bookmarks-gallery-item"> |
||||
| 32 | <h3>{$bookmark->getDisplayName()}</h3> |
||||
| 33 | <p class='subtitle'>$owner_link $date</p> |
||||
| 34 | </div> |
||||
| 35 | HTML; |
||||
| 36 | |||||
| 37 | return; |
||||
| 38 | } |
||||
| 39 | |||||
| 40 | if ($full) { |
||||
| 41 | $description = elgg_view('output/longtext', ['value' => $bookmark->description, 'class' => 'pbl']); |
||||
| 42 | |||||
| 43 | $params = [ |
||||
| 44 | 'title' => false, |
||||
| 45 | 'handler' => 'bookmarks', |
||||
| 46 | ]; |
||||
| 47 | $params = $params + $vars; |
||||
| 48 | $summary = elgg_view('object/elements/summary', $params); |
||||
| 49 | |||||
| 50 | $body = <<<HTML |
||||
| 51 | <div class="bookmark elgg-content mts"> |
||||
| 52 | <span class="elgg-heading-basic mbs">$link</span> |
||||
| 53 | $description |
||||
| 54 | </div> |
||||
| 55 | HTML; |
||||
| 56 | |||||
| 57 | echo elgg_view('object/elements/full', [ |
||||
| 58 | 'entity' => $bookmark, |
||||
| 59 | 'icon' => $owner_icon, |
||||
| 60 | 'summary' => $summary, |
||||
| 61 | 'body' => $body, |
||||
| 62 | 'show_responses' => elgg_extract('show_responses', $vars, false), |
||||
| 63 | 'show_navigation' => true, |
||||
| 64 | ]); |
||||
| 65 | |||||
| 66 | return; |
||||
| 67 | } |
||||
| 68 | |||||
| 69 | // brief view |
||||
| 70 | $url = $bookmark->address; |
||||
| 71 | $display_text = $url; |
||||
| 72 | $excerpt = elgg_get_excerpt($bookmark->description); |
||||
| 73 | if ($excerpt) { |
||||
| 74 | $excerpt = " - $excerpt"; |
||||
| 75 | } |
||||
| 76 | |||||
| 77 | if (strlen($url) > 25) { |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 78 | $bits = parse_url($url); |
||||
|
0 ignored issues
–
show
It seems like
$url can also be of type array; however, parameter $url of parse_url() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 79 | if (isset($bits['host'])) { |
||||
| 80 | $display_text = $bits['host']; |
||||
| 81 | } else { |
||||
| 82 | $display_text = elgg_get_excerpt($url, 100); |
||||
|
0 ignored issues
–
show
It seems like
$url can also be of type array; however, parameter $text of elgg_get_excerpt() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 83 | } |
||||
| 84 | } |
||||
| 85 | |||||
| 86 | $link = elgg_view('output/url', [ |
||||
| 87 | 'href' => $bookmark->address, |
||||
| 88 | 'text' => $display_text, |
||||
| 89 | 'icon' => 'push-pin-alt', |
||||
| 90 | ]); |
||||
| 91 | |||||
| 92 | $content = "$link{$excerpt}"; |
||||
| 93 | |||||
| 94 | $params = [ |
||||
| 95 | 'content' => $content, |
||||
| 96 | 'icon' => $owner_icon, |
||||
| 97 | 'handler' => 'bookmarks', |
||||
| 98 | ]; |
||||
| 99 | $params = $params + $vars; |
||||
| 100 | echo elgg_view('object/elements/summary', $params); |
||||
| 101 |