MT4.x¥×¥é¥°¥¤¥óºîÀ®/´ÉÍý²èÌ̤Υá¥Ë¥å¡¼¤ËÆȼ«¹àÌܤòÄɲ乤ë http://www.ark-web.jp/sandbox/wiki/300.html

MT4.x¥×¥é¥°¥¤¥óºîÀ®/´ÉÍý²èÌ̤Υá¥Ë¥å¡¼¤ËÆȼ«¹àÌܤòÄɲ乤ë

[edit]

¤ä¤ê¤¿¤¤¤³¤È

MT¤Î´ÉÍý²èÌ̤ˤϡ֥·¥¹¥Æ¥à¥á¥Ë¥å¡¼¡×¡¢¡Ö¿·µ¬ºîÀ®¡×¡¢¡Ö°ìÍ÷¡×¡¢¡ÖÀßÄê¡×¡¢¡Ö¥Ä¡¼¥ë¡×¤È¤¤¤Ã¤¿¡¢¥Þ¥¦¥¹¤ò¥Õ¥©¡¼¥«¥¹¤¹¤ë¤È²¼ÁؤΥá¥Ë¥å¡¼¤¬É½¼¨¤µ¤ì¤ë»ÅÁȤߤ¬¤¢¤ê¤Þ¤¹¡£¤³¤ì¤é¤Î¥á¥Ë¥å¡¼¤ËǤ°Õ¤Î¹àÌܤòÄɲ乤뤳¤È¤ò¹Ô¤¤¤Þ¤¹¡£

[edit]

ÊýË¡

Plugin¥Õ¥¡¥¤¥ë¤Îinit_registry()¥á¥½¥Ã¥É¤ÇÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
Plugin¤ÎºîÀ®¤Ë´Ø¤·¤Æ¤ÏMT4.0¥×¥é¥°¥¤¥óºîÀ®?¤Î¾¤Î¥³¥ó¥Æ¥ó¥Ä¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£

¥á¥Ë¥å¡¼¤òÄɲ乤ë¤Ë¤Ï¡¢°Ê²¼¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£

sub init_registry {
    my $plugin = shift;
    $plugin->registry({
        :
    'applications' => {
        'cms' => {
            'menus' => {
                'manage:hoge' => {
                   label => 'Hoge',
                   order => 10000,
                   mode => 'list_hoge',
                   view => "system",
                },
            },
            :
        },
    },
    :
  });

¤³¤ì¤Ç¡¢Hoge¤È¤¤¤¦¥á¥Ë¥å¡¼¤¬¥·¥¹¥Æ¥à´ÉÍý²èÌ̤Î[°ìÍ÷]¤ÎÃæ¤ËʤӤޤ¹¡£¤Þ¤¿¡¢Hoge¤Ë¤Ï__mode=list_hoge¤Ø¤Î¥ê¥ó¥¯¤¬Ä¥¤é¤ì¤Þ¤¹¡£

manage:[Åö³º¥á¥Ë¥å¡¼¤Îkey] => {
   label => [¥á¥Ë¥å¡¼É½¼¨¥é¥Ù¥ë],
   order => [ɽ¼¨½ç],
   mode => [¥ê¥ó¥¯Àè__mode],
   view => [ɽ¼¨Àè¡£system¤Ê¤é¥·¥¹¥Æ¥à´ÉÍý²èÌÌ¡¢blog¤Ê¤é¥Ö¥í¥°´ÉÍý²èÌÌ],
},

¤È¤¤¤Ã¤¿·Á¤Ç¤¹¡£Â¾¤Ë¤â system_permission¤Ç´ÉÍý¼Ô¤À¤±¤Ë¥¢¥¯¥»¥¹¤òµö¤¹¤È¤¤¤Ã¤¿ÀßÄ꤬²Äǽ¤Ç¤¹¡£

[edit]

¥á¥Ë¥å¡¼ID¤Î¥ë¡¼¥ë

[ÅÐÏ¿Àè¥á¥Ë¥å¡¼key]:[Åö³º¥á¥Ë¥å¡¼¤Îkey]¤Ç»ØÄꤷ¤Þ¤¹¡£

ÅÐÏ¿Àè¥á¥Ë¥å¡¼¤Îkey¤Ï°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

key¥á¥Ë¥å¡¼¡ÊÆüËܸìɽµ­¡Ë
create¿·µ¬ºîÀ®
manage°ìÍ÷
design¥Ç¥¶¥¤¥ó
prefsÀßÄê
tools¥Ä¡¼¥ë
system¥·¥¹¥Æ¥à¥á¥Ë¥å¡¼

½¾¤Ã¤Æ¡¢¿·¤·¤¯key=hoge¤Î¥á¥Ë¥å¡¼¤ò¿·µ¬ºîÀ®ÇÛ²¼¤ËÄɲ乤ë¾ì¹ç¤Ï

create:hoge

¤È¤¤¤¦ID¤ò»ØÄꤹ¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£

¥á¥Ë¥å¡¼ID¤ÏÁ´¥á¥Ë¥å¡¼¤òÄ̤·¤Æ¥æ¥Ë¡¼¥¯¤Ç¤¢¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£

¡Ê¥á¥Ë¥å¡¼ID¤È¸Æ¾Î¤·¤Æ¤¤¤Þ¤¹¤¬¡¢Àµ¤·¤¯¤Ï¤Ê¤ó¤È¸Æ¤Ù¤Ð¤¤¤¤¤Î¤«¤ï¤«¤ê¤Þ¤»¤ó^^;¡Ë

¤Þ¤¿¡¢Æȼ«¤Îkey¤òÄɲ乤뤳¤È¤â¤Ç¤­¤Þ¤¹¡£

         # Hoge¤È¤¤¤¦key¤òºî¤ê¡¢¤½¤ÎÇÛ²¼¤Ëlist¤òÄɲ乤롣
         'hoge' => {
           label => 'Hoge',
           order => 10000,
         },
         'hoge:list' => {
           label => 'List of Hoge',
           order => 100,
           mode => 'list_hoge',
         },
[edit]

order¤Î»ØÄê

order¤Ï¿ôÃͤ¬Â礭¤¤¤Û¤É²¼¡Ê¤Þ¤¿¤Ï±¦¡Ë¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¡£

[edit]

view¤Î»ØÄê

view¤Ë»ØÄê¤Ç¤­¤ëÃͤȵóÆ°¤Ï¼¡¤ÎÄ̤ê¤Ç¤¹¡£

view¤ÎÃ͵óÆ°
system¥·¥¹¥Æ¥à´ÉÍý²èÌ̤Υá¥Ë¥å¡¼¤Ëɽ¼¨¤µ¤ì¤ë
blog¥Ö¥í¥°´ÉÍý²èÌ̤Υá¥Ë¥å¡¼¤Ëɽ¼¨¤µ¤ì¤ë

¤Þ¤¿¡¢view¤ò»ØÄꤷ¤Ê¤¤¾ì¹ç¡¢¥·¥¹¥Æ¥à´ÉÍý²èÌÌ¡¢¥Ö¥í¥°´ÉÍý²èÌ̤ÎÁÐÊý¤Î¥á¥Ë¥å¡¼¤Ëɽ¼¨¤µ¤ì¤Þ¤¹

[edit]

permission¤Î»ØÄê

¥æ¡¼¥¶¤Î¥í¡¼¥ë¤Ë±þ¤¸¤¿¥¢¥¯¥»¥¹¸¢¤òÀßÄê¤Ç¤­¤Þ¤¹¡£
¥¢¥¯¥»¥¹¸¢¸Â¤ò»ý¤¿¤Ê¤¤¥æ¡¼¥¶¤ËÂФ·¤Æ¤Ï¥á¥Ë¥å¡¼¤Î¥ê¥ó¥¯¤¬¥Ç¥Ã¥É¥ê¥ó¥¯¤Ë¤Ê¤ê¤Þ¤¹¡£

¤³¤ì¤Ë¤è¤Ã¤Æ¡¢Î㤨¤Ð¡Ö¥Æ¥ó¥×¥ì¡¼¥È¤Î´ÉÍý¡×¤Î¸¢¸Â¤ò»ý¤Ä¥í¡¼¥ë¤Î¥æ¡¼¥¶¤·¤«¥¢¥¯¥»¥¹¤Ç¤­¤Ê¤¤¥á¥Ë¥å¡¼¤Ê¤É¤òÄêµÁ¤Ç¤­¤Þ¤¹¡£

¥í¡¼¥ë¤Î³Æ¸¢¸Â¤È¤½¤Î¸¢¸Â¤ò»ý¤Ä¥æ¡¼¥¶¤Ë¥¢¥¯¥»¥¹¤òµö²Ä¤¹¤ë¤¿¤á¤Ëpermission¤Ë»ØÄꤹ¤ëÃͤδط¸¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£

¸¢¸Âpermission¤Ë»ØÄꤹ¤ëÃÍ
administer_blog¥Ö¥í¥°´ÉÍý¼Ô
edit_config¥Ö¥í¥°¤ÎÀßÄê
set_publish_paths¸ø³«¥Ñ¥¹¤ÎÀßÄê
edit_categories¥«¥Æ¥´¥ê¤Î´ÉÍý
edit_tags¥¿¥°¤Î´ÉÍý
edit_notifications¥¢¥É¥ì¥¹Ä¢¤Î´ÉÍý
view_blog_log¥í¥°¤Î±ÜÍ÷
create_post¥Ö¥í¥°µ­»ö¤ÎºîÀ®
publish_post¥Ö¥í¥°µ­»ö¤Î¸ø³«
send_notificationsÄÌÃΤÎÁ÷¿®
edit_all_posts¤¹¤Ù¤Æ¤Î¥Ö¥í¥°µ­»ö¤ÎÊÔ½¸
manage_pages¥¦¥§¥Ö¥Ú¡¼¥¸¤Î´ÉÍý
rebuild¥Ö¥í¥°¤ÎºÆ¹½ÃÛ
edit_templates¥Æ¥ó¥×¥ì¡¼¥È¤Î´ÉÍý
edit_assets¥¢¥¤¥Æ¥à¤Î´ÉÍý
upload¥Õ¥¡¥¤¥ë¥¢¥Ã¥×¥í¡¼¥É
save_image_defaults²èÁü¤Ë´Ø¤¹¤ë´ûÄêÃͤÎÀßÄê
comment¥³¥á¥ó¥È¤ÎÁ÷¿®
manage_feedback¥³¥á¥ó¥È/¥È¥é¥Ã¥¯¥Ð¥Ã¥¯¤Î´ÉÍý

Ê£¿ô¤Î¸¢¸Â¤ËÂФ·¤Æµö²Ä¤òÍ¿¤¨¤¿¤¤¾ì¹ç¤Ï¡Ö,¡×¤Ç¶èÀڤäưʲ¼¤Î¤è¤¦¤ËÀßÄꤷ¤Þ¤¹¡£

# ¥Ö¥í¥°µ­»ö¤ÎºîÀ®¤È¥³¥á¥ó¥È¤ÎÁ÷¿®¤Î¸¢¸Â¤ò»ý¤Ä¥í¡¼¥ë¤Ë¥¢¥¯¥»¥¹¤òµö²Ä
permission => 'create_post,comment'
[edit]

system_permission¤Î»ØÄê

¥æ¡¼¥¶¤Î¥·¥¹¥Æ¥à¸¢¸Â¤Ë±þ¤¸¤¿¥¢¥¯¥»¥¹¸¢¤òÀßÄê¤Ç¤­¤Þ¤¹¡£
¥¢¥¯¥»¥¹¸¢¸Â¤ò»ý¤¿¤Ê¤¤¥æ¡¼¥¶¤ËÂФ·¤Æ¤Ï¥á¥Ë¥å¡¼¤Î¥ê¥ó¥¯¤¬¥Ç¥Ã¥É¥ê¥ó¥¯¤Ë¤Ê¤ê¤Þ¤¹¡£

¤³¤ì¤Ë¤è¤Ã¤Æ¡¢Î㤨¤Ð¡Ö¥Ö¥í¥°¤ÎºîÀ®¡×¤Î¥·¥¹¥Æ¥à¸¢¸Â¤ò»ý¤Ä¥æ¡¼¥¶¤·¤«¥¢¥¯¥»¥¹¤Ç¤­¤Ê¤¤¥á¥Ë¥å¡¼¤Ê¤É¤òÄêµÁ¤Ç¤­¤Þ¤¹¡£

³Æ¥·¥¹¥Æ¥à¸¢¸Â¤È¤½¤Î¸¢¸Â¤ò»ý¤Ä¥æ¡¼¥¶¤Ë¥¢¥¯¥»¥¹¤òµö²Ä¤¹¤ë¤¿¤á¤Ësystem_permission¤Ë»ØÄꤹ¤ëÃͤδط¸¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£

¥·¥¹¥Æ¥à¸¢¸Âsystem_permission¤Ë»ØÄꤹ¤ëÃÍ
administer¥·¥¹¥Æ¥à´ÉÍý¼Ô
create_blog¥Ö¥í¥°¤ÎºîÀ®
view_log¥í¥°¤Î±ÜÍ÷
edit_templates¥Æ¥ó¥×¥ì¡¼¥È¤Î´ÉÍý
manage_plugins¥×¥é¥°¥¤¥ó¤Î´ÉÍý

Ê£¿ô¤Î¸¢¸Â¤ËÂФ·¤Æµö²Ä¤òÍ¿¤¨¤¿¤¤¾ì¹ç¤Ïpermission¤ÈƱÍͤˡÖ,¡×¤Ç¶èÀڤäÆÀßÄꤷ¤Þ¤¹¡£

[edit]

¤½¤Î¾¤Î¥×¥í¥Ñ¥Æ¥£

¥á¥Ë¥å¡¼ID¤Ë»ØÄê¤Ç¤­¤ë¤½¤Î¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ë¤ÏÄ´¤Ù¤¿ÈϰϤǤϰʲ¼¤¬¤¢¤ê¤Þ¤¹*1

[edit]

args

¥á¥Ë¥å¡¼¤Î¥ê¥ó¥¯¤Ë°ú¤­ÅϤ¹QueryString¤Î¥Ñ¥é¥á¡¼¥¿¤ò»ØÄꤷ¤Þ¤¹¡£Î㤨¤Ð¡¢

mode => 'hoge',
args => { _type => "blog" },

¤È»ØÄꤷ¤¿¾ì¹ç¡¢¥á¥Ë¥å¡¼¤Ë»ØÄꤵ¤ì¤ë¥ê¥ó¥¯¤Ï

__mode=hoge&_type=blog

¤È¤Ê¤ê¤Þ¤¹¡£

[edit]

condition

permission¡Ê¤ª¤è¤Ósystem_permission¡Ë¤ÎȽÃǤòTrue(1) or False(0)¤òÊÖ¤¹¥á¥½¥Ã¥É¤Ë¤è¤Ã¤Æ»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤è¤êÊ£»¨¤Ê¸¢¸ÂÀßÄê¤ò¹Ô¤¤¤¿¤¤¾ì¹ç¤ËÊØÍø¤Ç¤¹¡£

Î㤨¤Ð¡¢°Ê²¼¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£

condition => sub { &permission_routine() },

sub permission_routine {
  my $app = MT->app;
  # ¥¹¡¼¥Ñ¡¼¥æ¡¼¥¶¤Ê¤é̵¾ò·ï¤Ç¥¢¥¯¥»¥¹²Ä(True)
  return 1 if $app->user->is_superuser;
  # ¥Ñ¥é¥á¡¼¥¿¤Ç¥Ö¥í¥°ID¤¬»ØÄꤵ¤ì¤Æ¤¤¤Æ
  if ( $app->param('blog_id') ) {
    # Åö³º¥æ¡¼¥¶¤¬¥Ö¥í¥°µ­»ö¤ÎºîÀ®¡¢¤Þ¤¿¤Ï¥¦¥§¥Ö¥Ú¡¼¥¸¤Î´ÉÍý¸¢¸Â¤ò»ý¤Ã¤Æ¤¤¤ë¾ì¹ç¤â¥¢¥¯¥»¥¹²Ä(True)
    my $perms = $app->user->permissions($app->param('blog_id'));
    return 1 if $perms->can_create_post || $perms->can_manage_pages;
  }
  # ¤½¤ì°Ê³°¤Ï¥¢¥¯¥»¥¹ÉÔ²Ä(False)
  return 0;
}

¸¢¸ÂȽÄê¤Î¥á¥½¥Ã¥É¤ÏMT::Permission¥ª¥Ö¥¸¥§¥¯¥È¤ÎAPI¤òÍøÍѤǤ­¤Þ¤¹¡£´ðËÜŪ¤Ë¤Ïpermission¥×¥í¥Ñ¥Æ¥£¤Ë»ØÄꤹ¤ëÃͤËcan_¤ò¤Ä¤±¤¿¥á¥½¥Ã¥É̾¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£Î㤨¤Ð¡¢¥Ö¥í¥°µ­»ö¤ÎºîÀ®¸¢¸Â¤ò¼¨¤¹create_post¤ò¤½¤Î¥æ¡¼¥¶¤¬»ý¤Ä¤«¤É¤¦¤«¤Ï¡¢Åö³º¥æ¡¼¥¶¤ÎMT::Permission¥ª¥Ö¥¸¥§¥¯¥È¤ò¼èÆÀ¤·¤¿¸å¡¢¤½¤ÎMT::Permission¥ª¥Ö¥¸¥§¥¯¥È¤Îcan_create_post¥á¥½¥Ã¥É¤ò¥³¡¼¥ë¤·¤Þ¤¹*2¡£

[edit]

dialog

¥ê¥ó¥¯Àè¤ò¥â¡¼¥À¥ë¥À¥¤¥¢¥í¥°¤Çɽ¼¨¤·¤¿¤¤¾ì¹ç¤Ëmode¤ÎÂå¤ï¤ê¤Ë»ØÄꤷ¤Þ¤¹¡£»ØÄꤹ¤ëÃͤÏmode¥×¥í¥Ñ¥Æ¥£¤Ë»ØÄꤹ¤ëÃͤÈƱÍÍ¡¢É½¼¨¤·¤¿¤¤²èÌ̤ò¤¢¤é¤ï¤¹__modeÃͤǤ¹¡£

 # __mode=hoge¤Î²èÌ̤ò¥â¡¼¥À¥ë¥À¥¤¥¢¥í¥°¤Çɽ¼¨¤¹¤ë
 #mode => 'hoge',
 dialog => 'hoge',

»²¹Í¡§How to Create a Modal Dialog

Åê¹Æ¼Ô¿ÊÃÏ | ¥Ñ¡¼¥Þ¥ê¥ó¥¯

| append.gif

*1 Creating Menu Items¤äMovable Type Registry Reference¤Ë¤ÏÁ´¤Æ¤Î¥×¥í¥Ñ¥Æ¥£¤¬ÌÖÍ夵¤ì¤Æ¤¤¤Ê¤¤¤è¤¦¤Ç¤¹¡Ê2008/06/12¸½ºß¡Ë¤½¤Î¤¿¤á¡¢¥½¡¼¥¹¥³¡¼¥É¤òľÀܳÎǧ¤·¤ÆÀö¤¤½Ð¤·¤¿¥×¥í¥Ñ¥Æ¥£¤¬´Þ¤Þ¤ì¤Þ¤¹¡£system_permission¤Ï´û¤Ë¤½¤Î°ìÎã¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹
*2 $app->user¤«¤é¥³¡¼¥ë¤·¤Æ¤¤¤ëis_superuser¤äpermissions¥á¥½¥Ã¥É¤Ï2008/06/13¸½ºß¡¢API¥É¥­¥å¥á¥ó¥È¤Ë¤Ïµ­ºÜ¤µ¤ì¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢»È¤ï¤Ê¤¤Êý¤¬¤è¤¤¤Î¤«¤â^^;

¥È¥Ã¥×   ÊÔ½¸ Åà·ë º¹Ê¬ ¥Ð¥Ã¥¯¥¢¥Ã¥× źÉÕ Ê£À½ ̾Á°Êѹ¹ ¥ê¥í¡¼¥É   ¿·µ¬ °ìÍ÷ ñ¸ì¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS
Last-modified: 2008-06-12 (ÌÚ) 10:58:08 (5992d)

¥¢¡¼¥¯¥¦¥§¥Ö¤Î¥µ¡¼¥Ó¥¹¤ä¥½¥ê¥å¡¼¥·¥ç¥ó¤Ï¤³¤Á¤é