paramBuild.php
2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/** @file paramBuild.php
* @brief parameter generator from templates and parameter name
* @version $Id: $
* @date Tue Sep 11 14:04:55 CEST 2007
*/
/*
* To exclude crazy stuff from parameter name
*/
function param2dd($paramID)
{
$pairs = array("-" => "_", "%" => "_","\\" => "_","$" => "_",":" => "_","+" =>" _","-" => "_","#" => "_","@" => "_", "." => "_",">" => "_", "<" => "_");
return strtr($paramID, $pairs);
}
/*
* Object -> Stuff for DD Graph
*/
function paramBuild($paramID)
{
$TargetDir = "./"; // WHERE CREATE???
$PRODIR = TEMPLATES;
$LIBDIR = PREDEFINED; // predefined ext params
$ddParamID = param2dd($paramID);
$paramFunc = strtolower($ddParamID);
$SED = "sed 's/NEWPARAM/".$paramID."/g' ".$PRODIR."newparam_init.pro | sed 's/DDPARAM/".$ddParamID."/g' > ".$TargetDir.$paramFunc."_init.pro";
system($SED);
$SED = "sed 's/NEWPARAM/".$paramID."/g' ".$PRODIR."newparam_com.pro | sed 's/DDPARAM/".$ddParamID."/g' > ".$TargetDir.$paramFunc."_com.pro";
system($SED);
$SED = "sed 's/DDPARAM/".$ddParamID."/g' ".$PRODIR."getnewparam.pro > ".$TargetDir."get".$paramFunc.".pro";
system($SED);
/*
* Add predefined functions if exists
*/
foreach (glob($LIBDIR."*".$paramFunc."*.pro") as $filename)
copy($filename, str_replace($LIBDIR, $TargetDir, $filename));
}
/*
* components
*/
function paramBuildComp($paramID, $comp)
{
$TargetDir = "./"; // WHERE CREATE???
$PRODIR = TEMPLATES;
$ddParamID = param2dd($paramID);
$paramFunc = strtolower($ddParamID).'_'.$comp;
$SED = "sed 's/DDPARAM/".$ddParamID."/g' ".$PRODIR."newparam_XXX_init.pro | sed 's/XXX/".$comp."/g' > ".$TargetDir.$paramFunc."_init.pro";
system($SED);
}
/*
* Real Parameter
*/
function paramBuild_($paramID)
{
$TargetDir = "./"; // WHERE CREATE???
$PRODIR = TEMPLATES;
$LIBDIR = PREDEFINED; // predefined ext params
$ddParamID = param2dd($paramID);
$paramFunc = strtolower($ddParamID);
/*
* Add predefined functions if exists
*/
if (file_exists($LIBDIR.$paramFunc."_.pro")) copy($LIBDIR.$paramFunc."_.pro",$TargetDir.$paramFunc."_.pro");
else
{
$SED = "sed 's/NEWPARAM/".$paramID."/g' ".$PRODIR."newparam_.pro | sed 's/DDPARAM/".$ddParamID."/g' > ".$TargetDir.$paramFunc."_.pro";
system($SED);
}
}
?>