3 |
# this sucks slightly, due to chuminess with Zot, especially wrt |
# this sucks slightly, due to chuminess with Zot, especially wrt |
4 |
# history. Ideas on how to fix that would be greatly appreciated. |
# history. Ideas on how to fix that would be greatly appreciated. |
5 |
|
|
6 |
|
# FIXME: estoy suponiendo que los dropdowns son siempre de cosas con |
7 |
|
# histórico. |
8 |
|
|
9 |
use warnings; |
use warnings; |
10 |
use strict; |
use strict; |
11 |
use AppConfig qw(:expand :argcount); |
use AppConfig qw(:expand :argcount); |
103 |
} |
} |
104 |
|
|
105 |
|
|
106 |
|
sub fkey_datasource |
107 |
|
{ |
108 |
|
my $database = shift; |
109 |
|
my $name = shift; |
110 |
|
|
111 |
|
return sprintf ' |
112 |
|
<datasource name="%sDataSource" database="%s" table="_%s_data"> |
113 |
|
<condition> |
114 |
|
<null> |
115 |
|
<cfield name="_end_t"/> |
116 |
|
</null> |
117 |
|
</condition> |
118 |
|
</datasource> |
119 |
|
', $name, $database, $name ; |
120 |
|
} |
121 |
|
|
122 |
my $PWD = `pwd`; |
my $PWD = `pwd`; |
123 |
chomp $PWD; |
chomp $PWD; |
124 |
my $config = AppConfig->new({ CASE => 1, |
my $config = AppConfig->new({ CASE => 1, |
140 |
'search_label' => { ARGCOUNT => ARGCOUNT_LIST }, |
'search_label' => { ARGCOUNT => ARGCOUNT_LIST }, |
141 |
'result_label' => { ARGCOUNT => ARGCOUNT_LIST }, |
'result_label' => { ARGCOUNT => ARGCOUNT_LIST }, |
142 |
'label' => { ARGCOUNT => ARGCOUNT_LIST }, |
'label' => { ARGCOUNT => ARGCOUNT_LIST }, |
143 |
'field' => { ARGCOUNT => ARGCOUNT_LIST } |
'field' => { ARGCOUNT => ARGCOUNT_LIST }, |
144 |
|
'fkey_desc' => { ARGCOUNT => ARGCOUNT_LIST } |
145 |
); |
); |
146 |
|
|
147 |
$config->file(pop @ARGV); |
$config->file(pop @ARGV); |
148 |
$config->args(); |
$config->args(); |
149 |
|
|
150 |
my ($zot, $skel, @tables, @histables, @conditions); |
my ($zot, $skel, @tables, @histables, @conditions, @datasources); |
151 |
|
|
152 |
open SKELETON, $config->skeleton |
open SKELETON, $config->skeleton |
153 |
or die("Unable to open skeleton " . $config->skeleton() ); |
or die("Unable to open skeleton " . $config->skeleton() ); |
186 |
if (!$table) |
if (!$table) |
187 |
{ |
{ |
188 |
($table) = grep $_->rel($field), @tables; |
($table) = grep $_->rel($field), @tables; |
189 |
|
my $fkey_desc = shift @{$config->fkey_desc}; |
190 |
|
$results{'fkey'}[$i] = sprintf( 'foreign_key="%sDataSource._table" foreign_key_description="%s" style="dropdown"', |
191 |
|
$field, |
192 |
|
$fkey_desc ); |
193 |
|
push @datasources, fkey_datasource($config->database, $table->rel($field)); |
194 |
} |
} |
195 |
print STDERR Dumper [ $table, $field, \@tables ]; |
my $attr = $table->attr($field) || $zot->table($table->rel($field))->attr('id'); |
|
my $attr = $table->attr($field); |
|
196 |
my $width = 0; |
my $width = 0; |
197 |
|
|
198 |
if ($attr eq 'text') |
if ($attr eq 'text') |
215 |
$results{'search_x'}[0] = 1; |
$results{'search_x'}[0] = 1; |
216 |
$results{'search_x'}[$_] = $results{'search_x'}[$_-1] + $results{'search_width'}[$_-1] |
$results{'search_x'}[$_] = $results{'search_x'}[$_-1] + $results{'search_width'}[$_-1] |
217 |
foreach (1..$#{ $results{'search_width'} }); |
foreach (1..$#{ $results{'search_width'} }); |
218 |
|
$results{'datasources'} = join '', @datasources; |
219 |
|
|
220 |
foreach my $i (0..$#{ $results{'field'} }) |
foreach my $i (0..$#{ $results{'field'} }) |
221 |
{ |
{ |
222 |
|
$results{'fkey'}[$i] ||= ''; |
223 |
my $field = $results{'field'}[$i]; |
my $field = $results{'field'}[$i]; |
224 |
my ($table) = grep $_->attr($field), @tables; |
my ($table) = grep $_->attr($field), @tables; |
225 |
if (!$table) |
if (!$table) |
226 |
{ |
{ |
227 |
($table) = grep $_->rel($field), @tables; |
($table) = grep $_->rel($field), @tables; |
228 |
} |
if (! $results{'fkey'}[$i]) |
229 |
my $attr = $table->attr($field); |
{ |
230 |
|
my $fkey_desc = shift @{$config->fkey_desc}; |
231 |
|
$results{'fkey'}[$i] = sprintf( 'foreign_key="%sDataSource._table" foreign_key_description="%s" style="dropdown"', |
232 |
|
$field, |
233 |
|
$fkey_desc ); |
234 |
|
push @datasources, fkey_datasource($config->database, $table->rel($field)); |
235 |
|
} |
236 |
|
} |
237 |
|
my $attr = $table->attr($field) || $zot->table($table->rel($field))->attr('id'); |
238 |
if ($attr eq 'text') |
if ($attr eq 'text') |
239 |
{ |
{ |
240 |
$results{'width'}[$i] ||= $DEFAULT_TEXT_WIDTH; |
$results{'width'}[$i] ||= $DEFAULT_TEXT_WIDTH; |
252 |
$results{'height'}[$i] ||= 1; |
$results{'height'}[$i] ||= 1; |
253 |
} |
} |
254 |
$results{'fqdn'}[$i] ||= sprintf "%s.%s", $table->name, $field; |
$results{'fqdn'}[$i] ||= sprintf "%s.%s", $table->name, $field; |
255 |
|
$results{'name'}[$i] ||= sprintf "%s%s", $table->name, ucfirst $field; |
256 |
} |
} |
257 |
|
|
258 |
$skel =~ s/\@\_DO\_SEARCHERS\_\@(.*?)\@\_DONE\_\@/repeat($1, $results{'search_by'})/ges; |
$skel =~ s/\@\_DO\_SEARCHERS\_\@(.*?)\@\_DONE\_\@/repeat($1, $results{'search_by'})/ges; |