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

  ViewVC Help
Powered by ViewVC 1.1.26