Changeset 431

Show
Ignore:
Timestamp:
09/19/07 20:21:33 (14 months ago)
Author:
ogawa
Message:

add list_item_actions.

Location:
HatenaBookmarker/trunk/HatenaBookmarker
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • HatenaBookmarker/trunk/HatenaBookmarker/HatenaBookmarker.pl

    r430 r431  
    3535sub init_registry { 
    3636    my $plugin = shift; 
    37     my $callbacks; 
    38     if (MT->instance->isa('MT::App::CMS')) { 
    39         $callbacks = { 'cms_post_save.entry' => \&cms_post_save_entry }; 
    40     } else { 
    41         $callbacks = { 'MT::Entry::post_save' => \&post_save_entry }; 
     37    if (!MT->instance->isa('MT::App::CMS')) { 
     38        $plugin->registry({ 
     39            callbacks => { 
     40                'MT::Entry::post_save' => \&post_save_entry 
     41            } 
     42        }); 
     43        return; 
    4244    } 
    4345    $plugin->registry({ 
    44         callbacks => $callbacks 
     46        callbacks => { 
     47            'cms_post_save.entry' => \&cms_post_save_entry 
     48        }, 
     49        applications => { 
     50            cms => { 
     51                list_actions => { 
     52                    entry => { 
     53                        bookmark_entry => { 
     54                            label           => $plugin->translate('Bookmark Entries'), 
     55                            continue_prompt => $plugin->translate('Are you sure you want to bookmark the selected entries?'), 
     56                            code            => \&bookmark_entries, 
     57                            permission      => 'create_post', 
     58                        } 
     59                    }, 
     60                    page => { 
     61                        bookmark_page => { 
     62                            label           => $plugin->translate('Bookmark Pages'), 
     63                            continue_prompt => $plugin->translate('Are you sure you want to bookmark the selected pages?'), 
     64                            code            => \&bookmark_entries, 
     65                            permission      => 'create_post', 
     66                        } 
     67                    }, 
     68                } 
     69            } 
     70        } 
    4571    }); 
    4672} 
     
    5177    return unless $entry->isa('MT::Entry') && $entry->status == MT::Entry::RELEASE(); 
    5278    MT::Util::start_background_task( 
    53         sub { do_bookmark(MT->instance, $entry) } 
     79        sub { bookmark_entry(MT->instance, $entry) } 
    5480    ); 
    5581} 
     
    6086    return unless $entry->isa('MT::Entry') && $entry->status == MT::Entry::RELEASE(); 
    6187    MT::Util::start_background_task( 
    62         sub { do_bookmark($app, $entry) } 
     88        sub { bookmark_entry($app, $entry) } 
    6389    ); 
     90} 
     91 
     92sub bookmark_entries { 
     93    my $app = shift; 
     94    my $perms = $app->permissions; 
     95    return $app->trans_error('Permission Denied.') 
     96        unless $perms && $perms->can_create_post; 
     97 
     98    my $type = $app->param('_type') || 'entry'; 
     99    my $class = MT->model($type); 
     100 
     101    my @entry_ids = $app->param('id') 
     102        or return $app->error($plugin->translate('No [_1] was selected to bookmark.', $type)); 
     103    for my $entry_id (@entry_ids) { 
     104        my $entry = $class->load($entry_id) 
     105            or return $app->error($plugin->translate('Invalid entry_id')); 
     106        bookmark_entry($app, $entry) 
     107            if $entry->status == MT::Entry::RELEASE(); 
     108    } 
     109    $app->call_return; 
    64110} 
    65111 
     
    68114use HatenaBookmarker::Client; 
    69115 
    70 sub do_bookmark { 
     116sub bookmark_entry { 
    71117    my ($app, $entry) = @_; 
    72118 
  • HatenaBookmarker/trunk/HatenaBookmarker/lib/HatenaBookmarker/L10N/ja.pm

    r430 r431  
    1414    'Hatena Username' => 'はてなIDのユーザ名', 
    1515    'Hatena Password' => 'はてなIDのパスワード', 
     16    'Bookmark Entries' => 'ブログ記事のブックマーク', 
     17    'Are you sure you want to bookmark the selected entries?' => '選択したブログ記事をブックマークしてよろしいですか?', 
     18    'Bookmark Pages' => 'ウェブページのブックマーク', 
     19    'Are you sure you want to bookmark the selected entries?' => '選択したウェブページをブックマークしてよろしいですか?', 
    1620); 
    1721