/[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 187 by dpavlin, Mon Jun 16 23:24:25 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    
# Line 116  sub strix { Line 123  sub strix {
123    
124  =cut  =cut
125    
126    sub strix_link {
127            my ( $url, $label ) = @_;
128            hyperlink(
129                    url => 'http://' . get('instance') . '.cms-qa.skole.hr' . $url,
130                    label => $label || $url,
131                    target => 'strix',
132            );
133    }
134    
135  template 'sitemap' => page {  template 'sitemap' => page {
136    
137          title is _('Sitemap');          title is _('Sitemap %1', get('instance'));
138    
139            render_region(
140                    name => 'selected-instances',
141                    path => '/strix/selected-instances'
142            );
143    
144          my $site_id = get('site_id') || 1;          my $site_id = get('site_id') || 1;
145    
# Line 126  template 'sitemap' => page { Line 147  template 'sitemap' => page {
147    
148          sub full_url {          sub full_url {
149                  my $p = shift;                  my $p = shift;
150                  hyperlink(                  strix_link( $p->{url}, $p->{naziv} );
                         url => 'http://new.cms-qa.skole.hr' . $p->{url},  
                         label => $p->{naziv},  
                 );  
151                  if ( $p->{type} eq 'category' ) {                  if ( $p->{type} eq 'category' ) {
152                          outs_raw(' ');                          outs_raw(' ');
153                          hyperlink(                          hyperlink(
154                                  url => '/strix/layout?url=' . $p->{url},                                  url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'),
155                                  label => '[layout]',                                  label => _('layout'),
156                                    class => 'layout',
157                          );                          );
158                  }                  }
159          }          }
# Line 145  template 'sitemap' => page { Line 164  template 'sitemap' => page {
164                  ul {                  ul {
165                          foreach my $p ( @{ $c->{children} } ) {                          foreach my $p ( @{ $c->{children} } ) {
166                                  li {                                  li {
167                                            { class is $p->{class} };
168                                          full_url( $p );                                          full_url( $p );
169                                          children( $p );                                          children( $p );
170                                  }                                  }
# Line 180  template 'layout' => page { Line 200  template 'layout' => page {
200                  $category->{naziv},                  $category->{naziv},
201          );          );
202    
203          hyperlink(          render_region(
204                  url => 'http://' . $category->{sitename} . '/' . $category->{url},                  name => 'selected-instances',
205                  label => $category->{naziv},                  path => '/strix/selected-instances'
206          );          );
207    
208            strix_link( $category->{url}, $category->{naziv} );
209    
210          my $layout = strix->layout( $url );          my $layout = strix->layout( $url );
211    
212          pre {          pre {
# Line 209  template 'execute-sql' => sub { Line 231  template 'execute-sql' => sub {
231                  sticky_on_success => 1,                  sticky_on_success => 1,
232                  sticky_on_failure => 1,                  sticky_on_failure => 1,
233                  arguments => {                  arguments => {
234                          strix => get('strix')                          instance => get('instance')
235                  }                  }
236          );          );
237    
238          form {          form {
239                  render_action( $action => [ 'strix', 'sql' ] );                  render_action( $action => [ 'instance', 'sql' ] );
240                  form_submit( label => _('Execute SQL') );                  form_submit( label => _('Execute SQL') );
241          };          };
242    
# Line 280  Show Selected instances for current user Line 302  Show Selected instances for current user
302  template 'selected-instances' => sub {  template 'selected-instances' => sub {
303          my $self = shift;          my $self = shift;
304    
305          warn "## IN selected-instances ",dump( @_ );  #       warn "## IN selected-instances ",dump( @_ );
306    
307          if ( my $op = get 'op' ) {          if ( my $op = get 'op' ) {
308                  my $instance = get 'instance' or die "no instance?";                  my $op_instance = get 'op_instance' or die "no op_instance?";
309                  warn "# selected-instances $op on $instance";                  warn "# selected-instances $op on $op_instance";
310    
311                  my $a;                  my $a;
312    
# Line 294  template 'selected-instances' => sub { Line 316  template 'selected-instances' => sub {
316                                  class => $op . 'StrixInstanceSelection',                                  class => $op . 'StrixInstanceSelection',
317                                  moniker => $op,                                  moniker => $op,
318                                  arguments => {                                  arguments => {
319                                          instance => $instance,                                          instance => $op_instance,
320                                          by_user => $self->current_user->id,                                          by_user => $self->current_user->id,
321                                  },                                  },
322                          );                          );
# Line 302  template 'selected-instances' => sub { Line 324  template 'selected-instances' => sub {
324                  } elsif ( $op eq 'Delete' ) {                  } elsif ( $op eq 'Delete' ) {
325    
326                          my $strix = A3C::Model::StrixInstanceSelection->new;                          my $strix = A3C::Model::StrixInstanceSelection->new;
327                          $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 );
328                          die "can't find instance $instance" unless $strix->id;                          warn "can't find instance $op_instance" unless $strix->id;
329                          $a = $strix->as_delete_action;                          $a = $strix->as_delete_action;
330    
331                  }                  }
332                  warn "# argument_values = ",dump( $a->argument_values );  #               warn "# argument_values = ",dump( $a->argument_values );
333                  $a->run;                  $a->run;
334                  warn "can't $op instance $instance" unless $a->result->success;  
335                    if ( $a->result->error ) {
336                            div {
337                                    { class is 'note error' }
338                                    $a->result->error;
339                            }
340                    }
341    
342                    set( op => '' );
343          }          }
344    
345          my $selected = A3C::Model::StrixInstanceSelectionCollection->new;          my $selected = A3C::Model::StrixInstanceSelectionCollection->new;
# Line 317  template 'selected-instances' => sub { Line 347  template 'selected-instances' => sub {
347    
348          if ( $selected->count > 0 ) {          if ( $selected->count > 0 ) {
349    
350                  div { _('%1 instances selected', $selected->count ) }                  my $instance = get('instance');
351    
352                    div { _('%1 instances selected', $selected->count ) };
353                  table {                  table {
354                          while (my $s = $selected->next) {                          while (my $s = $selected->next) {
355                                  row {                                  row {
356                                          cell { tt { $s->strix->instance } }                                          cell { tt {
357                                          cell { $s->strix->_site_name }                                                  if ( $s->instance->instance eq $instance ) {
358                                          cell { show( 'instance-op', 'Delete', '-', $s->strix->instance ) }                                                          b { $instance }
359                                                    } else {
360                                                            hyperlink(
361                                                                    url => '?instance=' . $s->instance->instance,
362                                                                    label => $s->instance->instance
363                                                            )
364                                                    }
365                                            } }
366                                            cell { $s->instance->_site_name }
367                                            cell { show( 'instance-op', 'Delete', '-', $s->instance->instance ) }
368                                  }                                  }
369                          }                          }
370                  }                  }
# Line 343  Display button to add/remove instance fr Line 384  Display button to add/remove instance fr
384  template 'instance-op' => sub {  template 'instance-op' => sub {
385          my $self = shift;          my $self = shift;
386    
387          warn "# instance-op = ",dump( @_ );  #       warn "# instance-op = ",dump( @_ );
388    
389          my ( $op, $label, $instance ) = @_;          my ( $op, $label, $instance ) = @_;
390    
# Line 354  template 'instance-op' => sub { Line 395  template 'instance-op' => sub {
395                                  refresh => 'selected-instances',                                  refresh => 'selected-instances',
396                                  path => '/strix/selected-instances',                                  path => '/strix/selected-instances',
397                                  args => {                                  args => {
398                                          instance => $instance,                                          op_instance => $instance,
399                                          op => $op,                                          op => $op,
400                                  }                                  }
401                          },                          },

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

  ViewVC Help
Powered by ViewVC 1.1.26