Graph not rendered - smarty error?
Hello all,
I never developed in PHP so I'm hoping that there's a quick resolution to my problem. I can't see the graphs generated on my workflows, but they're there physically on my web server. I know EXACTLY where the problem is, but not how to fix it.
Intro
I created a workflow process called "Test Process 1". Everything went great up until the point where I tried to view the graph of the workflow. I realized that I did not have GraphViz installed and after I rectified this, I went back to view the graph. This time, things were a little bit different: I could load up the page in my brower (tiki-g-admin_graph.php?pid=1) but instead of seeing the graph, I saw a broken-img-link icon. I knew that one of the two things happened:
- the graph was not created at all
- the graph was created, but somehow it did not get linked properly
Debug
I dug into the source code and realized that graphs are saved in this directory:
lib/Galaxia/processes/Test_Process_1_10/graph/
I found my graph there (*.png file) along with the map file. So the first possiblity was ruled out — the graph was created properly.
I then started reading tiki-g-admin_graph.php page and pretty quickly realized that the graph was created in this segment of code:
(somewhere around line 33 of tiki-g-admin_graph.php)
if ($_REQUEST%22pid%22) {
$info = $processManager->get_process($_REQUEST%22pid%22);
$info'graph' = GALAXIA_PROCESSES."/" . $info'normalized_name' . "/graph/" . $info'normalized_name' . ".png";
$mapfile = GALAXIA_PROCESSES."/" . $info'normalized_name' . "/graph/" . $info'normalized_name' . ".map";
if (file_exists($info'graph') && file_exists($mapfile)) {
$map = join('',file($mapfile));
$url = "tiki-g-admin_activities.php?pid=".$info'pId';
$map = preg_replace('/href=".*?activityId/', 'href="' . $url . '&activityId', $map); $info'map' = $map;
All right. So the info about my graph was created by concatenating stuff to GALAXIA_PROCESSES variable. I found this variable in lib/Galaxia/config.php. Unless it exists previously, it is created from GALAXIA_LIBRARY. GALAXIA_LIBRARY in turn is created by "dirname(FILE)". I don't know PHP but I take it that this lists my current working directory path.
Be that as it may, I put in a print statement in the above code segment and I realized that
$info'graph'="var/www/html/tikiwiki-1.9.0/lib/Galaxia/processes/Test_Process_1_10/graph/Test_Process_1_10.png" So it seems to be pointing in the right place, and the "file_exists" condition passes in the above code excerpt.
I then loaded up tiki-g-admin_graph.php page in my browser and viewed the source of the page. There was my culprit!
The source tries to connect "img src" to "var/www/html/tikiwiki-1.9.0/lib/Galaxia/processes/Test_Process_1_10/graph/Test_Process_1_10.png". But this is wrong! The apache expects to see only "tikiwiki-1.9.0/lib/Galaxia/processes/Test_Process_1_10/graph/Test_Process_1_10.png" !
Problem
I realized that this page is created by the mean of something called Smarty, which turns out to be a template-presentation framework (Learning PHP in these last few hours). I located this template here:
template/tiki-g-admin_graph.tpl
When I open this file up, I find this code excerpt:
(somewhere around line 51 of tiki-g-admin_graph.tpl)
img src="{$info.graph}" alt="{$info.name}" border="0" usemap="#procmap"
(in proper html tags that I removed here so it's rendered nicely).
As you can see, this template file reads in the $info.graph, which is set to my absolute path. I need it to be relative path. Rather than hack it by hand, how do we make this automatic?
The end
Sorry for the essay, but I really wanted to be as specific as possible so some developer could help me out.
What we need is to strip the leading "/var/www/html" (Apache root) from $info.graph. Any functions that do this for us?
Thanks in advance,
Milan