+sub sortable_table_header {
+ my ($self, $by, %params) = _hashify(2, @_);
+
+ my $controller = $self->{CONTEXT}->stash->get('SELF');
+ my $models = $params{models} || $self->{CONTEXT}->stash->get('MODELS');
+ my $sort_spec = $models->get_sort_spec;
+ my $by_spec = $sort_spec->{$by};
+ my %current_sort_params = $models->get_current_sort_params;
+ my ($image, $new_dir) = ('', $current_sort_params{dir});
+ my $title = delete($params{title}) || $::locale->text($by_spec->{title});
+
+ if ($current_sort_params{sort_by} eq $by) {
+ my $current_dir = $current_sort_params{sort_dir} ? 'up' : 'down';
+ $image = '<img border="0" src="image/' . $current_dir . '.png">';
+ $new_dir = 1 - ($current_sort_params{sort_dir} || 0);
+ }
+
+ $params{ $models->sorted->form_params->[0] } = $by;
+ $params{ $models->sorted->form_params->[1] } = ($new_dir ? '1' : '0');
+
+ return '<a href="' . $models->get_callback(%params) . '">' . _H($title) . $image . '</a>';
+}
+
+sub paginate_controls {
+ my ($self, %params) = _hashify(1, @_);
+
+ my $controller = $self->{CONTEXT}->stash->get('SELF');
+ my $models = $params{models} || $self->{CONTEXT}->stash->get('MODELS');
+ my $pager = $models->paginated;
+# my $paginate_spec = $controller->get_paginate_spec;
+
+ my %paginate_params = $models->get_paginate_args;
+
+ my %template_params = (
+ pages => \%paginate_params,
+ url_maker => sub {
+ my %url_params = _hashify(0, @_);
+ $url_params{ $pager->form_params->[0] } = delete $url_params{page};
+ $url_params{ $pager->form_params->[1] } = delete $url_params{per_page} if exists $url_params{per_page};
+
+ return $models->get_callback(%url_params);
+ },
+ %params,
+ );
+
+ return SL::Presenter->get->render('common/paginate', %template_params);
+}
+