1 |
joko |
1.1 |
<? |
2 |
joko |
1.2 |
/** |
3 |
|
|
* This file contains a Data::Lift actor component. |
4 |
|
|
* |
5 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
6 |
|
|
* @package org.netfrag.glib |
7 |
|
|
* @name Data::Lift::hash::job::html |
8 |
|
|
* |
9 |
|
|
*/ |
10 |
|
|
|
11 |
|
|
|
12 |
joko |
1.1 |
// ------------------------------------------------------------------------- |
13 |
joko |
1.4 |
// $Id: html.php,v 1.3 2003/03/29 08:49:11 joko Exp $ |
14 |
joko |
1.1 |
// ------------------------------------------------------------------------- |
15 |
joko |
1.2 |
// $Log: html.php,v $ |
16 |
joko |
1.4 |
// Revision 1.3 2003/03/29 08:49:11 joko |
17 |
|
|
// fix: catched php exception |
18 |
|
|
// |
19 |
joko |
1.3 |
// Revision 1.2 2003/03/10 17:55:30 joko |
20 |
|
|
// + metadata for phpDocumentor |
21 |
|
|
// |
22 |
joko |
1.2 |
// Revision 1.1 2003/02/22 16:21:11 joko |
23 |
|
|
// + initial commit |
24 |
|
|
// |
25 |
joko |
1.1 |
// ------------------------------------------------------------------------- |
26 |
|
|
|
27 |
|
|
|
28 |
|
|
// Data::Lift::hash::content2html - |
29 |
|
|
// Convert hash containing content information to html |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
//class Data_Lift_hash_job_html extends Data_Lift { |
33 |
joko |
1.2 |
|
34 |
|
|
|
35 |
|
|
/** |
36 |
|
|
* --- Data::Lift::hash::job::html |
37 |
|
|
* |
38 |
|
|
* |
39 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
40 |
|
|
* @copyright (c) 2003 - All Rights reserved. |
41 |
|
|
* @license GNU LGPL (GNU Lesser General Public License) |
42 |
|
|
* |
43 |
|
|
* @link http://www.netfrag.org/~joko/ |
44 |
|
|
* @link http://www.gnu.org/licenses/lgpl.txt |
45 |
|
|
* |
46 |
|
|
* @package org.netfrag.glib |
47 |
|
|
* @subpackage DataLift |
48 |
|
|
* @name Data::Lift::hash::job::html |
49 |
|
|
* |
50 |
|
|
* @link http://cvs.netfrag.org/php/libs/org.netfrag.glib |
51 |
|
|
* |
52 |
|
|
*/ |
53 |
joko |
1.1 |
class Data_Lift_hash_job_html { |
54 |
|
|
|
55 |
|
|
function perform(&$data) { |
56 |
|
|
|
57 |
|
|
//print Dumper($data); |
58 |
|
|
//return $data; |
59 |
|
|
|
60 |
|
|
//$description = ''; |
61 |
|
|
|
62 |
|
|
//print Dumper($value[description]); |
63 |
|
|
|
64 |
|
|
// V1: |
65 |
|
|
//$name = $value[name]; |
66 |
|
|
//$description = $value[metadata][description]; |
67 |
|
|
|
68 |
|
|
//$description = str_replace("", "\n", $description); |
69 |
|
|
|
70 |
|
|
/* |
71 |
|
|
// V2: |
72 |
|
|
$name = $key; |
73 |
|
|
if (!is_array($value[description])) { |
74 |
|
|
$description = $value[description]; |
75 |
|
|
$description = preg_replace("/^\n+/", " ", $description); |
76 |
|
|
} |
77 |
|
|
if (!$description) { |
78 |
|
|
$description = 'n/a'; |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
$description = str_replace("\n", "<br/>", $description); |
82 |
|
|
|
83 |
|
|
//$description = preg_replace("/\n+/", " ", $description); |
84 |
|
|
//$description = preg_replace("/^\s+/", "", $description); |
85 |
|
|
*/ |
86 |
|
|
|
87 |
|
|
// V3: |
88 |
|
|
|
89 |
|
|
// 1. modify description |
90 |
|
|
$description = $data[description]; |
91 |
|
|
|
92 |
|
|
if (is_array($description)) { |
93 |
|
|
if (count($description)) { |
94 |
|
|
$description = Dumper($description); |
95 |
|
|
} else { |
96 |
|
|
unset($description); |
97 |
|
|
} |
98 |
|
|
} else { |
99 |
|
|
$description = str_replace("\n", "<br/>", $description); |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
// if no description could be figured out, set to "not assigned" |
103 |
|
|
if (!$description) { |
104 |
|
|
$description = 'n/a'; |
105 |
|
|
} |
106 |
|
|
$data[description] = $description; |
107 |
|
|
|
108 |
|
|
// 2. try to make up some detailed information about steps from additional metadata |
109 |
joko |
1.3 |
if (is_array($data[container])) { |
110 |
joko |
1.1 |
$steps = array(); |
111 |
|
|
// check 'container' |
112 |
|
|
foreach ($data[container] as $key => $value) { |
113 |
|
|
if (is_array($value)) { |
114 |
|
|
$arg_parts = array(); |
115 |
|
|
|
116 |
|
|
foreach ($value as $step_entry) { |
117 |
|
|
if (is_array($value)) { |
118 |
|
|
$value = join(', ', $value); |
119 |
|
|
} |
120 |
|
|
if (is_array($step_entry)) { |
121 |
|
|
$buf = array(); |
122 |
|
|
foreach ($step_entry as $opt_name => $opt_value) { |
123 |
|
|
// special case 'target' |
124 |
|
|
if ($opt_name == 'target') { |
125 |
joko |
1.4 |
$link = link::page($opt_value, array( job => $opt_value ) ); |
126 |
joko |
1.1 |
$opt_value = $link->render(); |
127 |
|
|
} |
128 |
|
|
array_push($buf, "<i>$opt_name</i>=$opt_value"); |
129 |
|
|
} |
130 |
|
|
$value = join(', ', $buf); |
131 |
|
|
} |
132 |
|
|
array_push($arg_parts, "<b>$key</b>: $value"); |
133 |
|
|
} |
134 |
|
|
|
135 |
|
|
$args = join('<br/>', $arg_parts); |
136 |
|
|
} else { |
137 |
|
|
$args = "<b>$key</b>: $value"; |
138 |
|
|
} |
139 |
|
|
array_push($steps, $args); |
140 |
|
|
} |
141 |
|
|
$data[steps] = join('<br/>', $steps); |
142 |
joko |
1.3 |
} |
143 |
joko |
1.1 |
|
144 |
|
|
} |
145 |
|
|
|
146 |
|
|
} |
147 |
|
|
|
148 |
|
|
?> |