92 |
|
|
93 |
}; |
}; |
94 |
|
|
95 |
|
=head2 instances |
96 |
|
|
97 |
|
=cut |
98 |
|
|
99 |
|
template 'instances' => page { |
100 |
|
|
101 |
|
title is _('Strix instances'); |
102 |
|
|
103 |
|
my $sql = A3C::SQL->new({ query => qq{ |
104 |
|
select |
105 |
|
hrEduOrgUrl, o, l, postalAddress, telephoneNumber, facsimileTelephoneNumber |
106 |
|
from strix_instances |
107 |
|
join hr_edu_orgs on cn = instance |
108 |
|
order by l,o |
109 |
|
}}); |
110 |
|
|
111 |
|
if ( $sql->count > 0 ) { |
112 |
|
|
113 |
|
table { |
114 |
|
row { |
115 |
|
th { _('hrEduOrgUrl') } |
116 |
|
th { _('o') } |
117 |
|
th { _('l') } |
118 |
|
th { _('postalAddress') } |
119 |
|
th { _('telephoneNumber') } |
120 |
|
th { _('facsimileTelephoneNumber') } |
121 |
|
}; |
122 |
|
while ( my $row = $sql->next ) { |
123 |
|
row { |
124 |
|
cell { outs_raw '<a href="' . $row->hrEduOrgUrl . '">' . $row->hrEduOrgUrl . '</a>' } |
125 |
|
cell { $row->o } |
126 |
|
cell { $row->l } |
127 |
|
cell { $row->postalAddress } |
128 |
|
cell { $row->telephoneNumber } |
129 |
|
cell { $row->facsimileTelephoneNumber } |
130 |
|
} |
131 |
|
} |
132 |
|
} |
133 |
|
|
134 |
|
div { _("Found total of %1 strix instances", $sql->count) } |
135 |
|
|
136 |
|
} else { |
137 |
|
div { _("Can't find any strix instances") } |
138 |
|
} |
139 |
|
|
140 |
|
}; |
141 |
|
|
142 |
=head2 sql |
=head2 sql |
143 |
|
|
144 |
Execute SQL query on instance |
Execute SQL query on instance |
169 |
sub strix_link { |
sub strix_link { |
170 |
my ( $url, $label ) = @_; |
my ( $url, $label ) = @_; |
171 |
hyperlink( |
hyperlink( |
172 |
url => 'http://' . get('instance') . '.cms-qa.skole.hr' . $url, |
url => 'http://' . get('instance') . Jifty->config->app('strix')->{domain} . $url, |
173 |
label => $label || $url, |
label => $label || $url, |
174 |
target => 'strix', |
target => 'strix', |
175 |
); |
); |
195 |
|
|
196 |
}; |
}; |
197 |
|
|
|
=head2 layout |
|
|
|
|
|
=cut |
|
|
|
|
|
template 'layout' => sub { |
|
|
|
|
|
my $url = get('url') || '/'; |
|
|
|
|
|
my $category = strix->category( $url ); |
|
|
|
|
|
warn dump( $category ); |
|
|
|
|
|
strix_link( $category->{url}, $category->{naziv} ); |
|
|
|
|
|
my $layout = strix->layout( $url ); |
|
|
|
|
|
pre { |
|
|
dump( $layout ); |
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
198 |
=head1 REGIONS |
=head1 REGIONS |
199 |
|
|
200 |
=head2 execute-sql |
=head2 execute-sql |
205 |
|
|
206 |
template 'execute-sql' => sub { |
template 'execute-sql' => sub { |
207 |
|
|
208 |
|
my $sql = get('sql') || Jifty->web->session->get('sql'); |
209 |
|
warn ">>>> sql = $sql"; |
210 |
|
my $instance = get('instance'); |
211 |
|
warn ">>>> instance = $instance"; |
212 |
|
|
213 |
my $action = new_action( |
my $action = new_action( |
214 |
class => 'StrixSQL', |
class => 'StrixSQL', |
215 |
moniker => 'strix-sql', |
moniker => 'strix-sql', |
216 |
sticky_on_success => 1, |
sticky_on_success => 1, |
217 |
sticky_on_failure => 1, |
sticky_on_failure => 1, |
218 |
arguments => { |
arguments => { |
219 |
instance => get('instance') |
instance => $instance, |
220 |
} |
sql => $sql, |
221 |
|
}, |
222 |
); |
); |
223 |
|
|
224 |
form { |
form { |
225 |
render_action( $action => [ 'instance', 'sql' ] ); |
render_action( $action, [ 'instance', 'sql' ] ); |
226 |
form_submit( label => _('Execute SQL') ); |
form_submit( label => _('Execute SQL') ); |
227 |
}; |
}; |
228 |
|
|
229 |
if ( my $sql = $action->result->content('sql') ) { |
if ( my $sql = $action->result->content('sql') ) { |
230 |
div { _('Found %1 results', $sql->count ) } |
Jifty->web->session->set( sql => $sql->query ); |
231 |
|
div { _('Found %1 results for %2', $sql->count, $instance ) } |
232 |
table { |
table { |
233 |
row { map { th { $_ } } $sql->_column_names }; |
row { map { th { $_ } } $sql->_column_names }; |
234 |
while (my $row = $sql->next) { |
while (my $row = $sql->next) { |
240 |
} |
} |
241 |
} |
} |
242 |
} |
} |
243 |
|
warn ">>>> sql (at end) = ",Jifty->web->session->get('sql'); |
244 |
}; |
}; |
245 |
|
|
246 |
=head2 search-instances |
=head2 search-instances |
442 |
} |
} |
443 |
}; |
}; |
444 |
|
|
445 |
|
=head2 layout |
446 |
|
|
447 |
|
Shows layout for C<url> |
448 |
|
|
449 |
|
=cut |
450 |
|
|
451 |
|
template 'layout' => sub { |
452 |
|
|
453 |
|
my $url = get('url') || '/'; |
454 |
|
my $category = strix->category( $url ); |
455 |
|
my $layout = strix->layout( $url ); |
456 |
|
|
457 |
|
h1 { $category->{naziv} } |
458 |
|
pre { |
459 |
|
dump( $layout ); |
460 |
|
} |
461 |
|
|
462 |
|
}; |
463 |
|
|
464 |
|
=head2 category |
465 |
|
|
466 |
|
Show category data for C<url> |
467 |
|
|
468 |
|
=cut |
469 |
|
|
470 |
|
template 'category' => sub { |
471 |
|
|
472 |
|
my $url = get('url') || '/'; |
473 |
|
my $category = strix->category( $url ); |
474 |
|
|
475 |
|
h1 { $category->{naziv} } |
476 |
|
pre { |
477 |
|
dump( $category ); |
478 |
|
} |
479 |
|
|
480 |
|
}; |
481 |
|
|
482 |
=head1 PRIVATE TEMPLATES |
=head1 PRIVATE TEMPLATES |
483 |
|
|
484 |
=head2 navigation-tree-category |
=head2 navigation-tree-category |
491 |
my $self = shift; |
my $self = shift; |
492 |
#warn "## navigation-tree-category",dump( @_ ); |
#warn "## navigation-tree-category",dump( @_ ); |
493 |
my $p = shift; |
my $p = shift; |
494 |
strix_link( $p->{url}, $p->{naziv} ); |
hyperlink( |
495 |
|
onclick => { |
496 |
|
region => 'strix-site-layout', # FIXME do we have to hard-code region name here? |
497 |
|
replace_with => '/strix/category', |
498 |
|
args => { |
499 |
|
url => $p->{url}, |
500 |
|
instance => get('instance'), |
501 |
|
} |
502 |
|
}, |
503 |
|
label => $p->{naziv}, |
504 |
|
); |
505 |
|
outs_raw(' '); |
506 |
if ( $p->{type} eq 'category' ) { |
if ( $p->{type} eq 'category' ) { |
|
outs_raw(' '); |
|
507 |
hyperlink( |
hyperlink( |
508 |
# url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), |
# url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), |
509 |
onclick => { |
onclick => { |
510 |
region => 'strix-site-layout', # FIXME do we have to hard-code region name here? |
region => 'strix-site-layout', # FIXME do we have to hard-code region name here? |
511 |
replace_with => '/strix/layout', |
replace_with => '/strix/layout', |
518 |
class => 'layout', |
class => 'layout', |
519 |
); |
); |
520 |
} |
} |
521 |
|
outs_raw(' '); |
522 |
|
strix_link( $p->{url}, '>>' ); |
523 |
}; |
}; |
524 |
|
|
525 |
=head2 navigation-tree |
=head2 navigation-tree |
532 |
my $self = shift; |
my $self = shift; |
533 |
my ( $instance, $site_id ) = @_; |
my ( $instance, $site_id ) = @_; |
534 |
|
|
535 |
warn ">>>> instance: $instance site_id: $site_id"; |
warn "## navigation-tree instance: $instance site_id: $site_id"; |
536 |
|
|
537 |
set 'instance' => $instance; |
set 'instance' => $instance; |
538 |
|
|
|
|
|
539 |
sub children { |
sub children { |
540 |
my $c = shift; |
my $c = shift; |
541 |
return unless defined $c->{children}; |
return unless defined $c->{children}; |
558 |
#warn "## navigation = ",dump( $navigation ); |
#warn "## navigation = ",dump( $navigation ); |
559 |
if ( $navigation ) { |
if ( $navigation ) { |
560 |
ul { |
ul { |
561 |
|
{ class is 'navigation' }; |
562 |
foreach my $p ( @$navigation ) { |
foreach my $p ( @$navigation ) { |
563 |
li { |
li { |
564 |
show( 'navigation-tree-category', $p ); |
show( 'navigation-tree-category', $p ); |