From 59478e06c25303a790a0840ab2ac30662c4ef781 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Tue, 5 Aug 2014 16:46:22 +0200 Subject: c'est la merde.. --- plugins/listcommands/listcommands.php | 106 ++++++++++++++++++++++++++++ plugins/listcommands/localization/en_US.inc | 12 ++++ plugins/listcommands/localization/es_ES.inc | 12 ++++ plugins/listcommands/localization/fr_FR.inc | 13 ++++ plugins/listcommands/localization/nl_NL.inc | 12 ++++ plugins/listcommands/localization/pl_PL.inc | 12 ++++ plugins/listcommands/localization/ru_RU.inc | 12 ++++ plugins/listcommands/package.xml | 18 +++++ 8 files changed, 197 insertions(+) create mode 100644 plugins/listcommands/listcommands.php create mode 100644 plugins/listcommands/localization/en_US.inc create mode 100644 plugins/listcommands/localization/es_ES.inc create mode 100644 plugins/listcommands/localization/fr_FR.inc create mode 100644 plugins/listcommands/localization/nl_NL.inc create mode 100644 plugins/listcommands/localization/pl_PL.inc create mode 100644 plugins/listcommands/localization/ru_RU.inc create mode 100644 plugins/listcommands/package.xml (limited to 'plugins/listcommands') diff --git a/plugins/listcommands/listcommands.php b/plugins/listcommands/listcommands.php new file mode 100644 index 000000000..7a7948fd6 --- /dev/null +++ b/plugins/listcommands/listcommands.php @@ -0,0 +1,106 @@ +action || in_array($rcmail->action, array('list', 'show', 'preview'))) { + $this->add_hook('storage_init', array($this, 'storage_init')); + $this->add_hook('message_headers_output', array($this, 'listcommands_output')); + } + } + + function storage_init($p) + { + $rcmail = rcmail::get_instance(); + $mailinglist_headers = array_keys($this->get_list_headers()); + $p['fetch_headers'] .= trim($p['fetch_headers']. ' ' . strtoupper(join(' ', $mailinglist_headers))); + return($p); + } + + function listcommands_output($p) + { + $list_output = ""; + $rcmail = rcmail::get_instance(); + $this->add_texts('localization/', false); + $mailinglist_headers = $this->get_list_headers(); + + foreach ($mailinglist_headers as $header => $title) { + $key = strtolower($header); + + if($value = $p['headers']->others[$key]) { + if(is_string($value)){ + $list_output .= $this->create_link($key, $value, $title) . '  '; + } + else{ + $list_output .= $this->create_link($key, $value[0], $title) . '  '; + } + } + } + if($list_output != "") + $p['output']['Mailinglist'] = array( + 'title' => $this->gettext('listcommands_mailinglist'), 'value' => $list_output); + return($p); + } + + private function get_list_headers() + { + $mailinglist_headers = array( + 'List-Help' => $this->gettext('listcommands_help'), + 'List-Subscribe' => $this->gettext('listcommands_subscribe'), + 'List-Unsubscribe' => $this->gettext('listcommands_unsubscribe'), + 'List-Post' => $this->gettext('listcommands_post'), + 'List-Owner' => $this->gettext('listcommands_admin'), + 'List-Archive' => $this->gettext('listcommands_archive') + ); + return($mailinglist_headers); + } + + private function create_link($key, $value, $title) + { + $proto = ""; + + // some headers have multiple targets + $targets = explode(',', $value); + + // only use 1 of the targets + $target = strip_quotes($targets[0]); + + // first strip angle brackets + $link = trim($target, "<>"); + + if(preg_match('/^(mailto|http|https)(:\/\/|:)(.*)$/', $link, $matches)) { + $proto = $matches[1]; + $target = $matches[3]; + } + + // use RC for emailing instead of relying on the mailto header + if($proto == "mailto") { + $onclick = "return rcmail.command('compose','$target',this)"; + } else { + $onclick = ""; + } + + $a = html::a(array('href' => $link , + 'target' => '_blank', + 'onclick' => $onclick + ), $title); + + return($a); + } +} +?> diff --git a/plugins/listcommands/localization/en_US.inc b/plugins/listcommands/localization/en_US.inc new file mode 100644 index 000000000..8af9bdc78 --- /dev/null +++ b/plugins/listcommands/localization/en_US.inc @@ -0,0 +1,12 @@ + diff --git a/plugins/listcommands/localization/es_ES.inc b/plugins/listcommands/localization/es_ES.inc new file mode 100644 index 000000000..e27cb8774 --- /dev/null +++ b/plugins/listcommands/localization/es_ES.inc @@ -0,0 +1,12 @@ + diff --git a/plugins/listcommands/localization/fr_FR.inc b/plugins/listcommands/localization/fr_FR.inc new file mode 100644 index 000000000..1a08a1a7b --- /dev/null +++ b/plugins/listcommands/localization/fr_FR.inc @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/plugins/listcommands/localization/nl_NL.inc b/plugins/listcommands/localization/nl_NL.inc new file mode 100644 index 000000000..373870a83 --- /dev/null +++ b/plugins/listcommands/localization/nl_NL.inc @@ -0,0 +1,12 @@ + diff --git a/plugins/listcommands/localization/pl_PL.inc b/plugins/listcommands/localization/pl_PL.inc new file mode 100644 index 000000000..faefae7ba --- /dev/null +++ b/plugins/listcommands/localization/pl_PL.inc @@ -0,0 +1,12 @@ + diff --git a/plugins/listcommands/localization/ru_RU.inc b/plugins/listcommands/localization/ru_RU.inc new file mode 100644 index 000000000..3565d6cb5 --- /dev/null +++ b/plugins/listcommands/localization/ru_RU.inc @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/plugins/listcommands/package.xml b/plugins/listcommands/package.xml new file mode 100644 index 000000000..6c18bbc1f --- /dev/null +++ b/plugins/listcommands/package.xml @@ -0,0 +1,18 @@ + + + listcommands + + Cor Bosman + cor + cor@roundcu.be + yes + + https://github.com/corbosman/listcommands + + 2.0 + + GNU GPLv2 + -- cgit v1.2.3