{"id":114,"date":"2005-04-30T18:45:19","date_gmt":"2005-04-30T09:45:19","guid":{"rendered":"http:\/\/www.mainami.com\/~amano\/blog\/wp\/?p=113"},"modified":"2005-04-30T18:45:19","modified_gmt":"2005-04-30T09:45:19","slug":"mt%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%ae%e4%bd%9c%e3%82%8a%e6%96%b91","status":"publish","type":"post","link":"http:\/\/miku39.jp\/blog\/wp\/?p=114","title":{"rendered":"MT\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u4f5c\u308a\u65b9(1)"},"content":{"rendered":"<p>MT\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u4f5c\u308a\u65b9\u306f\u3044\u308d\u3044\u308d\u306a\u65b9\u304c\u3059\u3067\u306b\u8aac\u660e\u3055\u308c\u3066\u3044\u308b\u304c\u3001<br \/>\nAPI\u306e\u4f7f\u3044\u65b9\u304f\u3089\u3044\u3057\u304b\u898b\u304b\u3051\u306a\u3044\u306e\u3067\u3001\u5225\u306e\u65b9\u9762\u304b\u3089\u8aac\u660e\u3057\u3066\u307f\u308b\u3002<br \/>\n\u3068\u308a\u3042\u3048\u305a\u81ea\u5206\u5411\u3051\u306b\u5206\u304b\u3063\u305f\u3053\u3068\u3092\u307e\u3068\u3081\u308b\u3053\u3068\u304b\u3089\u3002<\/p>\n<p><!--more--><br \/>\n<strong>1. MT::App\u3092\u7d99\u627f\u3057\u3066\u30b5\u30d6\u30af\u30e9\u30b9\u3092\u4f5c\u308b<\/strong><br \/>\n<code><br \/>\npackage MT::App:TestModule; \u2190\u4ed6\u3068\u304b\u3076\u3089\u306a\u3044\u3088\u3046\u306b\u30d1\u30c3\u30b1\u30fc\u30b8\u540d<br \/>\nuse strict;<br \/>\nuse MT::App;<br \/>\n@MT::App::TestModule::ISA=qw(MT::App);<br \/>\n<\/code><\/p>\n<p><strong>2. \u521d\u671f\u5316<\/strong><br \/>\n\u3053\u308c\u3067\u3001MT::App\u30b5\u30d6\u30af\u30e9\u30b9\u306e\u521d\u671f\u5316\u306e\u307b\u307c\u6700\u5c0f\u69cb\u6210\u306b\u3002<br \/>\nadd_methods()\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067<br \/>\nURI\u306b http:\/\/hoge~\/hoge.cgi?__mode=XXXX \u3068\u3042\u3063\u305f\u5834\u5408\u3001<br \/>\nXXXX\u306b\u5bfe\u5fdc\u3059\u308b\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u3092\u547c\u3076\u3088\u3046\u306b\u306a\u308b\u3002<br \/>\n\u4ee5\u4e0b\u306e\u4f8b\u3060\u3068\u3001<br \/>\nhttp:\/\/hoge\/mt-plugintest.cgi?__mode=view \u306e\u3068\u304d\u3001<br \/>\nsub view() \u304c\u547c\u3070\u308c\u308b\u3088\u3046\u306b\u306a\u308b\u3002<br \/>\n$app->{default_mode}=&#8217;view&#8217;; \u3067\u3001<br \/>\n\u6307\u5b9a\u304c\u306a\u304b\u3063\u305f\u3068\u304d\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u547c\u3070\u308c\u308b\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u3092\u6307\u5b9a\u3002<br \/>\n\u30c7\u30d5\u30a9\u30eb\u30c8\u6307\u5b9a\u3057\u306a\u3044\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b\u306e\u3067\u5fc5\u305a\u6307\u5b9a\u3059\u308b\u3053\u3068\u3002<br \/>\n<code><br \/>\nsub init{<br \/>\nmy $app=shift;<br \/>\nmy %param = @_;<br \/>\n$app->SUPER::init(%param) or return;<br \/>\n$app->add_methods('view'=>\\&view);<br \/>\n$app->{default_mode}='view';<br \/>\n$app->{user_class}='MT::Author';<br \/>\n$app->{requires_login}=1;<br \/>\n$app->{mtscript_url}=$app->path . $app->{cfg}->AdminScript;<br \/>\n$app;<br \/>\n}<br \/>\n<\/code><\/p>\n<p><strong>3. \u3068\u308a\u3042\u3048\u305a\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u3092\u7528\u610f<\/strong><br \/>\n$app->SUPER::load_tmpl() \u3067HTML\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30ed\u30fc\u30c9\u3067\u304d\u308b\u3002<br \/>\n\u30ed\u30fc\u30c9\u3067\u304d\u308b\u3068 HTML::Template\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d7\u3051\u3068\u308c\u308b\u306e\u3067\u3001<br \/>\nHTML::Template\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u3002<br \/>\n$app->{query}\u306f CGI\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d7\u3051\u3068\u308c\u308b\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306f\u3001MT\u81ea\u4f53\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u306eheader.tmpl\u3092\u4f7f\u3063\u3066<br \/>\n\u30d8\u30c3\u30c0\u3060\u3051\u8868\u793a\u3057\u3066\u3044\u308b\u3068\u3053\u308d\u3002<br \/>\n<code><br \/>\nsub view{<br \/>\nmy $app=shift;<br \/>\nmy $tmpl=$app->SUPER::load_tmpl(\"..\/tmpl\/cms\/header.tmpl\");<br \/>\nmy $q = $app->{query};<br \/>\nmy $blog_id = $q->param('blog_id');<br \/>\nmy $blog = MT::Blog->load($blog_id);<br \/>\n$app->add_breadcrumb(\"Main Menu\",$app->{mtscript_url});<br \/>\n$tmpl->param(SCRIPT_URL=>$app->{mtscript_url});<br \/>\n$tmpl->param(AUTHOR_NAME=>$app->{author}->name);<br \/>\n$tmpl->param(AUTHOR_ID=>$app->{author}->id);<br \/>\n$app->l10n_filter($tmpl->output);<br \/>\n}<br \/>\n<\/code><br \/>\n$app->l10n_filter()\u304c\u3001MT_TRANS\u306e\u30ed\u30fc\u30ab\u30e9\u30a4\u30ba\u30d5\u30a3\u30eb\u30bf\u306b\u306a\u3063\u3066\u308b\u305d\u3046\u3060\u3002<br \/>\n\u3053\u3044\u3064\u4f7f\u3063\u3066HTML\u3092\u30a2\u30a6\u30c8\u30d7\u30c3\u30c8\u3057\u306a\u3044\u3068\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u4e2d\u306eMT_TRANS&#8230;\u304c<br \/>\n\u305d\u306e\u307e\u307e\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3002<\/p>\n<p><strong>4.\u5b9f\u884c<\/strong><br \/>\n\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u7528\u610f\u3057\u3066 run \u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3076\u3060\u3051\u3067OK<br \/>\n<code><br \/>\nuse testmodule;<br \/>\nmy $app=MT::App::TestModule->new(Config=>\"..\/mt.cfg\",Directory=>\"..\/\")<br \/>\nor die MT::App::TestModule->errstr;<br \/>\nlocal $SIG{__WARN__} = sub { $app->trace($_[0]) };<br \/>\n$app->run;<br \/>\n<\/code><\/p>\n<p>\u3068\u3001\u307e\u3041\u3001\u3053\u3093\u306a\u611f\u3058\u3067 MT::App \u3092\u7d99\u627f\u3057\u3066MT\u30a2\u30d7\u30ea\u304c\u4f5c\u6210\u3067\u304d\u308b\u3002<br \/>\nMT->new();&#8230;. \u304b\u3089\u59cb\u3081\u308b\u3084\u308a\u65b9\u3067\u3082\u3044\u3044\u3057\u3001\u597d\u304d\u306a\u3088\u3046\u306b\u4f5c\u308d\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MT\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u4f5c\u308a\u65b9\u306f\u3044\u308d\u3044\u308d\u306a\u65b9\u304c\u3059\u3067\u306b\u8aac\u660e\u3055\u308c\u3066\u3044\u308b\u304c\u3001 API\u306e\u4f7f\u3044\u65b9\u304f\u3089\u3044\u3057\u304b\u898b\u304b\u3051\u306a\u3044\u306e\u3067\u3001\u5225\u306e\u65b9\u9762\u304b\u3089\u8aac\u660e\u3057\u3066\u307f\u308b\u3002 \u3068\u308a\u3042\u3048\u305a\u81ea\u5206\u5411\u3051\u306b\u5206\u304b\u3063\u305f\u3053\u3068\u3092\u307e\u3068\u3081\u308b\u3053\u3068\u304b\u3089\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[3],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p82ahK-1Q","jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/miku39.jp\/blog\/wp\/index.php?rest_route=\/wp\/v2\/posts\/114"}],"collection":[{"href":"http:\/\/miku39.jp\/blog\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/miku39.jp\/blog\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/miku39.jp\/blog\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/miku39.jp\/blog\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=114"}],"version-history":[{"count":0,"href":"http:\/\/miku39.jp\/blog\/wp\/index.php?rest_route=\/wp\/v2\/posts\/114\/revisions"}],"wp:attachment":[{"href":"http:\/\/miku39.jp\/blog\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/miku39.jp\/blog\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/miku39.jp\/blog\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}