antoniop
committed
on 08 Oct 24
Rework array idioms in dict idioms, closer to the intended logics
/tcl/application-group-procs.tcl (+8 -7)
278 278                         over any provided URL.
279 279     @param include_self If true, include the current package in the search
280 280
281 281     @return The node of the first non-null application group in array get format.
282 282
283 283     @author Peter Marklund, Dave Bauer
284 284 } {
285 285     # Make sure we have a URL to work with
286 286     if { $url eq "" } {
287 287           if { $node_id eq "" } {
288 288               set url "/"
289 289           } else {
290 290               set url [site_node::get_url -node_id $node_id]
291 291           }
292 292     }
293 293
294 294     set group_id ""
295 295     while {$group_id eq "" && $url ne ""} {
296 296
297 297         if { $include_self_p } {
298               array set node_array [site_node::get -url $url]
  298             set node [site_node::get -url $url]
299 299             set group_id [application_group::group_id_from_package_id \
300                                -package_id $node_array(package_id) \
  300                               -package_id [dict get $node package_id] \
301 301                               -no_complain]
302 302         }
303 303
304 304         set include_self_p 1
305 305
306 306         # move up a level
307 307         set url [string trimright $url /]
308 308         set url [string range $url 0 [string last / $url]]
309 309     }
  310
310 311     if {$group_id eq ""} {
311           array unset -no_complain node_array
  312         unset -nocomplain node
312 313     }
313       set node_array(application_group_id) $group_id
  314     dict set node application_group_id $group_id
314 315
315       return [array get node_array]
  316     return $node
316 317 }
317 318
318 319 ad_proc -public application_group::closest_ancestor_element {
319 320     {-node_id ""}
320 321     {-url ""}
321 322     {-element:required}
322 323     {-include_self:boolean}
323 324 } {
324 325     Return one element of the site node for the closest ancestor package that has an
325 326     application group.
326 327
327 328     @param url URL of the node to start searching from.
328 329     @param node_id node_id of the node to start searching from (only one of node_id and URL
329 330            can be specified).
330 331     @param include_self If true, include the current package in the search
331 332
332 333     @return element The desired element of the appropriate site node.
333 334 } {
334 335     array set site_node \
335 336         [application_group::closest_ancestor_application_group_site_node \