/[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 102 - (show annotations)
Fri Feb 16 23:40:21 2007 UTC (17 years, 2 months ago) by dpavlin
File size: 1929 byte(s)
added concept of "parent" query if you started by editing existing one
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 && $edit) {
70 <% Jifty->web->tangent(
71 label => 'Save query',
72 onclick => {
73 region => 'query',
74 replace_with => '/fragments/save_query',
75 args => {
76 sql_query => $query->argument_value('sql_query'),
77 on_database => $query->argument_value('on_database'),
78 parent => $parent,
79 },
80 #toggle => 1,
81 },
82 as_button => 1,
83 ) %>
84 % }
85
86 </div>

  ViewVC Help
Powered by ViewVC 1.1.26