@@ -22,26 +22,41 @@ public function __construct()
2222 $ this ->api = $ opencastContainer [API ::class];
2323 }
2424
25+ /**
26+ * {@inheritdoc}
27+ */
2528 public function anyWorkflowExists (): bool
2629 {
2730 return (WorkflowAR::count () > 0 );
2831 }
2932
33+ /**
34+ * {@inheritdoc}
35+ */
3036 public function anyWorkflowAvailable (): bool
3137 {
3238 return (count ($ this ->getFilteredWorkflowsArray ()) > 0 );
3339 }
3440
41+ /**
42+ * {@inheritdoc}
43+ */
3544 public function getAllWorkflows (): array
3645 {
3746 return WorkflowAR::get ();
3847 }
3948
49+ /**
50+ * {@inheritdoc}
51+ */
4052 public function getAllWorkflowsAsArray ($ key = null , $ values = null ): array
4153 {
4254 return WorkflowAR::getArray ($ key , $ values );
4355 }
4456
57+ /**
58+ * {@inheritdoc}
59+ */
4560 public function store (string $ workflow_id , string $ title , string $ description ,
4661 string $ tags , string $ config_panel , int $ id = 0 ): void
4762 {
@@ -65,27 +80,42 @@ public function store(string $workflow_id, string $title, string $description,
6580 $ workflow ->store ();
6681 }
6782
83+ /**
84+ * {@inheritdoc}
85+ */
6886 public function exists (string $ workflow_id ): bool
6987 {
7088 return WorkflowAR::where (['workflow_id ' => $ workflow_id ])->hasSets ();
7189 }
7290
91+ /**
92+ * {@inheritdoc}
93+ */
7394 public function delete ($ id ): void
7495 {
7596 $ workflow = WorkflowAR::find ($ id );
7697 $ workflow ->delete ();
7798 }
7899
100+ /**
101+ * {@inheritdoc}
102+ */
79103 public function getByWorkflowId (string $ workflow_id )
80104 {
81105 return WorkflowAR::where (['workflow_id ' => $ workflow_id ])->first ();
82106 }
83107
108+ /**
109+ * {@inheritdoc}
110+ */
84111 public function getById (int $ id )
85112 {
86113 return WorkflowAR::where (['id ' => $ id ])->first ();
87114 }
88115
116+ /**
117+ * {@inheritdoc}
118+ */
89119 public function getConfigPanelAsArrayById (string $ id ): array
90120 {
91121 $ config_panel_array = [];
@@ -151,6 +181,9 @@ public function getConfigPanelAsArrayById(string $id): array
151181 return $ config_panel_array ;
152182 }
153183
184+ /**
185+ * {@inheritdoc}
186+ */
154187 public function getWorkflowsFromOpencastApi (array $ filter = [], bool $ with_configuration_panel = false ,
155188 bool $ with_tags = false ): array
156189 {
@@ -166,6 +199,9 @@ public function getWorkflowsFromOpencastApi(array $filter = [], bool $with_confi
166199 return $ workflows ;
167200 }
168201
202+ /**
203+ * {@inheritdoc}
204+ */
169205 public function updateList (?string $ tags_str = null ): bool
170206 {
171207 $ oc_workflows_all = $ this ->getWorkflowsFromOpencastApi ([], true , true );
@@ -228,6 +264,9 @@ public function updateList(?string $tags_str = null): bool
228264 return $ success ;
229265 }
230266
267+ /**
268+ * {@inheritdoc}
269+ */
231270 public function resetList (): bool
232271 {
233272 $ oc_workflows_all = $ this ->getWorkflowsFromOpencastApi ([], true , true );
@@ -268,6 +307,9 @@ public function resetList(): bool
268307 return $ success ;
269308 }
270309
310+ /**
311+ * {@inheritdoc}
312+ */
271313 public function createOrUpdate (string $ workflow_id , string $ title , string $ description , string $ tags = '' , string $ config_panel = '' ): WorkflowAR
272314 {
273315 $ id = 0 ;
@@ -282,6 +324,12 @@ public function createOrUpdate(string $workflow_id, string $title, string $descr
282324 return $ new_workflow ;
283325 }
284326
327+ /**
328+ * Helper function to convert comma separated list string to array
329+ * @param string $comma_separated_str
330+ *
331+ * @return array
332+ */
285333 private function commaToArray ($ comma_separated_str ): array
286334 {
287335 $ converted_list = [];
@@ -292,6 +340,14 @@ private function commaToArray($comma_separated_str): array
292340 return $ converted_list ;
293341 }
294342
343+ /**
344+ * Helper function to check if an array contains an item
345+ *
346+ * @param array $base
347+ * @param string|int $check
348+ *
349+ * @return bool
350+ */
295351 private function hasItem ($ base , $ check ): bool
296352 {
297353 foreach ($ base as $ item ) {
@@ -302,6 +358,9 @@ private function hasItem($base, $check): bool
302358 return false ;
303359 }
304360
361+ /**
362+ * {@inheritdoc}
363+ */
305364 public function getFilteredWorkflowsArray (
306365 array $ workflows = [],
307366 ?string $ tags_str = null ): array
@@ -353,11 +412,13 @@ public function getFilteredWorkflowsArray(
353412 return $ filtered_list ;
354413 }
355414
356- public function buildWorkflowSelectOptions (): string
415+
416+ /**
417+ * {@inheritdoc}
418+ */
419+ public function getWorkflowSelectionArray (): array
357420 {
358- $ options = [
359- '<option value=""> ' . $ this ->translate ('empty_select_option ' , 'workflow ' ) . '</option> '
360- ];
421+ $ workflow_selection_list = [];
361422 foreach ($ this ->getFilteredWorkflowsArray () as $ workflow ) {
362423 $ title = $ workflow ->getTitle ();
363424 $ workflow_record_id = $ workflow ->getId ();
@@ -370,11 +431,28 @@ public function buildWorkflowSelectOptions(): string
370431 if (empty ($ title )) {
371432 $ title = $ workflow_identifier ;
372433 }
434+ $ workflow_selection_list [$ workflow_record_id ] = $ title ;
435+ }
436+ return $ workflow_selection_list ;
437+ }
438+
439+ /**
440+ * {@inheritdoc}
441+ */
442+ public function buildWorkflowSelectOptions (): string
443+ {
444+ $ options = [
445+ '<option value=""> ' . $ this ->translate ('empty_select_option ' , 'workflow ' ) . '</option> '
446+ ];
447+ foreach ($ this ->getWorkflowSelectionArray () as $ workflow_record_id => $ title ) {
373448 $ options [] = "<option value=' {$ workflow_record_id }'> {$ title }</option> " ;
374449 }
375450 return implode ("\n" , $ options );
376451 }
377452
453+ /**
454+ * {@inheritdoc}
455+ */
378456 public function parseConfigPanels (): array
379457 {
380458 $ config_panels = [];
@@ -388,6 +466,14 @@ public function parseConfigPanels(): array
388466 return $ config_panels ;
389467 }
390468
469+ /**
470+ * Helper function to extract, map and generate configuration panel elements received from opencast.
471+ *
472+ * @param string $workflow_id
473+ * @param string $configuration_panel_html
474+ *
475+ * @return string
476+ */
391477 private function mapConfigPanelElements (string $ workflow_id , string $ configuration_panel_html ): string
392478 {
393479 $ dom = new \DOMDocument ();
@@ -416,10 +502,10 @@ private function mapConfigPanelElements(string $workflow_id, string $configurati
416502 // Legends replacements. We need to legend to be displayed in there!
417503 foreach ($ legends as $ legend ) {
418504 $ text = $ legend ->textContent ;
419- $ h3 = $ dom ->createElement ('h3 ' );
420- $ h3 ->textContent = $ text ;
505+ $ em = $ dom ->createElement ('em ' );
506+ $ em ->textContent = $ text ;
421507 $ legend ->setAttribute ('class ' , 'hidden ' );
422- $ legend ->parentNode ->insertBefore ($ h3 , $ legend );
508+ $ legend ->parentNode ->insertBefore ($ em , $ legend );
423509 }
424510
425511 // Stylings and classes of ul li elements.
@@ -481,6 +567,9 @@ private function mapConfigPanelElements(string $workflow_id, string $configurati
481567 $ input ->setAttribute ('name ' , $ new_name );
482568 }
483569 $ classes = ['wf-inputs ' ];
570+ if ($ input ->parentNode ->tagName === 'li ' ) {
571+ $ classes [] = 'wf-list-inputs ' ;
572+ }
484573 if ($ input ->hasAttribute ('class ' )) {
485574 $ classes [] = $ input ->getAttribute ('class ' );
486575 }
@@ -573,12 +662,12 @@ private function mapConfigPanelElements(string $workflow_id, string $configurati
573662 }
574663 $ label ->nodeValue = $ label_text ;
575664
576- $ classes = [' control-label ' ];
577- if ( $ label -> parentNode -> tagName !== ' li ' ) {
578- $ classes [] = 'col-sm-3 ' ;
579- $ classes [] = ' configLabel ' ;
580- } else {
581- $ classes [] = 'configListLabel ' ;
665+ $ classes = [
666+ ' wf-labels ' ,
667+ 'col-sm-4 '
668+ ] ;
669+ if ( $ label -> parentNode -> tagName == ' li ' ) {
670+ $ classes [] = 'wf-list-labels ' ;
582671 }
583672 if ($ label ->hasAttribute ('class ' )) {
584673 $ classes [] = $ label ->getAttribute ('class ' );
0 commit comments