45 |
|
|
46 |
}; |
}; |
47 |
|
|
48 |
=head2 name_diff |
=head2 errors |
49 |
|
|
50 |
=cut |
=cut |
51 |
|
|
52 |
template 'name_diff' => page { |
template 'errors' => page { |
53 |
|
|
54 |
title is _('Strix name differences'); |
title is _('Strix errors'); |
55 |
|
|
56 |
render_region( |
render_region( |
57 |
name => 'selected-instances', |
name => 'selected-instances', |
58 |
path => '/strix/selected-instances' |
path => '/strix/selected-instances' |
59 |
); |
); |
60 |
|
|
61 |
|
h2 { _('Name differences') } |
62 |
|
|
63 |
my $name_diff = A3C::SQL->new({ query => qq{ |
my $name_diff = A3C::SQL->new({ query => qq{ |
64 |
select |
select |
65 |
instance,hreduorgurl, |
instance,hreduorgurl, |
94 |
|
|
95 |
}; |
}; |
96 |
|
|
97 |
|
=head2 instances |
98 |
|
|
99 |
|
=cut |
100 |
|
|
101 |
|
template 'instances' => page { |
102 |
|
|
103 |
|
title is _('Strix instances'); |
104 |
|
|
105 |
|
my $sql = A3C::SQL->new({ query => qq{ |
106 |
|
select |
107 |
|
hrEduOrgUrl, o, l, postalAddress, telephoneNumber, facsimileTelephoneNumber |
108 |
|
from strix_instances |
109 |
|
join hr_edu_orgs on cn = instance |
110 |
|
order by l,o |
111 |
|
}}); |
112 |
|
|
113 |
|
if ( $sql->count > 0 ) { |
114 |
|
|
115 |
|
table { |
116 |
|
row { |
117 |
|
th { _('hrEduOrgUrl') } |
118 |
|
th { _('o') } |
119 |
|
th { _('l') } |
120 |
|
th { _('postalAddress') } |
121 |
|
th { _('telephoneNumber') } |
122 |
|
th { _('facsimileTelephoneNumber') } |
123 |
|
}; |
124 |
|
while ( my $row = $sql->next ) { |
125 |
|
row { |
126 |
|
cell { outs_raw '<a href="http://' . $row->hrEduOrgUrl . '">' . $row->hrEduOrgUrl . '</a>' } |
127 |
|
cell { $row->o } |
128 |
|
cell { $row->l } |
129 |
|
cell { $row->postalAddress } |
130 |
|
cell { $row->telephoneNumber } |
131 |
|
cell { $row->facsimileTelephoneNumber } |
132 |
|
} |
133 |
|
} |
134 |
|
} |
135 |
|
|
136 |
|
div { _("Found total of %1 strix instances", $sql->count) } |
137 |
|
|
138 |
|
} else { |
139 |
|
div { _("Can't find any strix instances") } |
140 |
|
} |
141 |
|
|
142 |
|
}; |
143 |
|
|
144 |
=head2 sql |
=head2 sql |
145 |
|
|
146 |
Execute SQL query on instance |
Execute SQL query on instance |
164 |
}; |
}; |
165 |
|
|
166 |
sub strix { |
sub strix { |
167 |
my $instance = get('instance') || shift || 'new'; |
my $instance = get('instance'); |
168 |
return Strix->new({ instance => $instance }); |
return Strix->new({ instance => $instance }); |
169 |
} |
} |
170 |
|
|
171 |
=head2 sitemap |
sub strix_link { |
172 |
|
my ( $url, $label ) = @_; |
173 |
|
hyperlink( |
174 |
|
url => 'http://' . get('instance') . Jifty->config->app('strix')->{domain} . $url, |
175 |
|
label => $label || $url, |
176 |
|
target => 'strix', |
177 |
|
); |
178 |
|
} |
179 |
|
|
180 |
|
=head2 navigation |
181 |
|
|
182 |
=cut |
=cut |
183 |
|
|
184 |
template 'sitemap' => page { |
template 'navigation' => page { |
185 |
|
|
186 |
title is _('Sitemap'); |
title is _('Site navigation'); |
187 |
|
|
188 |
render_region( |
render_region( |
189 |
name => 'selected-instances', |
name => 'selected-instances', |
190 |
path => '/strix/selected-instances' |
path => '/strix/selected-instances' |
191 |
); |
); |
192 |
|
|
193 |
my $site_id = get('site_id') || 1; |
render_region( |
194 |
|
name => 'strix-site', |
195 |
my $sitemap = strix->site_navigation( $site_id ); |
path => '/strix/site' |
|
|
|
|
sub full_url { |
|
|
my $p = shift; |
|
|
hyperlink( |
|
|
url => 'http://new.cms-qa.skole.hr' . $p->{url}, |
|
|
label => $p->{naziv}, |
|
|
); |
|
|
if ( $p->{type} eq 'category' ) { |
|
|
outs_raw(' '); |
|
|
hyperlink( |
|
|
url => '/strix/layout?url=' . $p->{url}, |
|
|
label => '[layout]', |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
sub children { |
|
|
my $c = shift; |
|
|
return unless defined $c->{children}; |
|
|
ul { |
|
|
foreach my $p ( @{ $c->{children} } ) { |
|
|
li { |
|
|
{ class is $p->{class} }; |
|
|
full_url( $p ); |
|
|
children( $p ); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
ul { |
|
|
foreach my $p ( @$sitemap ) { |
|
|
li { |
|
|
full_url( $p ); |
|
|
children( $p ); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
=head2 layout |
|
|
|
|
|
=cut |
|
|
|
|
|
template 'layout' => page { |
|
|
|
|
|
my $url = get('url') || '/'; |
|
|
|
|
|
my $category = strix->category( $url ); |
|
|
|
|
|
warn dump( $category ); |
|
|
|
|
|
title is _('Layout %1 : %2', |
|
|
$category->{sitename}, |
|
|
$category->{naziv}, |
|
|
); |
|
|
|
|
|
hyperlink( |
|
|
url => 'http://' . $category->{sitename} . '/' . $category->{url}, |
|
|
label => $category->{naziv}, |
|
196 |
); |
); |
197 |
|
|
|
my $layout = strix->layout( $url ); |
|
|
|
|
|
pre { |
|
|
dump( $layout ); |
|
|
} |
|
|
|
|
198 |
}; |
}; |
199 |
|
|
200 |
=head1 REGIONS |
=head1 REGIONS |
207 |
|
|
208 |
template 'execute-sql' => sub { |
template 'execute-sql' => sub { |
209 |
|
|
210 |
|
my $sql = get('sql') || Jifty->web->session->get('sql'); |
211 |
|
warn ">>>> sql = $sql"; |
212 |
|
my $instance = get('instance'); |
213 |
|
warn ">>>> instance = $instance"; |
214 |
|
|
215 |
my $action = new_action( |
my $action = new_action( |
216 |
class => 'StrixSQL', |
class => 'StrixSQL', |
217 |
moniker => 'strix-sql', |
moniker => 'strix-sql', |
218 |
sticky_on_success => 1, |
sticky_on_success => 1, |
219 |
sticky_on_failure => 1, |
sticky_on_failure => 1, |
220 |
arguments => { |
arguments => { |
221 |
instance => get('instance') |
instance => $instance, |
222 |
} |
sql => $sql, |
223 |
|
}, |
224 |
); |
); |
225 |
|
|
226 |
form { |
form { |
227 |
render_action( $action => [ 'instance', 'sql' ] ); |
render_action( $action, [ 'instance', 'sql' ] ); |
228 |
form_submit( label => _('Execute SQL') ); |
form_submit( label => _('Execute SQL') ); |
229 |
}; |
}; |
230 |
|
|
231 |
if ( my $sql = $action->result->content('sql') ) { |
if ( my $sql = $action->result->content('sql') ) { |
232 |
div { _('Found %1 results', $sql->count ) } |
Jifty->web->session->set( sql => $sql->query ); |
233 |
|
div { _('Found %1 results for %2', $sql->count, $instance ) } |
234 |
table { |
table { |
235 |
row { map { th { $_ } } $sql->_column_names }; |
row { map { th { $_ } } $sql->_column_names }; |
236 |
while (my $row = $sql->next) { |
while (my $row = $sql->next) { |
242 |
} |
} |
243 |
} |
} |
244 |
} |
} |
245 |
|
warn ">>>> sql (at end) = ",Jifty->web->session->get('sql'); |
246 |
}; |
}; |
247 |
|
|
248 |
=head2 search-instances |
=head2 search-instances |
273 |
table { |
table { |
274 |
while (my $strix = $search->next) { |
while (my $strix = $search->next) { |
275 |
row { |
row { |
276 |
|
cell { show( 'instance-op', 'Create', '+', $strix->instance ) } |
277 |
cell { tt { $strix->instance } } |
cell { tt { $strix->instance } } |
278 |
cell { $strix->_site_name } |
cell { $strix->_site_name } |
|
cell { show( 'instance-op', 'Create', '+', $strix->instance ) } |
|
279 |
} |
} |
280 |
} |
} |
281 |
} |
} |
292 |
template 'selected-instances' => sub { |
template 'selected-instances' => sub { |
293 |
my $self = shift; |
my $self = shift; |
294 |
|
|
295 |
warn "## IN selected-instances ",dump( @_ ); |
# warn "## IN selected-instances ",dump( @_ ); |
296 |
|
|
297 |
if ( my $op = get 'op' ) { |
if ( my $op = get 'op' ) { |
298 |
my $instance = get 'instance' or die "no instance?"; |
my $op_instance = get 'op_instance'; |
299 |
warn "# selected-instances $op on $instance"; |
return unless $op_instance; |
300 |
|
warn "# selected-instances $op on $op_instance"; |
301 |
|
|
302 |
my $a; |
my $a; |
303 |
|
|
307 |
class => $op . 'StrixInstanceSelection', |
class => $op . 'StrixInstanceSelection', |
308 |
moniker => $op, |
moniker => $op, |
309 |
arguments => { |
arguments => { |
310 |
instance => $instance, |
instance => $op_instance, |
311 |
by_user => $self->current_user->id, |
by_user => $self->current_user->id, |
312 |
}, |
}, |
313 |
); |
); |
315 |
} elsif ( $op eq 'Delete' ) { |
} elsif ( $op eq 'Delete' ) { |
316 |
|
|
317 |
my $strix = A3C::Model::StrixInstanceSelection->new; |
my $strix = A3C::Model::StrixInstanceSelection->new; |
318 |
$strix->load_by_cols( instance => $instance, by_user => $self->current_user->id ); |
$strix->load_by_cols( instance => $op_instance, by_user => $self->current_user->id ); |
319 |
die "can't find instance $instance" unless $strix->id; |
warn "can't find instance $op_instance" unless $strix->id; |
320 |
$a = $strix->as_delete_action; |
$a = $strix->as_delete_action; |
321 |
|
|
322 |
} |
} |
323 |
warn "# argument_values = ",dump( $a->argument_values ); |
# warn "# argument_values = ",dump( $a->argument_values ); |
324 |
$a->run; |
$a->run; |
325 |
warn "can't $op instance $instance" unless $a->result->success; |
|
326 |
|
if ( $a->result->error ) { |
327 |
|
div { |
328 |
|
{ class is 'note error' } |
329 |
|
$a->result->error; |
330 |
|
} |
331 |
|
} |
332 |
|
|
333 |
|
set( op => '' ); |
334 |
} |
} |
335 |
|
|
336 |
my $selected = A3C::Model::StrixInstanceSelectionCollection->new; |
my $selected = A3C::Model::StrixInstanceSelectionCollection->new; |
338 |
|
|
339 |
if ( $selected->count > 0 ) { |
if ( $selected->count > 0 ) { |
340 |
|
|
341 |
|
my $instance = get('instance'); |
342 |
|
warn "# selected-instances -- selected: $instance\n"; |
343 |
|
|
344 |
div { _('%1 instances selected', $selected->count ) }; |
div { _('%1 instances selected', $selected->count ) }; |
345 |
table { |
table { |
346 |
while (my $s = $selected->next) { |
while (my $s = $selected->next) { |
347 |
row { |
row { |
348 |
cell { tt { |
cell { tt { |
349 |
hyperlink( |
if ( $s->instance->instance eq $instance ) { |
350 |
url => '?instance=' . $s->instance->instance, |
b { $instance } |
351 |
label => $s->instance->instance |
} else { |
352 |
) |
hyperlink( |
353 |
|
url => '?instance=' . $s->instance->instance, |
354 |
|
label => $s->instance->instance |
355 |
|
) |
356 |
|
} |
357 |
} } |
} } |
358 |
cell { $s->instance->_site_name } |
cell { $s->instance->_site_name } |
359 |
cell { show( 'instance-op', 'Delete', '-', $s->instance->instance ) } |
cell { show( 'instance-op', 'Delete', '-', $s->instance->instance ) } |
376 |
template 'instance-op' => sub { |
template 'instance-op' => sub { |
377 |
my $self = shift; |
my $self = shift; |
378 |
|
|
379 |
warn "# instance-op = ",dump( @_ ); |
# warn "# instance-op = ",dump( @_ ); |
380 |
|
|
381 |
my ( $op, $label, $instance ) = @_; |
my ( $op, $label, $instance ) = @_; |
382 |
|
|
387 |
refresh => 'selected-instances', |
refresh => 'selected-instances', |
388 |
path => '/strix/selected-instances', |
path => '/strix/selected-instances', |
389 |
args => { |
args => { |
390 |
instance => $instance, |
op_instance => $instance, |
391 |
op => $op, |
op => $op, |
392 |
} |
} |
393 |
}, |
}, |
396 |
|
|
397 |
}; |
}; |
398 |
|
|
399 |
|
=head2 site |
400 |
|
|
401 |
|
=cut |
402 |
|
|
403 |
|
template 'site' => sub { |
404 |
|
|
405 |
|
my $action = new_action( |
406 |
|
class => 'StrixSelectSite', |
407 |
|
moniker => 'strix-select-site', |
408 |
|
); |
409 |
|
|
410 |
|
warn "# action = ", dump( $action ); |
411 |
|
|
412 |
|
warn "# argument_values = ", dump( $action->argument_values ); |
413 |
|
|
414 |
|
if ( ! $action->argument_value('instance') ) { |
415 |
|
$action->argument_value( 'instance', get('instance') ); |
416 |
|
warn "# run action with instance\n"; |
417 |
|
$action->run; |
418 |
|
} |
419 |
|
|
420 |
|
my $magic = [ |
421 |
|
{ submit => $action, refresh_self => 1 }, |
422 |
|
# this is basically a closure |
423 |
|
{ refresh => 'selected-instances', path => '/strix/selected-instances', args => { |
424 |
|
instance => { result_of => $action, name => 'instance' } |
425 |
|
} }, |
426 |
|
{ refresh => 'strix-site-layout', path => '/__jifty/empty' }, |
427 |
|
]; |
428 |
|
|
429 |
|
form { |
430 |
|
render_param( $action, 'instance', onchange => $magic ); |
431 |
|
render_param( $action, 'site_id', onchange => $magic ); |
432 |
|
form_submit( label => _('Show navigation'), onclick => $magic ); |
433 |
|
}; |
434 |
|
|
435 |
|
warn "## select-site action ",dump( $action->result ); |
436 |
|
|
437 |
|
render_region( |
438 |
|
name => 'layout', |
439 |
|
path => '/__jifty/empty', |
440 |
|
); |
441 |
|
|
442 |
|
if ( my $site_id = $action->result->content('site_id') ) { |
443 |
|
show('navigation-tree', $action->result->content('instance'), $site_id); |
444 |
|
} |
445 |
|
}; |
446 |
|
|
447 |
|
=head2 layout |
448 |
|
|
449 |
|
Shows layout for C<url> |
450 |
|
|
451 |
|
=cut |
452 |
|
|
453 |
|
template 'layout' => sub { |
454 |
|
|
455 |
|
my $url = get('url') || '/'; |
456 |
|
my $category = strix->category( $url ); |
457 |
|
my $layout = strix->layout( $url ); |
458 |
|
|
459 |
|
h1 { $category->{naziv} } |
460 |
|
pre { |
461 |
|
dump( $layout ); |
462 |
|
} |
463 |
|
|
464 |
|
}; |
465 |
|
|
466 |
|
=head2 category |
467 |
|
|
468 |
|
Show category data for C<url> |
469 |
|
|
470 |
|
=cut |
471 |
|
|
472 |
|
template 'category' => sub { |
473 |
|
|
474 |
|
my $url = get('url') || '/'; |
475 |
|
my $category = strix->category( $url ); |
476 |
|
|
477 |
|
h1 { $category->{naziv} } |
478 |
|
pre { |
479 |
|
dump( $category ); |
480 |
|
} |
481 |
|
|
482 |
|
}; |
483 |
|
|
484 |
|
=head1 PRIVATE TEMPLATES |
485 |
|
|
486 |
|
=head2 navigation-tree-category |
487 |
|
|
488 |
|
show('navigation-tree-category',$kat_row); |
489 |
|
|
490 |
|
=cut |
491 |
|
|
492 |
|
private template 'navigation-tree-category' => sub { |
493 |
|
my $self = shift; |
494 |
|
#warn "## navigation-tree-category",dump( @_ ); |
495 |
|
my $p = shift; |
496 |
|
hyperlink( |
497 |
|
onclick => { |
498 |
|
region => 'strix-site-layout', # FIXME do we have to hard-code region name here? |
499 |
|
replace_with => '/strix/category', |
500 |
|
args => { |
501 |
|
url => $p->{url}, |
502 |
|
instance => get('instance'), |
503 |
|
} |
504 |
|
}, |
505 |
|
label => $p->{naziv}, |
506 |
|
); |
507 |
|
outs_raw(' '); |
508 |
|
if ( $p->{type} eq 'category' ) { |
509 |
|
hyperlink( |
510 |
|
# url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), |
511 |
|
onclick => { |
512 |
|
region => 'strix-site-layout', # FIXME do we have to hard-code region name here? |
513 |
|
replace_with => '/strix/layout', |
514 |
|
args => { |
515 |
|
url => $p->{url}, |
516 |
|
instance => get('instance'), |
517 |
|
} |
518 |
|
}, |
519 |
|
label => _('layout'), |
520 |
|
class => 'layout', |
521 |
|
); |
522 |
|
} |
523 |
|
outs_raw(' '); |
524 |
|
strix_link( $p->{url}, '>>' ); |
525 |
|
}; |
526 |
|
|
527 |
|
=head2 navigation-tree |
528 |
|
|
529 |
|
show('navigation-tree',$instance,$site_id); |
530 |
|
|
531 |
|
=cut |
532 |
|
|
533 |
|
private template 'navigation-tree' => sub { |
534 |
|
my $self = shift; |
535 |
|
my ( $instance, $site_id ) = @_; |
536 |
|
|
537 |
|
warn "## navigation-tree instance: $instance site_id: $site_id"; |
538 |
|
|
539 |
|
set 'instance' => $instance; |
540 |
|
|
541 |
|
sub children { |
542 |
|
my $c = shift; |
543 |
|
return unless defined $c->{children}; |
544 |
|
ul { |
545 |
|
foreach my $p ( @{ $c->{children} } ) { |
546 |
|
li { |
547 |
|
if ( defined( $p->{class} ) ) { |
548 |
|
{ class is $p->{class} }; |
549 |
|
} |
550 |
|
show( 'navigation-tree-category', $p ); |
551 |
|
children( $p ); |
552 |
|
} |
553 |
|
} |
554 |
|
} |
555 |
|
} |
556 |
|
|
557 |
|
my $strix = Strix->new({ instance => $instance }); |
558 |
|
|
559 |
|
my $navigation = $strix->site_navigation( $site_id ); |
560 |
|
#warn "## navigation = ",dump( $navigation ); |
561 |
|
if ( $navigation ) { |
562 |
|
ul { |
563 |
|
{ class is 'navigation' }; |
564 |
|
foreach my $p ( @$navigation ) { |
565 |
|
li { |
566 |
|
show( 'navigation-tree-category', $p ); |
567 |
|
children( $p ); |
568 |
|
} |
569 |
|
} |
570 |
|
} |
571 |
|
} else { |
572 |
|
div { |
573 |
|
{ class is 'note error' } |
574 |
|
_('No navigation found for instance %1 site_id %2', $instance, $site_id) |
575 |
|
} |
576 |
|
|
577 |
|
} |
578 |
|
|
579 |
|
}; |
580 |
|
|
581 |
1; |
1; |