119 |
return Strix->new({ instance => $instance }); |
return Strix->new({ instance => $instance }); |
120 |
} |
} |
121 |
|
|
|
=head2 sitemap |
|
|
|
|
|
=cut |
|
|
|
|
122 |
sub strix_link { |
sub strix_link { |
123 |
my ( $url, $label ) = @_; |
my ( $url, $label ) = @_; |
124 |
hyperlink( |
hyperlink( |
128 |
); |
); |
129 |
} |
} |
130 |
|
|
131 |
template 'sitemap' => page { |
=head2 navigation |
|
|
|
|
title is _('Sitemap %1', get('instance')); |
|
|
|
|
|
render_region( |
|
|
name => 'selected-instances', |
|
|
path => '/strix/selected-instances' |
|
|
); |
|
|
|
|
|
my $site_id = get('site_id') || 1; |
|
|
|
|
|
my $sitemap = strix->site_navigation( $site_id ); |
|
|
|
|
|
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 ); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
=head2 layout |
|
132 |
|
|
133 |
=cut |
=cut |
134 |
|
|
135 |
template 'layout' => page { |
template 'navigation' => page { |
|
|
|
|
my $url = get('url') || '/'; |
|
|
|
|
|
my $category = strix->category( $url ); |
|
136 |
|
|
137 |
warn dump( $category ); |
title is _('Site navigation'); |
|
|
|
|
title is _('Layout %1 : %2', |
|
|
$category->{sitename}, |
|
|
$category->{naziv}, |
|
|
); |
|
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 |
strix_link( $category->{url}, $category->{naziv} ); |
render_region( |
145 |
|
name => 'strix-site', |
146 |
my $layout = strix->layout( $url ); |
path => '/strix/site' |
147 |
|
); |
|
pre { |
|
|
dump( $layout ); |
|
|
} |
|
148 |
|
|
149 |
}; |
}; |
150 |
|
|
216 |
table { |
table { |
217 |
while (my $strix = $search->next) { |
while (my $strix = $search->next) { |
218 |
row { |
row { |
219 |
|
cell { show( 'instance-op', 'Create', '+', $strix->instance ) } |
220 |
cell { tt { $strix->instance } } |
cell { tt { $strix->instance } } |
221 |
cell { $strix->_site_name } |
cell { $strix->_site_name } |
|
cell { show( 'instance-op', 'Create', '+', $strix->instance ) } |
|
222 |
} |
} |
223 |
} |
} |
224 |
} |
} |
238 |
# warn "## IN selected-instances ",dump( @_ ); |
# warn "## IN selected-instances ",dump( @_ ); |
239 |
|
|
240 |
if ( my $op = get 'op' ) { |
if ( my $op = get 'op' ) { |
241 |
my $op_instance = get 'op_instance' or die "no op_instance?"; |
my $op_instance = get 'op_instance'; |
242 |
|
return unless $op_instance; |
243 |
warn "# selected-instances $op on $op_instance"; |
warn "# selected-instances $op on $op_instance"; |
244 |
|
|
245 |
my $a; |
my $a; |
282 |
if ( $selected->count > 0 ) { |
if ( $selected->count > 0 ) { |
283 |
|
|
284 |
my $instance = get('instance'); |
my $instance = get('instance'); |
285 |
|
warn "# selected-instances -- selected: $instance\n"; |
286 |
|
|
287 |
div { _('%1 instances selected', $selected->count ) }; |
div { _('%1 instances selected', $selected->count ) }; |
288 |
table { |
table { |
339 |
|
|
340 |
}; |
}; |
341 |
|
|
342 |
|
=head2 site |
343 |
|
|
344 |
|
=cut |
345 |
|
|
346 |
|
template 'site' => sub { |
347 |
|
|
348 |
|
my $action = new_action( |
349 |
|
class => 'StrixSelectSite', |
350 |
|
moniker => 'strix-select-site', |
351 |
|
); |
352 |
|
|
353 |
|
warn "# action = ", dump( $action ); |
354 |
|
|
355 |
|
warn "# argument_values = ", dump( $action->argument_values ); |
356 |
|
|
357 |
|
if ( ! $action->argument_value('instance') ) { |
358 |
|
$action->argument_value( 'instance', get('instance') ); |
359 |
|
warn "# run action with instance\n"; |
360 |
|
$action->run; |
361 |
|
} |
362 |
|
|
363 |
|
my $magic = [ |
364 |
|
{ submit => $action, refresh_self => 1 }, |
365 |
|
# this is basically a closure |
366 |
|
{ refresh => 'selected-instances', path => '/strix/selected-instances', args => { |
367 |
|
instance => { result_of => $action, name => 'instance' } |
368 |
|
} }, |
369 |
|
{ refresh => 'strix-site-layout', path => '/__jifty/empty' }, |
370 |
|
]; |
371 |
|
|
372 |
|
form { |
373 |
|
render_param( $action, 'instance', onchange => $magic ); |
374 |
|
render_param( $action, 'site_id', onchange => $magic ); |
375 |
|
form_submit( label => _('Show navigation'), onclick => $magic ); |
376 |
|
}; |
377 |
|
|
378 |
|
warn "## select-site action ",dump( $action->result ); |
379 |
|
|
380 |
|
render_region( |
381 |
|
name => 'layout', |
382 |
|
path => '/__jifty/empty', |
383 |
|
); |
384 |
|
|
385 |
|
if ( my $site_id = $action->result->content('site_id') ) { |
386 |
|
show('navigation-tree', $action->result->content('instance'), $site_id); |
387 |
|
} |
388 |
|
}; |
389 |
|
|
390 |
|
=head2 layout |
391 |
|
|
392 |
|
Shows layout for C<url> |
393 |
|
|
394 |
|
=cut |
395 |
|
|
396 |
|
template 'layout' => sub { |
397 |
|
|
398 |
|
my $url = get('url') || '/'; |
399 |
|
my $category = strix->category( $url ); |
400 |
|
my $layout = strix->layout( $url ); |
401 |
|
|
402 |
|
h1 { $category->{naziv} } |
403 |
|
pre { |
404 |
|
dump( $layout ); |
405 |
|
} |
406 |
|
|
407 |
|
}; |
408 |
|
|
409 |
|
=head2 category |
410 |
|
|
411 |
|
Show category data for C<url> |
412 |
|
|
413 |
|
=cut |
414 |
|
|
415 |
|
template 'category' => sub { |
416 |
|
|
417 |
|
my $url = get('url') || '/'; |
418 |
|
my $category = strix->category( $url ); |
419 |
|
|
420 |
|
h1 { $category->{naziv} } |
421 |
|
pre { |
422 |
|
dump( $category ); |
423 |
|
} |
424 |
|
|
425 |
|
}; |
426 |
|
|
427 |
|
=head1 PRIVATE TEMPLATES |
428 |
|
|
429 |
|
=head2 navigation-tree-category |
430 |
|
|
431 |
|
show('navigation-tree-category',$kat_row); |
432 |
|
|
433 |
|
=cut |
434 |
|
|
435 |
|
private template 'navigation-tree-category' => sub { |
436 |
|
my $self = shift; |
437 |
|
#warn "## navigation-tree-category",dump( @_ ); |
438 |
|
my $p = shift; |
439 |
|
hyperlink( |
440 |
|
onclick => { |
441 |
|
region => 'strix-site-layout', # FIXME do we have to hard-code region name here? |
442 |
|
replace_with => '/strix/category', |
443 |
|
args => { |
444 |
|
url => $p->{url}, |
445 |
|
instance => get('instance'), |
446 |
|
} |
447 |
|
}, |
448 |
|
label => $p->{naziv}, |
449 |
|
); |
450 |
|
outs_raw(' '); |
451 |
|
if ( $p->{type} eq 'category' ) { |
452 |
|
hyperlink( |
453 |
|
# url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), |
454 |
|
onclick => { |
455 |
|
region => 'strix-site-layout', # FIXME do we have to hard-code region name here? |
456 |
|
replace_with => '/strix/layout', |
457 |
|
args => { |
458 |
|
url => $p->{url}, |
459 |
|
instance => get('instance'), |
460 |
|
} |
461 |
|
}, |
462 |
|
label => _('layout'), |
463 |
|
class => 'layout', |
464 |
|
); |
465 |
|
} |
466 |
|
outs_raw(' '); |
467 |
|
strix_link( $p->{url}, '>>' ); |
468 |
|
}; |
469 |
|
|
470 |
|
=head2 navigation-tree |
471 |
|
|
472 |
|
show('navigation-tree',$instance,$site_id); |
473 |
|
|
474 |
|
=cut |
475 |
|
|
476 |
|
private template 'navigation-tree' => sub { |
477 |
|
my $self = shift; |
478 |
|
my ( $instance, $site_id ) = @_; |
479 |
|
|
480 |
|
warn "## navigation-tree instance: $instance site_id: $site_id"; |
481 |
|
|
482 |
|
set 'instance' => $instance; |
483 |
|
|
484 |
|
sub children { |
485 |
|
my $c = shift; |
486 |
|
return unless defined $c->{children}; |
487 |
|
ul { |
488 |
|
foreach my $p ( @{ $c->{children} } ) { |
489 |
|
li { |
490 |
|
if ( defined( $p->{class} ) ) { |
491 |
|
{ class is $p->{class} }; |
492 |
|
} |
493 |
|
show( 'navigation-tree-category', $p ); |
494 |
|
children( $p ); |
495 |
|
} |
496 |
|
} |
497 |
|
} |
498 |
|
} |
499 |
|
|
500 |
|
my $strix = Strix->new({ instance => $instance }); |
501 |
|
|
502 |
|
my $navigation = $strix->site_navigation( $site_id ); |
503 |
|
#warn "## navigation = ",dump( $navigation ); |
504 |
|
if ( $navigation ) { |
505 |
|
ul { |
506 |
|
{ class is 'navigation' }; |
507 |
|
foreach my $p ( @$navigation ) { |
508 |
|
li { |
509 |
|
show( 'navigation-tree-category', $p ); |
510 |
|
children( $p ); |
511 |
|
} |
512 |
|
} |
513 |
|
} |
514 |
|
} else { |
515 |
|
div { |
516 |
|
{ class is 'note error' } |
517 |
|
_('No navigation found for instance %1 site_id %2', $instance, $site_id) |
518 |
|
} |
519 |
|
|
520 |
|
} |
521 |
|
|
522 |
|
}; |
523 |
|
|
524 |
1; |
1; |