|
@@ -0,0 +1,64 @@
|
|
1
|
+<?php
|
|
2
|
+
|
|
3
|
+namespace Muzich\CoreBundle\Factory\Elements;
|
|
4
|
+
|
|
5
|
+use Muzich\CoreBundle\Factory\ElementFactory;
|
|
6
|
+use Muzich\CoreBundle\Entity\Element;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+ *
|
|
10
|
+ *
|
|
11
|
+ * @author bux
|
|
12
|
+ */
|
|
13
|
+class Vimeocom extends ElementFactory
|
|
14
|
+{
|
|
15
|
+
|
|
16
|
+ public function retrieveDatas()
|
|
17
|
+ {
|
|
18
|
+ $url_clean = $this->getCleanedUrl();
|
|
19
|
+ $ref_id = null;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+ if (preg_match("#\/([0-9]+)#", $url_clean, $chaines))
|
|
23
|
+ {
|
|
24
|
+ $ref_id = $chaines[1];
|
|
25
|
+ }
|
|
26
|
+
|
|
27
|
+ if ($ref_id)
|
|
28
|
+ {
|
|
29
|
+ $this->element->setData(Element::DATA_REF_ID, $ref_id);
|
|
30
|
+ $this->getDataFromApi($ref_id);
|
|
31
|
+ }
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ protected function getDataFromApi($ref_id)
|
|
35
|
+ {
|
|
36
|
+ $data = $this->getJsonDataFromApiWithUrl('http://vimeo.com/api/v2/video/'.$ref_id.'.json');
|
|
37
|
+
|
|
38
|
+ if (count($data))
|
|
39
|
+ {
|
|
40
|
+ if (array_key_exists('title', $data[0]))
|
|
41
|
+ {
|
|
42
|
+ $this->element->setData(Element::DATA_TITLE, $data[0]['title']);
|
|
43
|
+ }
|
|
44
|
+ if (array_key_exists('thumbnail_medium', $data[0]))
|
|
45
|
+ {
|
|
46
|
+ $this->element->setData(Element::DATA_THUMB_URL, $data[0]['thumbnail_medium']);
|
|
47
|
+ }
|
|
48
|
+ }
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ public function proceedEmbedCode()
|
|
52
|
+ {
|
|
53
|
+ if (($ref_id = $this->element->getData(Element::DATA_REF_ID)))
|
|
54
|
+ {
|
|
55
|
+ $width = $this->container->getParameter('vimeo_player_width');
|
|
56
|
+ $height = $this->container->getParameter('vimeo_player_height');
|
|
57
|
+ $this->element->setEmbed(
|
|
58
|
+ '<iframe src="http://player.vimeo.com/video/'.$ref_id.'&autoplay=1&api=1" '
|
|
59
|
+ .'width="'.$width.'" height="'.$height.'" frameborder="0" '
|
|
60
|
+ .'webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'
|
|
61
|
+ );
|
|
62
|
+ }
|
|
63
|
+ }
|
|
64
|
+}
|