OSDN Git Service

96a8d346388d41d2a0c76e181ad20a39984f0e73
[mtpm/PluginManager.git] / lib / PluginManager / Repository.pm
1 package PluginManager::Repository;
2
3 sub repository_root {
4         my ($create_if_not_exists) = @_;
5
6         my $app = MT->instance;
7     my $dir_mode = (~ oct(MT->config('DirUmask'))) & oct('777');
8         #File::Spec->catdir($app->server_path(), 'mpm');
9         my $path = File::Spec->catdir($app->support_directory_path, 'mpm');
10         if (! -d $path && $create_if_not_exists) {
11                 mkdir($path);
12                 chmod($dir_mode, $path);
13         }
14         $path;
15 }
16
17 sub repository_pool {
18         my ($create_if_not_exists) = @_;
19
20     my $dir_mode = (~ oct(MT->config('DirUmask'))) & oct('777');
21         my $path = File::Spec->catdir(repository_root(@_), 'pool');
22         if (! -d $path && $create_if_not_exists) {
23                 mkdir($path);
24                 chmod($dir_mode, $path);
25         }
26         $path;
27 }
28
29 sub repository_url {
30         my ($create_if_not_exists) = @_;
31
32         my $app = MT->instance;
33         my $root_path = repository_root;
34         
35         return '' if ! -d $root_path;
36
37         return $app->support_directory_url . 'mpm/';
38 }
39
40 sub available_components {
41         my @defaults = qw(
42                 core
43                 typepadantispam
44                 markdown/smartypants.pl
45                 spamlookup/spamlookup_words.pl
46                 spamlookup/spamlookup.pl
47                 multiblog
48                 textile/textile2.pl
49                 spamlookup/spamlookup_urls.pl
50                 wxrimporter/wxrimporter.pl
51                 stylecatcher
52                 markdown/markdown.pl
53                 cloner/cloner.pl
54                 facebookcommenters
55                 community
56                 actionstreams
57                 commercial
58                 widgetmanager
59                 motion
60                 mixicomment
61                 feedsapplite
62                 communityactionstreams
63         );
64         my $defaults_count = scalar(@defaults);
65         my %comp = %MT::Components;
66         grep({
67                 my $c = $_;
68                 grep({ $_ ne $c } @defaults) == $defaults_count
69         } keys(%MT::Components));
70 }
71
72 1;