/[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 183 by dpavlin, Mon Jun 16 21:33:59 2008 UTC revision 189 by dpavlin, Tue Jun 17 10:15:13 2008 UTC
# Line 115  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 123  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(          render_region(
140                  name => 'selected-instances',                  name => 'selected-instances',
# Line 138  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 193  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 274  template 'search-instances' => sub { Line 283  template 'search-instances' => sub {
283                  table {                  table {
284                          while (my $strix = $search->next) {                          while (my $strix = $search->next) {
285                                  row {                                  row {
286                                            cell { show( 'instance-op', 'Create', '+', $strix->instance ) }
287                                          cell { tt { $strix->instance } }                                          cell { tt { $strix->instance } }
288                                          cell { $strix->_site_name }                                          cell { $strix->_site_name }
                                         cell { show( 'instance-op', 'Create', '+', $strix->instance ) }  
289                                  }                                  }
290                          }                          }
291                  }                  }
# Line 293  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 307  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 315  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 330  template 'selected-instances' => sub { Line 347  template 'selected-instances' => sub {
347    
348          if ( $selected->count > 0 ) {          if ( $selected->count > 0 ) {
349    
350                    my $instance = get('instance');
351    
352                  div { _('%1 instances selected', $selected->count ) };                  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 {                                          cell { tt {
357                                                  hyperlink(                                                  if ( $s->instance->instance eq $instance ) {
358                                                          url => '?instance=' . $s->instance->instance,                                                          b { $instance }
359                                                          label => $s->instance->instance                                                  } else {
360                                                  )                                                          hyperlink(
361                                                                    url => '?instance=' . $s->instance->instance,
362                                                                    label => $s->instance->instance
363                                                            )
364                                                    }
365                                          } }                                          } }
366                                          cell { $s->instance->_site_name }                                          cell { $s->instance->_site_name }
367                                          cell { show( 'instance-op', 'Delete', '-', $s->instance->instance ) }                                          cell { show( 'instance-op', 'Delete', '-', $s->instance->instance ) }
# Line 361  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 372  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.183  
changed lines
  Added in v.189

  ViewVC Help
Powered by ViewVC 1.1.26