/[SQLSession]/trunk/share/web/templates/fragments/enter_query
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/share/web/templates/fragments/enter_query

Parent Directory Parent Directory | Revision Log Revision Log


Revision 114 - (show annotations)
Fri Apr 13 10:22:23 2007 UTC (17 years ago) by dpavlin
File size: 2161 byte(s)
move export CVS in between buttons
1 <%args>
2 $sth => undef
3 $q => undef
4 $max_rows => 100
5
6 $sql_query => undef
7 $on_database => undef
8 $parent => undef
9 </%args>
10 <%init>
11
12 $sql_query = $q->sql_query if ($q && $q->can('sql_query'));
13 $on_database = $q->on_database->id if ($q && $q->can('on_database'));
14
15 my $query = Jifty->web->new_action(
16 class => 'DoSQL',
17 moniker => 'query',
18 );
19
20 my $result = Jifty->web->response->result('query');
21 $sth = $result->content('sth') if $result and !defined $sth;
22
23 my $edit = Jifty->web->current_user->role('edit');
24 warn $edit ? 'edit mode for SQL' : 'student mode';
25
26 </%init>
27
28 % if ($q && $q->can('note')) {
29 <div class="sql-note"><% $q->note %></div>
30 % }
31
32 <% Jifty->web->form->start() %>
33 % if ( Jifty->web->current_user->id ) {
34 <% $query->form_field('sql_query',
35 default_value => $sql_query,
36 cols => 80,
37 rows => 12,
38 ) %>
39 % } else {
40 <% $query->hidden('sql_query', $sql_query ) %>
41 <% $query->form_value('sql_query', default_value => $sql_query ) %>
42 % }
43
44 <div class="database-schema">
45 <%perl>
46 my $db = SQLSession::Model::Database->new();
47 $db->load_by_cols( id => $on_database );
48 if ($db->dsn =~ m/^.*dbname=(.+)/) {
49 $m->out("<a href=\"/static/spy/$1/index.html\" target=\"_spy\">$1 shema</a>");
50 }
51 </%perl>
52 </div>
53
54 % if ( $edit ) {
55 <% $query->form_field('on_database', default_value => $on_database ) %>
56 % } else {
57
58 <!-- hidden database -->
59 <% $query->hidden('on_database', $on_database ) %>
60 <% $query->form_value('on_database', default_value => $on_database ) %>
61
62 % }
63
64 <div class="submit_button">
65 % if ( Jifty->web->current_user->id ) {
66 <% $query->button( label => 'Try it!' ) %>
67 % }
68
69 % if ($sth) {
70 <% Jifty->web->link(
71 label => 'CSV export',
72 url => '/csv',
73 parameters => {
74 sql_query => $query->argument_value('sql_query'),
75 on_database => $query->argument_value('on_database'),
76 },
77 #as_button => 1,
78 ) %>
79 % }
80
81 % if ($sth && $edit) {
82 <% Jifty->web->tangent(
83 label => 'Save query',
84 onclick => {
85 region => 'query',
86 replace_with => '/fragments/save_query',
87 args => {
88 sql_query => $query->argument_value('sql_query'),
89 on_database => $query->argument_value('on_database'),
90 parent => $parent,
91 },
92 #toggle => 1,
93 },
94 as_button => 1,
95 ) %>
96 % }
97
98 </div>

  ViewVC Help
Powered by ViewVC 1.1.26