63 $this->GalleryAccess =
get_package(
'gallery::gallery_access' ,
'last' , __FILE__ );
64 $this->GalleryAlgorithms =
get_package(
'gallery::gallery_algorithms' ,
'last' , __FILE__ );
65 $this->Link =
get_package(
'link' ,
'last' , __FILE__ );
66 $this->String =
get_package(
'string' ,
'last' , __FILE__ );
100 private function create_dependent_gallery( $MasterType , $MasterId )
105 'title' =>
"gallery for $MasterType|id=$MasterId" ,
106 'description' =>
"description for $MasterType|id=$MasterId"
109 $id = $this->GalleryAccess->create( $Gallery );
111 $this->Link->create_link( $MasterId , $id , $MasterType ,
'gallery' );
115 catch( Exception $e )
147 $MasterType = $BlockSettings->get_setting(
'master_type' );
148 $MasterId = $BlockSettings->get_setting(
'master_id' );
150 if( $this->Link->link_exists( $MasterId ,
false , $MasterType ,
'gallery' ) )
152 $Link = $this->Link->get_links( $MasterId ,
false , $MasterType ,
'gallery' );
158 return( $this->create_dependent_gallery( $MasterType , $MasterId ) );
161 catch( Exception $e )
193 if( $BlockSettings->get_setting(
'master_id' ,
false ) === false )
195 $id = $BlockSettings->get_setting(
'id' );
202 return( $this->GalleryAlgorithms->get_by_id( $id ) );
204 catch( Exception $e )
240 $GalleryTemplate = $this->CachedMultyFS->file_get_contents( $FilePath );
241 $GalleryTemplate = str_replace(
'{gallery_id}' , $GalleryId , $GalleryTemplate );
242 $GalleryTemplate = str_replace(
'{id}' ,
'[id]' , $GalleryTemplate );
243 $GalleryTemplate = str_replace(
'{file_path}' ,
'[file_path]' , $GalleryTemplate );
244 $GalleryTemplate = str_replace(
'{original_file_name}' ,
'[original_file_name]' , $GalleryTemplate );
245 $GalleryTemplate = str_replace(
'{' ,
'[lfb]' , $GalleryTemplate );
246 $GalleryTemplate = str_replace(
'}' ,
'[rfb]' , $GalleryTemplate );
248 return( $GalleryTemplate );
250 catch( Exception $e )
282 private function compile_gallery_parts( $Gallery , $Files )
287 $FilePath = dirname( __FILE__ ).
'/res/templates/simple_file_list.tpl';
289 foreach( $Files as $i => $File )
291 $Code .= $this->CachedMultyFS->file_get_contents( $FilePath );
292 $Code = $this->String->print_record( $Code , $File );
294 $Code = str_replace(
'{gallery_id}' , $id , $Code );
296 $Input =
"{file_input:file_types=images;upload_url=gallery_upload.html?gallery_id[eq]{gallery_id};";
297 $Input .=
"upload_success_handler=ultimix_file_input_view_after_image_upload_processor}";
298 return( array( $Code , str_replace(
'{gallery_id}' , $id , $Input ) ) );
300 catch( Exception $e )
332 private function compile_gallery_files( $Gallery , $Files )
336 list( $Code , $Input ) = $this->compile_gallery_parts( $Gallery , $Files );
340 $Gallery = $this->CachedMultyFS->get_teplate( __FILE__ ,
'gallery.tpl' );
341 $PlaceHolders = array(
'{code}' ,
'{gallery_template}' ,
'{input}' );
342 $Gallery = str_replace( $PlaceHolders , array( $Code , $Template , $Input ) , $Gallery );
343 $Gallery = str_replace(
'{gallery_id}' , $GalleryId , $Gallery );
347 catch( Exception $e )
381 $Files = $this->GalleryAlgorithms->get_gallery_files(
get_field( $Gallery ,
'id' ) );
383 $Code = $this->compile_gallery_files( $Gallery , $Files );
387 catch( Exception $e )