119 |
return Strix->new({ instance => $instance }); |
return Strix->new({ instance => $instance }); |
120 |
} |
} |
121 |
|
|
122 |
=head2 sitemap |
sub strix_link { |
123 |
|
my ( $url, $label ) = @_; |
124 |
|
hyperlink( |
125 |
|
url => 'http://' . get('instance') . '.cms-qa.skole.hr' . $url, |
126 |
|
label => $label || $url, |
127 |
|
target => 'strix', |
128 |
|
); |
129 |
|
} |
130 |
|
|
131 |
|
=head2 navigation |
132 |
|
|
133 |
=cut |
=cut |
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 => 'strix-site', |
146 |
my $sitemap = strix->site_navigation( $site_id ); |
path => '/strix/site' |
147 |
|
); |
|
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'), |
|
|
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 |
|
|
152 |
|
|
153 |
=cut |
=cut |
154 |
|
|
155 |
template 'layout' => page { |
template 'layout' => sub { |
156 |
|
|
157 |
my $url = get('url') || '/'; |
my $url = get('url') || '/'; |
158 |
|
|
160 |
|
|
161 |
warn dump( $category ); |
warn dump( $category ); |
162 |
|
|
163 |
title is _('Layout %1 : %2', |
strix_link( $category->{url}, $category->{naziv} ); |
|
$category->{sitename}, |
|
|
$category->{naziv}, |
|
|
); |
|
|
|
|
|
render_region( |
|
|
name => 'selected-instances', |
|
|
path => '/strix/selected-instances' |
|
|
); |
|
|
|
|
|
hyperlink( |
|
|
url => 'http://' . $category->{sitename} . '/' . $category->{url}, |
|
|
label => $category->{naziv}, |
|
|
); |
|
164 |
|
|
165 |
my $layout = strix->layout( $url ); |
my $layout = strix->layout( $url ); |
166 |
|
|
238 |
table { |
table { |
239 |
while (my $strix = $search->next) { |
while (my $strix = $search->next) { |
240 |
row { |
row { |
241 |
|
cell { show( 'instance-op', 'Create', '+', $strix->instance ) } |
242 |
cell { tt { $strix->instance } } |
cell { tt { $strix->instance } } |
243 |
cell { $strix->_site_name } |
cell { $strix->_site_name } |
|
cell { show( 'instance-op', 'Create', '+', $strix->instance ) } |
|
244 |
} |
} |
245 |
} |
} |
246 |
} |
} |
260 |
# warn "## IN selected-instances ",dump( @_ ); |
# warn "## IN selected-instances ",dump( @_ ); |
261 |
|
|
262 |
if ( my $op = get 'op' ) { |
if ( my $op = get 'op' ) { |
263 |
my $op_instance = get 'op_instance' or die "no op_instance?"; |
my $op_instance = get 'op_instance'; |
264 |
|
return unless $op_instance; |
265 |
warn "# selected-instances $op on $op_instance"; |
warn "# selected-instances $op on $op_instance"; |
266 |
|
|
267 |
my $a; |
my $a; |
304 |
if ( $selected->count > 0 ) { |
if ( $selected->count > 0 ) { |
305 |
|
|
306 |
my $instance = get('instance'); |
my $instance = get('instance'); |
307 |
|
warn "# selected-instances -- selected: $instance\n"; |
308 |
|
|
309 |
div { _('%1 instances selected', $selected->count ) }; |
div { _('%1 instances selected', $selected->count ) }; |
310 |
table { |
table { |
361 |
|
|
362 |
}; |
}; |
363 |
|
|
364 |
|
=head2 site |
365 |
|
|
366 |
|
=cut |
367 |
|
|
368 |
|
template 'site' => sub { |
369 |
|
|
370 |
|
my $action = new_action( |
371 |
|
class => 'StrixSelectSite', |
372 |
|
moniker => 'strix-select-site', |
373 |
|
); |
374 |
|
|
375 |
|
warn "# action = ", dump( $action ); |
376 |
|
|
377 |
|
warn "# argument_values = ", dump( $action->argument_values ); |
378 |
|
|
379 |
|
if ( ! $action->argument_value('instance') ) { |
380 |
|
$action->argument_value( 'instance', get('instance') ); |
381 |
|
warn "# run action with instance\n"; |
382 |
|
$action->run; |
383 |
|
} |
384 |
|
|
385 |
|
my $magic = [ |
386 |
|
{ submit => $action, refresh_self => 1 }, |
387 |
|
# this is basically a closure |
388 |
|
{ refresh => 'selected-instances', path => '/strix/selected-instances', args => { |
389 |
|
instance => { result_of => $action, name => 'instance' } |
390 |
|
} }, |
391 |
|
{ refresh => 'strix-site-layout', path => '/__jifty/empty' }, |
392 |
|
]; |
393 |
|
|
394 |
|
form { |
395 |
|
render_param( $action, 'instance', onchange => $magic ); |
396 |
|
render_param( $action, 'site_id', onchange => $magic ); |
397 |
|
form_submit( label => _('Show navigation'), onclick => $magic ); |
398 |
|
}; |
399 |
|
|
400 |
|
warn "## select-site action ",dump( $action->result ); |
401 |
|
|
402 |
|
render_region( |
403 |
|
name => 'layout', |
404 |
|
path => '/__jifty/empty', |
405 |
|
); |
406 |
|
|
407 |
|
if ( my $site_id = $action->result->content('site_id') ) { |
408 |
|
show('navigation-tree', $action->result->content('instance'), $site_id); |
409 |
|
} |
410 |
|
}; |
411 |
|
|
412 |
|
=head1 PRIVATE TEMPLATES |
413 |
|
|
414 |
|
=head2 navigation-tree-category |
415 |
|
|
416 |
|
show('navigation-tree-category',$kat_row); |
417 |
|
|
418 |
|
=cut |
419 |
|
|
420 |
|
private template 'navigation-tree-category' => sub { |
421 |
|
my $self = shift; |
422 |
|
#warn "## navigation-tree-category",dump( @_ ); |
423 |
|
my $p = shift; |
424 |
|
strix_link( $p->{url}, $p->{naziv} ); |
425 |
|
if ( $p->{type} eq 'category' ) { |
426 |
|
outs_raw(' '); |
427 |
|
hyperlink( |
428 |
|
# url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), |
429 |
|
onclick => { |
430 |
|
region => 'strix-site-layout', # FIXME do we have to hard-code region name here? |
431 |
|
replace_with => '/strix/layout', |
432 |
|
args => { |
433 |
|
url => $p->{url}, |
434 |
|
instance => get('instance'), |
435 |
|
} |
436 |
|
}, |
437 |
|
label => _('layout'), |
438 |
|
class => 'layout', |
439 |
|
); |
440 |
|
} |
441 |
|
}; |
442 |
|
|
443 |
|
=head2 navigation-tree |
444 |
|
|
445 |
|
show('navigation-tree',$instance,$site_id); |
446 |
|
|
447 |
|
=cut |
448 |
|
|
449 |
|
private template 'navigation-tree' => sub { |
450 |
|
my $self = shift; |
451 |
|
my ( $instance, $site_id ) = @_; |
452 |
|
|
453 |
|
warn ">>>> instance: $instance site_id: $site_id"; |
454 |
|
|
455 |
|
set 'instance' => $instance; |
456 |
|
|
457 |
|
|
458 |
|
sub children { |
459 |
|
my $c = shift; |
460 |
|
return unless defined $c->{children}; |
461 |
|
ul { |
462 |
|
foreach my $p ( @{ $c->{children} } ) { |
463 |
|
li { |
464 |
|
if ( defined( $p->{class} ) ) { |
465 |
|
{ class is $p->{class} }; |
466 |
|
} |
467 |
|
show( 'navigation-tree-category', $p ); |
468 |
|
children( $p ); |
469 |
|
} |
470 |
|
} |
471 |
|
} |
472 |
|
} |
473 |
|
|
474 |
|
my $strix = Strix->new({ instance => $instance }); |
475 |
|
|
476 |
|
my $navigation = $strix->site_navigation( $site_id ); |
477 |
|
#warn "## navigation = ",dump( $navigation ); |
478 |
|
if ( $navigation ) { |
479 |
|
ul { |
480 |
|
foreach my $p ( @$navigation ) { |
481 |
|
li { |
482 |
|
show( 'navigation-tree-category', $p ); |
483 |
|
children( $p ); |
484 |
|
} |
485 |
|
} |
486 |
|
} |
487 |
|
} else { |
488 |
|
div { |
489 |
|
{ class is 'note error' } |
490 |
|
_('No navigation found for instance %1 site_id %2', $instance, $site_id) |
491 |
|
} |
492 |
|
|
493 |
|
} |
494 |
|
|
495 |
|
}; |
496 |
|
|
497 |
1; |
1; |