/[A3C]/lib/A3C/View/Strix.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/A3C/View/Strix.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 189 by dpavlin, Tue Jun 17 10:15:13 2008 UTC revision 197 by dpavlin, Tue Jun 17 21:32:12 2008 UTC
# Line 119  sub strix { Line 119  sub strix {
119          return Strix->new({ instance => $instance });          return Strix->new({ instance => $instance });
120  }  }
121    
122  =head2 sitemap  =head2 site-navigation
123    
124  =cut  =cut
125    
# Line 132  sub strix_link { Line 132  sub strix_link {
132          );          );
133  }  }
134    
135  template 'sitemap' => page {  template 'site-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 => 'select-strix-site',
141                  path => '/strix/selected-instances'                  path => '/strix/select-site'
142          );          );
143    
         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 );  
                         }  
                 }  
         }  
   
144  };  };
145    
146  =head2 layout  =head2 layout
# Line 404  template 'instance-op' => sub { Line 364  template 'instance-op' => sub {
364    
365  };  };
366    
367    =head2 select-site
368    
369    =cut
370    
371    template 'select-site' => sub {
372    
373            my $action = new_action(
374                    class   => 'StrixSelectSite',
375                    moniker => 'strix-select-site',
376            );
377    
378            #warn "action = ", dump( $action );
379    
380            form {
381                    render_param( $action, 'instance', onchange => { submit => $action, refresh_self => 1 }, default => get('instance') );
382                    render_param( $action, 'site_id', onchange => { submit => $action, refresh_self => 1 } );
383            };
384    
385            warn "## select-site action ",dump( $action->result );
386    
387            if ( my $site_id = $action->result->content('site_id') ) {
388                    show('strix-site-navigation-tree', $action->result->content('instance'), $site_id);
389            }
390    };
391    
392    =head1 PRIVATE TEMPLATES
393    
394    =head2 strix-site-navigation-tree
395    
396      show('strix-site-navigation-tree',$instance,$site_id);
397    
398    =cut
399    
400    private template 'strix-site-navigation-tree' => sub {
401            my $self = shift;
402            my ( $instance, $site_id ) = @_;
403    
404            warn ">>>> instance: $instance site_id: $site_id";
405    
406            set 'instance' => $instance;
407    
408            sub full_url {
409                    my $p = shift;
410                    strix_link( $p->{url}, $p->{naziv} );
411                    if ( $p->{type} eq 'category' ) {
412                            outs_raw(' ');
413                            hyperlink(
414                                    url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'),
415                                    label => _('layout'),
416                                    class => 'layout',
417                            );
418                    }
419            }
420    
421            sub children {
422                    my $c = shift;
423                    return unless defined $c->{children};
424                    ul {
425                            foreach my $p ( @{ $c->{children} } ) {
426                                    li {
427                                            { class is $p->{class} };
428                                            full_url( $p );
429                                            children( $p );
430                                    }
431                            }
432                    }
433            }
434    
435            my $strix = Strix->new({ instance => $instance });
436    
437            my @navigation = @{ $strix->site_navigation( $site_id ) };
438            if ( @navigation ) {
439                    ul {
440                            foreach my $p ( @navigation ) {
441                                    li {
442                                            full_url( $p );
443                                            children( $p );
444                                    }
445                            }
446                    }
447            } else {
448                    div {
449                            { class is 'note error' }
450                            _('No navigation found for instance %1 site_id %2', $instance, $site_id)
451                    }
452    
453            }
454    
455    };
456    
457  1;  1;

Legend:
Removed from v.189  
changed lines
  Added in v.197

  ViewVC Help
Powered by ViewVC 1.1.26