diff --git a/config/config.ini b/config/config.ini index d374493..ac39bdd 100644 --- a/config/config.ini +++ b/config/config.ini @@ -101,6 +101,9 @@ condensedAdminUI = default ; fakeMimetype = false fakeMimetype = default +; "dot" command location +dot = dot + [i18n] ; Default language for the interface defaultLanguage = en diff --git a/plugins/ktcore/admin/workflowsv2.php b/plugins/ktcore/admin/workflowsv2.php index d0a35e3..57de81d 100644 --- a/plugins/ktcore/admin/workflowsv2.php +++ b/plugins/ktcore/admin/workflowsv2.php @@ -101,9 +101,12 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { ); } - // FIXME actually detect this. - $this->HAVE_GRAPHVIZ = true; - + $this->HAVE_GRAPHVIZ = false; + $dotCommand = KTUtil::findCommand("ui/dot", 'dot'); + if (!empty($dotCommand)) { + $this->HAVE_GRAPHVIZ = true; + $this->dotCommand = $dotCommand; + } } function do_main() { @@ -155,16 +158,18 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { // we want to "outsource" some of the analysis - $graph_data = $this->get_graph($this->oWorkflow); - if (!empty($graph_data['errors'])) { - foreach ($graph_data['errors'] as $error) { - $this->addErrorMessage($error); + if ($this->HAVE_GRAPHVIZ) { + $graph_data = $this->get_graph($this->oWorkflow); + if (!empty($graph_data['errors'])) { + foreach ($graph_data['errors'] as $error) { + $this->addErrorMessage($error); + } } - } - - if (!empty($graph_data['info'])) { - foreach ($graph_data['info'] as $info) { - $this->addInfoMessage($info); + + if (!empty($graph_data['info'])) { + foreach ($graph_data['info'] as $info) { + $this->addInfoMessage($info); + } } } @@ -288,18 +293,20 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { $aTransitions = KTWorkflowTransition::getByWorkflow($this->oWorkflow); - $graph_data = $this->get_graph($this->oWorkflow); - if (!empty($graph_data['errors'])) { - foreach ($graph_data['errors'] as $error) { - $this->addErrorMessage($error); + if ($this->HAVE_GRAPHVIZ) { + $graph_data = $this->get_graph($this->oWorkflow); + if (!empty($graph_data['errors'])) { + foreach ($graph_data['errors'] as $error) { + $this->addErrorMessage($error); + } } - } - - if (!empty($graph_data['info'])) { - foreach ($graph_data['info'] as $info) { - $this->addInfoMessage($info); + + if (!empty($graph_data['info'])) { + foreach ($graph_data['info'] as $info) { + $this->addInfoMessage($info); + } } - } + } $oTemplate->setData(array( 'context' => $this, @@ -363,18 +370,20 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { } - $graph_data = $this->get_graph($this->oWorkflow); - if (!empty($graph_data['errors'])) { - foreach ($graph_data['errors'] as $error) { - $this->addErrorMessage($error); + if ($this->HAVE_GRAPHVIZ) { + $graph_data = $this->get_graph($this->oWorkflow); + if (!empty($graph_data['errors'])) { + foreach ($graph_data['errors'] as $error) { + $this->addErrorMessage($error); + } } - } - - if (!empty($graph_data['info'])) { - foreach ($graph_data['info'] as $info) { - $this->addInfoMessage($info); + + if (!empty($graph_data['info'])) { + foreach ($graph_data['info'] as $info) { + $this->addInfoMessage($info); + } } - } + } $oTemplate->setData(array( 'context' => $this, @@ -2133,7 +2142,8 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { 'fontname' => $fontname, ); - $graph = new Image_GraphViz(true, $opts); + $graph = new Image_GraphViz(true, $opts); + $graph->dotCommand = $this->dotCommand; // we need all states & transitions // FIXME do we want guards? @@ -2287,6 +2297,7 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { $sourceless_transitions[] = $oTransition->getHumanName(); } } + if (!empty($sourceless_transitions)) { $errors[] = sprintf(_kt("Some transitions have no source states: %s"), implode(', ', $sourceless_transitions)); }