{"id":2904,"date":"2013-05-21T17:13:56","date_gmt":"2013-05-21T08:13:56","guid":{"rendered":"http:\/\/www.lancard.com\/blog\/?p=2904"},"modified":"2025-03-12T11:29:02","modified_gmt":"2025-03-12T02:29:02","slug":"roundcube%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%80%80%e3%83%95%e3%83%83%e3%82%af%e3%82%92%e8%a8%ad%e7%bd%ae%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.lancard.com\/blog\/2013\/05\/21\/roundcube%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%80%80%e3%83%95%e3%83%83%e3%82%af%e3%82%92%e8%a8%ad%e7%bd%ae%e3%81%99%e3%82%8b\/","title":{"rendered":"Roundcube\u30d7\u30e9\u30b0\u30a4\u30f3\u3000\u30d5\u30c3\u30af\u3092\u8a2d\u7f6e\u3059\u308b"},"content":{"rendered":"<p>Roundcube\u3067\u30d5\u30c3\u30af\u3092\u8a2d\u7f6e\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306fsample_a\u30d7\u30e9\u30b0\u30a4\u30f3\u306b\u30d5\u30c3\u30af\u3092\u8a2d\u7f6e\u3057\u3001\u305d\u308c\u3092sample_b\u304b\u3089\u5229\u7528\u3059\u308b\u4f8b\u3067\u3059\u3002<br \/>\nsample_a\u306f\u753b\u9762\u3092\u3082\u3063\u305f\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u3089\u3001\u30d5\u30c3\u30af\u3092\u5b9f\u884c\u3057<br \/>\n\u5143\u306e\u753b\u9762\u3092\u518d\u5ea6\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30bd\u30fc\u30b9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\nsample_a.php<\/p>\n<pre line=\"1\" lang=\"php\">\r\n<?php \r\nclass sample_a extends rcube_plugin {\r\nprivate $rc = null;\r\nfunction init(){\r\n\/\/rcmail\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\r\n$this->rc = rcmail::get_instance();\r\n\r\n\/\/\u30ed\u30fc\u30ab\u30e9\u30a4\u30ba\u5bfe\u5fdc\r\n$this->add_texts('localization\/');\r\n\r\n\/\/\u30bf\u30b9\u30af\u3068\u3057\u3066sample_a\u3092\u8a2d\u5b9a\r\n$this->register_task('sample_a');\r\n\r\n\/\/\u30bf\u30b9\u30af\u30d0\u30fc\u306b\u30dc\u30bf\u30f3\u3092\u8ffd\u52a0\r\n$this->add_button(array(\r\n'command'    => 'sample_a',\r\n'label'      => 'sample_a.sample',\r\n), 'taskbar');\r\n\r\n\/\/sample\u30bf\u30b9\u30af\u306e\u5834\u5408\u306e\u307f\u3001\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3092\u767b\u9332\r\nif($this->rc->task == 'sample_a'){\r\n$this->register_action('index', array($this, 'action'));\r\n$this->register_action('fook_test', array($this, 'action'));\r\n}\r\n}\r\n\r\npublic function action(){\r\nif($this->rc->action === 'fook_test'){\r\n$data = $this->rc->plugins->exec_hook('sample_hook', array('data_a' => 'hoge'));\r\nerror_log(print_r($data,true));\r\n}\r\n$this->rc->output->send('sample_a.index');\r\n}\r\n}\r\n?>\r\n<\/pre>\n<p>index.html<\/p>\n<pre line=\"1\" lang=\"html\">\r\n<roundcube:object name=\"doctype\" value=\"html5\" \/>\r\n<html>\r\n<head>\r\n<title><roundcube:object name=\"pagetitle\" \/><\/title>\r\n<roundcube:include file=\"\/includes\/links.html\" \/>\r\n<\/head>\r\n<body>\r\n\r\n<roundcube:include file=\"\/includes\/header.html\" \/>\r\n\r\n<div id=\"mainscreen\">\r\n\r\n<roundcube:button href=\"?_task=sample_a&amp;_action=fook_test\" type=\"link\" label=\"sample_a.fook_test\" title=\"sample_a.fook_test\" \/>\r\n\r\n<\/div>\r\n\r\n<roundcube:include file=\"\/includes\/footer.html\" \/>\r\n\r\n<\/body>\r\n<\/html>\r\n<\/pre>\n<p>sample_b.php<\/p>\n<pre line=\"1\" lang=\"php\">\r\n<?php \r\nclass sample_b extends rcube_plugin {\r\nfunction init(){\r\n$this->add_hook('sample_hook', array($this, 'set_data'));\r\n}\r\n\r\npublic function set_data($args){\r\nerror_log(print_r($args,true));\r\n$data['data_b'] = \"foo\";\r\nreturn $data;\r\n}\r\n}\r\n?>\r\n<\/pre>\n<p>\u2460\u30d5\u30c3\u30af\u3092\u8a2d\u7f6e\u3059\u308b\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u90e8\u5206\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre line=\"1\" lang=\"php\">\r\n$data = $this->rc->plugins->exec_hook('sample_hook', array('data_a' => 'hoge'));\r\n<\/pre>\n<p>\u5f15\u6570\u3068\u3057\u3066\u914d\u5217\u3092\u6e21\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u2461\u30d5\u30c3\u30af\u3092\u5229\u7528\u3059\u308b\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u90e8\u5206\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre line=\"1\" lang=\"php\">\r\nfunction init(){\r\n$this->add_hook('sample_hook', array($this, 'set_data'));\r\n}\r\n\r\npublic function set_data($args){\r\nerror_log(print_r($args,true));\r\n$data['data_b'] = \"foo\";\r\nreturn $data;\r\n}\r\n<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306a\u914d\u5217\u304c\u6e21\u3055\u308c\u3066\u304d\u307e\u3059\u3002<br \/>\n(<br \/>\n\u3000\u3000[data_a] => hoge<br \/>\n\u3000\u3000[abort] =><br \/>\n)<\/p>\n<p>\u6e21\u3055\u308c\u305f\u5f15\u6570\u3092\u51e6\u7406\u3057\u3066\u623b\u308a\u5024\u3092\u8fd4\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<br \/>\n\u623b\u308a\u5024\u306f\u3053\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n(<br \/>\n\u3000\u3000[data_b] => foo<br \/>\n\u3000\u3000[data_a] => hoge<br \/>\n\u3000\u3000[abort] =><br \/>\n)<\/p>\n<p>exec_hook\u306e\u5b9a\u7fa9\u304c\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u305f\u3081\u3001\u623b\u308a\u5024\u304c\u914d\u5217\u306e\u5834\u5408\u306f\u81ea\u52d5\u7684\u306b<br \/>\n\u6e21\u3055\u308c\u305f\u914d\u5217\u306b\u8db3\u3057\u3066\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre line=\"1\" lang=\"php\">\r\n  public function exec_hook($hook, $args = array())\r\n  {\r\n    if (!is_array($args))\r\n      $args = array('arg' => $args);\r\n\r\n    $args += array('abort' => false);\r\n    $this->active_hook = $hook;\r\n\r\n    foreach ((array)$this->handlers[$hook] as $callback) {\r\n      $ret = call_user_func($callback, $args);\r\n      if ($ret && is_array($ret))\r\n        $args = $ret + $args;\r\n\r\n      if ($args['abort'])\r\n        break;\r\n    }\r\n\r\n    $this->active_hook = false;\r\n    return $args;\r\n  }\r\n<\/pre>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2904&#038;t=Roundcube%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E3%80%80%E3%83%95%E3%83%83%E3%82%AF%E3%82%92%E8%A8%AD%E7%BD%AE%E3%81%99%E3%82%8B&#038;s=100&#038;p&#091;url&#093;=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2904&#038;p&#091;images&#093;&#091;0&#093;=&#038;p&#091;title&#093;=Roundcube%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E3%80%80%E3%83%95%E3%83%83%E3%82%AF%E3%82%92%E8%A8%AD%E7%BD%AE%E3%81%99%E3%82%8B\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/facebook.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"http:\/\/twitter.com\/share?url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2904&#038;text=Roundcube%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E3%80%80%E3%83%95%E3%83%83%E3%82%AF%E3%82%92%E8%A8%AD%E7%BD%AE%E3%81%99%E3%82%8B\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2904&#038;title=Roundcube%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E3%80%80%E3%83%95%E3%83%83%E3%82%AF%E3%82%92%E8%A8%AD%E7%BD%AE%E3%81%99%E3%82%8B\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/linkedin.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-tumblr nolightbox\" data-provider=\"tumblr\" target=\"_blank\" rel=\"nofollow\" title=\"Share on tumblr\" href=\"https:\/\/tumblr.com\/share?s=&#038;v=3&#038;t=Roundcube%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E3%80%80%E3%83%95%E3%83%83%E3%82%AF%E3%82%92%E8%A8%AD%E7%BD%AE%E3%81%99%E3%82%8B&#038;u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2904\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"tumblr\" title=\"Share on tumblr\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/tumblr.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=Roundcube%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E3%80%80%E3%83%95%E3%83%83%E3%82%AF%E3%82%92%E8%A8%AD%E7%BD%AE%E3%81%99%E3%82%8B&#038;body=%E3%82%B7%E3%82%A7%E3%82%A2%E3%81%99%E3%82%8B%EF%BC%9A:%20https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2904\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>Roundcube\u3067\u30d5\u30c3\u30af\u3092\u8a2d\u7f6e\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002 \u4eca\u56de\u306fsample_a\u30d7\u30e9\u30b0\u30a4\u30f3\u306b\u30d5\u30c3\u30af\u3092\u8a2d\u7f6e\u3057\u3001\u305d\u308c\u3092sample_b\u304b\u3089\u5229\u7528\u3059\u308b\u4f8b\u3067\u3059\u3002 sample_a\u306f\u753b\u9762\u3092\u3082\u3063\u305f\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u3089\u3001\u30d5\u30c3 [&hellip;]<\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[99],"tags":[],"class_list":["post-2904","post","type-post","status-publish","format-standard","hentry","category-roundcube"],"_links":{"self":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/2904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/comments?post=2904"}],"version-history":[{"count":7,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/2904\/revisions"}],"predecessor-version":[{"id":2911,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/2904\/revisions\/2911"}],"wp:attachment":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/media?parent=2904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/categories?post=2904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/tags?post=2904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}