/[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 187 by dpavlin, Mon Jun 16 23:24:25 2008 UTC revision 205 by dpavlin, Thu Jun 19 19:05:26 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 navigation
123    
124  =cut  =cut
125    
# Line 132  sub strix_link { Line 132  sub strix_link {
132          );          );
133  }  }
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 => 'select-strix-site',
146          my $sitemap = strix->site_navigation( $site_id );                  path => '/strix/select-site'
147            );
         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 );  
                         }  
                 }  
         }  
148    
149  };  };
150    
# Line 283  template 'search-instances' => sub { Line 248  template 'search-instances' => sub {
248                  table {                  table {
249                          while (my $strix = $search->next) {                          while (my $strix = $search->next) {
250                                  row {                                  row {
251                                            cell { show( 'instance-op', 'Create', '+', $strix->instance ) }
252                                          cell { tt { $strix->instance } }                                          cell { tt { $strix->instance } }
253                                          cell { $strix->_site_name }                                          cell { $strix->_site_name }
                                         cell { show( 'instance-op', 'Create', '+', $strix->instance ) }  
254                                  }                                  }
255                          }                          }
256                  }                  }
# Line 348  template 'selected-instances' => sub { Line 313  template 'selected-instances' => sub {
313          if ( $selected->count > 0 ) {          if ( $selected->count > 0 ) {
314    
315                  my $instance = get('instance');                  my $instance = get('instance');
316                    warn "# selected-instances -- selected: $instance\n";
317    
318                  div { _('%1 instances selected', $selected->count ) };                  div { _('%1 instances selected', $selected->count ) };
319                  table {                  table {
# Line 404  template 'instance-op' => sub { Line 370  template 'instance-op' => sub {
370    
371  };  };
372    
373    =head2 select-site
374    
375    =cut
376    
377    template 'select-site' => sub {
378    
379            my $action = new_action(
380                    class   => 'StrixSelectSite',
381                    moniker => 'strix-select-site',
382            );
383    
384            warn "# action = ", dump( $action );
385    
386            warn "# argument_values = ", dump( $action->argument_values );
387    
388            if ( ! $action->argument_value('instance') ) {
389                    $action->argument_value( 'instance', get('instance') );
390                    warn "# run action with instance\n";
391                    $action->run;
392            }
393    
394            my $magic = [
395                    { submit => $action, refresh_self => 1 },
396                    # this is basically a closure
397                    { refresh => 'selected-instances', path => '/strix/selected-instances', args => {
398                            instance => { result_of => $action, name => 'instance' }
399                    } }
400            ];
401    
402            form {
403                    render_param( $action, 'instance', onchange => $magic );
404                    render_param( $action, 'site_id', onchange => $magic );
405                    form_submit( label => _('Show navigation'), onclick => $magic );
406            };
407    
408            warn "## select-site action ",dump( $action->result );
409    
410            if ( my $site_id = $action->result->content('site_id') ) {
411                    show('strix-site-navigation-tree', $action->result->content('instance'), $site_id);
412            }
413    };
414    
415    =head1 PRIVATE TEMPLATES
416    
417    =head2 strix-site-navigation-tree
418    
419      show('strix-site-navigation-tree',$instance,$site_id);
420    
421    =cut
422    
423    private template 'strix-site-navigation-tree' => sub {
424            my $self = shift;
425            my ( $instance, $site_id ) = @_;
426    
427            warn ">>>> instance: $instance site_id: $site_id";
428    
429            set 'instance' => $instance;
430    
431            sub full_url {
432                    my $p = shift;
433                    strix_link( $p->{url}, $p->{naziv} );
434                    if ( $p->{type} eq 'category' ) {
435                            outs_raw(' ');
436                            hyperlink(
437                                    url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'),
438                                    label => _('layout'),
439                                    class => 'layout',
440                            );
441                    }
442            }
443    
444            sub children {
445                    my $c = shift;
446                    return unless defined $c->{children};
447                    ul {
448                            foreach my $p ( @{ $c->{children} } ) {
449                                    li {
450                                            { class is $p->{class} };
451                                            full_url( $p );
452                                            children( $p );
453                                    }
454                            }
455                    }
456            }
457    
458            my $strix = Strix->new({ instance => $instance });
459    
460            my @navigation = @{ $strix->site_navigation( $site_id ) };
461            if ( @navigation ) {
462                    ul {
463                            foreach my $p ( @navigation ) {
464                                    li {
465                                            full_url( $p );
466                                            children( $p );
467                                    }
468                            }
469                    }
470            } else {
471                    div {
472                            { class is 'note error' }
473                            _('No navigation found for instance %1 site_id %2', $instance, $site_id)
474                    }
475    
476            }
477    
478    };
479    
480  1;  1;

Legend:
Removed from v.187  
changed lines
  Added in v.205

  ViewVC Help
Powered by ViewVC 1.1.26