Browse Source

Evolution #52: Embeds: En ajouter: jamendo

bastien 13 years ago
parent
commit
023ca6ae2d
1 changed files with 41 additions and 1 deletions
  1. 41 1
      src/Muzich/CoreBundle/ElementFactory/Site/JamendoFactory.php

+ 41 - 1
src/Muzich/CoreBundle/ElementFactory/Site/JamendoFactory.php View File

@@ -11,7 +11,47 @@ use Muzich\CoreBundle\ElementFactory\Site\base\BaseFactory;
11 11
  */
12 12
 class JamendoFactory extends BaseFactory
13 13
 {
14
-  
14
+  public function getEmbedCode()
15
+  {
16
+    $url = str_replace('www.', '', $this->element->getUrl());
17
+    $data = str_replace('http://jamendo.com', '', $url);
18
+    
19
+    $embed_url = null;
20
+    // http://www.jamendo.com/fr/album/30661
21
+    if (preg_match("#^\/[a-zA-Z0-9_-]+\/album\/([0-9]+)#", $data, $chaines))
22
+    {
23
+      $id_album = $chaines[1];
24
+      $embed_url = "http://widgets.jamendo.com/fr/album/?album_id=$id_album&playertype=2008";
25
+    }
26
+    // http://www.jamendo.com/fr/track/207079
27
+    else if (preg_match("#^\/[a-zA-Z0-9_-]+\/track\/([0-9]+)#", $data, $chaines))
28
+    {
29
+      $id_track = $chaines[1];
30
+      $embed_url = "http://widgets.jamendo.com/fr/track/?playertype=2008&track_id=$id_track";
31
+    }
32
+    
33
+    if ($embed_url)
34
+    {
35
+      $height = $this->container->getParameter('jamendo_player_height');
36
+      $width = $this->container->getParameter('jamendo_player_width');
37
+      return  '
38
+          <object width="'.$width.'" height="'.$height.'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" align="middle">
39
+            <param name="allowScriptAccess" value="always" />
40
+            <param name="wmode" value="transparent" />
41
+            <param name="movie" value="'.$embed_url.'" />
42
+            <param name="quality" value="high" />
43
+            <param name="bgcolor" value="#FFFFFF" />
44
+            <embed src="'.$embed_url.'" quality="high" wmode="transparent" bgcolor="#FFFFFF" width="'.$width.'" height="'.$height.'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
45
+              &nbsp;
46
+            </embed>
47
+            &nbsp;
48
+          </object>
49
+          <a href="http://pro.jamendo.com/" style="display:block;font-size:8px !important;">Catalogue professionnel de musique libre</a>
50
+        ';
51
+    }
52
+    
53
+    return null;
54
+  }
15 55
 }
16 56
 
17 57
 ?>