/[suikacvs]/webroot/swe/lib/SWE/Object/Document.pm
Suika

Contents of /webroot/swe/lib/SWE/Object/Document.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sun Jul 12 10:26:28 2009 UTC (15 years, 9 months ago) by wakaba
Branch: MAIN
++ swe/lib/SWE/Object/ChangeLog	12 Jul 2009 10:25:36 -0000
2009-07-12  Wakaba  <wakaba@suika.fam.cx>

	* Document.pm: New module.

++ swe/lib/suikawiki/ChangeLog	12 Jul 2009 10:25:59 -0000
	* main.pl: Facted out the code to associate new pages names to the
	document.

2009-07-12  Wakaba  <wakaba@suika.fam.cx>

1 wakaba 1.1 package SWE::Object::Document;
2     use strict;
3     use warnings;
4    
5     sub new ($%) {
6     my $class = shift;
7     my $self = bless {@_}, $class;
8    
9     return $self;
10     }
11    
12     sub db { $_[0]->{db} }
13    
14     sub id { $_[0]->{id} }
15    
16     sub associate_names ($$%) {
17     my ($self, $names, %args) = @_;
18    
19     ## NOTE: names_lock MUST be executed before the invocation.
20    
21     my $id = $self->id;
22     my $time = $args{time} || time;
23     my $sw3_pages = $self->{sw3_pages}; ## TODO: ...
24    
25     my $vc = $self->db->vc;
26    
27     my $name_prop_db = $self->{name_prop_db}; ## TODO: ...
28     local $name_prop_db->{version_control} = $vc;
29    
30     my $name_history_db = $self->db->name_history;
31     local $name_history_db->{version_control} = $vc;
32    
33     for my $name (keys %$names) {
34     my $name_props = $name_prop_db->get_data ($name);
35     unless (defined $name_props) {
36     my $sw3id = $sw3_pages->get_data ($name);
37     main::convert_sw3_page ($sw3id => $name); ## TODO: ...
38    
39     $name_props = $name_prop_db->get_data ($name);
40     unless (defined $name_props) {
41     $name_history_db->append_data ($name => [$time, 'c']);
42     }
43     }
44    
45     push @{$name_props->{id} ||= []}, $id;
46     $name_props->{name} = $name;
47     $name_prop_db->set_data ($name => $name_props);
48    
49     $name_history_db->append_data ($name => [$time, 'a', $id]);
50     }
51    
52     my $user = $args{user} || '(anon)';
53     $vc->commit_changes ("id=$id created by $user");
54     } # associate_names
55    
56     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24