| 1 |
jonen |
1.1 |
<?php |
| 2 |
|
|
|
| 3 |
|
|
/** |
| 4 |
jonen |
1.7 |
* $Id: utils.php,v 1.6 2003/05/10 18:17:19 jonen Exp $ |
| 5 |
jonen |
1.2 |
* |
| 6 |
|
|
* $Log: utils.php,v $ |
| 7 |
jonen |
1.7 |
* Revision 1.6 2003/05/10 18:17:19 jonen |
| 8 |
|
|
* + added 'create/add new' links |
| 9 |
|
|
* |
| 10 |
jonen |
1.6 |
* Revision 1.5 2003/04/18 13:38:40 jonen |
| 11 |
|
|
* + added use of url::short function at 'decode_item_expr' |
| 12 |
|
|
* |
| 13 |
jonen |
1.5 |
* Revision 1.4 2003/04/16 16:22:01 joko |
| 14 |
|
|
* + introduced url::short |
| 15 |
|
|
* |
| 16 |
joko |
1.4 |
* Revision 1.3 2003/04/09 07:57:15 joko |
| 17 |
|
|
* revamped 'function decode_item_expr' |
| 18 |
|
|
* introduced shortcut 'link::store' |
| 19 |
|
|
* |
| 20 |
joko |
1.3 |
* Revision 1.2 2003/04/09 00:32:42 jonen |
| 21 |
|
|
* some tests according to form rendering at the decode functions |
| 22 |
|
|
* |
| 23 |
jonen |
1.2 |
* Revision 1.1 2003/04/06 01:28:04 jonen |
| 24 |
|
|
* + initial commit |
| 25 |
|
|
* + moved decode functions here |
| 26 |
|
|
* + reworked decode functions to use new LinkBuilder class |
| 27 |
jonen |
1.1 |
* |
| 28 |
|
|
* |
| 29 |
|
|
* |
| 30 |
|
|
*/ |
| 31 |
|
|
|
| 32 |
|
|
/** |
| 33 |
|
|
* Container holds most helper functions are used at the WebExplorer itself |
| 34 |
|
|
* or at its components, e.g. decode functions used at the GUI modules. |
| 35 |
|
|
* |
| 36 |
|
|
* |
| 37 |
|
|
* @author Sebastian Utz <seut@tunemedia.de> |
| 38 |
|
|
* @package org.netfrag.app |
| 39 |
|
|
* @name WebExplorer::utils |
| 40 |
|
|
* |
| 41 |
|
|
*/ |
| 42 |
|
|
|
| 43 |
|
|
|
| 44 |
|
|
class WebExplorer_utils { |
| 45 |
|
|
|
| 46 |
|
|
|
| 47 |
|
|
|
| 48 |
|
|
// TODO: refactor to Data::Lift - subcomponent: handling will get way more easy! |
| 49 |
joko |
1.3 |
function decode_item_array(&$item, $hidden_elements, $options) { |
| 50 |
jonen |
1.1 |
//$options = $this->_options['decode_args']; |
| 51 |
|
|
//print "item: " . Dumper($item); |
| 52 |
|
|
//print "options: " . Dumper($options); |
| 53 |
|
|
if( is_array($item) ) { |
| 54 |
|
|
//$cur_row_index = $this->_datasource->get_cur_data_index(); |
| 55 |
|
|
//$parent_guid = $this->_datasource->_data[$cur_row_index]['guid']; |
| 56 |
|
|
// build list for selection form |
| 57 |
|
|
if($options['form']) { |
| 58 |
|
|
foreach($item as $key => $value) { |
| 59 |
jonen |
1.5 |
$link_meta = php::untwingle_reference($value, $options); |
| 60 |
jonen |
1.2 |
$link_vars = array( |
| 61 |
jonen |
1.5 |
'ecdid' => $link_meta[ident], |
| 62 |
|
|
'ecdm' => $link_meta[type] |
| 63 |
jonen |
1.2 |
); |
| 64 |
|
|
|
| 65 |
|
|
foreach($hidden_elements as $label => $value) { |
| 66 |
|
|
$link_vars[$label] = $value; |
| 67 |
|
|
} |
| 68 |
|
|
|
| 69 |
joko |
1.4 |
// V1 - create new LinkBuilder instance and get link GUID by saving vars |
| 70 |
joko |
1.3 |
$link_guid = link::store($link_vars); |
| 71 |
jonen |
1.2 |
|
| 72 |
joko |
1.4 |
// V2 - more flexible - adjustable link shrinking via some constant defined elsewhere |
| 73 |
|
|
//$link_guid = url::short('', $link_vars); |
| 74 |
|
|
|
| 75 |
jonen |
1.2 |
$list[$key] = $link_guid; |
| 76 |
jonen |
1.1 |
} |
| 77 |
|
|
if(is_array($list) ) { |
| 78 |
|
|
$container = container( |
| 79 |
jonen |
1.2 |
//form_open( $item[0], $_SERVER['PHP_SELF'], "POST" ), |
| 80 |
|
|
form_select("lbid", $list), |
| 81 |
jonen |
1.1 |
form_submit("submit","view" ) |
| 82 |
|
|
); |
| 83 |
jonen |
1.2 |
//$container->add(form_close() ); |
| 84 |
jonen |
1.1 |
$item = $container; |
| 85 |
|
|
} |
| 86 |
|
|
} else { |
| 87 |
|
|
//print "<b>2</b><br/>"; |
| 88 |
|
|
$container = container(); |
| 89 |
jonen |
1.6 |
|
| 90 |
|
|
// add default 'add new' link |
| 91 |
|
|
$link_vars_create = array( |
| 92 |
|
|
'ecdid' => $options[label], |
| 93 |
|
|
'ecdm' => $options[parent_guid], |
| 94 |
|
|
'ecdmx' => $options[parent_class], |
| 95 |
|
|
'ecmod' => "create", |
| 96 |
jonen |
1.7 |
'ecat' => 'item' |
| 97 |
jonen |
1.6 |
); |
| 98 |
|
|
foreach($hidden_elements as $label => $value) { |
| 99 |
|
|
if(!$link_vars_create[$label]) { |
| 100 |
|
|
$link_vars_create[$label] = $value; |
| 101 |
|
|
} |
| 102 |
|
|
} |
| 103 |
|
|
$url_short = url::short($_SERVER["PHP_SELF"], $link_vars_create); |
| 104 |
|
|
$container->add(_HTML_SPACE, html_a( $url_short, $key . " add new"), html_br()); |
| 105 |
|
|
|
| 106 |
|
|
if(count($item) != 0) { |
| 107 |
|
|
foreach($item as $key => $value) { |
| 108 |
jonen |
1.5 |
$link_meta = php::untwingle_reference($value, $options); |
| 109 |
|
|
$link_vars = array( |
| 110 |
|
|
'ecdid' => $link_meta[ident], |
| 111 |
jonen |
1.7 |
'ecdm' => $link_meta[type], |
| 112 |
|
|
'ecat' => 'item' |
| 113 |
jonen |
1.5 |
); |
| 114 |
jonen |
1.1 |
|
| 115 |
|
|
foreach($hidden_elements as $label => $value) { |
| 116 |
jonen |
1.6 |
if(!$link_vars[$label]) { |
| 117 |
|
|
$link_vars[$label] = $value; |
| 118 |
|
|
} |
| 119 |
jonen |
1.1 |
//$tmp_array[] = $label . "=" . $value; |
| 120 |
|
|
} |
| 121 |
|
|
|
| 122 |
|
|
//$str_hidden = join("&", $tmp_array); |
| 123 |
|
|
//$container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, $key . " view"), html_br()); |
| 124 |
|
|
|
| 125 |
joko |
1.4 |
// V1 - create new LinkBuilder instance and get link GUID by saving vars |
| 126 |
|
|
//$link_guid = link::store($link_vars); |
| 127 |
|
|
//$container->add("->", html_a($_SERVER["PHP_SELF"] . "?lbid=" . $link_guid, $key . " view"), html_br()); |
| 128 |
|
|
|
| 129 |
|
|
// V2 - more flexible - adjustable link shrinking via some constant defined elsewhere |
| 130 |
|
|
$url_short = url::short($_SERVER["PHP_SELF"], $link_vars); |
| 131 |
jonen |
1.6 |
$container->add( _HTML_SPACE, html_a( $url_short, $key . " - " . " view"), html_br()); |
| 132 |
jonen |
1.1 |
|
| 133 |
jonen |
1.6 |
} |
| 134 |
jonen |
1.1 |
} |
| 135 |
|
|
$item = $container; |
| 136 |
|
|
} |
| 137 |
joko |
1.3 |
//return $item; |
| 138 |
|
|
return 1; |
| 139 |
jonen |
1.1 |
} |
| 140 |
|
|
} |
| 141 |
|
|
|
| 142 |
|
|
// decodes serialized string representations of object-references |
| 143 |
|
|
// TODO: refactor to Data::Lift - subcomponent: handling will get way more easy! |
| 144 |
joko |
1.3 |
function decode_item_expr(&$item, $hidden_elements, $options) { |
| 145 |
|
|
|
| 146 |
|
|
//return; |
| 147 |
|
|
|
| 148 |
|
|
// debug |
| 149 |
jonen |
1.1 |
//$options = $this->_options['decode_args']; |
| 150 |
|
|
//print "item: $item<br/>"; |
| 151 |
|
|
|
| 152 |
jonen |
1.6 |
if($item == "_REF") { |
| 153 |
|
|
$link_vars_create = array( |
| 154 |
|
|
'ecdid' => $options[label], |
| 155 |
|
|
'ecdm' => $options[parent_guid], |
| 156 |
|
|
'ecdmx' => $options[parent_class], |
| 157 |
|
|
'ecmod' => "create", |
| 158 |
jonen |
1.7 |
'ecat' => 'item' |
| 159 |
jonen |
1.6 |
); |
| 160 |
|
|
foreach($hidden_elements as $label => $value) { |
| 161 |
|
|
if(!$link_vars_create[$label]) { |
| 162 |
|
|
$link_vars_create[$label] = $value; |
| 163 |
|
|
} |
| 164 |
|
|
} |
| 165 |
|
|
$url_short = url::short($_SERVER["PHP_SELF"], $link_vars_create); |
| 166 |
|
|
$item = html_a( $url_short, " create"); |
| 167 |
|
|
} else { |
| 168 |
|
|
// resolve 'o_{guid}_{classname}' - encoded string |
| 169 |
|
|
$link_meta = php::untwingle_reference($item); |
| 170 |
|
|
//print Dumper($link_meta); |
| 171 |
|
|
|
| 172 |
|
|
if (!is_array($link_meta)) { |
| 173 |
|
|
//return $item; |
| 174 |
|
|
//print "NO<br/>"; |
| 175 |
|
|
return; |
| 176 |
|
|
} |
| 177 |
|
|
|
| 178 |
|
|
$link_vars = array( |
| 179 |
|
|
'ecdid' => $link_meta[ident], |
| 180 |
|
|
'ecdm' => $link_meta[type], |
| 181 |
jonen |
1.7 |
'ecat' => 'item' |
| 182 |
jonen |
1.6 |
); |
| 183 |
|
|
|
| 184 |
|
|
foreach($hidden_elements as $label => $value) { |
| 185 |
|
|
if(!$link_vars[$label]) { |
| 186 |
|
|
$link_vars[$label] = $value; |
| 187 |
|
|
} |
| 188 |
|
|
} |
| 189 |
|
|
|
| 190 |
|
|
// V1 |
| 191 |
|
|
//$str_hidden = join("&", $tmp_array); |
| 192 |
|
|
//$item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, "view"); |
| 193 |
|
|
|
| 194 |
|
|
// V2 |
| 195 |
|
|
//$link_guid = link::store($link_vars); |
| 196 |
|
|
//$item = html_a($_SERVER["PHP_SELF"] . "?lbid=" . $link_guid, "view"); |
| 197 |
|
|
|
| 198 |
|
|
// V3 - more flexible - adjustable link shrinking via some constant defined elsewhere |
| 199 |
|
|
$url_short = url::short($_SERVER["PHP_SELF"], $link_vars); |
| 200 |
|
|
$item = html_a( $url_short, " view"); |
| 201 |
joko |
1.3 |
} |
| 202 |
|
|
|
| 203 |
|
|
return 1; |
| 204 |
jonen |
1.1 |
} |
| 205 |
|
|
|
| 206 |
|
|
|
| 207 |
|
|
|
| 208 |
|
|
} |
| 209 |
|
|
|
| 210 |
|
|
|
| 211 |
|
|
?> |