-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmediaLinkDriver.php
138 lines (137 loc) · 4.07 KB
/
mediaLinkDriver.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of mediaDriver
*
* @author olamedia
*/
class mediaLinkDriver{
protected $_width = '100%';
protected $_height = '400';
/**
* @var mediaLink
*/
protected $_link = null;
public function __construct($link){
$this->_link = $link;
}
/**
* @return string
*/
public function getUrl(){
return $this->_link->getUrl();
}
public function getFixedUrl(){
return $this->_link->getUrl();
}
public function getDomainName(){
return $this->_link->getDomainName();
}
public function fetchUrl(){
return file_get_contents($this->getUrl());
}
public function load(){
return false;
}
protected function _px($size){
if (strval(intval($size))==strval($size)){
return $size.'px';
}
return $size;
}
public function setWidth($width){
$this->_width = $width;
}
public function setHeight($height){
$this->_height = $height;
}
public function getWidth(){
return $this->_width;
}
public function getHeight(){
return $this->_height;
}
public function getFlashVars(){
return '';
}
public function getEmbedHtml(){
$h =
'<div style="width: '.$this->_px($this->getWidth()).';height: '.$this->_px($this->getHeight()).'">
<object width="'.$this->getWidth().'" height="'.$this->getHeight().'">
<param name="movie" value="'.$this->getEmbedUrl().'"></param>
<param name="flashVars" value="'.$this->getFlashVars().'"></param>
<param name="allowFullScreen" value="true"></param>
<param name="wmode" value="transparent"></param>
<param name="allowscriptaccess" value="sameDomain"></param>
<embed src="'.$this->getEmbedUrl().'"
type="application/x-shockwave-flash"
allowscriptaccess="sameDomain"
allowfullscreen="true"
wmode="transparent"
flashvars="'.$this->getFlashVars().'"
width="'.$this->getWidth().'"
height="'.$this->getHeight().'">
</embed>
</object>
</div>';
return $h;
}
public function getTitle(){
// any video
$results = googleVideo::search($this->getFixedUrl());
foreach ($results as $k => $result){
//var_dump($result);
$pubDate = strtotime(strval($result->pubDate));
$link = (strval($result->link));
$link = str_replace('http://www.google.com/url?q=', '', $link);
$link = preg_replace("#^(.*)&source=video&vgc=rss.*$#is", '\1', $link);
$link = urldecode($link);
//$tm = $result->xpath('media:group/media:thumbnail');
$tm = strval($result['thumbnail'][0]['url']);
$desc = $result['description'][0]['url'];
$desc = strip_tags(html_entity_decode(htmlspecialchars_decode($desc[0])));
$title = $result['title'][0]['#text'];
if (is_array($title)) $title = implode('', $title);
$title = strip_tags(html_entity_decode(htmlspecialchars_decode($title)));
return $title;
}
return false;
}
public function getPreviewUrl(){
// any video
$results = googleVideo::search($this->getFixedUrl());
foreach ($results->xpath("//item") as $k => $result){
$pubDate = strtotime(strval($result->pubDate));
$link = (strval($result->link));
$link = str_replace('http://www.google.com/url?q=', '', $link);
$link = preg_replace("#^(.*)&source=video&vgc=rss.*$#is", '\1', $link);
$link = urldecode($link);
$tm = $result->xpath('media:group/media:thumbnail');
$tm = strval($tm[0]['url']);
$desc = $result->xpath('media:group/media:description');
$desc = strip_tags(html_entity_decode(htmlspecialchars_decode($desc[0])));
$title = strip_tags(html_entity_decode(htmlspecialchars_decode(str_replace(array('<title>', '</title>'), '', $result->title->asXML()))));
return $tm;
}
return false;
}
public function getEmbedUrl(){
return false;
}
public function getIframeUrl(){
return false;
}
public function getOnClick($playerId){
if ($this->getEmbedUrl()){
return "video.show('preview-".$playerId."')";
//,'".($this->getEmbedUrl())."','".$this->getFlashVars()."'
}
if ($this->getIframeUrl()){
return "showIframe('preview-".$playerId."','".$this->getIframeUrl()."','".$this->getUrl()."')";
}
}
}
?>