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