--- lib/A3C/View/Strix.pm 2008/06/16 13:32:01 172 +++ lib/A3C/View/Strix.pm 2008/06/16 16:48:16 174 @@ -6,7 +6,7 @@ =head1 DESCRIPTION -Display information about Strix sites +Display information about Strix instances =head1 TEMPLATES @@ -20,27 +20,27 @@ =head2 / -Display sites search and some stats +Display instaces search and some stats =cut template 'index.html' => page { - title is _('Strix sites'); + title is _('Strix instances'); - my $orgs = A3C::Model::StrixSiteCollection->new; + my $orgs = A3C::Model::StrixInstanceCollection->new; $orgs->unlimit; - div { _('Number of sites in Strix: %1', $orgs->count ) }; + div { _('Number of instances in Strix: %1', $orgs->count ) }; render_region( - name => 'selected-sites', - path => '/strix/selected-sites' + name => 'selected-instances', + path => '/strix/selected-instances' ); render_region( - name => 'search-sites', - path => '/strix/search-sites', + name => 'search-instances', + path => '/strix/search-instances', ); }; @@ -55,10 +55,10 @@ my $name_diff = A3C::SQL->new({ query => qq{ select - site,hreduorgurl, + instance,hreduorgurl, _site_name,o - from strix_sites - join hr_edu_orgs on cn = site + from strix_instances + join hr_edu_orgs on cn = instance where o != _site_name }}); @@ -66,13 +66,13 @@ table { row { - th { _('Site') } - th { _('Strix site name') } + th { _('Instance') } + th { _('Strix instance name') } th { _('hrEduOrg.o') } }; while ( my $row = $name_diff->next ) { row { - cell { hyperlink( url => 'http://' . $row->hreduorgurl, label => $row->site ) } + cell { hyperlink( url => 'http://' . $row->hreduorgurl, label => $row->instance ) } cell { $row->_site_name } cell { $row->o } } @@ -80,14 +80,14 @@ } } else { - div { _("Can't find any site in strix which has different name than data from LDAP") } + div { _("Can't find any instance of strix which has different name than data from LDAP") } } }; =head2 sql -Execute SQL query on site +Execute SQL query on instance =cut @@ -96,8 +96,8 @@ title is _('Execute SQL'); render_region( - name => 'selected-sites', - path => '/strix/selected-sites' + name => 'selected-instances', + path => '/strix/selected-instances' ); render_region( @@ -107,6 +107,11 @@ }; +sub strix { + my $instance = get('instance') || shift || 'new'; + return Strix->new({ instance => $instance }); +} + =head2 sitemap =cut @@ -115,8 +120,9 @@ title is _('Sitemap'); - my $strix = Strix->new({ site => 'new' }); - my $sitemap = $strix->site_navigation( 1 ); + my $site_id = get('site_id') || 1; + + my $sitemap = strix->site_navigation( $site_id ); sub full_url { my $p = shift; @@ -124,6 +130,13 @@ 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 { @@ -150,11 +163,41 @@ }; +=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}, + ); + + my $layout = strix->layout( $url ); + + pre { + dump( $layout ); + } + +}; + =head1 REGIONS =head2 execute-sql -Execute SQL query on site +Execute SQL query on instance =cut @@ -190,24 +233,24 @@ } }; -=head2 search-sites +=head2 search-instances =cut -template 'search-sites' => sub { +template 'search-instances' => sub { - h1 { _('Find site') } + h1 { _('Find instance') } my $action = new_action( - class => 'SearchStrixSite', - moniker => 'search-strix-site', + class => 'SearchStrixInstance', + moniker => 'search-strix-instance', sticky_on_success => 1, sticky_on_failure => 1, ); form { - render_action( $action => [ 'site_contains', '_site_name_contains' ] ); + render_action( $action => [ 'instance_contains', '_site_name_contains' ] ); form_submit( label => _('Search') ); }; @@ -218,9 +261,9 @@ table { while (my $strix = $search->next) { row { - cell { tt { $strix->site } } + cell { tt { $strix->instance } } cell { $strix->_site_name } - cell { show( 'site-op', 'Create', '+', $strix->site ) } + cell { show( 'instance-op', 'Create', '+', $strix->instance ) } } } } @@ -228,90 +271,90 @@ }; -=head2 selected-sites +=head2 selected-instances -Show Selected sites for current user +Show Selected instances for current user =cut -template 'selected-sites' => sub { +template 'selected-instances' => sub { my $self = shift; - warn "## IN selected-sites ",dump( @_ ); + warn "## IN selected-instances ",dump( @_ ); if ( my $op = get 'op' ) { - my $site = get 'site' or die "no site?"; - warn "# selected-sites $op on $site"; + my $instance = get 'instance' or die "no instance?"; + warn "# selected-instances $op on $instance"; my $a; if ( $op eq 'Create' ) { $a = new_action( - class => $op . 'StrixSiteSelection', + class => $op . 'StrixInstanceSelection', moniker => $op, arguments => { - strix => $site, + instance => $instance, by_user => $self->current_user->id, }, ); } elsif ( $op eq 'Delete' ) { - my $strix = A3C::Model::StrixSiteSelection->new; - $strix->load_by_cols( strix => $site, by_user => $self->current_user->id ); - die "can't find site $site" unless $strix->id; + my $strix = A3C::Model::StrixInstanceSelection->new; + $strix->load_by_cols( instance => $instance, by_user => $self->current_user->id ); + die "can't find instance $instance" unless $strix->id; $a = $strix->as_delete_action; } warn "# argument_values = ",dump( $a->argument_values ); $a->run; - warn "can't $op site $site" unless $a->result->success; + warn "can't $op instance $instance" unless $a->result->success; } - my $selected = A3C::Model::StrixSiteSelectionCollection->new; + my $selected = A3C::Model::StrixInstanceSelectionCollection->new; $selected->limit( column => 'by_user', value => Jifty->web->current_user->id ); if ( $selected->count > 0 ) { - div { _('%1 sites selected', $selected->count ) } + div { _('%1 instances selected', $selected->count ) } table { while (my $s = $selected->next) { row { - cell { tt { $s->strix->site } } + cell { tt { $s->strix->instance } } cell { $s->strix->_site_name } - cell { show( 'site-op', 'Delete', '-', $s->strix->site ) } + cell { show( 'instance-op', 'Delete', '-', $s->strix->instance ) } } } } } else { - div { _('No sites selected') } + div { _('No instances selected') } } }; -=head2 site-op +=head2 instance-op -Display button to add/remove site from selection +Display button to add/remove instance from selection - show( 'site-op', 'Delete', '-', $strix->site ); + show( 'instance-op', 'Delete', '-', $strix->instace ); =cut -template 'site-op' => sub { +template 'instance-op' => sub { my $self = shift; - warn "# site-op = ",dump( @_ ); + warn "# instance-op = ",dump( @_ ); - my ( $op, $label, $site ) = @_; + my ( $op, $label, $instance ) = @_; form { hyperlink( label => $label, onclick => { - refresh => 'selected-sites', - path => '/strix/selected-sites', + refresh => 'selected-instances', + path => '/strix/selected-instances', args => { - site => $site, + instance => $instance, op => $op, } },