/[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 174 by dpavlin, Mon Jun 16 16:48:16 2008 UTC revision 197 by dpavlin, Tue Jun 17 21:32:12 2008 UTC
# Line 53  template 'name_diff' => page { Line 53  template 'name_diff' => page {
53    
54          title is _('Strix name differences');          title is _('Strix name differences');
55    
56            render_region(
57                    name => 'selected-instances',
58                    path => '/strix/selected-instances'
59            );
60    
61          my $name_diff = A3C::SQL->new({ query => qq{          my $name_diff = A3C::SQL->new({ query => qq{
62                  select                  select
63                          instance,hreduorgurl,                          instance,hreduorgurl,
# Line 66  template 'name_diff' => page { Line 71  template 'name_diff' => page {
71    
72                  table {                  table {
73                          row {                          row {
74                                    th {}
75                                  th { _('Instance') }                                  th { _('Instance') }
76                                  th { _('Strix instance name') }                                  th { _('Strix instance name') }
77                                  th { _('hrEduOrg.o') }                                  th { _('hrEduOrg.o') }
78                          };                          };
79                          while ( my $row = $name_diff->next ) {                          while ( my $row = $name_diff->next ) {
80                                  row {                                  row {
81                                          cell { hyperlink( url => 'http://' . $row->hreduorgurl, label => $row->instance ) }                                          cell { show( 'instance-op', 'Create', '+', $row->instance ) }
82                                            cell { $row->instance }
83                                          cell { $row->_site_name }                                          cell { $row->_site_name }
84                                          cell { $row->o }                                          cell { $row->o }
85                                  }                                  }
# Line 108  template 'sql' => page { Line 115  template 'sql' => page {
115  };  };
116    
117  sub strix {  sub strix {
118          my $instance = get('instance') || shift || 'new';          my $instance = get('instance');
119          return Strix->new({ instance => $instance });          return Strix->new({ instance => $instance });
120  }  }
121    
122  =head2 sitemap  =head2 site-navigation
123    
124  =cut  =cut
125    
126  template 'sitemap' => page {  sub strix_link {
127            my ( $url, $label ) = @_;
128          title is _('Sitemap');          hyperlink(
129                    url => 'http://' . get('instance') . '.cms-qa.skole.hr' . $url,
130          my $site_id = get('site_id') || 1;                  label => $label || $url,
131                    target => 'strix',
132            );
133    }
134    
135          my $sitemap = strix->site_navigation( $site_id );  template 'site-navigation' => page {
136    
137          sub full_url {          title is _('Site navigation');
                 my $p = shift;  
                 hyperlink(  
                         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]',  
                         );  
                 }  
         }  
138    
139          sub children {          render_region(
140                  my $c = shift;                  name => 'select-strix-site',
141                  return unless defined $c->{children};                  path => '/strix/select-site'
142                  ul {          );
                         foreach my $p ( @{ $c->{children} } ) {  
                                 li {  
                                         full_url( $p );  
                                         children( $p );  
                                 }  
                         }  
                 }  
         }  
   
         ul {  
                 foreach my $p ( @$sitemap ) {  
                         li {  
                                 full_url( $p );  
                                 children( $p );  
                         }  
                 }  
         }  
143    
144  };  };
145    
# Line 180  template 'layout' => page { Line 160  template 'layout' => page {
160                  $category->{naziv},                  $category->{naziv},
161          );          );
162    
163          hyperlink(          render_region(
164                  url => 'http://' . $category->{sitename} . '/' . $category->{url},                  name => 'selected-instances',
165                  label => $category->{naziv},                  path => '/strix/selected-instances'
166          );          );
167    
168            strix_link( $category->{url}, $category->{naziv} );
169    
170          my $layout = strix->layout( $url );          my $layout = strix->layout( $url );
171    
172          pre {          pre {
# Line 209  template 'execute-sql' => sub { Line 191  template 'execute-sql' => sub {
191                  sticky_on_success => 1,                  sticky_on_success => 1,
192                  sticky_on_failure => 1,                  sticky_on_failure => 1,
193                  arguments => {                  arguments => {
194                          strix => get('strix')                          instance => get('instance')
195                  }                  }
196          );          );
197    
198          form {          form {
199                  render_action( $action => [ 'strix', 'sql' ] );                  render_action( $action => [ 'instance', 'sql' ] );
200                  form_submit( label => _('Execute SQL') );                  form_submit( label => _('Execute SQL') );
201          };          };
202    
# Line 261  template 'search-instances' => sub { Line 243  template 'search-instances' => sub {
243                  table {                  table {
244                          while (my $strix = $search->next) {                          while (my $strix = $search->next) {
245                                  row {                                  row {
246                                            cell { show( 'instance-op', 'Create', '+', $strix->instance ) }
247                                          cell { tt { $strix->instance } }                                          cell { tt { $strix->instance } }
248                                          cell { $strix->_site_name }                                          cell { $strix->_site_name }
                                         cell { show( 'instance-op', 'Create', '+', $strix->instance ) }  
249                                  }                                  }
250                          }                          }
251                  }                  }
# Line 280  Show Selected instances for current user Line 262  Show Selected instances for current user
262  template 'selected-instances' => sub {  template 'selected-instances' => sub {
263          my $self = shift;          my $self = shift;
264    
265          warn "## IN selected-instances ",dump( @_ );  #       warn "## IN selected-instances ",dump( @_ );
266    
267          if ( my $op = get 'op' ) {          if ( my $op = get 'op' ) {
268                  my $instance = get 'instance' or die "no instance?";                  my $op_instance = get 'op_instance' or die "no op_instance?";
269                  warn "# selected-instances $op on $instance";                  warn "# selected-instances $op on $op_instance";
270    
271                  my $a;                  my $a;
272    
# Line 294  template 'selected-instances' => sub { Line 276  template 'selected-instances' => sub {
276                                  class => $op . 'StrixInstanceSelection',                                  class => $op . 'StrixInstanceSelection',
277                                  moniker => $op,                                  moniker => $op,
278                                  arguments => {                                  arguments => {
279                                          instance => $instance,                                          instance => $op_instance,
280                                          by_user => $self->current_user->id,                                          by_user => $self->current_user->id,
281                                  },                                  },
282                          );                          );
# Line 302  template 'selected-instances' => sub { Line 284  template 'selected-instances' => sub {
284                  } elsif ( $op eq 'Delete' ) {                  } elsif ( $op eq 'Delete' ) {
285    
286                          my $strix = A3C::Model::StrixInstanceSelection->new;                          my $strix = A3C::Model::StrixInstanceSelection->new;
287                          $strix->load_by_cols( instance => $instance, by_user => $self->current_user->id );                          $strix->load_by_cols( instance => $op_instance, by_user => $self->current_user->id );
288                          die "can't find instance $instance" unless $strix->id;                          warn "can't find instance $op_instance" unless $strix->id;
289                          $a = $strix->as_delete_action;                          $a = $strix->as_delete_action;
290    
291                  }                  }
292                  warn "# argument_values = ",dump( $a->argument_values );  #               warn "# argument_values = ",dump( $a->argument_values );
293                  $a->run;                  $a->run;
294                  warn "can't $op instance $instance" unless $a->result->success;  
295                    if ( $a->result->error ) {
296                            div {
297                                    { class is 'note error' }
298                                    $a->result->error;
299                            }
300                    }
301    
302                    set( op => '' );
303          }          }
304    
305          my $selected = A3C::Model::StrixInstanceSelectionCollection->new;          my $selected = A3C::Model::StrixInstanceSelectionCollection->new;
# Line 317  template 'selected-instances' => sub { Line 307  template 'selected-instances' => sub {
307    
308          if ( $selected->count > 0 ) {          if ( $selected->count > 0 ) {
309    
310                  div { _('%1 instances selected', $selected->count ) }                  my $instance = get('instance');
311    
312                    div { _('%1 instances selected', $selected->count ) };
313                  table {                  table {
314                          while (my $s = $selected->next) {                          while (my $s = $selected->next) {
315                                  row {                                  row {
316                                          cell { tt { $s->strix->instance } }                                          cell { tt {
317                                          cell { $s->strix->_site_name }                                                  if ( $s->instance->instance eq $instance ) {
318                                          cell { show( 'instance-op', 'Delete', '-', $s->strix->instance ) }                                                          b { $instance }
319                                                    } else {
320                                                            hyperlink(
321                                                                    url => '?instance=' . $s->instance->instance,
322                                                                    label => $s->instance->instance
323                                                            )
324                                                    }
325                                            } }
326                                            cell { $s->instance->_site_name }
327                                            cell { show( 'instance-op', 'Delete', '-', $s->instance->instance ) }
328                                  }                                  }
329                          }                          }
330                  }                  }
# Line 343  Display button to add/remove instance fr Line 344  Display button to add/remove instance fr
344  template 'instance-op' => sub {  template 'instance-op' => sub {
345          my $self = shift;          my $self = shift;
346    
347          warn "# instance-op = ",dump( @_ );  #       warn "# instance-op = ",dump( @_ );
348    
349          my ( $op, $label, $instance ) = @_;          my ( $op, $label, $instance ) = @_;
350    
# Line 354  template 'instance-op' => sub { Line 355  template 'instance-op' => sub {
355                                  refresh => 'selected-instances',                                  refresh => 'selected-instances',
356                                  path => '/strix/selected-instances',                                  path => '/strix/selected-instances',
357                                  args => {                                  args => {
358                                          instance => $instance,                                          op_instance => $instance,
359                                          op => $op,                                          op => $op,
360                                  }                                  }
361                          },                          },
# Line 363  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.174  
changed lines
  Added in v.197

  ViewVC Help
Powered by ViewVC 1.1.26