Bläddra i källkod

test fixs remniement code factorys

Sevajol Bastien 12 år sedan
förälder
incheckning
3525f20b68

+ 1 - 1
src/Muzich/CoreBundle/Command/CheckModerateCommand.php Visa fil

@@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputInterface;
8 8
 use Symfony\Component\Console\Input\InputOption;
9 9
 use Symfony\Component\Console\Output\OutputInterface;
10 10
 
11
-use Muzich\CoreBundle\ElementFactory\ElementManager;
11
+use Muzich\CoreBundle\Managers\ElementManager;
12 12
 
13 13
 class CheckModerateCommand extends ContainerAwareCommand
14 14
 {

+ 1 - 1
src/Muzich/CoreBundle/Command/RefreshEmbedsCommand.php Visa fil

@@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputInterface;
8 8
 use Symfony\Component\Console\Input\InputOption;
9 9
 use Symfony\Component\Console\Output\OutputInterface;
10 10
 
11
-use Muzich\CoreBundle\ElementFactory\ElementManager;
11
+use Muzich\CoreBundle\Managers\ElementManager;
12 12
 
13 13
 class RefreshEmbedsCommand extends ContainerAwareCommand
14 14
 {

+ 1 - 1
src/Muzich/CoreBundle/Command/UpdateTagSlugsCommand.php Visa fil

@@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputInterface;
8 8
 use Symfony\Component\Console\Input\InputOption;
9 9
 use Symfony\Component\Console\Output\OutputInterface;
10 10
 
11
-use Muzich\CoreBundle\ElementFactory\ElementManager;
11
+use Muzich\CoreBundle\Managers\ElementManager;
12 12
 
13 13
 class UpdateTagSlugsCommand extends ContainerAwareCommand
14 14
 {

+ 1 - 1
src/Muzich/CoreBundle/Controller/CoreController.php Visa fil

@@ -8,7 +8,7 @@ use Muzich\CoreBundle\Entity\FollowUser;
8 8
 use Muzich\CoreBundle\Entity\FollowGroup;
9 9
 //use Doctrine\ORM\Query;
10 10
 use Muzich\CoreBundle\Form\Element\ElementAddForm;
11
-use Muzich\CoreBundle\ElementFactory\ElementManager;
11
+use Muzich\CoreBundle\Managers\ElementManager;
12 12
 use Muzich\CoreBundle\Entity\Element;
13 13
 use Symfony\Component\HttpFoundation\RedirectResponse;
14 14
 use Muzich\CoreBundle\Form\Search\ElementSearchForm;

+ 1 - 1
src/Muzich/CoreBundle/Controller/ElementController.php Visa fil

@@ -3,7 +3,7 @@
3 3
 namespace Muzich\CoreBundle\Controller;
4 4
 
5 5
 use Muzich\CoreBundle\lib\Controller;
6
-use Muzich\CoreBundle\ElementFactory\ElementManager;
6
+use Muzich\CoreBundle\Managers\ElementManager;
7 7
 use Muzich\CoreBundle\Propagator\EventElement;
8 8
 use Muzich\CoreBundle\Entity\ElementTagsProposition;
9 9
 

+ 1 - 1
src/Muzich/CoreBundle/Factory/Elements/Dailymotioncom.php Visa fil

@@ -31,7 +31,7 @@ class Dailymotioncom extends ElementFactory
31 31
     // Récupération de données auprés de l'API
32 32
     if ($ref_id)
33 33
     {
34
-      $api_url = curl_init('https://api.dailymotion.com/video/'.$chaines[2]
34
+      $api_url = curl_init('https://api.dailymotion.com/video/'.$ref_id
35 35
         .'&fields=thumbnail_medium_url');
36 36
       
37 37
       $options = array(

+ 1 - 1
src/Muzich/CoreBundle/Factory/Elements/Jamendocom.php Visa fil

@@ -96,7 +96,7 @@ class Jamendocom extends ElementFactory
96 96
     {
97 97
       $height = $this->container->getParameter('jamendo_player_height');
98 98
       $width = $this->container->getParameter('jamendo_player_width');
99
-      $embed_url = "http://widgets.jamendo.com/fr/$type/?album_id=$ref_id&playertype=2008";
99
+      $embed_url = "http://widgets.jamendo.com/fr/$type/?".$type."_id=$ref_id&playertype=2008";
100 100
       $this->element->setEmbed(
101 101
         '<object width="'.$width.'" height="'.$height.'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
102 102
             .' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" align="middle">

+ 5 - 4
src/Muzich/CoreBundle/Factory/Elements/Soundcloudcom.php Visa fil

@@ -9,7 +9,7 @@ use Muzich\CoreBundle\Factory\ElementFactory;
9 9
  *
10 10
  * @author bux
11 11
  */
12
-class SoundcloudcomFactory extends ElementFactory
12
+class Soundcloudcom extends ElementFactory
13 13
 {
14 14
   
15 15
   /**
@@ -24,12 +24,12 @@ class SoundcloudcomFactory extends ElementFactory
24 24
     // ??SET
25 25
     if (preg_match("#^\/[a-zA-Z0-9_-]+\/sets\/[a-zA-Z0-9_-]+#", $url_clean, $chaines))
26 26
     {
27
-      $ref_id = $url;
27
+      $ref_id = $url_clean;
28 28
     }
29 29
     // ???
30 30
     else if (preg_match("#^\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+#", $url_clean, $chaines))
31 31
     {
32
-      $ref_id = $url;
32
+      $ref_id = $url_clean;
33 33
     }
34 34
     
35 35
     // On en gère pas encore les recherches
@@ -43,7 +43,7 @@ class SoundcloudcomFactory extends ElementFactory
43 43
     // récupération de données avec l'API
44 44
     if ($ref_id)
45 45
     {
46
-      $ch = curl_init('http://api.soundcloud.com/resolve.json?url='.$url_object.'&client_id=39946ea18e3d78d64c0ac95a025794e1');
46
+      $ch = curl_init('http://api.soundcloud.com/resolve.json?url='.$ref_id.'&client_id=39946ea18e3d78d64c0ac95a025794e1');
47 47
 
48 48
       $options = array(
49 49
         CURLOPT_RETURNTRANSFER => true,
@@ -77,6 +77,7 @@ class SoundcloudcomFactory extends ElementFactory
77 77
   {
78 78
     if (($ref_id = $this->element->getData('ref_id')))
79 79
     {
80
+      $ref_id = 'http://soundcloud.com'.$ref_id;
80 81
       $embed_id = md5($ref_id);
81 82
       $height = $this->container->getParameter('soundcloud_player_height');
82 83
       $this->element->setEmbed(

+ 1 - 1
src/Muzich/CoreBundle/Factory/Elements/Youtube.php Visa fil

@@ -19,7 +19,7 @@ class Youtube extends Youtubecom
19 19
     
20 20
     if (preg_match("#\/([a-zA-Z0-9]+)#", $url_clean, $chaines))
21 21
     {
22
-      $ref_id = $chaines[2];
22
+      $ref_id = $chaines[1];
23 23
     }
24 24
     
25 25
     $this->element->setData('ref_id', $ref_id);

+ 12 - 12
src/Muzich/CoreBundle/Managers/ElementManager.php Visa fil

@@ -7,12 +7,12 @@ use Muzich\CoreBundle\Entity\User;
7 7
 use Doctrine\ORM\EntityManager;
8 8
 use Symfony\Component\DependencyInjection\Container;
9 9
 
10
-use Muzich\CoreBundle\Factory\Elements\YoutubecomFactory;
11
-use Muzich\CoreBundle\Factory\Elements\YoutubeFactory;
12
-use Muzich\CoreBundle\Factory\Elements\DailymotioncomFactory;
13
-use Muzich\CoreBundle\Factory\Elements\JamendocomFactory;
14
-use Muzich\CoreBundle\Factory\Elements\SoundcloudcomFactory;
15
-use Muzich\CoreBundle\Factory\Elements\DeezercomFactory;
10
+use Muzich\CoreBundle\Factory\Elements\Youtubecom;
11
+use Muzich\CoreBundle\Factory\Elements\Youtube;
12
+use Muzich\CoreBundle\Factory\Elements\Dailymotioncom;
13
+use Muzich\CoreBundle\Factory\Elements\Jamendocom;
14
+use Muzich\CoreBundle\Factory\Elements\Soundcloudcom;
15
+use Muzich\CoreBundle\Factory\Elements\Deezercom;
16 16
 
17 17
 /**
18 18
  * 
@@ -147,22 +147,22 @@ class ElementManager
147 147
     switch ($this->element->getType())
148 148
     {
149 149
       case 'youtube.com':
150
-        return new YoutubecomFactory($this->element, $this->container);
150
+        return new Youtubecom($this->element, $this->container);
151 151
       break;
152 152
       case 'youtu.be':
153
-        return new YoutubeFactory($this->element, $this->container);
153
+        return new Youtube($this->element, $this->container);
154 154
       break;
155 155
       case 'soundcloud.com':
156
-        return new SoundcloudcomFactory($this->element, $this->container);
156
+        return new Soundcloudcom($this->element, $this->container);
157 157
       break;
158 158
       case 'jamendo.com':
159
-        return new JamendocomFactory($this->element, $this->container);
159
+        return new Jamendocom($this->element, $this->container);
160 160
       break;
161 161
       case 'dailymotion.com':
162
-        return new DailymotioncomFactory($this->element, $this->container);
162
+        return new Dailymotioncom($this->element, $this->container);
163 163
       break;
164 164
       case 'deezer.com':
165
-        return new DeezercomFactory($this->element, $this->container);
165
+        return new Deezercom($this->element, $this->container);
166 166
       break;
167 167
       default:
168 168
         throw new \Exception("La Factory n'est pas prise en charge pour ce type.");

+ 39 - 26
src/Muzich/CoreBundle/Tests/ElementFactory/ElementFactoryTest.php Visa fil

@@ -4,7 +4,7 @@ namespace Muzich\CoreBundle\Tests\Searcher;
4 4
 
5 5
 use Muzich\CoreBundle\lib\UnitTest;
6 6
 use Muzich\CoreBundle\Entity\Element;
7
-use Muzich\CoreBundle\ElementFactory\ElementManager;
7
+use Muzich\CoreBundle\Managers\ElementManager;
8 8
 use Doctrine\Common\Collections\ArrayCollection;
9 9
 
10 10
 class ElementFactoryTest extends UnitTest
@@ -122,32 +122,43 @@ class ElementFactoryTest extends UnitTest
122 122
     /*
123 123
      * - soundcloud.com
124 124
      */
125
-    $id = md5('http://soundcloud.com/matas/sets/library-project');
125
+    $url_id = 'http://soundcloud.com/matas/sets/library-project';
126
+    $embed_id = md5($url_id);
126 127
     $this->proceed_elementAndFill(
127 128
       $bux, 
128 129
       'faez7tf8re9h4gf5j64dssz', 
129 130
       'http://soundcloud.com/matas/sets/library-project', 
130 131
       array($hardtek->getId(), $tribe->getId()), 
131
-      '<object height="'.$this->getParam('soundcloud_player_height').'" width="100%" id="embed_'.$id.'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
132
-          <param name="movie" value="http://player.soundcloud.com/player.swf?url=http://soundcloud.com/matas/sets/library-project&amp;enable_api=true&amp;object_id=embed_'.$id.'"></param>
132
+      '<object height="'.$this->getParam('soundcloud_player_height').'" width="100%" id="embed_'.$embed_id.'" '
133
+          .'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
134
+          <param name="movie" value="http://player.soundcloud.com/player.swf?url='.$url_id.'&amp;'
135
+          .'enable_api=true&amp;object_id=embed_'.$embed_id.'"></param>
133 136
           <param name="allowscriptaccess" value="always"></param>
134
-          <embed allowscriptaccess="always" height="'.$this->getParam('soundcloud_player_height').'" src="http://player.soundcloud.com/player.swf?url=http://soundcloud.com/matas/sets/library-project&amp;enable_api=true&amp;object_id=embed_'.$id.'" type="application/x-shockwave-flash" width="100%" name="embed_'.$id.'"></embed>
135
-        </object>
136
-        '
137
+          <embed allowscriptaccess="always" height="'.$this->getParam('soundcloud_player_height').'" '
138
+          .'src="http://player.soundcloud.com/player.swf?url='.$url_id.'&amp;enable_api=true'
139
+          .'&amp;object_id=embed_'.$embed_id.'" type="application/x-shockwave-flash" '
140
+          .'width="100%" name="embed_'.$embed_id.'"></embed>
141
+        </object>'
137 142
     );
138 143
     
139
-    $id = md5('http://soundcloud.com/matas/above-hyperion-redux');
144
+    $url_id = 'http://soundcloud.com/matas/above-hyperion-redux';
145
+    $embed_id = md5($url_id);
140 146
     $this->proceed_elementAndFill(
141 147
       $bux, 
142 148
       'faez7tf8re9h4gf5j64dssz', 
143 149
       'http://soundcloud.com/matas/above-hyperion-redux', 
144 150
       array($hardtek->getId(), $tribe->getId()), 
145
-      '<object height="'.$this->getParam('soundcloud_player_height').'" width="100%" id="embed_'.$id.'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
146
-          <param name="movie" value="http://player.soundcloud.com/player.swf?url=http://soundcloud.com/matas/above-hyperion-redux&amp;enable_api=true&amp;object_id=embed_'.$id.'"></param>
151
+      
152
+        '<object height="'.$this->getParam('soundcloud_player_height').'" width="100%" id="embed_'.$embed_id.'" '
153
+          .'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
154
+          <param name="movie" value="http://player.soundcloud.com/player.swf?url='.$url_id.'&amp;'
155
+          .'enable_api=true&amp;object_id=embed_'.$embed_id.'"></param>
147 156
           <param name="allowscriptaccess" value="always"></param>
148
-          <embed allowscriptaccess="always" height="'.$this->getParam('soundcloud_player_height').'" src="http://player.soundcloud.com/player.swf?url=http://soundcloud.com/matas/above-hyperion-redux&amp;enable_api=true&amp;object_id=embed_'.$id.'" type="application/x-shockwave-flash" width="100%" name="embed_'.$id.'"></embed>
149
-        </object>
150
-        '
157
+          <embed allowscriptaccess="always" height="'.$this->getParam('soundcloud_player_height').'" '
158
+          .'src="http://player.soundcloud.com/player.swf?url='.$url_id.'&amp;enable_api=true'
159
+          .'&amp;object_id=embed_'.$embed_id.'" type="application/x-shockwave-flash" '
160
+          .'width="100%" name="embed_'.$embed_id.'"></embed>
161
+        </object>'
151 162
     );
152 163
     
153 164
     $this->proceed_elementAndFill(
@@ -183,20 +194,21 @@ class ElementFactoryTest extends UnitTest
183 194
       'gthyk456+liszz', 
184 195
       'http://www.jamendo.com/fr/album/30661', 
185 196
       array($hardtek->getId(), $tribe->getId()), 
186
-      '
187
-          <object width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_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">
197
+      
198
+        '<object width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
199
+            .' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" align="middle">
188 200
             <param name="allowScriptAccess" value="always" />
189 201
             <param name="wmode" value="transparent" />
190 202
             <param name="movie" value="http://widgets.jamendo.com/fr/album/?album_id=30661&playertype=2008" />
191 203
             <param name="quality" value="high" />
192 204
             <param name="bgcolor" value="#FFFFFF" />
193
-            <embed src="http://widgets.jamendo.com/fr/album/?album_id=30661&playertype=2008" quality="high" wmode="transparent" bgcolor="#FFFFFF" width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
205
+            <embed src="http://widgets.jamendo.com/fr/album/?album_id=30661&playertype=2008" quality="high" wmode="transparent" bgcolor="#FFFFFF"'
206
+            .' width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" align="middle" allowScriptAccess="always"'
207
+            .' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
194 208
               &nbsp;
195 209
             </embed>
196 210
             &nbsp;
197
-          </object>
198
-          <a href="http://pro.jamendo.com/" style="display:block;font-size:8px !important;">Catalogue professionnel de musique libre</a>
199
-        '
211
+          </object>' 
200 212
     );
201 213
     
202 214
     $this->proceed_elementAndFill(
@@ -204,20 +216,21 @@ class ElementFactoryTest extends UnitTest
204 216
       'gthyk456+liszz', 
205 217
       'http://www.jamendo.com/fr/track/207079', 
206 218
       array($hardtek->getId(), $tribe->getId()), 
207
-      '
208
-          <object width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_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">
219
+      
220
+      '<object width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
221
+      .' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" align="middle">
209 222
             <param name="allowScriptAccess" value="always" />
210 223
             <param name="wmode" value="transparent" />
211
-            <param name="movie" value="http://widgets.jamendo.com/fr/track/?playertype=2008&track_id=207079" />
224
+            <param name="movie" value="http://widgets.jamendo.com/fr/track/?track_id=207079&playertype=2008" />
212 225
             <param name="quality" value="high" />
213 226
             <param name="bgcolor" value="#FFFFFF" />
214
-            <embed src="http://widgets.jamendo.com/fr/track/?playertype=2008&track_id=207079" quality="high" wmode="transparent" bgcolor="#FFFFFF" width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
227
+            <embed src="http://widgets.jamendo.com/fr/track/?track_id=207079&playertype=2008" quality="high" wmode="transparent" bgcolor="#FFFFFF"'
228
+      .' width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" align="middle" allowScriptAccess="always"'
229
+      .' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
215 230
               &nbsp;
216 231
             </embed>
217 232
             &nbsp;
218
-          </object>
219
-          <a href="http://pro.jamendo.com/" style="display:block;font-size:8px !important;">Catalogue professionnel de musique libre</a>
220
-        '
233
+          </object>' 
221 234
     );
222 235
     
223 236
     $this->proceed_elementAndFill(

+ 1 - 1
src/Muzich/CoreBundle/lib/UnitTest.php Visa fil

@@ -4,7 +4,7 @@ namespace Muzich\CoreBundle\lib;
4 4
 
5 5
 require_once(__DIR__ . "/../../../../app/AppKernel.php");
6 6
 use Muzich\CoreBundle\Entity\Element;
7
-use Muzich\CoreBundle\ElementFactory\ElementManager;
7
+use Muzich\CoreBundle\Managers\ElementManager;
8 8
 
9 9
 class UnitTest extends \PHPUnit_Framework_TestCase
10 10
 {