@@ -112,8 +112,18 @@ public function getBlock(Tree $tree, int $block_id, string $context, array $conf
112112 $ title = $ module ->chartTitle ($ individual );
113113 $ chart_url = $ module ->chartUrl ($ individual , [
114114 'ajax ' => true ,
115- 'generations ' => 3 ,
116- 'layout ' => PedigreeChartModule::STYLE_RIGHT ,
115+ 'generations ' => $ this ->getBlockSetting ($ block_id , 'pedigree_generations ' , '3 ' ),
116+ 'layout ' => $ this ->getBlockSetting (
117+ $ block_id ,
118+ 'pedigree_style ' ,
119+ PedigreeChartModule::DEFAULT_STYLE
120+ ),
121+ 'style ' => $ this ->getBlockSetting (
122+ $ block_id ,
123+ 'pedigree_style ' ,
124+ PedigreeChartModule::DEFAULT_STYLE
125+ ),
126+ // Note: some modules use 'layout', others 'style'
117127 ]);
118128 $ content = view ('modules/charts/chart ' , [
119129 'block_id ' => $ block_id ,
@@ -132,7 +142,7 @@ public function getBlock(Tree $tree, int $block_id, string $context, array $conf
132142 $ title = $ module ->chartTitle ($ individual );
133143 $ chart_url = $ module ->chartUrl ($ individual , [
134144 'ajax ' => true ,
135- 'generations ' => 2 ,
145+ 'generations ' => $ this -> getBlockSetting ( $ block_id , ' descendants_generations ' , ' 2 ' ) ,
136146 'chart_style ' => DescendancyChartModule::CHART_STYLE_TREE ,
137147 ]);
138148 $ content = view ('modules/charts/chart ' , [
@@ -153,7 +163,7 @@ public function getBlock(Tree $tree, int $block_id, string $context, array $conf
153163 $ title = $ module ->chartTitle ($ individual );
154164 $ chart_url = $ module ->chartUrl ($ individual , [
155165 'ajax ' => true ,
156- 'generations ' => 2 ,
166+ 'generations ' => $ this -> getBlockSetting ( $ block_id , ' hourglass_generations ' , ' 2 ' ) ,
157167 ]);
158168 $ content = view ('modules/charts/chart ' , [
159169 'block_id ' => $ block_id ,
@@ -231,9 +241,17 @@ public function saveBlockConfiguration(ServerRequestInterface $request, int $blo
231241 {
232242 $ type = Validator::parsedBody ($ request )->string ('type ' );
233243 $ xref = Validator::parsedBody ($ request )->isXref ()->string ('xref ' );
244+ $ pedigree_generations = Validator::parsedBody ($ request )->integer ('pedigree_generations ' );
245+ $ pedigree_style = Validator::parsedBody ($ request )->string ('pedigree_style ' );
246+ $ descendants_generations = Validator::parsedBody ($ request )->integer ('descendants_generations ' );
247+ $ hourglass_generations = Validator::parsedBody ($ request )->integer ('hourglass_generations ' );
234248
235249 $ this ->setBlockSetting ($ block_id , 'type ' , $ type );
236250 $ this ->setBlockSetting ($ block_id , 'pid ' , $ xref );
251+ $ this ->setBlockSetting ($ block_id , 'pedigree_generations ' , (string ) $ pedigree_generations );
252+ $ this ->setBlockSetting ($ block_id , 'pedigree_style ' , $ pedigree_style );
253+ $ this ->setBlockSetting ($ block_id , 'descendants_generations ' , (string ) $ descendants_generations );
254+ $ this ->setBlockSetting ($ block_id , 'hourglass_generations ' , (string ) $ hourglass_generations );
237255 }
238256
239257 /**
@@ -253,21 +271,56 @@ public function editBlockConfiguration(Tree $tree, int $block_id): string
253271 $ type = $ this ->getBlockSetting ($ block_id , 'type ' , 'pedigree ' );
254272 $ xref = $ this ->getBlockSetting ($ block_id , 'pid ' , $ default_xref );
255273
256- $ charts = [
257- 'pedigree ' => I18N ::translate ('Pedigree ' ),
258- 'descendants ' => I18N ::translate ('Descendants ' ),
259- 'hourglass ' => I18N ::translate ('Hourglass chart ' ),
260- 'treenav ' => I18N ::translate ('Interactive tree ' ),
261- ];
274+ $ charts = [];
275+ // Only add charts that are available
276+ $ pedigreeModule = $ this ->module_service ->findByInterface (PedigreeChartModule::class)->first ();
277+ if ($ pedigreeModule instanceof PedigreeChartModule) {
278+ $ charts ['pedigree ' ] = I18N ::translate ('Pedigree ' );
279+ $ pedigree_max_generations = $ pedigreeModule ::MAXIMUM_GENERATIONS ;
280+ $ pedigree_min_generations = $ pedigreeModule ::MINIMUM_GENERATIONS ;
281+ $ pedigree_styles = $ pedigreeModule ->styles (I18N ::direction ());
282+ }
283+ $ descendantsModule = $ this ->module_service ->findByInterface (DescendancyChartModule::class)->first ();
284+ if ($ descendantsModule instanceof DescendancyChartModule) {
285+ $ charts ['descendants ' ] = I18N ::translate ('Descendants ' );
286+ $ descendants_max_generations = $ descendantsModule ::MAXIMUM_GENERATIONS ;
287+ $ descendants_min_generations = $ descendantsModule ::MINIMUM_GENERATIONS ;
288+ }
289+ $ hourglassModule = $ this ->module_service ->findByInterface (HourglassChartModule::class)->first ();
290+ if ($ hourglassModule instanceof HourglassChartModule) {
291+ $ charts ['hourglass ' ] = I18N ::translate ('Hourglass chart ' );
292+ $ hourglass_max_generations = $ hourglassModule ::MAXIMUM_GENERATIONS ;
293+ $ hourglass_min_generations = $ hourglassModule ::MINIMUM_GENERATIONS ;
294+ }
295+ $ treeModule = $ this ->module_service ->findByInterface (InteractiveTreeModule::class)->first ();
296+ if ($ treeModule instanceof InteractiveTreeModule) {
297+ $ charts ['treenav ' ] = I18N ::translate ('Interactive tree ' );
298+ }
262299 uasort ($ charts , I18N ::comparator ());
263300
301+ $ pedigree_generations = $ this ->getBlockSetting ($ block_id , 'pedigree_generations ' , '3 ' );
302+ $ pedigree_style = $ this ->getBlockSetting ($ block_id , 'pedigree_style ' , $ pedigreeModule ::DEFAULT_STYLE );
303+ $ descendants_generations = $ this ->getBlockSetting ($ block_id , 'descendants_generations ' , '2 ' );
304+ $ hourglass_generations = $ this ->getBlockSetting ($ block_id , 'hourglass_generations ' , '2 ' );
305+
264306 $ individual = Registry::individualFactory ()->make ($ xref , $ tree );
265307
266308 return view ('modules/charts/config ' , [
267- 'charts ' => $ charts ,
268- 'individual ' => $ individual ,
269- 'tree ' => $ tree ,
270- 'type ' => $ type ,
309+ 'charts ' => $ charts ,
310+ 'individual ' => $ individual ,
311+ 'tree ' => $ tree ,
312+ 'type ' => $ type ,
313+ 'pedigree_generations ' => $ pedigree_generations ?? null ,
314+ 'pedigree_max_generations ' => $ pedigree_max_generations ?? null ,
315+ 'pedigree_min_generations ' => $ pedigree_min_generations ?? null ,
316+ 'pedigree_style ' => $ pedigree_style ?? null ,
317+ 'pedigree_styles ' => $ pedigree_styles ?? null ,
318+ 'descendants_generations ' => $ descendants_generations ?? null ,
319+ 'descendants_max_generations ' => $ descendants_max_generations ?? null ,
320+ 'descendants_min_generations ' => $ descendants_min_generations ?? null ,
321+ 'hourglass_generations ' => $ hourglass_generations ?? null ,
322+ 'hourglass_max_generations ' => $ hourglass_max_generations ?? null ,
323+ 'hourglass_min_generations ' => $ hourglass_min_generations ?? null ,
271324 ]);
272325 }
273326}
0 commit comments