/[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 212 by dpavlin, Fri Jun 20 17:04:20 2008 UTC
# Line 119  sub strix { Line 119  sub strix {
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(
# Line 132  sub strix_link { Line 128  sub strix_link {
128          );          );
129  }  }
130    
131  template 'sitemap' => page {  =head2 navigation
132    
133          title is _('Sitemap %1', get('instance'));  =cut
134    
135    template 'navigation' => page {
136    
137            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 => 'strix-site',
146          my $sitemap = strix->site_navigation( $site_id );                  path => '/strix/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 187  template 'sitemap' => page { Line 152  template 'sitemap' => page {
152    
153  =cut  =cut
154    
155  template 'layout' => page {  template 'layout' => sub {
156    
157          my $url = get('url') || '/';          my $url = get('url') || '/';
158    
# Line 195  template 'layout' => page { Line 160  template 'layout' => page {
160    
161          warn dump( $category );          warn dump( $category );
162    
         title is _('Layout %1 : %2',  
                 $category->{sitename},  
                 $category->{naziv},  
         );  
   
         render_region(  
                 name => 'selected-instances',  
                 path => '/strix/selected-instances'  
         );  
   
163          strix_link( $category->{url}, $category->{naziv} );          strix_link( $category->{url}, $category->{naziv} );
164    
165          my $layout = strix->layout( $url );          my $layout = strix->layout( $url );
# Line 283  template 'search-instances' => sub { Line 238  template 'search-instances' => sub {
238                  table {                  table {
239                          while (my $strix = $search->next) {                          while (my $strix = $search->next) {
240                                  row {                                  row {
241                                            cell { show( 'instance-op', 'Create', '+', $strix->instance ) }
242                                          cell { tt { $strix->instance } }                                          cell { tt { $strix->instance } }
243                                          cell { $strix->_site_name }                                          cell { $strix->_site_name }
                                         cell { show( 'instance-op', 'Create', '+', $strix->instance ) }  
244                                  }                                  }
245                          }                          }
246                  }                  }
# Line 305  template 'selected-instances' => sub { Line 260  template 'selected-instances' => sub {
260  #       warn "## IN selected-instances ",dump( @_ );  #       warn "## IN selected-instances ",dump( @_ );
261    
262          if ( my $op = get 'op' ) {          if ( my $op = get 'op' ) {
263                  my $op_instance = get 'op_instance' or die "no op_instance?";                  my $op_instance = get 'op_instance';
264                    return unless $op_instance;
265                  warn "# selected-instances $op on $op_instance";                  warn "# selected-instances $op on $op_instance";
266    
267                  my $a;                  my $a;
# Line 348  template 'selected-instances' => sub { Line 304  template 'selected-instances' => sub {
304          if ( $selected->count > 0 ) {          if ( $selected->count > 0 ) {
305    
306                  my $instance = get('instance');                  my $instance = get('instance');
307                    warn "# selected-instances -- selected: $instance\n";
308    
309                  div { _('%1 instances selected', $selected->count ) };                  div { _('%1 instances selected', $selected->count ) };
310                  table {                  table {
# Line 404  template 'instance-op' => sub { Line 361  template 'instance-op' => sub {
361    
362  };  };
363    
364    =head2 site
365    
366    =cut
367    
368    template 'site' => sub {
369    
370            my $action = new_action(
371                    class   => 'StrixSelectSite',
372                    moniker => 'strix-select-site',
373            );
374    
375            warn "# action = ", dump( $action );
376    
377            warn "# argument_values = ", dump( $action->argument_values );
378    
379            if ( ! $action->argument_value('instance') ) {
380                    $action->argument_value( 'instance', get('instance') );
381                    warn "# run action with instance\n";
382                    $action->run;
383            }
384    
385            my $magic = [
386                    { submit => $action, refresh_self => 1 },
387                    # this is basically a closure
388                    { refresh => 'selected-instances', path => '/strix/selected-instances', args => {
389                            instance => { result_of => $action, name => 'instance' }
390                    } },
391                    { refresh => 'strix-site-layout', path => '/__jifty/empty' },
392            ];
393    
394            form {
395                    render_param( $action, 'instance', onchange => $magic );
396                    render_param( $action, 'site_id', onchange => $magic );
397                    form_submit( label => _('Show navigation'), onclick => $magic );
398            };
399    
400            warn "## select-site action ",dump( $action->result );
401    
402            render_region(
403                    name => 'layout',
404                    path => '/__jifty/empty',
405            );
406    
407            if ( my $site_id = $action->result->content('site_id') ) {
408                    show('strix-site-navigation-tree', $action->result->content('instance'), $site_id);
409            }
410    };
411    
412    =head1 PRIVATE TEMPLATES
413    
414    =head2 strix-site-navigation-tree
415    
416      show('strix-site-navigation-tree',$instance,$site_id);
417    
418    =cut
419    
420    private template 'select-category' => sub {
421            my $self = shift;
422            my $p = shift;
423            strix_link( $p->{url}, $p->{naziv} );
424            if ( $p->{type} eq 'category' ) {
425                    outs_raw(' ');
426                    hyperlink(
427    #                       url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'),
428                            onclick => {
429                                    region => 'strix-site-layout',  # FIXME do we have to hard-code region name here?
430                                    replace_with => '/strix/layout',
431                                    args => {
432                                            url => $p->{url},
433                                            instance => get('instance'),
434                                    }
435                            },
436                            label => _('layout'),
437                            class => 'layout',
438                    );
439            }
440    };
441    
442    private template 'strix-site-navigation-tree' => sub {
443            my $self = shift;
444            my ( $instance, $site_id ) = @_;
445    
446            warn ">>>> instance: $instance site_id: $site_id";
447    
448            set 'instance' => $instance;
449    
450    
451            sub children {
452                    my $c = shift;
453                    return unless defined $c->{children};
454                    ul {
455                            foreach my $p ( @{ $c->{children} } ) {
456                                    li {
457                                            if ( defined( $p->{class} ) ) {
458                                                    { class is $p->{class} };
459                                            }
460                                            show( 'select-category', $p );
461                                            children( $p );
462                                    }
463                            }
464                    }
465            }
466    
467            my $strix = Strix->new({ instance => $instance });
468    
469            my @navigation = @{ $strix->site_navigation( $site_id ) };
470            if ( @navigation ) {
471                    ul {
472                            foreach my $p ( @navigation ) {
473                                    li {
474                                            show( 'select-category', $p );
475                                            children( $p );
476                                    }
477                            }
478                    }
479            } else {
480                    div {
481                            { class is 'note error' }
482                            _('No navigation found for instance %1 site_id %2', $instance, $site_id)
483                    }
484    
485            }
486    
487    };
488    
489  1;  1;

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

  ViewVC Help
Powered by ViewVC 1.1.26