package HTML::Mason::Commands; use strict; use vars qw($m $r); my $_escape = \&HTML::Mason::Parser::_escape_perl_expression; ; my $sort_by = { story => [ [ cover_date => 'Cover Date' ], [ priority => 'Priority' ], [ name => 'Title' ], [ category_name => 'Category' ], [ element => 'Story Type' ], [ id => 'ID' ], ], media => [ [ cover_date => 'Cover Date' ], [ priority => 'Priority' ], [ name => 'Title' ], [ category_name => 'Category' ], [ element => 'Media Type' ], [ id => 'ID' ], ], formatting => [ [ deploy_date => 'Cover Date' ], [ priority => 'Priority' ], [ file_name => 'File Name' ], [ category_name => 'Category' ], [ element => 'Asset Type' ], [ id => 'ID' ], ] }; my $pl_names = { story => get_class_info('story')->get_plural_name, media => get_class_info('media')->get_plural_name, formatting => 'templates' #get_class_info('formatting')->get_plural_name }; HTML::Mason::Component::FileBased->new ( 'code'=>sub { my %ARGS; if (@_ % 2 == 0) { %ARGS = @_ } else { die "Odd number of parameters passed to component expecting name/value pairs" } my $class = (!exists $ARGS{'class'} ? 'story' : $ARGS{'class'}); my $caption = (!exists $ARGS{'caption'} ? '' : $ARGS{'caption'}); my $sort_by_val = (!exists $ARGS{'sort_by_val'} ? undef : $ARGS{'sort_by_val'}); my $others = (!exists $ARGS{'others'} ? {} : $ARGS{'others'}); my $_out = $m->current_sink; $m->debug_hook($m->current_comp->path) if (%DB::); ; $caption ||= $pl_names->{$class}; my ($link1, $link2, $lab1, $lab2); if ($class eq 'story') { ($link1, $lab1) = ('#media', $pl_names->{media}) if $others->{media}; ($link2, $lab2) = ('#formatting', $pl_names->{formatting}) if $others->{formatting}; } elsif ($class eq 'media') { ($link1, $lab1) = ('#story', $pl_names->{story}) if $others->{story}; ($link2, $lab2) = ('#formatting', $pl_names->{formatting}) if $others->{formatting}; } else { ($link1, $lab1) = ('#story', $pl_names->{story}) if $others->{story}; ($link2, $lab2) = ('#media', $pl_names->{media}) if $others->{media}; } $_out->('
 '); $_out->( uc $caption ); $_out->('     Sort By: '); $m->comp('/widgets/profile/select.mc', value => $sort_by_val, useTable => 0, indent => 70, width => 100, options => $sort_by->{$class}, name => $class . '_sort_by', js => qq{onChange="document.location='} . $r->uri . "?${class}_sort_by=' + " . qq{escape(this.options[this.selectedIndex].value)"},); $_out->('   '); if ($link1) { $_out->(' '); } if ($link2) { $_out->(' '); } $_out->('
'); $_out->(' '); $_out->(' '); return undef; }, 'create_time'=>1001670213, 'declared_args'=> { '$caption' => { 'default' => ' \'\'' }, '$class' => { 'default' => ' \'story\'' }, '$others' => { 'default' => ' {}' }, '$sort_by_val' => { 'default' => ' undef' } }, 'object_size'=>4286, 'parser_version'=>0.8 ) ;