119 |
return Strix->new({ instance => $instance }); |
return Strix->new({ instance => $instance }); |
120 |
} |
} |
121 |
|
|
122 |
=head2 sitemap |
=head2 navigation |
123 |
|
|
124 |
=cut |
=cut |
125 |
|
|
132 |
); |
); |
133 |
} |
} |
134 |
|
|
135 |
template 'sitemap' => page { |
template 'navigation' => page { |
136 |
|
|
137 |
title is _('Sitemap %1', get('instance')); |
title is _('Site navigation'); |
138 |
|
|
139 |
render_region( |
render_region( |
140 |
name => 'selected-instances', |
name => 'selected-instances', |
141 |
path => '/strix/selected-instances' |
path => '/strix/selected-instances' |
142 |
); |
); |
143 |
|
|
144 |
my $site_id = get('site_id') || 1; |
render_region( |
145 |
|
name => 'select-strix-site', |
146 |
my $sitemap = strix->site_navigation( $site_id ); |
path => '/strix/select-site' |
147 |
|
); |
|
sub full_url { |
|
|
my $p = shift; |
|
|
strix_link( $p->{url}, $p->{naziv} ); |
|
|
if ( $p->{type} eq 'category' ) { |
|
|
outs_raw(' '); |
|
|
hyperlink( |
|
|
url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), |
|
|
label => _('layout'), |
|
|
class => '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 ); |
|
|
} |
|
|
} |
|
|
} |
|
148 |
|
|
149 |
}; |
}; |
150 |
|
|
248 |
table { |
table { |
249 |
while (my $strix = $search->next) { |
while (my $strix = $search->next) { |
250 |
row { |
row { |
251 |
|
cell { show( 'instance-op', 'Create', '+', $strix->instance ) } |
252 |
cell { tt { $strix->instance } } |
cell { tt { $strix->instance } } |
253 |
cell { $strix->_site_name } |
cell { $strix->_site_name } |
|
cell { show( 'instance-op', 'Create', '+', $strix->instance ) } |
|
254 |
} |
} |
255 |
} |
} |
256 |
} |
} |
313 |
if ( $selected->count > 0 ) { |
if ( $selected->count > 0 ) { |
314 |
|
|
315 |
my $instance = get('instance'); |
my $instance = get('instance'); |
316 |
|
warn "# selected-instances -- selected: $instance\n"; |
317 |
|
|
318 |
div { _('%1 instances selected', $selected->count ) }; |
div { _('%1 instances selected', $selected->count ) }; |
319 |
table { |
table { |
370 |
|
|
371 |
}; |
}; |
372 |
|
|
373 |
|
=head2 select-site |
374 |
|
|
375 |
|
=cut |
376 |
|
|
377 |
|
template 'select-site' => sub { |
378 |
|
|
379 |
|
my $action = new_action( |
380 |
|
class => 'StrixSelectSite', |
381 |
|
moniker => 'strix-select-site', |
382 |
|
); |
383 |
|
|
384 |
|
warn "# action = ", dump( $action ); |
385 |
|
|
386 |
|
warn "# argument_values = ", dump( $action->argument_values ); |
387 |
|
|
388 |
|
if ( ! $action->argument_value('instance') ) { |
389 |
|
$action->argument_value( 'instance', get('instance') ); |
390 |
|
warn "# run action with instance\n"; |
391 |
|
$action->run; |
392 |
|
} |
393 |
|
|
394 |
|
my $magic = [ |
395 |
|
{ submit => $action, refresh_self => 1 }, |
396 |
|
# this is basically a closure |
397 |
|
{ refresh => 'selected-instances', path => '/strix/selected-instances', args => { |
398 |
|
instance => { result_of => $action, name => 'instance' } |
399 |
|
} } |
400 |
|
]; |
401 |
|
|
402 |
|
form { |
403 |
|
render_param( $action, 'instance', onchange => $magic ); |
404 |
|
render_param( $action, 'site_id', onchange => $magic ); |
405 |
|
form_submit( label => _('Show navigation'), onclick => $magic ); |
406 |
|
}; |
407 |
|
|
408 |
|
warn "## select-site action ",dump( $action->result ); |
409 |
|
|
410 |
|
if ( my $site_id = $action->result->content('site_id') ) { |
411 |
|
show('strix-site-navigation-tree', $action->result->content('instance'), $site_id); |
412 |
|
} |
413 |
|
}; |
414 |
|
|
415 |
|
=head1 PRIVATE TEMPLATES |
416 |
|
|
417 |
|
=head2 strix-site-navigation-tree |
418 |
|
|
419 |
|
show('strix-site-navigation-tree',$instance,$site_id); |
420 |
|
|
421 |
|
=cut |
422 |
|
|
423 |
|
private template 'strix-site-navigation-tree' => sub { |
424 |
|
my $self = shift; |
425 |
|
my ( $instance, $site_id ) = @_; |
426 |
|
|
427 |
|
warn ">>>> instance: $instance site_id: $site_id"; |
428 |
|
|
429 |
|
set 'instance' => $instance; |
430 |
|
|
431 |
|
sub full_url { |
432 |
|
my $p = shift; |
433 |
|
strix_link( $p->{url}, $p->{naziv} ); |
434 |
|
if ( $p->{type} eq 'category' ) { |
435 |
|
outs_raw(' '); |
436 |
|
hyperlink( |
437 |
|
url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), |
438 |
|
label => _('layout'), |
439 |
|
class => 'layout', |
440 |
|
); |
441 |
|
} |
442 |
|
} |
443 |
|
|
444 |
|
sub children { |
445 |
|
my $c = shift; |
446 |
|
return unless defined $c->{children}; |
447 |
|
ul { |
448 |
|
foreach my $p ( @{ $c->{children} } ) { |
449 |
|
li { |
450 |
|
{ class is $p->{class} }; |
451 |
|
full_url( $p ); |
452 |
|
children( $p ); |
453 |
|
} |
454 |
|
} |
455 |
|
} |
456 |
|
} |
457 |
|
|
458 |
|
my $strix = Strix->new({ instance => $instance }); |
459 |
|
|
460 |
|
my @navigation = @{ $strix->site_navigation( $site_id ) }; |
461 |
|
if ( @navigation ) { |
462 |
|
ul { |
463 |
|
foreach my $p ( @navigation ) { |
464 |
|
li { |
465 |
|
full_url( $p ); |
466 |
|
children( $p ); |
467 |
|
} |
468 |
|
} |
469 |
|
} |
470 |
|
} else { |
471 |
|
div { |
472 |
|
{ class is 'note error' } |
473 |
|
_('No navigation found for instance %1 site_id %2', $instance, $site_id) |
474 |
|
} |
475 |
|
|
476 |
|
} |
477 |
|
|
478 |
|
}; |
479 |
|
|
480 |
1; |
1; |