@@ -471,10 +471,11 @@ |
||
471 | 471 | /** |
472 | 472 | * Stores a binary file and returns it's new relative file name |
473 | 473 | * |
474 | - * @param \Aimeos\MW\Media\Iface $media Media object |
|
475 | - * @param string $type Type of the image like "preview" or "files" |
|
476 | 474 | * @param string $filepath Path of the new file |
477 | 475 | * @param string Name of the file system to store the files at |
476 | + * @param string|null $content |
|
477 | + * @param string $fsname |
|
478 | + * @param string $oldpath |
|
478 | 479 | * @return string Relative path to the new file |
479 | 480 | * @throws \Aimeos\Controller\Common\Exception If an error occurs |
480 | 481 | */ |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $fs->rm( $path ); |
104 | 104 | } |
105 | 105 | } |
106 | - catch( \Exception $e ) { ; } // Can be a mime icon with relative path |
|
106 | + catch( \Exception $e ) {; } // Can be a mime icon with relative path |
|
107 | 107 | |
108 | 108 | $item->setPreview( '' ); |
109 | 109 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | default: $ext = ''; |
234 | 234 | } |
235 | 235 | |
236 | - $filename = md5( $filename . getmypid() . microtime( true ) ); |
|
236 | + $filename = md5( $filename.getmypid().microtime( true ) ); |
|
237 | 237 | |
238 | 238 | return "${type}/${filename[0]}/${filename[1]}/${filename}${ext}"; |
239 | 239 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | $ext = $config->get( 'controller/common/media/standard/mimeicon/extension', '.png' ); |
322 | 322 | |
323 | - return $mimedir . DIRECTORY_SEPARATOR . $mimetype . $ext; |
|
323 | + return $mimedir.DIRECTORY_SEPARATOR.$mimetype.$ext; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * @category User |
365 | 365 | */ |
366 | 366 | $default = array( 'image/jpeg', 'image/png', 'image/gif' ); |
367 | - $allowed = $config->get( 'controller/common/media/standard/' . $type . '/allowedtypes', $default ); |
|
367 | + $allowed = $config->get( 'controller/common/media/standard/'.$type.'/allowedtypes', $default ); |
|
368 | 368 | |
369 | 369 | if( in_array( $mimetype, $allowed ) === false ) |
370 | 370 | { |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @category Developer |
426 | 426 | * @category User |
427 | 427 | */ |
428 | - $maxwidth = $config->get( 'controller/common/media/standard/' . $type . '/maxwidth', null ); |
|
428 | + $maxwidth = $config->get( 'controller/common/media/standard/'.$type.'/maxwidth', null ); |
|
429 | 429 | |
430 | 430 | /** controller/common/media/standard/files/maxheight |
431 | 431 | * Maximum height of the uploaded images |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * @category Developer |
463 | 463 | * @category User |
464 | 464 | */ |
465 | - $maxheight = $config->get( 'controller/common/media/standard/' . $type . '/maxheight', null ); |
|
465 | + $maxheight = $config->get( 'controller/common/media/standard/'.$type.'/maxheight', null ); |
|
466 | 466 | |
467 | 467 | return $media->scale( $maxwidth, $maxheight ); |
468 | 468 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | public function testConstruct() |
15 | 15 | { |
16 | 16 | $ds = DIRECTORY_SEPARATOR; |
17 | - $content = file_get_contents( dirname( __DIR__ ) . $ds . '_testfiles' . $ds . 'application.txt' ); |
|
17 | + $content = file_get_contents( dirname( __DIR__ ).$ds.'_testfiles'.$ds.'application.txt' ); |
|
18 | 18 | |
19 | 19 | $media = new \Aimeos\MW\Media\Application\Standard( $content, 'application/octet-stream', array() ); |
20 | 20 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | public function testSave() |
26 | 26 | { |
27 | 27 | $ds = DIRECTORY_SEPARATOR; |
28 | - $content = file_get_contents( dirname( __DIR__ ) . $ds . '_testfiles' . $ds . 'application.txt' ); |
|
28 | + $content = file_get_contents( dirname( __DIR__ ).$ds.'_testfiles'.$ds.'application.txt' ); |
|
29 | 29 | |
30 | 30 | $media = new \Aimeos\MW\Media\Application\Standard( $content, 'application/octet-stream', array() ); |
31 | 31 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | public function testSaveFile() |
37 | 37 | { |
38 | 38 | $ds = DIRECTORY_SEPARATOR; |
39 | - $content = file_get_contents( dirname( __DIR__ ) . $ds . '_testfiles' . $ds . 'application.txt' ); |
|
40 | - $dest = dirname( dirname( dirname( __DIR__ ) ) ) . $ds . 'tmp' . $ds . 'application.txt'; |
|
39 | + $content = file_get_contents( dirname( __DIR__ ).$ds.'_testfiles'.$ds.'application.txt' ); |
|
40 | + $dest = dirname( dirname( dirname( __DIR__ ) ) ).$ds.'tmp'.$ds.'application.txt'; |
|
41 | 41 | |
42 | 42 | $media = new \Aimeos\MW\Media\Application\Standard( $content, 'application/octet-stream', array() ); |
43 | 43 | $media->save( $dest ); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | public function testGetImage() |
16 | 16 | { |
17 | 17 | $ds = DIRECTORY_SEPARATOR; |
18 | - $object = \Aimeos\MW\Media\Factory::get( __DIR__ . $ds .'_testfiles' . $ds . 'image.png' ); |
|
18 | + $object = \Aimeos\MW\Media\Factory::get( __DIR__.$ds.'_testfiles'.$ds.'image.png' ); |
|
19 | 19 | |
20 | 20 | $this->assertInstanceOf( '\\Aimeos\\MW\\Media\\Iface', $object ); |
21 | 21 | $this->assertInstanceOf( '\\Aimeos\\MW\\Media\\Image\\Iface', $object ); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | public function testGetImageAsResource() |
26 | 26 | { |
27 | 27 | $ds = DIRECTORY_SEPARATOR; |
28 | - $resource = fopen( __DIR__ . $ds .'_testfiles' . $ds . 'image.png', 'rw' ); |
|
28 | + $resource = fopen( __DIR__.$ds.'_testfiles'.$ds.'image.png', 'rw' ); |
|
29 | 29 | $object = \Aimeos\MW\Media\Factory::get( $resource ); |
30 | 30 | |
31 | 31 | $this->assertInstanceOf( '\\Aimeos\\MW\\Media\\Iface', $object ); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function testGetImageAsString() |
37 | 37 | { |
38 | 38 | $ds = DIRECTORY_SEPARATOR; |
39 | - $content = file_get_contents( __DIR__ . $ds .'_testfiles' . $ds . 'image.png' ); |
|
39 | + $content = file_get_contents( __DIR__.$ds.'_testfiles'.$ds.'image.png' ); |
|
40 | 40 | $object = \Aimeos\MW\Media\Factory::get( $content ); |
41 | 41 | |
42 | 42 | $this->assertInstanceOf( '\\Aimeos\\MW\\Media\\Iface', $object ); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | public function testGetBinary() |
49 | 49 | { |
50 | 50 | $ds = DIRECTORY_SEPARATOR; |
51 | - $object = \Aimeos\MW\Media\Factory::get( __DIR__ . $ds . '_testfiles' . $ds . 'application.txt' ); |
|
51 | + $object = \Aimeos\MW\Media\Factory::get( __DIR__.$ds.'_testfiles'.$ds.'application.txt' ); |
|
52 | 52 | |
53 | 53 | $this->assertInstanceOf( '\\Aimeos\\MW\\Media\\Iface', $object ); |
54 | 54 | $this->assertInstanceOf( '\\Aimeos\\MW\\Media\\Application\\Iface', $object ); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | $file = $this->getMockBuilder( '\Psr\Http\Message\UploadedFileInterface' )->getMock(); |
42 | 42 | $file->expects( $this->once() )->method( 'getStream' ) |
43 | - ->will( $this->returnValue( file_get_contents( __DIR__ . '/testfiles/test.gif' ) ) ); |
|
43 | + ->will( $this->returnValue( file_get_contents( __DIR__.'/testfiles/test.gif' ) ) ); |
|
44 | 44 | |
45 | 45 | $item = \Aimeos\MShop\Factory::createManager( $this->context, 'media' )->createItem(); |
46 | 46 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | $file = $this->getMockBuilder( '\Psr\Http\Message\UploadedFileInterface' )->getMock(); |
62 | 62 | $file->expects( $this->once() )->method( 'getStream' ) |
63 | - ->will( $this->returnValue( file_get_contents( __DIR__ . '/testfiles/test.pdf' ) ) ); |
|
63 | + ->will( $this->returnValue( file_get_contents( __DIR__.'/testfiles/test.pdf' ) ) ); |
|
64 | 64 | |
65 | 65 | $item = \Aimeos\MShop\Factory::createManager( $this->context, 'media' )->createItem(); |
66 | 66 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ->getMock(); |
109 | 109 | |
110 | 110 | $object->expects( $this->once() )->method( 'getFileContent' ) |
111 | - ->will( $this->returnValue( file_get_contents( __DIR__ . '/testfiles/test.png' ) ) ); |
|
111 | + ->will( $this->returnValue( file_get_contents( __DIR__.'/testfiles/test.png' ) ) ); |
|
112 | 112 | |
113 | 113 | $object->expects( $this->exactly( 2 ) )->method( 'storeFile' ); |
114 | 114 | |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | |
205 | 205 | public function testGetFileContent() |
206 | 206 | { |
207 | - $dest = dirname( dirname( dirname( __DIR__ ) ) ) . '/tmp/'; |
|
207 | + $dest = dirname( dirname( dirname( __DIR__ ) ) ).'/tmp/'; |
|
208 | 208 | if( !is_dir( $dest ) ) { mkdir( $dest, 0755, true ); } |
209 | - copy( __DIR__ . '/testfiles/test.gif', $dest . 'test.gif' ); |
|
209 | + copy( __DIR__.'/testfiles/test.gif', $dest.'test.gif' ); |
|
210 | 210 | |
211 | 211 | $result = $this->access( 'getFileContent' )->invokeArgs( $this->object, array( 'test.gif', 'fs-media' ) ); |
212 | 212 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | |
297 | 297 | public function testGetMimeType() |
298 | 298 | { |
299 | - $file = \Aimeos\MW\Media\Factory::get( __DIR__ . '/testfiles/test.png' ); |
|
299 | + $file = \Aimeos\MW\Media\Factory::get( __DIR__.'/testfiles/test.png' ); |
|
300 | 300 | |
301 | 301 | $result = $this->access( 'getMimeType' )->invokeArgs( $this->object, array( $file, 'files' ) ); |
302 | 302 | $this->assertEquals( 'image/png', $result ); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | public function testGetMimeTypeNotAllowed() |
307 | 307 | { |
308 | - $file = \Aimeos\MW\Media\Factory::get( __DIR__ . '/testfiles/test.gif' ); |
|
308 | + $file = \Aimeos\MW\Media\Factory::get( __DIR__.'/testfiles/test.gif' ); |
|
309 | 309 | $this->context->getConfig()->set( 'controller/common/media/standard/files/allowedtypes', array( 'image/jpeg' ) ); |
310 | 310 | |
311 | 311 | $result = $this->access( 'getMimeType' )->invokeArgs( $this->object, array( $file, 'files' ) ); |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | |
316 | 316 | public function testGetMimeTypeNoTypes() |
317 | 317 | { |
318 | - $file = \Aimeos\MW\Media\Factory::get( __DIR__ . '/testfiles/test.gif' ); |
|
318 | + $file = \Aimeos\MW\Media\Factory::get( __DIR__.'/testfiles/test.gif' ); |
|
319 | 319 | $this->context->getConfig()->set( 'controller/common/media/standard/files/allowedtypes', array() ); |
320 | 320 | |
321 | 321 | $this->setExpectedException( '\Aimeos\Controller\Common\Exception' ); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | public function testScaleImage() |
327 | 327 | { |
328 | - $file = \Aimeos\MW\Media\Factory::get( __DIR__ . '/testfiles/test.gif' ); |
|
328 | + $file = \Aimeos\MW\Media\Factory::get( __DIR__.'/testfiles/test.gif' ); |
|
329 | 329 | |
330 | 330 | $this->access( 'scaleImage' )->invokeArgs( $this->object, array( $file, 'files' ) ); |
331 | 331 | } |
@@ -333,18 +333,18 @@ discard block |
||
333 | 333 | |
334 | 334 | public function testStoreFile() |
335 | 335 | { |
336 | - $content = file_get_contents( __DIR__ . '/testfiles/test.gif' ); |
|
336 | + $content = file_get_contents( __DIR__.'/testfiles/test.gif' ); |
|
337 | 337 | |
338 | - $dest = dirname( dirname( dirname( __DIR__ ) ) ) . '/tmp/'; |
|
338 | + $dest = dirname( dirname( dirname( __DIR__ ) ) ).'/tmp/'; |
|
339 | 339 | if( !is_dir( $dest ) ) { mkdir( $dest, 0755, true ); } |
340 | - copy( __DIR__ . '/testfiles/test.gif', $dest . 'test2.gif' ); |
|
340 | + copy( __DIR__.'/testfiles/test.gif', $dest.'test2.gif' ); |
|
341 | 341 | |
342 | 342 | $this->access( 'storeFile' )->invokeArgs( $this->object, array( $content, 'fs-media', 'test.gif', 'test2.gif' ) ); |
343 | 343 | |
344 | - $this->assertFalse( file_exists( $dest . 'test2.gif' ) ); |
|
345 | - $this->assertTrue( file_exists( $dest . 'test.gif' ) ); |
|
344 | + $this->assertFalse( file_exists( $dest.'test2.gif' ) ); |
|
345 | + $this->assertTrue( file_exists( $dest.'test.gif' ) ); |
|
346 | 346 | |
347 | - unlink( $dest . 'test.gif' ); |
|
347 | + unlink( $dest.'test.gif' ); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 |