/
db_hash.coretag
62 lines (59 loc) · 1.5 KB
/
db_hash.coretag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Copyright 2002-2007 Interchange Development Group and others
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. See the LICENSE file for details.
#
# $Id: db_hash.coretag,v 1.5 2007-03-30 23:40:54 pajamian Exp $
UserTag db-hash Order table column key
UserTag db-hash PosNumber 3
UserTag db-hash addAttr
UserTag db-hash Version $Revision: 1.5 $
UserTag db-hash Routine <<EOR
sub {
my($table, $col, $key, $opt) = @_;
$col =~ s/:+(.*)//s;
my $out;
my $rest = $1;
my $val = ::tag_data($table,$col,$key);
my $ref;
if ($val !~ /\S/) {
$ref = {};
}
else {
$ref = $Vend::Interpolate::ready_safe->reval($val);
if (! ref $ref) {
$ref = {};
}
}
if (! $rest) {
return $val unless defined $opt->{value};
}
my @extra;
@extra = split /:+/, $rest;
my $final = pop @extra;
my $curr = $ref;
$out .= "Original key request: $rest\n";
$out .= "\nFinal key: $final\n";
for(@extra) {
$out .= "key --> $_\n";
$curr = $curr->{$_};
if (! ref $curr) {
return "BAD HASH: $out" if $opt->{show_error};
return;
}
}
if($opt->{keys}) {
return join get_joiner($opt->{joiner}), sort keys %$curr;
}
elsif(! defined $opt->{value}) {
return $curr->{$final};
}
else {
$curr->{$final} = $opt->{value};
tag_data($table, $col, $key, { value => uneval_it($ref) });
return $curr->{$final};
}
}
EOR