|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* VideoFork.php |
|
4
|
|
|
* |
|
5
|
|
|
* @package Providers |
|
6
|
|
|
* @author Michael Pratt <[email protected]> |
|
7
|
|
|
* @link http://www.michael-pratt.com/ |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Embera\Providers; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* The videofork.com Provider |
|
17
|
|
|
*/ |
|
18
|
|
|
class VideoFork extends \Embera\Adapters\Service |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* inline {@inheritdoc} |
|
22
|
|
|
* |
|
23
|
|
|
* This services doesnt have one single endpoint, but instead |
|
24
|
|
|
* every video has its own oembed url based on the id of the |
|
25
|
|
|
* video. |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $apiUrl = 'http://videofork.com/oembed/'; |
|
28
|
|
|
|
|
29
|
|
|
/** inline {@inheritdoc} */ |
|
30
|
|
|
protected function validateUrl() |
|
31
|
|
|
{ |
|
32
|
|
|
return (preg_match('~videofork\.com/(?:play|oembed)/(?:[0-9]+)$~i', $this->url)); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** inline {@inheritdoc} */ |
|
36
|
|
|
protected function normalizeUrl() |
|
37
|
|
|
{ |
|
38
|
|
|
if (preg_match('~/(?:play|oembed)/([0-9]+)~i', $this->url, $matches)) { |
|
39
|
|
|
// Overwrite the oembed endpoint with a valid one |
|
40
|
|
|
$this->apiUrl = 'http://videofork.com/oembed/' . $matches['1']; |
|
41
|
|
|
$this->url = new \Embera\Url('http://videofork.com/play/' . $matches['1']); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** inline {@inheritdoc} */ |
|
46
|
|
|
public function fakeResponse() |
|
47
|
|
|
{ |
|
48
|
|
|
$url = str_replace('/play/', '/embed/', $this->url); |
|
49
|
|
|
|
|
50
|
|
|
return array( |
|
51
|
|
|
'type' => 'video', |
|
52
|
|
|
'provider_name' => 'VideoFork', |
|
53
|
|
|
'provider_url' => 'http://videofork.com', |
|
54
|
|
|
'html' => '<object width="{width}" height="{height}"> <param name="movie" value="' . $url . '"></param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="' . $url . '" type="application/x-shockwave-flash" width="{width}" height="{height}" allowscriptaccess="always" allowfullscreen="true"></embed> </object>', |
|
55
|
|
|
); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
?> |
|
|
|
|
|
|
60
|
|
|
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.