|
@@ -0,0 +1,52 @@
|
|
1
|
+<?php
|
|
2
|
+
|
|
3
|
+namespace Muzich\CoreBundle\ElementFactory\Site;
|
|
4
|
+
|
|
5
|
+use Muzich\CoreBundle\ElementFactory\Site\base\BaseFactory;
|
|
6
|
+
|
|
7
|
+/**
|
|
8
|
+ *
|
|
9
|
+ *
|
|
10
|
+ * @author bux
|
|
11
|
+ */
|
|
12
|
+class DeezercomFactory extends BaseFactory
|
|
13
|
+{
|
|
14
|
+ public function getEmbedCode()
|
|
15
|
+ {
|
|
16
|
+ $url = str_replace('www.', '', $this->element->getUrl());
|
|
17
|
+ $data = str_replace('http://deezer.com', '', $url);
|
|
18
|
+
|
|
19
|
+ $embed = null;
|
|
20
|
+ $element_id = null;
|
|
21
|
+ $type = null;
|
|
22
|
+ // album
|
|
23
|
+ // http://www.deezer.com/fr/music/pantera/far-beyond-driven-80398
|
|
24
|
+ if (preg_match("#^\/[a-zA-Z_-]+\/music\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+-([0-9]+)#", $data, $chaines))
|
|
25
|
+ {
|
|
26
|
+ $element_id = $chaines[1];
|
|
27
|
+ $type = 'album';
|
|
28
|
+ }
|
|
29
|
+ // playlist
|
|
30
|
+ // http://www.deezer.com/fr/music/playlist/18701350
|
|
31
|
+ else if (preg_match("#^\/[a-zA-Z_-]+\/music\/playlist\/([0-9]+)#", $data, $chaines))
|
|
32
|
+ {
|
|
33
|
+ $element_id = $chaines[1];
|
|
34
|
+ $type = 'playlist';
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+ if ($element_id)
|
|
38
|
+ {
|
|
39
|
+ $width = $this->container->getParameter('deezer_player_width');
|
|
40
|
+ $heigth = $this->container->getParameter('deezer_player_heigth');
|
|
41
|
+ $embed = '<iframe scrolling="no" frameborder="0" allowTransparency="true" '
|
|
42
|
+ .'src="http://www.deezer.com/fr/plugins/player?autoplay=false&playlist=true'
|
|
43
|
+ .'&width='.$width.'&height='.$heigth.'&cover=true&btn_popup=true&type='.$type.'&id='.$chaines[1].'&title=" '
|
|
44
|
+ .'width="'.$width.'" height="'.$heigth.'"></iframe>'
|
|
45
|
+ ;
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ return $embed;
|
|
49
|
+ }
|
|
50
|
+}
|
|
51
|
+
|
|
52
|
+?>
|