@@ -54,7 +54,7 @@ public function copy($targetid) {
54
54
unset($ newitemrecord ->id );
55
55
$ newitemrecord ->galleryid = $ targetid ;
56
56
57
- $ newitem = item ::create ($ newitemrecord );
57
+ $ newitem = self ::create ($ newitemrecord );
58
58
59
59
$ fs = get_file_storage ();
60
60
if ($ file = $ this ->get_file ()) { // Item.
@@ -98,7 +98,7 @@ public static function create(\stdClass $data) {
98
98
return $ result ;
99
99
}
100
100
101
- public static function create_from_archive (gallery $ gallery , \stored_file $ stored_file , $ formdata = array ()) {
101
+ public static function create_from_archive (gallery $ gallery , \stored_file $ storedfile , $ formdata = array ()) {
102
102
global $ DB ;
103
103
$ context = $ gallery ->get_collection ()->context ;
104
104
@@ -111,18 +111,18 @@ public static function create_from_archive(gallery $gallery, \stored_file $store
111
111
$ fs = get_file_storage ();
112
112
$ packer = get_file_packer ('application/zip ' );
113
113
$ fs ->delete_area_files ($ context ->id , 'mod_mediagallery ' , 'unpacktemp ' , 0 );
114
- $ stored_file ->extract_to_storage ($ packer , $ context ->id , 'mod_mediagallery ' , 'unpacktemp ' , 0 , '/ ' );
114
+ $ storedfile ->extract_to_storage ($ packer , $ context ->id , 'mod_mediagallery ' , 'unpacktemp ' , 0 , '/ ' );
115
115
$ itemfiles = $ fs ->get_area_files ($ context ->id , 'mod_mediagallery ' , 'unpacktemp ' , 0 );
116
- $ stored_file ->delete ();
116
+ $ storedfile ->delete ();
117
117
118
- foreach ($ itemfiles as $ stored_file ) {
119
- if ($ stored_file ->get_filesize () == 0 || preg_match ('#^/.DS_Store|__MACOSX/# ' , $ stored_file ->get_filepath ())) {
118
+ foreach ($ itemfiles as $ storedfile ) {
119
+ if ($ storedfile ->get_filesize () == 0 || preg_match ('#^/.DS_Store|__MACOSX/# ' , $ storedfile ->get_filepath ())) {
120
120
continue ;
121
121
}
122
122
if ($ maxitems != 0 && $ count >= $ maxitems ) {
123
123
break ;
124
124
}
125
- $ filename = $ stored_file ->get_filename ();
125
+ $ filename = $ storedfile ->get_filename ();
126
126
127
127
// Create an item.
128
128
$ data = new \stdClass ();
@@ -159,7 +159,7 @@ public static function create_from_archive(gallery $gallery, \stored_file $store
159
159
'filename ' => $ filename
160
160
);
161
161
if (!$ fs ->get_file ($ context ->id , 'mod_mediagallery ' , 'item ' , $ item ->id , '/ ' , $ filename )) {
162
- $ stored_file = $ fs ->create_file_from_storedfile ($ fileinfo , $ stored_file );
162
+ $ storedfile = $ fs ->create_file_from_storedfile ($ fileinfo , $ storedfile );
163
163
}
164
164
$ item ->generate_image_by_type ('lowres ' );
165
165
$ item ->generate_image_by_type ('thumbnail ' );
@@ -212,7 +212,7 @@ public static function delete_all_by_gallery($galleryid) {
212
212
return true ;
213
213
}
214
214
215
- public function generate_thumbnail (\stored_file $ stored_file = null ) {
215
+ public function generate_thumbnail (\stored_file $ storedfile = null ) {
216
216
return $ this ->generate_image_by_type ('thumbnail ' );
217
217
}
218
218
@@ -260,7 +260,8 @@ public function generate_image_by_type($type = 'thumbnail', $force = false, \sto
260
260
return $ fs ->create_file_from_string ($ fileinfo , $ newfiledata );
261
261
}
262
262
263
- private function get_image_resized (\stored_file $ file = null , $ height = 250 , $ width = 250 , $ offsetx = 0 , $ offsety = 0 , $ crop = true ) {
263
+ private function get_image_resized (\stored_file $ file = null , $ height = 250 , $ width = 250 , $ offsetx = 0 , $ offsety = 0 ,
264
+ $ crop = true ) {
264
265
global $ CFG ;
265
266
266
267
if (is_null ($ file ) && !$ file = $ this ->get_file_by_type ('item ' )) {
@@ -377,8 +378,14 @@ private function get_file_by_type($type = 'item') {
377
378
378
379
public function get_metainfo () {
379
380
$ info = clone $ this ->record ;
380
- $ info ->timecreatedformatted = $ info ->timecreated > 0 ? userdate ($ info ->timecreated , get_string ('strftimedaydatetime ' , 'langconfig ' )) : '' ;
381
- $ info ->productiondateformatted = $ info ->productiondate > 0 ? userdate ($ info ->productiondate , get_string ('strftimedaydate ' , 'langconfig ' )) : '' ;
381
+ $ info ->timecreatedformatted = '' ;
382
+ $ info ->productiondateformatted = '' ;
383
+ if ($ info ->timecreated > 0 ) {
384
+ $ info ->timecreatedformatted = userdate ($ info ->timecreated , get_string ('strftimedaydatetime ' , 'langconfig ' ));
385
+ }
386
+ if ($ info ->productiondate > 0 ) {
387
+ $ info ->productiondateformatted = userdate ($ info ->productiondate , get_string ('strftimedaydate ' , 'langconfig ' ));
388
+ }
382
389
return $ info ;
383
390
}
384
391
@@ -400,8 +407,14 @@ public function get_structured_metainfo() {
400
407
$ info ->fields = array ();
401
408
402
409
$ data = clone $ this ->record ;
403
- $ data ->timecreatedformatted = $ data ->timecreated > 0 ? userdate ($ data ->timecreated , get_string ('strftimedaydatetime ' , 'langconfig ' )) : '' ;
404
- $ data ->productiondateformatted = $ data ->productiondate > 0 ? userdate ($ data ->productiondate , get_string ('strftimedaydate ' , 'langconfig ' )) : '' ;
410
+ $ data ->timecreatedformatted = '' ;
411
+ $ data ->productiondateformatted = '' ;
412
+ if ($ data ->timecreated > 0 ) {
413
+ $ data ->timecreatedformatted = userdate ($ data ->timecreated , get_string ('strftimedaydatetime ' , 'langconfig ' ));
414
+ }
415
+ if ($ data ->productiondate > 0 ) {
416
+ $ data ->productiondateformatted = userdate ($ data ->productiondate , get_string ('strftimedaydate ' , 'langconfig ' ));
417
+ }
405
418
$ data ->moralrightsformatted = $ data ->moralrights ? get_string ('yes ' ) : get_string ('no ' );
406
419
foreach ($ displayfields as $ key => $ displayname ) {
407
420
$ info ->fields [] = array (
@@ -559,7 +572,7 @@ public function get_socialinfo() {
559
572
$ info ->client_id = isset ($ matches [1 ]) ? $ matches [1 ] : null ;
560
573
}
561
574
562
- //Creator name.
575
+ // Creator name.
563
576
$ info ->extradetails = '' ;
564
577
565
578
return $ info ;
0 commit comments