4 |
## $Id$ |
## $Id$ |
5 |
## ------------------------------------------------------------------------- |
## ------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.4 2003/04/11 00:58:08 joko |
8 |
|
## + link::plain |
9 |
|
## + url::viewdatanode |
10 |
|
## |
11 |
|
## Revision 1.3 2003/04/08 22:38:43 joko |
12 |
|
## NEW: 'class url' as code container for some shortcut functions |
13 |
|
## |
14 |
|
## Revision 1.2 2003/04/08 17:56:09 joko |
15 |
|
## bugfixes |
16 |
|
## |
17 |
## Revision 1.1 2003/04/06 04:30:10 joko |
## Revision 1.1 2003/04/06 04:30:10 joko |
18 |
## initial commit |
## initial commit |
19 |
## |
## |
86 |
// FIXME: do this more generic! use array_merge for this purpose? |
// FIXME: do this more generic! use array_merge for this purpose? |
87 |
$opts = array_merge($_GET, $_POST); |
$opts = array_merge($_GET, $_POST); |
88 |
if (!$args[ap]) { $args[ap] = $opts[ap]; } |
if (!$args[ap]) { $args[ap] = $opts[ap]; } |
89 |
$query_string = httpQuery($args); |
$query_string = url::query($args); |
90 |
return html_a($query_string, $caption); |
return html_a($query_string, $caption); |
91 |
} |
} |
92 |
|
|
93 |
|
function action($action_name, $args = array()) { |
94 |
|
$query_string = linkargs::action($action_name, $args); |
95 |
|
return html_a($query_string, "[$action_name]"); |
96 |
|
} |
97 |
|
|
98 |
|
function plain($url, $caption = '') { |
99 |
|
if (!$caption) { $caption = $url; } |
100 |
|
return html_a($url, $caption); |
101 |
|
} |
102 |
|
|
103 |
} |
} |
104 |
|
|
128 |
function page($page_name, $args = array()) { |
function page($page_name, $args = array()) { |
129 |
$args[ap] = $page_name; |
$args[ap] = $page_name; |
130 |
//unset($args[ap]); |
//unset($args[ap]); |
131 |
return httpQuery($args); |
return url::query($args); |
132 |
} |
} |
133 |
|
|
134 |
function topic($topic_name, $args = array()) { |
function topic($topic_name, $args = array()) { |
135 |
$args[t] = $topic_name; |
$args[t] = $topic_name; |
136 |
//unset($args[ap]); |
//unset($args[ap]); |
137 |
return httpQuery($args); |
return url::query($args); |
138 |
} |
} |
139 |
|
|
140 |
} |
function action($action_name, $args = array()) { |
141 |
|
$args[ga] = $action_name; |
142 |
|
return url::query($args); |
143 |
|
} |
144 |
|
|
|
function httpQuery($args = array()) { |
|
|
$query_list = array(); |
|
|
foreach ($args as $key => $val) { |
|
|
array_push($query_list, "$key=$val"); |
|
|
} |
|
|
$query_string = join('&', $query_list); |
|
|
if ($query_string) { $query_string = '?' . $query_string; } |
|
|
return $query_string; |
|
145 |
} |
} |
146 |
|
|
147 |
|
|
148 |
function yesno($bool) { |
class url { |
|
return $bool ? 'yes' : 'no'; |
|
|
} |
|
149 |
|
|
150 |
function qLink_old($args = array()) { |
function query($args = array()) { |
151 |
return httpQuery($args); |
$query_list = array(); |
152 |
} |
foreach ($args as $key => $val) { |
153 |
|
array_push($query_list, "$key=$val"); |
154 |
|
} |
155 |
|
$query_string = join('&', $query_list); |
156 |
|
if ($query_string) { $query_string = '?' . $query_string; } |
157 |
|
return $query_string; |
158 |
|
} |
159 |
|
|
160 |
|
// shortcut to 'link::store' |
161 |
|
function short($base = '', $link_vars = array()) { |
162 |
|
|
163 |
|
// if $base isn't defined, use the current url as base |
164 |
|
if (!$base) { $base = $_SERVER['PHP_SELF']; } |
165 |
|
|
166 |
|
if (constants::get('URL_ENCODE_GUID')) { |
167 |
|
// store and encode the argument payload |
168 |
|
$link_guid = link::store($link_vars); |
169 |
|
|
170 |
|
// build complete url |
171 |
|
$url = $base . "?lbid=" . $link_guid; |
172 |
|
} else { |
173 |
|
$url = $base . url::query($link_vars); |
174 |
|
} |
175 |
|
|
176 |
|
|
177 |
|
// there you have it.. |
178 |
|
return $url; |
179 |
|
} |
180 |
|
|
181 |
|
function viewdatanode($nodename) { |
182 |
|
|
183 |
|
$final = array(); |
184 |
|
$defaults = array( 'ap' => 'explorer', 'ecl' => 'content' ); |
185 |
|
$location = array( 'ecdlk' => 'rpc' ); |
186 |
|
$args = array( 'ecmod' => 'view', 'ect' => 'data', ); |
187 |
|
$ident = array( 'ecat' => 'list', 'ecdid' => $nodename ); |
188 |
|
|
189 |
|
$final = php::array_join_merge($final, $defaults); |
190 |
|
$final = php::array_join_merge($final, $location); |
191 |
|
$final = php::array_join_merge($final, $args); |
192 |
|
$final = php::array_join_merge($final, $ident); |
193 |
|
|
194 |
|
return url::short('', $final); |
195 |
|
} |
196 |
|
|
197 |
|
} |
198 |
|
|
199 |
?> |
?> |