Browse Source

Ajout de la gestion des liens deezers.

bastien 13 years ago
parent
commit
704299cdc7

+ 5 - 1
src/Muzich/CoreBundle/ElementFactory/ElementManager.php View File

@@ -11,6 +11,7 @@ use Muzich\CoreBundle\ElementFactory\Site\YoutubecomFactory;
11 11
 use Muzich\CoreBundle\ElementFactory\Site\DailymotioncomFactory;
12 12
 use Muzich\CoreBundle\ElementFactory\Site\JamendocomFactory;
13 13
 use Muzich\CoreBundle\ElementFactory\Site\SoundcloudcomFactory;
14
+use Muzich\CoreBundle\ElementFactory\Site\DeezercomFactory;
14 15
 
15 16
 /**
16 17
  * 
@@ -152,8 +153,11 @@ class ElementManager
152 153
       case 'dailymotion.com':
153 154
         return new DailymotioncomFactory($this->element, $this->container);
154 155
       break;
156
+      case 'deezer.com':
157
+        return new DeezercomFactory($this->element, $this->container);
158
+      break;
155 159
       default:
156
-        throw new Exception("La Factory n'est pas prise en charge pour ce type.");
160
+        throw new \Exception("La Factory n'est pas prise en charge pour ce type.");
157 161
       break;
158 162
     }
159 163
     

+ 52 - 0
src/Muzich/CoreBundle/ElementFactory/Site/DeezercomFactory.php View File

@@ -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
+?>