1- <?php namespace Samuell \ContentEditor \Http \Controllers ;
1+ <?php
2+
3+ namespace Samuell \ContentEditor \Http \Controllers ;
24
35use File ;
6+ use Lang ;
47use Input ;
58use Response ;
69use Exception ;
10+ use SystemException ;
711use ApplicationException ;
8- use Cms \Classes \MediaLibrary ;
12+ use Media \Classes \MediaLibrary ;
13+ use October \Rain \Resize \Resizer ;
914use Illuminate \Routing \Controller ;
10- use October \Rain \Database \Attach \Resizer ;
1115use Samuell \ContentEditor \Models \Settings ;
1216use October \Rain \Filesystem \Definitions as FileDefinitions ;
1317
1418/**
1519 * ImageController
16- *
20+ *
1721 * Handle content editor image upload
1822 */
1923class ImageController extends Controller
@@ -32,7 +36,7 @@ public function upload()
3236 * Convert uppcare case file extensions to lower case
3337 */
3438 $ extension = strtolower ($ uploadedFile ->getClientOriginalExtension ());
35- $ fileName = File::name ($ fileName ). '. ' . $ extension ;
39+ $ fileName = File::name ($ fileName ) . '. ' . $ extension ;
3640
3741 /*
3842 * File name contains non-latin characters, attempt to slug the value
@@ -54,29 +58,28 @@ public function upload()
5458 $ path = MediaLibrary::validatePath ($ path );
5559
5660 $ realPath = empty (trim ($ uploadedFile ->getRealPath ()))
57- ? $ uploadedFile ->getPath () . DIRECTORY_SEPARATOR . $ uploadedFile ->getFileName ()
58- : $ uploadedFile ->getRealPath ();
61+ ? $ uploadedFile ->getPath () . DIRECTORY_SEPARATOR . $ uploadedFile ->getFileName ()
62+ : $ uploadedFile ->getRealPath ();
5963
6064 MediaLibrary::instance ()->put (
61- $ path. '/ ' . $ fileName ,
65+ $ path . '/ ' . $ fileName ,
6266 File::get ($ realPath )
6367 );
6468
6569 list ($ width , $ height ) = getimagesize ($ uploadedFile );
6670
6771 return Response::json ([
68- 'url ' => MediaLibrary::instance ()->getPathUrl ($ path. '/ ' . $ fileName ),
69- 'filePath ' => $ path. '/ ' . $ fileName ,
72+ 'url ' => MediaLibrary::instance ()->getPathUrl ($ path . '/ ' . $ fileName ),
73+ 'filePath ' => $ path . '/ ' . $ fileName ,
7074 'filename ' => $ fileName ,
7175 'size ' => [
72- $ width ,
73- $ height
74- ]
76+ $ width ,
77+ $ height
78+ ]
7579 ]);
7680 } catch (Exception $ ex ) {
7781 throw new ApplicationException ($ ex );
7882 }
79-
8083 }
8184
8285 public function save ()
@@ -86,14 +89,14 @@ public function save()
8689 $ width = post ('width ' );
8790 $ height = post ('height ' );
8891 $ filePath = post ('filePath ' );
89- $ relativeFilePath = config ('cms.storage.media.path ' ). $ filePath ;
92+ $ relativeFilePath = config ('cms.storage.media.path ' , config ( ' system.storage.media.path ' )) . $ filePath ;
9093
9194 if ($ crop && $ crop != '0,0,1,1 ' ) {
9295 $ crop = explode (', ' , $ crop );
9396
9497 $ file = MediaLibrary::instance ()->get (post ('filePath ' ));
95- $ tempDirectory = temp_path (). '/contenteditor ' ;
96- $ tempFilePath = temp_path (). post ('filePath ' );
98+ $ tempDirectory = temp_path () . '/contenteditor ' ;
99+ $ tempFilePath = temp_path () . post ('filePath ' );
97100 File::makeDirectory ($ tempDirectory , 0777 , true , true );
98101
99102 if (!File::put ($ tempFilePath , $ file )) {
0 commit comments