-
Notifications
You must be signed in to change notification settings - Fork 4
/
mediaLinkProperty.php
71 lines (68 loc) · 2.48 KB
/
mediaLinkProperty.php
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
class mediaLinkProperty extends stringProperty{
protected static $_id = 0;
public function getMediaLinks($limit = false){
$links = array();
if (preg_match_all("#(http://\S+(?:\#|\s|$))#i", $this->getValue(), $subs)){
foreach ($subs[1] as $url){
$links[] = new mediaLink($url);
}
return $links;
}
return false;
//http://
}
public function html(){
$ah = '';
if ($mediaLinks = $this->getMediaLinks()){
$mediaWidth = '150px';
$limit = 8;
$shown = 0;
$showId = 0;
if (count($mediaLinks)){
foreach ($mediaLinks as $mediaLink){
//$h .= '<div>fixed: '.$mediaLink->getFixedUrl().'</div>';
self::$_id++;
$previewId = self::$_id;
if ($shown >= $limit) continue;
if ($mediaLink->getDriver()!==null){
$title = '';
if ($title = $mediaLink->getTitle()){
$etitle = htmlspecialchars($title,ENT_QUOTES);
$text = str_replace(htmlspecialchars($mediaLink->getUrl()), '<a href="'.$mediaLink->getFixedUrl().'" target="_blank" class="external">'.$etitle.'</a>', $text);
}
$etitle = htmlspecialchars($title,ENT_QUOTES);
$onclick = htmlspecialchars($mediaLink->getOnClick($previewId),ENT_QUOTES);
if ($previewUrl = $mediaLink->getPreviewUrl()){
$shown++;
//$ah .= $mediaLink->getEmbedHtml();
$ah .= '<div id="preview-'.$previewId.'" class="video video-block">'."\r\n";
$ah .= '<div class="video-thumb">';
$ah .= '<div class="preview-load"></div>'."\r\n";
$ah .= '<div class="preview-alt"
embed-url="'.htmlspecialchars($mediaLink->getEmbedUrl(),ENT_QUOTES).'"
flashvars="'.htmlspecialchars($mediaLink->getFlashVars(),ENT_QUOTES).'"
>';
$ah .= '<div title="'.$etitle.'" onclick="'.$onclick.'" class="play"><img style="width: '.$mediaWidth.';" src="'.$previewUrl.'" /></div>'."\r\n";
$ah .= '<img class="block" title="'.$etitle.'" style="width: '.$mediaWidth.';" src="'.$previewUrl.'" />'."\r\n";
$ah .= '</div>';
$ah .= '</div>';
$ah .= '</div>';
}else{
/*$ah .= '<div id="preview-'.$previewId.'" class="video video-block">';
$ah .= '<div class="video-thumb">';
$ah .= '<div class="preview-load"></div>';
$ah .= '<div class="preview-alt">';
$ah .= '<div title="'.$etitle.'" onclick="'.$onclick.'">'.$etitle.'</div>';
$ah .= '</div>';
$ah .= '</div>';
$ah .= '</div>';*/
}
}
}
if (strlen($ah)) return $ah;
}
}
return $this->getValue();
}
}