Platform
3.1
PHP API documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Pages
view_workflow_graph.php
Go to the documentation of this file.
1
<?php
2
/*
3
* @author Anakeen
4
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5
* @package FDL
6
*/
7
/**
8
* Edition to affect document
9
*
10
* @author Anakeen 2000
11
* @version $Id: view_workflow_graph.php,v 1.8 2008/12/31 16:05:20 eric Exp $
12
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13
* @package FDL
14
* @subpackage
15
*/
16
/**
17
*/
18
19
include_once (
"FDL/Class.WDoc.php"
);
20
// -----------------------------------
21
22
/**
23
* Edition to affect document
24
* @param Action &$action current action
25
* @global id Http var : document id to affect
26
* @global type Http var : type of graph
27
* @global format Http var : file format pnh or svg
28
* @global orient Http var :orientation TB (TopBottom) or LR (LeftRight)
29
* @global size Http var : global size of graph
30
*/
31
function
view_workflow_graph
(&
$action
)
32
{
33
$docid
=
GetHttpVars
(
"id"
);
34
$type
=
GetHttpVars
(
"type"
,
"simple"
);
// type of graph
35
$format
=
GetHttpVars
(
"format"
,
"png"
);
36
$orient
=
GetHttpVars
(
"orient"
,
"LR"
);
// type of graph
37
$size
=
GetHttpVars
(
"size"
,
"10"
);
// size of graph
38
$ratio
=
GetHttpVars
(
"ratio"
,
"auto"
);
// ratio of graph
39
$dbaccess
=
$action
->GetParam(
"FREEDOM_DB"
);
40
41
if
(
$type
!=
'simple'
&&
$type
!=
'activity'
&&
$type
!=
'complet'
) {
42
return
$action
->exitError(sprintf(
"Invalid type '%s'"
, htmlspecialchars(
$type
)));
43
}
44
if
(
$format
!=
'dot'
&&
$format
!=
'png'
&&
$format
!=
'svg'
) {
45
return
$action
->exitError(sprintf(
"Invalid format '%s'"
, htmlspecialchars(
$format
)));
46
}
47
if
(
$orient
!=
'LR'
&&
$orient
!=
'TB'
) {
48
return
$action
->exitError(sprintf(
"Invalid orient '%s'"
, htmlspecialchars(
$orient
)));
49
}
50
if
(
$ratio
!=
'fill'
&&
$ratio
!=
'compress'
&&
$ratio
!=
'expand'
&&
$ratio
!=
'auto'
) {
51
return
$action
->exitError(sprintf(
"Invalid ratio '%s'"
, htmlspecialchars(
$ratio
)));
52
}
53
54
$doc
= new_doc(
$dbaccess
,
$docid
);
55
$cmd
=
getWshCmd
(
false
,
$action
->user->id);
56
57
if
(count(
$doc
->cycle) == 0) {
58
$action
->lay->template = _(
"no cycle defined"
);
59
}
else
{
60
61
$cmd
.= sprintf(
"--api=wdoc_graphviz --size=%d --ratio=%s --type=%s --orient=%s --docid=%d"
,
$size
, escapeshellarg(
$ratio
) , escapeshellarg(
$type
) , escapeshellarg(
$orient
) ,
$doc
->id);
62
$svgfile =
"img-cache/w$type-"
.
$action
->getParam(
"CORE_LANG"
) .
"-"
.
$doc
->id .
".$format"
;
63
if
(
$format
==
"dot"
) $svgfile.=
".txt"
;
// conflict with document template
64
$dest
=
DEFAULT_PUBDIR
.
"/$svgfile"
;
65
if
(
$format
==
"dot"
)
$cmd
.= sprintf(
"> %s"
, escapeshellarg(
$dest
));
66
$sed = sprintf(
"s/%s/../"
, str_replace(
'/'
,
'\/'
,
DEFAULT_PUBDIR
));
67
if
(
$format
==
"svg"
)
$cmd
.= sprintf(
"| dot -T%s | sed -e %s > %s"
, escapeshellarg(
$format
) , escapeshellarg($sed) , escapeshellarg(
$dest
));
68
else
$cmd
.= sprintf(
"| dot -T%s > %s"
, escapeshellarg(
$format
) , escapeshellarg(
$dest
));
69
70
system(
$cmd
);
71
// print_r2( $cmd);
72
if
(
$format
==
"png"
) $mime =
"image/png"
;
73
elseif (
$format
==
"svg"
) $mime =
"image/svg+xml"
;
74
else
$mime =
"text/plain"
;
75
Http_DownloadFile
($svgfile, sprintf(
"graph %s.%s"
,
$doc
->getTitle() ,
$format
) , $mime,
true
,
false
,
true
);
76
exit
;
77
}
78
}
← centre documentaire
© anakeen
- published under
CC License
-
Dynacase