From: Allen Day Date: Fri, 2 Jan 2004 10:04:37 +0000 (+0000) Subject: transfering functionality from branch X-Git-Tag: v0.06~243 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8bba52b226bff22025ab952d578da827155743c9;p=dbsrgits%2FSQL-Translator.git transfering functionality from branch --- diff --git a/lib/SQL/Translator/Producer/Turnkey.pm b/lib/SQL/Translator/Producer/Turnkey.pm index 6acacf7..529c004 100644 --- a/lib/SQL/Translator/Producer/Turnkey.pm +++ b/lib/SQL/Translator/Producer/Turnkey.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::Turnkey; # ------------------------------------------------------------------- -# $Id: Turnkey.pm,v 1.14 2004-01-02 08:15:09 allenday Exp $ +# $Id: Turnkey.pm,v 1.15 2004-01-02 10:04:37 allenday Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 Allen Day , # Brian O'Connor . @@ -23,7 +23,7 @@ package SQL::Translator::Producer::Turnkey; use strict; use vars qw[ $VERSION $DEBUG ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.14 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.15 $ =~ /(\d+)\.(\d+)/; $DEBUG = 1 unless defined $DEBUG; use SQL::Translator::Schema::Constants; @@ -386,11 +386,20 @@ sub _render_record { my @output = (); my $row = {}; my $field_hash = {}; + + #data [% FOREACH value = node.value.data_fields %] - [% IF value != 1 %] - $field_hash->{[% value %]} = $dbobject->[% value %](); - [% END %] - [% END %] + [% IF value != 1 %] + $field_hash->{[% value %]} = $dbobject->[% value %](); + [% END %] + [% END %] + + #keys + [% FOREACH value = node.value.edges %] + [% NEXT IF value.type != 'import' %] + $field_hash->{[% value.thisfield.name %]} = $dbobject->[% value.thisfield.name %](); + [% END %] + $row->{data} = $field_hash; $row->{id} = $dbobject->id(); push @output, $row; @@ -405,11 +414,20 @@ sub _render_list { { my $row = {}; my $field_hash = {}; - [% FOREACH value = node.value.data_fields %] - [% IF value != 1 %] - $field_hash->{[% value %]} = $object->[% value %](); - [% END %] - [% END %] + + #data + [% FOREACH value = node.value.data_fields %] + [% IF value != 1 %] + $field_hash->{[% value %]} = $object->[% value %](); + [% END %] + [% END %] + + #keys + [% FOREACH value = node.value.edges %] + [% NEXT IF value.type != 'import' %] + $field_hash->{[% value.thisfield.name %]} = $dbobject->[% value.thisfield.name %](); + [% END %] + $row->{data} = $field_hash; $row->{id} = $object->id(); push @output, $row; @@ -537,6 +555,35 @@ EOF [% END %] +[% BLOCK make_linked_dbobject %] + [% PERL %] + $stash->set(linked_dbobject => [% class %]->retrieve([% id %])); + [% END %] +[% END %] +[% MACRO obj2link(obj) SWITCH ref(obj) %] + [% CASE '' %] + [% obj %] + [% CASE DEFAULT %] + [% IF obj.name %] + [% obj.name %] + [% ELSE %] + [% obj %] + [% END %] +[% END %] +[% MACRO obj2url(obj) SWITCH obj %] + [% CASE DEFAULT %] + /?id=[% obj %];class=[% ref(obj) %] +[% END %] +[% MACRO obj2desc(obj) SWITCH ref(obj) %] + [% CASE '' %] + [% obj %] + [% CASE DEFAULT %] + [% IF obj.value %] + [% obj.value %] + [% ELSE %] + [% obj %] + [% END %] +[% END %] [% MACRO renderatom(atom, dbobject) SWITCH atom.name %] [- FOREACH node = nodes -] [- IF !node.value.is_trivial_link -] @@ -556,19 +603,28 @@ EOF [- pkey = "Turnkey::Model::${pname}" -] [- FOREACH field = node.value.data_fields -] [- IF field != "1" -] - [- field -][% fields.[- field -] %] + [- field -][% obj2link(fields.[- field -]) %] + [- END -] [- END -] + [- FOREACH field = node.value.edges -] + [- NEXT IF field.type != 'import' -] + [- field.thisfield.name -][% obj2link(fields.[- field.thisfield.name -]) %] [- END -] [% id = record.id %] - Link + Link
[% END %] [% END %] [- END -] [- END -] [% MACRO renderlist(lstArr) BLOCK %] - [% FOREACH item = lstArr %] - [% item %] +
    + [% FOREACH item = lstArr %] + [% class = ref(atom) | replace('::Atom::', '::Model::') %] + [% id = item.id %] + [% PROCESS make_linked_dbobject %] +
  • [% obj2link(linked_dbobject) %]
  • [% END %] +
[% END %] EOF