-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathFolder.pm
105 lines (84 loc) · 2.58 KB
/
Folder.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Movable Type (r) Open Source (C) 2001-2010 Six Apart, Ltd.
# This program is distributed under the terms of the
# GNU General Public License, version 2.
#
# $Id$
package MT::Folder;
use strict;
use base qw( MT::Category );
__PACKAGE__->install_properties( {
class_type => 'folder',
child_of => 'MT::Blog',
child_classes => [ 'MT::Placement', 'MT::FileInfo' ],
}
);
sub class_label {
return MT->translate("Folder");
}
sub class_label_plural {
MT->translate("Folders");
}
sub contents_label {
MT->translate("Page");
}
sub contents_label_plural {
MT->translate("Pages");
}
sub list_props {
return {
parent => { base => 'category.parent', },
entry_count => { base => 'category.entry_count', },
custom_sort => { class => 'folder', base => 'category.custom_sort', },
};
}
sub basename_prefix {
"folder";
}
sub remove {
my $folder = shift;
my $delete_files_at_rebuild = MT->config('DeleteFilesAtRebuild');
my $rebuild_at_delete = MT->config('RebuildAtDelete');
my @moving_pages;
if ( ref $folder && $rebuild_at_delete && $delete_files_at_rebuild ) {
my $search_pages;
$search_pages = sub {
my $folder = shift;
my $join =
MT::Placement->join_on( 'entry_id',
{ category_id => $folder->id, },
{ unique => 1 },
);
push @moving_pages,
MT->model('page')->load( undef, { join => $join } );
my @children = $folder->children_categories;
for my $child (@children) {
$search_pages->($child);
}
};
$search_pages->($folder);
require MT::WeblogPublisher;
for my $page (@moving_pages) {
MT::WeblogPublisher->remove_entry_archive_file(
Entry => $page,
ArchiveType => 'Page',
);
}
} ## end if ( ref $folder && $rebuild_at_delete...)
$folder->SUPER::remove(@_) or return $folder->errstr;
if ( ref $folder && $rebuild_at_delete ) {
for my $page (@moving_pages) {
$page->clear_cache();
MT->rebuild_entry( Entry => $page );
}
}
1;
} ## end sub remove
1;
__END__
=head1 NAME
MT::Folder
=head1 METHODS
TODO
=head1 AUTHOR & COPYRIGHT
Please see L<MT/AUTHOR & COPYRIGHT>.
=cut