Permalink
Browse files

option of ignore upload root.

  • Loading branch information...
1 parent f362674 commit b3abd2ae2f2f6849dea1215c4f23e32ec386e728 @naoaki011 committed May 16, 2012
View
8 plugins/UploadPrefs/config.yaml
@@ -1,16 +1,16 @@
name: Upload Prefs
-id: 'UploadPrefs'
+id: UploadPrefs
description: <__trans phrase="Set default values and actions of file upload.">
author_name: naoaki.onozaki
author_link: http://www.zelazny.mydns.jp/
plugin_link: https://github.com/naoaki011/mt-plugin-upload-prefs
l10n_class: UploadPrefs::L10N
-version: 1.01
+version: 1.02
blog_config_template: blog_config_upload_prefs.tmpl
settings:
upload_folder_base:
- default: ''
+ default: 'images/'
scope: blog
name_of_siteroot:
default: <__trans phrase="Site Root">
@@ -29,5 +29,5 @@ settings:
scope: blog
callbacks:
template_source.asset_upload:
- code: $UploadPrefs::UploadPrefs::Plugin::xfm_src
+ code: $UploadPrefs::UploadPrefs::Plugin::_asset_src_upload
priority: 1
View
1 plugins/UploadPrefs/lib/UploadPrefs/L10N/ja.pm
@@ -18,6 +18,7 @@ use vars qw( %Lexicon );
'Check this box to Admin will change upload path.' => 'ここにチェックを入れると、管理者のみアップロード先の変更が可能になります。',
'Disabled Upload Site Root' => 'サイトルートへのアップロードを禁止',
'Check this box to Never Upload Site Root.' => 'ここにチェックを入れると、サイトルートへのアップロードが出来なくなります。',
+ 'Ignore BlankPath.' => 'パスを空白には出来ません',
);
1;
View
42 plugins/UploadPrefs/lib/UploadPrefs/Plugin.pm
@@ -4,10 +4,10 @@ use MT 5.1;
use warnings;
use strict;
-sub xfm_src {
+sub _asset_src_upload {
my ($cb, $app, $tmpl) = @_;
my $blog = $app->blog or return;
- return unless ((MT->version_number >= 5.12) && (MT->version_number < 5.2));
+ return unless ((MT->version_number >= 5) && (MT->version_number < 5.2));
my $user = current_user( $app ) or return;
my $plugin = MT->component("UploadPrefs");
@@ -17,7 +17,7 @@ sub xfm_src {
$is_admin = $user->is_superuser ? 1
: $app->can_do('administer_blog') ? 2
: 0;
- MT->log('admin: ' . $is_admin);
+ #MT->log('admin: ' . $is_admin);
}
my $upload_folder_base = $plugin->get_config_value('upload_folder_base' , 'blog:' . $blog->id ) || '';
@@ -126,6 +126,30 @@ HTML
}
}
+ my $ignore_root = $plugin->get_config_value('ignore_root_path' , 'blog:' . $blog->id ) || 0;
+ if ($ignore_root) {
+ my $old = <<'HTML';
+ <div class="actions-bar">
+HTML
+ $old = quotemeta($old);
+ my $new = <<"HTML";
+ <script type="text/javascript">
+ jQuery(document).ready( function () {
+ jQuery('#upload-form').validate({
+ rules: {
+ extra_path: "required"
+ },
+ messages: {
+ extra_path: "<__trans_section component="UploadPrefs"><__trans phrase="Ignore BlankPath."></__trans_section>"
+ }
+ });
+ });
+ </script>
+ <div class="actions-bar">
+HTML
+ $$tmpl =~ s!$old!$new!;
+ }
+
my $ua = $ENV{'HTTP_USER_AGENT'};
if ($ua =~ /(Firefox\/|Chrome\/|Opera\/)/) {
my $old = <<'HTML';
@@ -143,7 +167,7 @@ HTML
<input type="file" name="file" id="file" />
HTML
$old = quotemeta($old);
- my $new = <<"HTML";
+ $new = <<"HTML";
<input type="file" name="file" id="file" />
<script>
jQuery(document).ready( function () {
@@ -191,4 +215,14 @@ sub current_user {
return undef;
}
+sub include_multibyte {
+ my ( $file_path ) = @_;
+ my $file_basename = File::Basename::basename( $file_path );
+ my $encoded = encode_url( $file_basename );
+ unless ( $file_basename eq $encoded ) {
+ return 1;
+ }
+ return 0;
+}
+
1;

0 comments on commit b3abd2a

Please sign in to comment.