From beab86860e62fda96de1d071c5749628a53d3e99 Mon Sep 17 00:00:00 2001 From: Dylan Thiedeke Date: Tue, 7 Jul 2015 08:43:11 +1000 Subject: [PATCH 01/44] Create Krynn plugin --- krynn/krynn.css | 14 +++ krynn/krynn.php | 165 +++++++++++++++++++++++++++++++++++ krynn/lang/C/messages.po | 30 +++++++ krynn/lang/ca/strings.php | 5 ++ krynn/lang/cs/messages.po | 32 +++++++ krynn/lang/cs/strings.php | 10 +++ krynn/lang/de/messages.po | 33 +++++++ krynn/lang/de/strings.php | 10 +++ krynn/lang/eo/strings.php | 5 ++ krynn/lang/es/strings.php | 5 ++ krynn/lang/fr/strings.php | 5 ++ krynn/lang/is/strings.php | 5 ++ krynn/lang/it/messages.po | 32 +++++++ krynn/lang/it/strings.php | 10 +++ krynn/lang/nb-no/strings.php | 5 ++ krynn/lang/pl/strings.php | 5 ++ krynn/lang/pt-br/strings.php | 5 ++ krynn/lang/ro/messages.po | 32 +++++++ krynn/lang/ro/strings.php | 10 +++ krynn/lang/ru/strings.php | 5 ++ krynn/lang/sv/strings.php | 3 + krynn/lang/zh-cn/strings.php | 5 ++ 22 files changed, 431 insertions(+) create mode 100755 krynn/krynn.css create mode 100755 krynn/krynn.php create mode 100644 krynn/lang/C/messages.po create mode 100644 krynn/lang/ca/strings.php create mode 100644 krynn/lang/cs/messages.po create mode 100644 krynn/lang/cs/strings.php create mode 100644 krynn/lang/de/messages.po create mode 100644 krynn/lang/de/strings.php create mode 100644 krynn/lang/eo/strings.php create mode 100644 krynn/lang/es/strings.php create mode 100644 krynn/lang/fr/strings.php create mode 100644 krynn/lang/is/strings.php create mode 100644 krynn/lang/it/messages.po create mode 100644 krynn/lang/it/strings.php create mode 100644 krynn/lang/nb-no/strings.php create mode 100644 krynn/lang/pl/strings.php create mode 100644 krynn/lang/pt-br/strings.php create mode 100644 krynn/lang/ro/messages.po create mode 100644 krynn/lang/ro/strings.php create mode 100644 krynn/lang/ru/strings.php create mode 100644 krynn/lang/sv/strings.php create mode 100644 krynn/lang/zh-cn/strings.php diff --git a/krynn/krynn.css b/krynn/krynn.css new file mode 100755 index 00000000..466a3ecd --- /dev/null +++ b/krynn/krynn.css @@ -0,0 +1,14 @@ + + + +#krynn-enable-label { + float: left; + width: 200px; + margin-bottom: 25px; +} + +#krynn-checkbox { + float: left; +} + + diff --git a/krynn/krynn.php b/krynn/krynn.php new file mode 100755 index 00000000..4f336d7b --- /dev/null +++ b/krynn/krynn.php @@ -0,0 +1,165 @@ + + * Planets Author: Tony Baldwin + * Krynn modifications: Dylan Thiedeke + * + *"My body was my sacrifice... for my magic. This damage is permanent." - Raislin Majere + */ + + +function krynn_install() { + + /** + * + * Our demo plugin will attach in three places. + * The first is just prior to storing a local post. + * + */ + + register_hook('post_local', 'addon/krynn/krynn.php', 'krynn_post_hook'); + + /** + * + * Then we'll attach into the plugin settings page, and also the + * settings post hook so that we can create and update + * user preferences. + * + */ + + register_hook('plugin_settings', 'addon/krynn/krynn.php', 'krynn_settings'); + register_hook('plugin_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post'); + + logger("installed krynn"); +} + + +function krynn_uninstall() { + + /** + * + * uninstall unregisters any hooks created with register_hook + * during install. It may also delete configuration settings + * and any other cleanup. + * + */ + + unregister_hook('post_local', 'addon/krynn/krynn.php', 'krynn_post_hook'); + unregister_hook('plugin_settings', 'addon/krynn/krynn.php', 'krynn_settings'); + unregister_hook('plugin_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post'); + + + logger("removed krynn"); +} + + + +function krynn_post_hook($a, &$item) { + + /** + * + * An item was posted on the local system. + * We are going to look for specific items: + * - A status post by a profile owner + * - The profile owner must have allowed our plugin + * + */ + + logger('krynn invoked'); + + if(! local_user()) /* non-zero if this is a logged in user of this system */ + return; + + if(local_user() != $item['uid']) /* Does this person own the post? */ + return; + + if($item['parent']) /* If the item has a parent, this is a comment or something else, not a status post. */ + return; + + /* Retrieve our personal config setting */ + + $active = get_pconfig(local_user(), 'krynn', 'enable'); + + if(! $active) + return; + + /** + * + * OK, we're allowed to do our stuff. + * Here's what we are going to do: + * load the list of timezone names, and use that to generate a list of krynn locales. + * Then we'll pick one of those at random and put it in the "location" field for the post. + * + */ + + $krynn = array('Ansalon','Abanasinia','Solace','Haven','Gateway','Qualinost','Ankatavaka','Pax Tharkas','Ergoth','Newsea','Straights of Schallsea','Plains of Dust','Tarsis','Barren Hills','Que Shu','Citadel of Light','Solinari','Hedge Maze','Tower of High Sorcery','Inn of the Last Home','Last Heroes Tomb','Academy of Sorcery','Gods Row','Temple of Majere','Temple of Kiri-Jolith','Temple of Mishakal','Temple of Zeboim,','The Trough','Sad Town','Xak Tsaroth','ZHaman','SKullcap',); + + $planet = array_rand($krynn,1); + $item['location'] = $krynn[$planet]; + + return; +} + + + + +/** + * + * Callback from the settings post function. + * $post contains the $_POST array. + * We will make sure we've got a valid user account + * and if so set our configuration setting for this person. + * + */ + +function krynn_settings_post($a,$post) { + if(! local_user()) + return; + if($_POST['krynn-submit']) + set_pconfig(local_user(),'krynn','enable',intval($_POST['krynn'])); +} + + +/** + * + * Called from the Plugin Setting form. + * Add our own settings info to the page. + * + */ + + + +function krynn_settings(&$a,&$s) { + + if(! local_user()) + return; + + /* Add our stylesheet to the page so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + + /* Get the current state of our config variable */ + + $enabled = get_pconfig(local_user(),'krynn','enable'); + + $checked = (($enabled) ? ' checked="checked" ' : ''); + + /* Add some HTML to the existing form */ + + $s .= '
'; + $s .= '

' . t('Krynn Settings') . '

'; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + /* provide a submit button */ + + $s .= '
'; + +} + + diff --git a/krynn/lang/C/messages.po b/krynn/lang/C/messages.po new file mode 100644 index 00000000..843752a1 --- /dev/null +++ b/krynn/lang/C/messages.po @@ -0,0 +1,30 @@ +# ADDON planets +# Copyright (C) +# This file is distributed under the same license as the Friendica planets addon package. +# +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-27 05:01-0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: planets.php:150 +msgid "Planets Settings" +msgstr "" + +#: planets.php:152 +msgid "Enable Planets Plugin" +msgstr "" + +#: planets.php:158 +msgid "Submit" +msgstr "" diff --git a/krynn/lang/ca/strings.php b/krynn/lang/ca/strings.php new file mode 100644 index 00000000..79fdd6be --- /dev/null +++ b/krynn/lang/ca/strings.php @@ -0,0 +1,5 @@ +strings["Planets Settings"] = "Ajustos de Planet"; +$a->strings["Enable Planets Plugin"] = "Activa Plugin de Planet"; +$a->strings["Submit"] = "Enviar"; diff --git a/krynn/lang/cs/messages.po b/krynn/lang/cs/messages.po new file mode 100644 index 00000000..c47ff06c --- /dev/null +++ b/krynn/lang/cs/messages.po @@ -0,0 +1,32 @@ +# ADDON planets +# Copyright (C) +# This file is distributed under the same license as the Friendica planets addon package. +# +# +# Translators: +# Michal Šupler , 2014-2015 +msgid "" +msgstr "" +"Project-Id-Version: friendica\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-27 05:01-0500\n" +"PO-Revision-Date: 2015-02-11 19:37+0000\n" +"Last-Translator: Michal Šupler \n" +"Language-Team: Czech (http://www.transifex.com/projects/p/friendica/language/cs/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: cs\n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" + +#: planets.php:150 +msgid "Planets Settings" +msgstr "Planets Nastavení" + +#: planets.php:152 +msgid "Enable Planets Plugin" +msgstr "Povolit Planets plugin" + +#: planets.php:158 +msgid "Submit" +msgstr "Odeslat" diff --git a/krynn/lang/cs/strings.php b/krynn/lang/cs/strings.php new file mode 100644 index 00000000..268f3192 --- /dev/null +++ b/krynn/lang/cs/strings.php @@ -0,0 +1,10 @@ +=2 && $n<=4) ? 1 : 2;; +}} +; +$a->strings["Planets Settings"] = "Planets Nastavení"; +$a->strings["Enable Planets Plugin"] = "Povolit Planets plugin"; +$a->strings["Submit"] = "Odeslat"; diff --git a/krynn/lang/de/messages.po b/krynn/lang/de/messages.po new file mode 100644 index 00000000..42788d56 --- /dev/null +++ b/krynn/lang/de/messages.po @@ -0,0 +1,33 @@ +# ADDON planets +# Copyright (C) +# This file is distributed under the same license as the Friendica planets addon package. +# +# +# Translators: +# Abrax , 2014 +# bavatar , 2014 +msgid "" +msgstr "" +"Project-Id-Version: friendica\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-27 05:01-0500\n" +"PO-Revision-Date: 2014-10-15 12:32+0000\n" +"Last-Translator: Abrax \n" +"Language-Team: German (http://www.transifex.com/projects/p/friendica/language/de/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: planets.php:150 +msgid "Planets Settings" +msgstr "Planeten Einstellungen" + +#: planets.php:152 +msgid "Enable Planets Plugin" +msgstr "Planeten-Plugin aktivieren" + +#: planets.php:158 +msgid "Submit" +msgstr "Senden" diff --git a/krynn/lang/de/strings.php b/krynn/lang/de/strings.php new file mode 100644 index 00000000..ab513fac --- /dev/null +++ b/krynn/lang/de/strings.php @@ -0,0 +1,10 @@ +strings["Planets Settings"] = "Planeten Einstellungen"; +$a->strings["Enable Planets Plugin"] = "Planeten-Plugin aktivieren"; +$a->strings["Submit"] = "Senden"; diff --git a/krynn/lang/eo/strings.php b/krynn/lang/eo/strings.php new file mode 100644 index 00000000..2f9ff97c --- /dev/null +++ b/krynn/lang/eo/strings.php @@ -0,0 +1,5 @@ +strings["Planets Settings"] = "Agordo pri Planets"; +$a->strings["Enable Planets Plugin"] = "Ŝalti la Planets kromprogamon"; +$a->strings["Submit"] = "Sendi"; diff --git a/krynn/lang/es/strings.php b/krynn/lang/es/strings.php new file mode 100644 index 00000000..67b52dcd --- /dev/null +++ b/krynn/lang/es/strings.php @@ -0,0 +1,5 @@ +strings["Planets Settings"] = "Configuración de Planets"; +$a->strings["Enable Planets Plugin"] = "Activar el módulo de planetas Planets"; +$a->strings["Submit"] = "Envíar"; diff --git a/krynn/lang/fr/strings.php b/krynn/lang/fr/strings.php new file mode 100644 index 00000000..505d24c3 --- /dev/null +++ b/krynn/lang/fr/strings.php @@ -0,0 +1,5 @@ +strings["Planets Settings"] = "Réglages des Planets"; +$a->strings["Enable Planets Plugin"] = "Activer Planets"; +$a->strings["Submit"] = "Envoyer"; diff --git a/krynn/lang/is/strings.php b/krynn/lang/is/strings.php new file mode 100644 index 00000000..d59b838f --- /dev/null +++ b/krynn/lang/is/strings.php @@ -0,0 +1,5 @@ +strings["Planets Settings"] = ""; +$a->strings["Enable Planets Plugin"] = ""; +$a->strings["Submit"] = "Senda inn"; diff --git a/krynn/lang/it/messages.po b/krynn/lang/it/messages.po new file mode 100644 index 00000000..3740be8f --- /dev/null +++ b/krynn/lang/it/messages.po @@ -0,0 +1,32 @@ +# ADDON planets +# Copyright (C) +# This file is distributed under the same license as the Friendica planets addon package. +# +# +# Translators: +# fabrixxm , 2014 +msgid "" +msgstr "" +"Project-Id-Version: friendica\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-27 05:01-0500\n" +"PO-Revision-Date: 2014-10-15 09:01+0000\n" +"Last-Translator: fabrixxm \n" +"Language-Team: Italian (http://www.transifex.com/projects/p/friendica/language/it/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: it\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: planets.php:150 +msgid "Planets Settings" +msgstr "Impostazioni \"Pianeti\"" + +#: planets.php:152 +msgid "Enable Planets Plugin" +msgstr "Abilita il plugin \"Pianeti\"" + +#: planets.php:158 +msgid "Submit" +msgstr "" diff --git a/krynn/lang/it/strings.php b/krynn/lang/it/strings.php new file mode 100644 index 00000000..635183fa --- /dev/null +++ b/krynn/lang/it/strings.php @@ -0,0 +1,10 @@ +strings["Planets Settings"] = "Impostazioni \"Pianeti\""; +$a->strings["Enable Planets Plugin"] = "Abilita il plugin \"Pianeti\""; +$a->strings["Submit"] = ""; diff --git a/krynn/lang/nb-no/strings.php b/krynn/lang/nb-no/strings.php new file mode 100644 index 00000000..628eb2ae --- /dev/null +++ b/krynn/lang/nb-no/strings.php @@ -0,0 +1,5 @@ +strings["Planets Settings"] = ""; +$a->strings["Enable Planets Plugin"] = ""; +$a->strings["Submit"] = "Lagre"; diff --git a/krynn/lang/pl/strings.php b/krynn/lang/pl/strings.php new file mode 100644 index 00000000..97120046 --- /dev/null +++ b/krynn/lang/pl/strings.php @@ -0,0 +1,5 @@ +strings["Planets Settings"] = ""; +$a->strings["Enable Planets Plugin"] = ""; +$a->strings["Submit"] = "Potwierdź"; diff --git a/krynn/lang/pt-br/strings.php b/krynn/lang/pt-br/strings.php new file mode 100644 index 00000000..5cb179c5 --- /dev/null +++ b/krynn/lang/pt-br/strings.php @@ -0,0 +1,5 @@ +strings["Planets Settings"] = "Configuração dos planetas"; +$a->strings["Enable Planets Plugin"] = "Habilita configuração dos planetas"; +$a->strings["Submit"] = "Enviar"; diff --git a/krynn/lang/ro/messages.po b/krynn/lang/ro/messages.po new file mode 100644 index 00000000..67932a8b --- /dev/null +++ b/krynn/lang/ro/messages.po @@ -0,0 +1,32 @@ +# ADDON planets +# Copyright (C) +# This file is distributed under the same license as the Friendica planets addon package. +# +# +# Translators: +# Doru DEACONU , 2014 +msgid "" +msgstr "" +"Project-Id-Version: friendica\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-27 05:01-0500\n" +"PO-Revision-Date: 2014-11-27 14:16+0000\n" +"Last-Translator: Doru DEACONU \n" +"Language-Team: Romanian (Romania) (http://www.transifex.com/projects/p/friendica/language/ro_RO/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ro_RO\n" +"Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));\n" + +#: planets.php:150 +msgid "Planets Settings" +msgstr "Configurări Planets" + +#: planets.php:152 +msgid "Enable Planets Plugin" +msgstr "Activare Modul Planets" + +#: planets.php:158 +msgid "Submit" +msgstr "Trimite" diff --git a/krynn/lang/ro/strings.php b/krynn/lang/ro/strings.php new file mode 100644 index 00000000..93736aad --- /dev/null +++ b/krynn/lang/ro/strings.php @@ -0,0 +1,10 @@ +19)||(($n%100==0)&&($n!=0)))?2:1));; +}} +; +$a->strings["Planets Settings"] = "Configurări Planets"; +$a->strings["Enable Planets Plugin"] = "Activare Modul Planets"; +$a->strings["Submit"] = "Trimite"; diff --git a/krynn/lang/ru/strings.php b/krynn/lang/ru/strings.php new file mode 100644 index 00000000..1902b826 --- /dev/null +++ b/krynn/lang/ru/strings.php @@ -0,0 +1,5 @@ +strings["Planets Settings"] = ""; +$a->strings["Enable Planets Plugin"] = ""; +$a->strings["Submit"] = "Подтвердить"; diff --git a/krynn/lang/sv/strings.php b/krynn/lang/sv/strings.php new file mode 100644 index 00000000..3ec569a7 --- /dev/null +++ b/krynn/lang/sv/strings.php @@ -0,0 +1,3 @@ +strings["Submit"] = "Spara"; diff --git a/krynn/lang/zh-cn/strings.php b/krynn/lang/zh-cn/strings.php new file mode 100644 index 00000000..ac066c77 --- /dev/null +++ b/krynn/lang/zh-cn/strings.php @@ -0,0 +1,5 @@ +strings["Planets Settings"] = "行星设置"; +$a->strings["Enable Planets Plugin"] = "使行星插件可用"; +$a->strings["Submit"] = "提交"; -- 2.43.4 From 21a6ac9396966439b7f0cc600a91ae032059ce65 Mon Sep 17 00:00:00 2001 From: Dylan Thiedeke Date: Tue, 7 Jul 2015 10:46:09 +1000 Subject: [PATCH 02/44] Replace planet with krynn --- krynn/krynn.css-e | 14 +++ krynn/krynn.php | 2 +- krynn/krynn.php-e | 165 +++++++++++++++++++++++++++++++++ krynn/lang/C/messages.po | 14 +-- krynn/lang/C/messages.po-e | 30 ++++++ krynn/lang/ca/strings.php | 4 +- krynn/lang/ca/strings.php-e | 5 + krynn/lang/cs/messages.po | 18 ++-- krynn/lang/cs/messages.po-e | 32 +++++++ krynn/lang/cs/strings.php | 4 +- krynn/lang/cs/strings.php-e | 10 ++ krynn/lang/de/messages.po | 14 +-- krynn/lang/de/messages.po-e | 33 +++++++ krynn/lang/de/strings.php-e | 10 ++ krynn/lang/eo/strings.php-e | 5 + krynn/lang/es/strings.php-e | 5 + krynn/lang/fr/strings.php-e | 5 + krynn/lang/is/strings.php-e | 5 + krynn/lang/it/messages.po | 10 +- krynn/lang/it/messages.po-e | 32 +++++++ krynn/lang/it/strings.php-e | 10 ++ krynn/lang/nb-no/strings.php-e | 5 + krynn/lang/pl/strings.php-e | 5 + krynn/lang/pt-br/strings.php-e | 5 + krynn/lang/ro/messages.po | 10 +- krynn/lang/ro/messages.po-e | 32 +++++++ krynn/lang/ro/strings.php-e | 10 ++ krynn/lang/ru/strings.php-e | 5 + krynn/lang/sv/strings.php-e | 3 + krynn/lang/zh-cn/strings.php-e | 5 + 30 files changed, 469 insertions(+), 38 deletions(-) create mode 100755 krynn/krynn.css-e create mode 100755 krynn/krynn.php-e create mode 100644 krynn/lang/C/messages.po-e create mode 100644 krynn/lang/ca/strings.php-e create mode 100644 krynn/lang/cs/messages.po-e create mode 100644 krynn/lang/cs/strings.php-e create mode 100644 krynn/lang/de/messages.po-e create mode 100644 krynn/lang/de/strings.php-e create mode 100644 krynn/lang/eo/strings.php-e create mode 100644 krynn/lang/es/strings.php-e create mode 100644 krynn/lang/fr/strings.php-e create mode 100644 krynn/lang/is/strings.php-e create mode 100644 krynn/lang/it/messages.po-e create mode 100644 krynn/lang/it/strings.php-e create mode 100644 krynn/lang/nb-no/strings.php-e create mode 100644 krynn/lang/pl/strings.php-e create mode 100644 krynn/lang/pt-br/strings.php-e create mode 100644 krynn/lang/ro/messages.po-e create mode 100644 krynn/lang/ro/strings.php-e create mode 100644 krynn/lang/ru/strings.php-e create mode 100644 krynn/lang/sv/strings.php-e create mode 100644 krynn/lang/zh-cn/strings.php-e diff --git a/krynn/krynn.css-e b/krynn/krynn.css-e new file mode 100755 index 00000000..466a3ecd --- /dev/null +++ b/krynn/krynn.css-e @@ -0,0 +1,14 @@ + + + +#krynn-enable-label { + float: left; + width: 200px; + margin-bottom: 25px; +} + +#krynn-checkbox { + float: left; +} + + diff --git a/krynn/krynn.php b/krynn/krynn.php index 4f336d7b..d9ec7fae 100755 --- a/krynn/krynn.php +++ b/krynn/krynn.php @@ -1,7 +1,7 @@ * Planets Author: Tony Baldwin diff --git a/krynn/krynn.php-e b/krynn/krynn.php-e new file mode 100755 index 00000000..4f336d7b --- /dev/null +++ b/krynn/krynn.php-e @@ -0,0 +1,165 @@ + + * Planets Author: Tony Baldwin + * Krynn modifications: Dylan Thiedeke + * + *"My body was my sacrifice... for my magic. This damage is permanent." - Raislin Majere + */ + + +function krynn_install() { + + /** + * + * Our demo plugin will attach in three places. + * The first is just prior to storing a local post. + * + */ + + register_hook('post_local', 'addon/krynn/krynn.php', 'krynn_post_hook'); + + /** + * + * Then we'll attach into the plugin settings page, and also the + * settings post hook so that we can create and update + * user preferences. + * + */ + + register_hook('plugin_settings', 'addon/krynn/krynn.php', 'krynn_settings'); + register_hook('plugin_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post'); + + logger("installed krynn"); +} + + +function krynn_uninstall() { + + /** + * + * uninstall unregisters any hooks created with register_hook + * during install. It may also delete configuration settings + * and any other cleanup. + * + */ + + unregister_hook('post_local', 'addon/krynn/krynn.php', 'krynn_post_hook'); + unregister_hook('plugin_settings', 'addon/krynn/krynn.php', 'krynn_settings'); + unregister_hook('plugin_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post'); + + + logger("removed krynn"); +} + + + +function krynn_post_hook($a, &$item) { + + /** + * + * An item was posted on the local system. + * We are going to look for specific items: + * - A status post by a profile owner + * - The profile owner must have allowed our plugin + * + */ + + logger('krynn invoked'); + + if(! local_user()) /* non-zero if this is a logged in user of this system */ + return; + + if(local_user() != $item['uid']) /* Does this person own the post? */ + return; + + if($item['parent']) /* If the item has a parent, this is a comment or something else, not a status post. */ + return; + + /* Retrieve our personal config setting */ + + $active = get_pconfig(local_user(), 'krynn', 'enable'); + + if(! $active) + return; + + /** + * + * OK, we're allowed to do our stuff. + * Here's what we are going to do: + * load the list of timezone names, and use that to generate a list of krynn locales. + * Then we'll pick one of those at random and put it in the "location" field for the post. + * + */ + + $krynn = array('Ansalon','Abanasinia','Solace','Haven','Gateway','Qualinost','Ankatavaka','Pax Tharkas','Ergoth','Newsea','Straights of Schallsea','Plains of Dust','Tarsis','Barren Hills','Que Shu','Citadel of Light','Solinari','Hedge Maze','Tower of High Sorcery','Inn of the Last Home','Last Heroes Tomb','Academy of Sorcery','Gods Row','Temple of Majere','Temple of Kiri-Jolith','Temple of Mishakal','Temple of Zeboim,','The Trough','Sad Town','Xak Tsaroth','ZHaman','SKullcap',); + + $planet = array_rand($krynn,1); + $item['location'] = $krynn[$planet]; + + return; +} + + + + +/** + * + * Callback from the settings post function. + * $post contains the $_POST array. + * We will make sure we've got a valid user account + * and if so set our configuration setting for this person. + * + */ + +function krynn_settings_post($a,$post) { + if(! local_user()) + return; + if($_POST['krynn-submit']) + set_pconfig(local_user(),'krynn','enable',intval($_POST['krynn'])); +} + + +/** + * + * Called from the Plugin Setting form. + * Add our own settings info to the page. + * + */ + + + +function krynn_settings(&$a,&$s) { + + if(! local_user()) + return; + + /* Add our stylesheet to the page so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + + /* Get the current state of our config variable */ + + $enabled = get_pconfig(local_user(),'krynn','enable'); + + $checked = (($enabled) ? ' checked="checked" ' : ''); + + /* Add some HTML to the existing form */ + + $s .= '
'; + $s .= '

' . t('Krynn Settings') . '

'; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + /* provide a submit button */ + + $s .= '
'; + +} + + diff --git a/krynn/lang/C/messages.po b/krynn/lang/C/messages.po index 843752a1..0831b915 100644 --- a/krynn/lang/C/messages.po +++ b/krynn/lang/C/messages.po @@ -1,6 +1,6 @@ -# ADDON planets +# ADDON krynn # Copyright (C) -# This file is distributed under the same license as the Friendica planets addon package. +# This file is distributed under the same license as the Friendica krynn addon package. # # #, fuzzy @@ -17,14 +17,14 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: planets.php:150 -msgid "Planets Settings" +#: krynn.php:150 +msgid "Krynn Settings" msgstr "" -#: planets.php:152 -msgid "Enable Planets Plugin" +#: krynn.php:152 +msgid "Enable Krynn Plugin" msgstr "" -#: planets.php:158 +#: krynn.php:158 msgid "Submit" msgstr "" diff --git a/krynn/lang/C/messages.po-e b/krynn/lang/C/messages.po-e new file mode 100644 index 00000000..0831b915 --- /dev/null +++ b/krynn/lang/C/messages.po-e @@ -0,0 +1,30 @@ +# ADDON krynn +# Copyright (C) +# This file is distributed under the same license as the Friendica krynn addon package. +# +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-27 05:01-0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: krynn.php:150 +msgid "Krynn Settings" +msgstr "" + +#: krynn.php:152 +msgid "Enable Krynn Plugin" +msgstr "" + +#: krynn.php:158 +msgid "Submit" +msgstr "" diff --git a/krynn/lang/ca/strings.php b/krynn/lang/ca/strings.php index 79fdd6be..ec7bf803 100644 --- a/krynn/lang/ca/strings.php +++ b/krynn/lang/ca/strings.php @@ -1,5 +1,5 @@ strings["Planets Settings"] = "Ajustos de Planet"; -$a->strings["Enable Planets Plugin"] = "Activa Plugin de Planet"; +$a->strings["Krynn Settings"] = "Ajustos de Krynn"; +$a->strings["Enable Krynn Plugin"] = "Activa Plugin de Krynn"; $a->strings["Submit"] = "Enviar"; diff --git a/krynn/lang/ca/strings.php-e b/krynn/lang/ca/strings.php-e new file mode 100644 index 00000000..ec7bf803 --- /dev/null +++ b/krynn/lang/ca/strings.php-e @@ -0,0 +1,5 @@ +strings["Krynn Settings"] = "Ajustos de Krynn"; +$a->strings["Enable Krynn Plugin"] = "Activa Plugin de Krynn"; +$a->strings["Submit"] = "Enviar"; diff --git a/krynn/lang/cs/messages.po b/krynn/lang/cs/messages.po index c47ff06c..69e803e3 100644 --- a/krynn/lang/cs/messages.po +++ b/krynn/lang/cs/messages.po @@ -1,6 +1,6 @@ -# ADDON planets +# ADDON krynn # Copyright (C) -# This file is distributed under the same license as the Friendica planets addon package. +# This file is distributed under the same license as the Friendica krynn addon package. # # # Translators: @@ -19,14 +19,14 @@ msgstr "" "Language: cs\n" "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" -#: planets.php:150 -msgid "Planets Settings" -msgstr "Planets Nastavení" +#: krynn.php:150 +msgid "Krynn Settings" +msgstr "Krynn Nastavení" -#: planets.php:152 -msgid "Enable Planets Plugin" -msgstr "Povolit Planets plugin" +#: krynn.php:152 +msgid "Enable Krynn Plugin" +msgstr "Povolit Krynn plugin" -#: planets.php:158 +#: krynn.php:158 msgid "Submit" msgstr "Odeslat" diff --git a/krynn/lang/cs/messages.po-e b/krynn/lang/cs/messages.po-e new file mode 100644 index 00000000..69e803e3 --- /dev/null +++ b/krynn/lang/cs/messages.po-e @@ -0,0 +1,32 @@ +# ADDON krynn +# Copyright (C) +# This file is distributed under the same license as the Friendica krynn addon package. +# +# +# Translators: +# Michal Šupler , 2014-2015 +msgid "" +msgstr "" +"Project-Id-Version: friendica\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-27 05:01-0500\n" +"PO-Revision-Date: 2015-02-11 19:37+0000\n" +"Last-Translator: Michal Šupler \n" +"Language-Team: Czech (http://www.transifex.com/projects/p/friendica/language/cs/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: cs\n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" + +#: krynn.php:150 +msgid "Krynn Settings" +msgstr "Krynn Nastavení" + +#: krynn.php:152 +msgid "Enable Krynn Plugin" +msgstr "Povolit Krynn plugin" + +#: krynn.php:158 +msgid "Submit" +msgstr "Odeslat" diff --git a/krynn/lang/cs/strings.php b/krynn/lang/cs/strings.php index 268f3192..e725ffc3 100644 --- a/krynn/lang/cs/strings.php +++ b/krynn/lang/cs/strings.php @@ -5,6 +5,6 @@ function string_plural_select_cs($n){ return ($n==1) ? 0 : ($n>=2 && $n<=4) ? 1 : 2;; }} ; -$a->strings["Planets Settings"] = "Planets Nastavení"; -$a->strings["Enable Planets Plugin"] = "Povolit Planets plugin"; +$a->strings["Krynn Settings"] = "Krynn Nastavení"; +$a->strings["Enable Krynn Plugin"] = "Povolit Krynn plugin"; $a->strings["Submit"] = "Odeslat"; diff --git a/krynn/lang/cs/strings.php-e b/krynn/lang/cs/strings.php-e new file mode 100644 index 00000000..e725ffc3 --- /dev/null +++ b/krynn/lang/cs/strings.php-e @@ -0,0 +1,10 @@ +=2 && $n<=4) ? 1 : 2;; +}} +; +$a->strings["Krynn Settings"] = "Krynn Nastavení"; +$a->strings["Enable Krynn Plugin"] = "Povolit Krynn plugin"; +$a->strings["Submit"] = "Odeslat"; diff --git a/krynn/lang/de/messages.po b/krynn/lang/de/messages.po index 42788d56..12dceb31 100644 --- a/krynn/lang/de/messages.po +++ b/krynn/lang/de/messages.po @@ -1,6 +1,6 @@ -# ADDON planets +# ADDON Krynn # Copyright (C) -# This file is distributed under the same license as the Friendica planets addon package. +# This file is distributed under the same license as the Friendica Krynn addon package. # # # Translators: @@ -20,14 +20,14 @@ msgstr "" "Language: de\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: planets.php:150 -msgid "Planets Settings" +#: Krynn.php:150 +msgid "Krynn Settings" msgstr "Planeten Einstellungen" -#: planets.php:152 -msgid "Enable Planets Plugin" +#: Krynn.php:152 +msgid "Enable Krynn Plugin" msgstr "Planeten-Plugin aktivieren" -#: planets.php:158 +#: Krynn.php:158 msgid "Submit" msgstr "Senden" diff --git a/krynn/lang/de/messages.po-e b/krynn/lang/de/messages.po-e new file mode 100644 index 00000000..12dceb31 --- /dev/null +++ b/krynn/lang/de/messages.po-e @@ -0,0 +1,33 @@ +# ADDON Krynn +# Copyright (C) +# This file is distributed under the same license as the Friendica Krynn addon package. +# +# +# Translators: +# Abrax , 2014 +# bavatar , 2014 +msgid "" +msgstr "" +"Project-Id-Version: friendica\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-27 05:01-0500\n" +"PO-Revision-Date: 2014-10-15 12:32+0000\n" +"Last-Translator: Abrax \n" +"Language-Team: German (http://www.transifex.com/projects/p/friendica/language/de/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: Krynn.php:150 +msgid "Krynn Settings" +msgstr "Planeten Einstellungen" + +#: Krynn.php:152 +msgid "Enable Krynn Plugin" +msgstr "Planeten-Plugin aktivieren" + +#: Krynn.php:158 +msgid "Submit" +msgstr "Senden" diff --git a/krynn/lang/de/strings.php-e b/krynn/lang/de/strings.php-e new file mode 100644 index 00000000..ab513fac --- /dev/null +++ b/krynn/lang/de/strings.php-e @@ -0,0 +1,10 @@ +strings["Planets Settings"] = "Planeten Einstellungen"; +$a->strings["Enable Planets Plugin"] = "Planeten-Plugin aktivieren"; +$a->strings["Submit"] = "Senden"; diff --git a/krynn/lang/eo/strings.php-e b/krynn/lang/eo/strings.php-e new file mode 100644 index 00000000..2f9ff97c --- /dev/null +++ b/krynn/lang/eo/strings.php-e @@ -0,0 +1,5 @@ +strings["Planets Settings"] = "Agordo pri Planets"; +$a->strings["Enable Planets Plugin"] = "Ŝalti la Planets kromprogamon"; +$a->strings["Submit"] = "Sendi"; diff --git a/krynn/lang/es/strings.php-e b/krynn/lang/es/strings.php-e new file mode 100644 index 00000000..67b52dcd --- /dev/null +++ b/krynn/lang/es/strings.php-e @@ -0,0 +1,5 @@ +strings["Planets Settings"] = "Configuración de Planets"; +$a->strings["Enable Planets Plugin"] = "Activar el módulo de planetas Planets"; +$a->strings["Submit"] = "Envíar"; diff --git a/krynn/lang/fr/strings.php-e b/krynn/lang/fr/strings.php-e new file mode 100644 index 00000000..505d24c3 --- /dev/null +++ b/krynn/lang/fr/strings.php-e @@ -0,0 +1,5 @@ +strings["Planets Settings"] = "Réglages des Planets"; +$a->strings["Enable Planets Plugin"] = "Activer Planets"; +$a->strings["Submit"] = "Envoyer"; diff --git a/krynn/lang/is/strings.php-e b/krynn/lang/is/strings.php-e new file mode 100644 index 00000000..d59b838f --- /dev/null +++ b/krynn/lang/is/strings.php-e @@ -0,0 +1,5 @@ +strings["Planets Settings"] = ""; +$a->strings["Enable Planets Plugin"] = ""; +$a->strings["Submit"] = "Senda inn"; diff --git a/krynn/lang/it/messages.po b/krynn/lang/it/messages.po index 3740be8f..20b7be17 100644 --- a/krynn/lang/it/messages.po +++ b/krynn/lang/it/messages.po @@ -1,6 +1,6 @@ -# ADDON planets +# ADDON krynn # Copyright (C) -# This file is distributed under the same license as the Friendica planets addon package. +# This file is distributed under the same license as the Friendica krynn addon package. # # # Translators: @@ -19,14 +19,14 @@ msgstr "" "Language: it\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: planets.php:150 +#: krynn.php:150 msgid "Planets Settings" msgstr "Impostazioni \"Pianeti\"" -#: planets.php:152 +#: krynn.php:152 msgid "Enable Planets Plugin" msgstr "Abilita il plugin \"Pianeti\"" -#: planets.php:158 +#: krynn.php:158 msgid "Submit" msgstr "" diff --git a/krynn/lang/it/messages.po-e b/krynn/lang/it/messages.po-e new file mode 100644 index 00000000..3740be8f --- /dev/null +++ b/krynn/lang/it/messages.po-e @@ -0,0 +1,32 @@ +# ADDON planets +# Copyright (C) +# This file is distributed under the same license as the Friendica planets addon package. +# +# +# Translators: +# fabrixxm , 2014 +msgid "" +msgstr "" +"Project-Id-Version: friendica\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-27 05:01-0500\n" +"PO-Revision-Date: 2014-10-15 09:01+0000\n" +"Last-Translator: fabrixxm \n" +"Language-Team: Italian (http://www.transifex.com/projects/p/friendica/language/it/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: it\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: planets.php:150 +msgid "Planets Settings" +msgstr "Impostazioni \"Pianeti\"" + +#: planets.php:152 +msgid "Enable Planets Plugin" +msgstr "Abilita il plugin \"Pianeti\"" + +#: planets.php:158 +msgid "Submit" +msgstr "" diff --git a/krynn/lang/it/strings.php-e b/krynn/lang/it/strings.php-e new file mode 100644 index 00000000..635183fa --- /dev/null +++ b/krynn/lang/it/strings.php-e @@ -0,0 +1,10 @@ +strings["Planets Settings"] = "Impostazioni \"Pianeti\""; +$a->strings["Enable Planets Plugin"] = "Abilita il plugin \"Pianeti\""; +$a->strings["Submit"] = ""; diff --git a/krynn/lang/nb-no/strings.php-e b/krynn/lang/nb-no/strings.php-e new file mode 100644 index 00000000..628eb2ae --- /dev/null +++ b/krynn/lang/nb-no/strings.php-e @@ -0,0 +1,5 @@ +strings["Planets Settings"] = ""; +$a->strings["Enable Planets Plugin"] = ""; +$a->strings["Submit"] = "Lagre"; diff --git a/krynn/lang/pl/strings.php-e b/krynn/lang/pl/strings.php-e new file mode 100644 index 00000000..97120046 --- /dev/null +++ b/krynn/lang/pl/strings.php-e @@ -0,0 +1,5 @@ +strings["Planets Settings"] = ""; +$a->strings["Enable Planets Plugin"] = ""; +$a->strings["Submit"] = "Potwierdź"; diff --git a/krynn/lang/pt-br/strings.php-e b/krynn/lang/pt-br/strings.php-e new file mode 100644 index 00000000..5cb179c5 --- /dev/null +++ b/krynn/lang/pt-br/strings.php-e @@ -0,0 +1,5 @@ +strings["Planets Settings"] = "Configuração dos planetas"; +$a->strings["Enable Planets Plugin"] = "Habilita configuração dos planetas"; +$a->strings["Submit"] = "Enviar"; diff --git a/krynn/lang/ro/messages.po b/krynn/lang/ro/messages.po index 67932a8b..df7a3806 100644 --- a/krynn/lang/ro/messages.po +++ b/krynn/lang/ro/messages.po @@ -1,6 +1,6 @@ -# ADDON planets +# ADDON krynn # Copyright (C) -# This file is distributed under the same license as the Friendica planets addon package. +# This file is distributed under the same license as the Friendica krynn addon package. # # # Translators: @@ -19,14 +19,14 @@ msgstr "" "Language: ro_RO\n" "Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));\n" -#: planets.php:150 +#: krynn.php:150 msgid "Planets Settings" msgstr "Configurări Planets" -#: planets.php:152 +#: krynn.php:152 msgid "Enable Planets Plugin" msgstr "Activare Modul Planets" -#: planets.php:158 +#: krynn.php:158 msgid "Submit" msgstr "Trimite" diff --git a/krynn/lang/ro/messages.po-e b/krynn/lang/ro/messages.po-e new file mode 100644 index 00000000..67932a8b --- /dev/null +++ b/krynn/lang/ro/messages.po-e @@ -0,0 +1,32 @@ +# ADDON planets +# Copyright (C) +# This file is distributed under the same license as the Friendica planets addon package. +# +# +# Translators: +# Doru DEACONU , 2014 +msgid "" +msgstr "" +"Project-Id-Version: friendica\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-27 05:01-0500\n" +"PO-Revision-Date: 2014-11-27 14:16+0000\n" +"Last-Translator: Doru DEACONU \n" +"Language-Team: Romanian (Romania) (http://www.transifex.com/projects/p/friendica/language/ro_RO/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ro_RO\n" +"Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));\n" + +#: planets.php:150 +msgid "Planets Settings" +msgstr "Configurări Planets" + +#: planets.php:152 +msgid "Enable Planets Plugin" +msgstr "Activare Modul Planets" + +#: planets.php:158 +msgid "Submit" +msgstr "Trimite" diff --git a/krynn/lang/ro/strings.php-e b/krynn/lang/ro/strings.php-e new file mode 100644 index 00000000..93736aad --- /dev/null +++ b/krynn/lang/ro/strings.php-e @@ -0,0 +1,10 @@ +19)||(($n%100==0)&&($n!=0)))?2:1));; +}} +; +$a->strings["Planets Settings"] = "Configurări Planets"; +$a->strings["Enable Planets Plugin"] = "Activare Modul Planets"; +$a->strings["Submit"] = "Trimite"; diff --git a/krynn/lang/ru/strings.php-e b/krynn/lang/ru/strings.php-e new file mode 100644 index 00000000..1902b826 --- /dev/null +++ b/krynn/lang/ru/strings.php-e @@ -0,0 +1,5 @@ +strings["Planets Settings"] = ""; +$a->strings["Enable Planets Plugin"] = ""; +$a->strings["Submit"] = "Подтвердить"; diff --git a/krynn/lang/sv/strings.php-e b/krynn/lang/sv/strings.php-e new file mode 100644 index 00000000..3ec569a7 --- /dev/null +++ b/krynn/lang/sv/strings.php-e @@ -0,0 +1,3 @@ +strings["Submit"] = "Spara"; diff --git a/krynn/lang/zh-cn/strings.php-e b/krynn/lang/zh-cn/strings.php-e new file mode 100644 index 00000000..ac066c77 --- /dev/null +++ b/krynn/lang/zh-cn/strings.php-e @@ -0,0 +1,5 @@ +strings["Planets Settings"] = "行星设置"; +$a->strings["Enable Planets Plugin"] = "使行星插件可用"; +$a->strings["Submit"] = "提交"; -- 2.43.4 From 6a9e0c040445376849a849605f685904ae1be832 Mon Sep 17 00:00:00 2001 From: Dylan Thiedeke Date: Tue, 7 Jul 2015 11:03:34 +1000 Subject: [PATCH 03/44] Fixed Language files to reflect plugin name --- krynn/krynn.css-e | 14 --- krynn/krynn.php | 2 +- krynn/krynn.php-e | 165 --------------------------------- krynn/lang/C/messages.po-e | 30 ------ krynn/lang/ca/strings.php-e | 5 - krynn/lang/cs/messages.po-e | 32 ------- krynn/lang/cs/strings.php-e | 10 -- krynn/lang/de/messages.po-e | 33 ------- krynn/lang/de/strings.php | 4 +- krynn/lang/de/strings.php-e | 10 -- krynn/lang/eo/strings.php | 4 +- krynn/lang/eo/strings.php-e | 5 - krynn/lang/es/strings.php | 4 +- krynn/lang/es/strings.php-e | 5 - krynn/lang/fr/strings.php | 4 +- krynn/lang/fr/strings.php-e | 5 - krynn/lang/is/strings.php | 4 +- krynn/lang/is/strings.php-e | 5 - krynn/lang/it/messages.po | 4 +- krynn/lang/it/messages.po-e | 32 ------- krynn/lang/it/strings.php | 4 +- krynn/lang/it/strings.php-e | 10 -- krynn/lang/nb-no/strings.php | 4 +- krynn/lang/nb-no/strings.php-e | 5 - krynn/lang/pl/strings.php | 4 +- krynn/lang/pl/strings.php-e | 5 - krynn/lang/pt-br/strings.php | 4 +- krynn/lang/pt-br/strings.php-e | 5 - krynn/lang/ro/messages.po | 8 +- krynn/lang/ro/messages.po-e | 32 ------- krynn/lang/ro/strings.php | 4 +- krynn/lang/ro/strings.php-e | 10 -- krynn/lang/ru/strings.php | 4 +- krynn/lang/ru/strings.php-e | 5 - krynn/lang/sv/strings.php-e | 3 - krynn/lang/zh-cn/strings.php | 4 +- krynn/lang/zh-cn/strings.php-e | 5 - 37 files changed, 31 insertions(+), 462 deletions(-) delete mode 100755 krynn/krynn.css-e delete mode 100755 krynn/krynn.php-e delete mode 100644 krynn/lang/C/messages.po-e delete mode 100644 krynn/lang/ca/strings.php-e delete mode 100644 krynn/lang/cs/messages.po-e delete mode 100644 krynn/lang/cs/strings.php-e delete mode 100644 krynn/lang/de/messages.po-e delete mode 100644 krynn/lang/de/strings.php-e delete mode 100644 krynn/lang/eo/strings.php-e delete mode 100644 krynn/lang/es/strings.php-e delete mode 100644 krynn/lang/fr/strings.php-e delete mode 100644 krynn/lang/is/strings.php-e delete mode 100644 krynn/lang/it/messages.po-e delete mode 100644 krynn/lang/it/strings.php-e delete mode 100644 krynn/lang/nb-no/strings.php-e delete mode 100644 krynn/lang/pl/strings.php-e delete mode 100644 krynn/lang/pt-br/strings.php-e delete mode 100644 krynn/lang/ro/messages.po-e delete mode 100644 krynn/lang/ro/strings.php-e delete mode 100644 krynn/lang/ru/strings.php-e delete mode 100644 krynn/lang/sv/strings.php-e delete mode 100644 krynn/lang/zh-cn/strings.php-e diff --git a/krynn/krynn.css-e b/krynn/krynn.css-e deleted file mode 100755 index 466a3ecd..00000000 --- a/krynn/krynn.css-e +++ /dev/null @@ -1,14 +0,0 @@ - - - -#krynn-enable-label { - float: left; - width: 200px; - margin-bottom: 25px; -} - -#krynn-checkbox { - float: left; -} - - diff --git a/krynn/krynn.php b/krynn/krynn.php index d9ec7fae..bfc9e42f 100755 --- a/krynn/krynn.php +++ b/krynn/krynn.php @@ -7,7 +7,7 @@ * Planets Author: Tony Baldwin * Krynn modifications: Dylan Thiedeke * - *"My body was my sacrifice... for my magic. This damage is permanent." - Raislin Majere + *"My body was my sacrifice... for my magic. This damage is permanent." - Raistlin Majere */ diff --git a/krynn/krynn.php-e b/krynn/krynn.php-e deleted file mode 100755 index 4f336d7b..00000000 --- a/krynn/krynn.php-e +++ /dev/null @@ -1,165 +0,0 @@ - - * Planets Author: Tony Baldwin - * Krynn modifications: Dylan Thiedeke - * - *"My body was my sacrifice... for my magic. This damage is permanent." - Raislin Majere - */ - - -function krynn_install() { - - /** - * - * Our demo plugin will attach in three places. - * The first is just prior to storing a local post. - * - */ - - register_hook('post_local', 'addon/krynn/krynn.php', 'krynn_post_hook'); - - /** - * - * Then we'll attach into the plugin settings page, and also the - * settings post hook so that we can create and update - * user preferences. - * - */ - - register_hook('plugin_settings', 'addon/krynn/krynn.php', 'krynn_settings'); - register_hook('plugin_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post'); - - logger("installed krynn"); -} - - -function krynn_uninstall() { - - /** - * - * uninstall unregisters any hooks created with register_hook - * during install. It may also delete configuration settings - * and any other cleanup. - * - */ - - unregister_hook('post_local', 'addon/krynn/krynn.php', 'krynn_post_hook'); - unregister_hook('plugin_settings', 'addon/krynn/krynn.php', 'krynn_settings'); - unregister_hook('plugin_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post'); - - - logger("removed krynn"); -} - - - -function krynn_post_hook($a, &$item) { - - /** - * - * An item was posted on the local system. - * We are going to look for specific items: - * - A status post by a profile owner - * - The profile owner must have allowed our plugin - * - */ - - logger('krynn invoked'); - - if(! local_user()) /* non-zero if this is a logged in user of this system */ - return; - - if(local_user() != $item['uid']) /* Does this person own the post? */ - return; - - if($item['parent']) /* If the item has a parent, this is a comment or something else, not a status post. */ - return; - - /* Retrieve our personal config setting */ - - $active = get_pconfig(local_user(), 'krynn', 'enable'); - - if(! $active) - return; - - /** - * - * OK, we're allowed to do our stuff. - * Here's what we are going to do: - * load the list of timezone names, and use that to generate a list of krynn locales. - * Then we'll pick one of those at random and put it in the "location" field for the post. - * - */ - - $krynn = array('Ansalon','Abanasinia','Solace','Haven','Gateway','Qualinost','Ankatavaka','Pax Tharkas','Ergoth','Newsea','Straights of Schallsea','Plains of Dust','Tarsis','Barren Hills','Que Shu','Citadel of Light','Solinari','Hedge Maze','Tower of High Sorcery','Inn of the Last Home','Last Heroes Tomb','Academy of Sorcery','Gods Row','Temple of Majere','Temple of Kiri-Jolith','Temple of Mishakal','Temple of Zeboim,','The Trough','Sad Town','Xak Tsaroth','ZHaman','SKullcap',); - - $planet = array_rand($krynn,1); - $item['location'] = $krynn[$planet]; - - return; -} - - - - -/** - * - * Callback from the settings post function. - * $post contains the $_POST array. - * We will make sure we've got a valid user account - * and if so set our configuration setting for this person. - * - */ - -function krynn_settings_post($a,$post) { - if(! local_user()) - return; - if($_POST['krynn-submit']) - set_pconfig(local_user(),'krynn','enable',intval($_POST['krynn'])); -} - - -/** - * - * Called from the Plugin Setting form. - * Add our own settings info to the page. - * - */ - - - -function krynn_settings(&$a,&$s) { - - if(! local_user()) - return; - - /* Add our stylesheet to the page so we can make our settings look nice */ - - $a->page['htmlhead'] .= '' . "\r\n"; - - /* Get the current state of our config variable */ - - $enabled = get_pconfig(local_user(),'krynn','enable'); - - $checked = (($enabled) ? ' checked="checked" ' : ''); - - /* Add some HTML to the existing form */ - - $s .= '
'; - $s .= '

' . t('Krynn Settings') . '

'; - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - /* provide a submit button */ - - $s .= '
'; - -} - - diff --git a/krynn/lang/C/messages.po-e b/krynn/lang/C/messages.po-e deleted file mode 100644 index 0831b915..00000000 --- a/krynn/lang/C/messages.po-e +++ /dev/null @@ -1,30 +0,0 @@ -# ADDON krynn -# Copyright (C) -# This file is distributed under the same license as the Friendica krynn addon package. -# -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: \n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-02-27 05:01-0500\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: krynn.php:150 -msgid "Krynn Settings" -msgstr "" - -#: krynn.php:152 -msgid "Enable Krynn Plugin" -msgstr "" - -#: krynn.php:158 -msgid "Submit" -msgstr "" diff --git a/krynn/lang/ca/strings.php-e b/krynn/lang/ca/strings.php-e deleted file mode 100644 index ec7bf803..00000000 --- a/krynn/lang/ca/strings.php-e +++ /dev/null @@ -1,5 +0,0 @@ -strings["Krynn Settings"] = "Ajustos de Krynn"; -$a->strings["Enable Krynn Plugin"] = "Activa Plugin de Krynn"; -$a->strings["Submit"] = "Enviar"; diff --git a/krynn/lang/cs/messages.po-e b/krynn/lang/cs/messages.po-e deleted file mode 100644 index 69e803e3..00000000 --- a/krynn/lang/cs/messages.po-e +++ /dev/null @@ -1,32 +0,0 @@ -# ADDON krynn -# Copyright (C) -# This file is distributed under the same license as the Friendica krynn addon package. -# -# -# Translators: -# Michal Šupler , 2014-2015 -msgid "" -msgstr "" -"Project-Id-Version: friendica\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-02-27 05:01-0500\n" -"PO-Revision-Date: 2015-02-11 19:37+0000\n" -"Last-Translator: Michal Šupler \n" -"Language-Team: Czech (http://www.transifex.com/projects/p/friendica/language/cs/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Language: cs\n" -"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" - -#: krynn.php:150 -msgid "Krynn Settings" -msgstr "Krynn Nastavení" - -#: krynn.php:152 -msgid "Enable Krynn Plugin" -msgstr "Povolit Krynn plugin" - -#: krynn.php:158 -msgid "Submit" -msgstr "Odeslat" diff --git a/krynn/lang/cs/strings.php-e b/krynn/lang/cs/strings.php-e deleted file mode 100644 index e725ffc3..00000000 --- a/krynn/lang/cs/strings.php-e +++ /dev/null @@ -1,10 +0,0 @@ -=2 && $n<=4) ? 1 : 2;; -}} -; -$a->strings["Krynn Settings"] = "Krynn Nastavení"; -$a->strings["Enable Krynn Plugin"] = "Povolit Krynn plugin"; -$a->strings["Submit"] = "Odeslat"; diff --git a/krynn/lang/de/messages.po-e b/krynn/lang/de/messages.po-e deleted file mode 100644 index 12dceb31..00000000 --- a/krynn/lang/de/messages.po-e +++ /dev/null @@ -1,33 +0,0 @@ -# ADDON Krynn -# Copyright (C) -# This file is distributed under the same license as the Friendica Krynn addon package. -# -# -# Translators: -# Abrax , 2014 -# bavatar , 2014 -msgid "" -msgstr "" -"Project-Id-Version: friendica\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-02-27 05:01-0500\n" -"PO-Revision-Date: 2014-10-15 12:32+0000\n" -"Last-Translator: Abrax \n" -"Language-Team: German (http://www.transifex.com/projects/p/friendica/language/de/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Language: de\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: Krynn.php:150 -msgid "Krynn Settings" -msgstr "Planeten Einstellungen" - -#: Krynn.php:152 -msgid "Enable Krynn Plugin" -msgstr "Planeten-Plugin aktivieren" - -#: Krynn.php:158 -msgid "Submit" -msgstr "Senden" diff --git a/krynn/lang/de/strings.php b/krynn/lang/de/strings.php index ab513fac..74b5e9f9 100644 --- a/krynn/lang/de/strings.php +++ b/krynn/lang/de/strings.php @@ -5,6 +5,6 @@ function string_plural_select_de($n){ return ($n != 1);; }} ; -$a->strings["Planets Settings"] = "Planeten Einstellungen"; -$a->strings["Enable Planets Plugin"] = "Planeten-Plugin aktivieren"; +$a->strings["Krynn Settings"] = "Krynn Einstellungen"; +$a->strings["Enable Krynn Plugin"] = "Krynn-Plugin aktivieren"; $a->strings["Submit"] = "Senden"; diff --git a/krynn/lang/de/strings.php-e b/krynn/lang/de/strings.php-e deleted file mode 100644 index ab513fac..00000000 --- a/krynn/lang/de/strings.php-e +++ /dev/null @@ -1,10 +0,0 @@ -strings["Planets Settings"] = "Planeten Einstellungen"; -$a->strings["Enable Planets Plugin"] = "Planeten-Plugin aktivieren"; -$a->strings["Submit"] = "Senden"; diff --git a/krynn/lang/eo/strings.php b/krynn/lang/eo/strings.php index 2f9ff97c..8b8dd24a 100644 --- a/krynn/lang/eo/strings.php +++ b/krynn/lang/eo/strings.php @@ -1,5 +1,5 @@ strings["Planets Settings"] = "Agordo pri Planets"; -$a->strings["Enable Planets Plugin"] = "Ŝalti la Planets kromprogamon"; +$a->strings["Krynn Settings"] = "Agordo pri Krynn"; +$a->strings["Enable Krynn Plugin"] = "Ŝalti la Krynn kromprogamon"; $a->strings["Submit"] = "Sendi"; diff --git a/krynn/lang/eo/strings.php-e b/krynn/lang/eo/strings.php-e deleted file mode 100644 index 2f9ff97c..00000000 --- a/krynn/lang/eo/strings.php-e +++ /dev/null @@ -1,5 +0,0 @@ -strings["Planets Settings"] = "Agordo pri Planets"; -$a->strings["Enable Planets Plugin"] = "Ŝalti la Planets kromprogamon"; -$a->strings["Submit"] = "Sendi"; diff --git a/krynn/lang/es/strings.php b/krynn/lang/es/strings.php index 67b52dcd..3369d1b4 100644 --- a/krynn/lang/es/strings.php +++ b/krynn/lang/es/strings.php @@ -1,5 +1,5 @@ strings["Planets Settings"] = "Configuración de Planets"; -$a->strings["Enable Planets Plugin"] = "Activar el módulo de planetas Planets"; +$a->strings["Krynn Settings"] = "Configuración de Krynn"; +$a->strings["Enable Krynn Plugin"] = "Activar el módulo de planetas Krynn"; $a->strings["Submit"] = "Envíar"; diff --git a/krynn/lang/es/strings.php-e b/krynn/lang/es/strings.php-e deleted file mode 100644 index 67b52dcd..00000000 --- a/krynn/lang/es/strings.php-e +++ /dev/null @@ -1,5 +0,0 @@ -strings["Planets Settings"] = "Configuración de Planets"; -$a->strings["Enable Planets Plugin"] = "Activar el módulo de planetas Planets"; -$a->strings["Submit"] = "Envíar"; diff --git a/krynn/lang/fr/strings.php b/krynn/lang/fr/strings.php index 505d24c3..601f9502 100644 --- a/krynn/lang/fr/strings.php +++ b/krynn/lang/fr/strings.php @@ -1,5 +1,5 @@ strings["Planets Settings"] = "Réglages des Planets"; -$a->strings["Enable Planets Plugin"] = "Activer Planets"; +$a->strings["Krynn Settings"] = "Réglages des Krynn"; +$a->strings["Enable Krynn Plugin"] = "Activer Krynn"; $a->strings["Submit"] = "Envoyer"; diff --git a/krynn/lang/fr/strings.php-e b/krynn/lang/fr/strings.php-e deleted file mode 100644 index 505d24c3..00000000 --- a/krynn/lang/fr/strings.php-e +++ /dev/null @@ -1,5 +0,0 @@ -strings["Planets Settings"] = "Réglages des Planets"; -$a->strings["Enable Planets Plugin"] = "Activer Planets"; -$a->strings["Submit"] = "Envoyer"; diff --git a/krynn/lang/is/strings.php b/krynn/lang/is/strings.php index d59b838f..976a601e 100644 --- a/krynn/lang/is/strings.php +++ b/krynn/lang/is/strings.php @@ -1,5 +1,5 @@ strings["Planets Settings"] = ""; -$a->strings["Enable Planets Plugin"] = ""; +$a->strings["Krynn Settings"] = ""; +$a->strings["Enable Krynn Plugin"] = ""; $a->strings["Submit"] = "Senda inn"; diff --git a/krynn/lang/is/strings.php-e b/krynn/lang/is/strings.php-e deleted file mode 100644 index d59b838f..00000000 --- a/krynn/lang/is/strings.php-e +++ /dev/null @@ -1,5 +0,0 @@ -strings["Planets Settings"] = ""; -$a->strings["Enable Planets Plugin"] = ""; -$a->strings["Submit"] = "Senda inn"; diff --git a/krynn/lang/it/messages.po b/krynn/lang/it/messages.po index 20b7be17..2dbfa3c7 100644 --- a/krynn/lang/it/messages.po +++ b/krynn/lang/it/messages.po @@ -20,11 +20,11 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: krynn.php:150 -msgid "Planets Settings" +msgid "Krynn Settings" msgstr "Impostazioni \"Pianeti\"" #: krynn.php:152 -msgid "Enable Planets Plugin" +msgid "Enable Krynn Plugin" msgstr "Abilita il plugin \"Pianeti\"" #: krynn.php:158 diff --git a/krynn/lang/it/messages.po-e b/krynn/lang/it/messages.po-e deleted file mode 100644 index 3740be8f..00000000 --- a/krynn/lang/it/messages.po-e +++ /dev/null @@ -1,32 +0,0 @@ -# ADDON planets -# Copyright (C) -# This file is distributed under the same license as the Friendica planets addon package. -# -# -# Translators: -# fabrixxm , 2014 -msgid "" -msgstr "" -"Project-Id-Version: friendica\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-02-27 05:01-0500\n" -"PO-Revision-Date: 2014-10-15 09:01+0000\n" -"Last-Translator: fabrixxm \n" -"Language-Team: Italian (http://www.transifex.com/projects/p/friendica/language/it/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Language: it\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: planets.php:150 -msgid "Planets Settings" -msgstr "Impostazioni \"Pianeti\"" - -#: planets.php:152 -msgid "Enable Planets Plugin" -msgstr "Abilita il plugin \"Pianeti\"" - -#: planets.php:158 -msgid "Submit" -msgstr "" diff --git a/krynn/lang/it/strings.php b/krynn/lang/it/strings.php index 635183fa..9e4d7037 100644 --- a/krynn/lang/it/strings.php +++ b/krynn/lang/it/strings.php @@ -5,6 +5,6 @@ function string_plural_select_it($n){ return ($n != 1);; }} ; -$a->strings["Planets Settings"] = "Impostazioni \"Pianeti\""; -$a->strings["Enable Planets Plugin"] = "Abilita il plugin \"Pianeti\""; +$a->strings["Krynn Settings"] = "Impostazioni \"Kryn"; +$a->strings["Enable Krynn Plugin"] = "Abilita il plugin \"Krynn\""; $a->strings["Submit"] = ""; diff --git a/krynn/lang/it/strings.php-e b/krynn/lang/it/strings.php-e deleted file mode 100644 index 635183fa..00000000 --- a/krynn/lang/it/strings.php-e +++ /dev/null @@ -1,10 +0,0 @@ -strings["Planets Settings"] = "Impostazioni \"Pianeti\""; -$a->strings["Enable Planets Plugin"] = "Abilita il plugin \"Pianeti\""; -$a->strings["Submit"] = ""; diff --git a/krynn/lang/nb-no/strings.php b/krynn/lang/nb-no/strings.php index 628eb2ae..06ad32cb 100644 --- a/krynn/lang/nb-no/strings.php +++ b/krynn/lang/nb-no/strings.php @@ -1,5 +1,5 @@ strings["Planets Settings"] = ""; -$a->strings["Enable Planets Plugin"] = ""; +$a->strings["Krynn Settings"] = ""; +$a->strings["Enable Krynn Plugin"] = ""; $a->strings["Submit"] = "Lagre"; diff --git a/krynn/lang/nb-no/strings.php-e b/krynn/lang/nb-no/strings.php-e deleted file mode 100644 index 628eb2ae..00000000 --- a/krynn/lang/nb-no/strings.php-e +++ /dev/null @@ -1,5 +0,0 @@ -strings["Planets Settings"] = ""; -$a->strings["Enable Planets Plugin"] = ""; -$a->strings["Submit"] = "Lagre"; diff --git a/krynn/lang/pl/strings.php b/krynn/lang/pl/strings.php index 97120046..239001b1 100644 --- a/krynn/lang/pl/strings.php +++ b/krynn/lang/pl/strings.php @@ -1,5 +1,5 @@ strings["Planets Settings"] = ""; -$a->strings["Enable Planets Plugin"] = ""; +$a->strings["Krynn Settings"] = ""; +$a->strings["Enable Krynn Plugin"] = ""; $a->strings["Submit"] = "Potwierdź"; diff --git a/krynn/lang/pl/strings.php-e b/krynn/lang/pl/strings.php-e deleted file mode 100644 index 97120046..00000000 --- a/krynn/lang/pl/strings.php-e +++ /dev/null @@ -1,5 +0,0 @@ -strings["Planets Settings"] = ""; -$a->strings["Enable Planets Plugin"] = ""; -$a->strings["Submit"] = "Potwierdź"; diff --git a/krynn/lang/pt-br/strings.php b/krynn/lang/pt-br/strings.php index 5cb179c5..a3b2d663 100644 --- a/krynn/lang/pt-br/strings.php +++ b/krynn/lang/pt-br/strings.php @@ -1,5 +1,5 @@ strings["Planets Settings"] = "Configuração dos planetas"; -$a->strings["Enable Planets Plugin"] = "Habilita configuração dos planetas"; +$a->strings["Krynn Settings"] = "Configuração dos Krynn"; +$a->strings["Enable Krynn Plugin"] = "Habilita configuração dos Krynn"; $a->strings["Submit"] = "Enviar"; diff --git a/krynn/lang/pt-br/strings.php-e b/krynn/lang/pt-br/strings.php-e deleted file mode 100644 index 5cb179c5..00000000 --- a/krynn/lang/pt-br/strings.php-e +++ /dev/null @@ -1,5 +0,0 @@ -strings["Planets Settings"] = "Configuração dos planetas"; -$a->strings["Enable Planets Plugin"] = "Habilita configuração dos planetas"; -$a->strings["Submit"] = "Enviar"; diff --git a/krynn/lang/ro/messages.po b/krynn/lang/ro/messages.po index df7a3806..2e629e1c 100644 --- a/krynn/lang/ro/messages.po +++ b/krynn/lang/ro/messages.po @@ -20,12 +20,12 @@ msgstr "" "Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));\n" #: krynn.php:150 -msgid "Planets Settings" -msgstr "Configurări Planets" +msgid "Krynn Settings" +msgstr "Configurări Krynn" #: krynn.php:152 -msgid "Enable Planets Plugin" -msgstr "Activare Modul Planets" +msgid "Enable Krynn Plugin" +msgstr "Activare Modul Krynn" #: krynn.php:158 msgid "Submit" diff --git a/krynn/lang/ro/messages.po-e b/krynn/lang/ro/messages.po-e deleted file mode 100644 index 67932a8b..00000000 --- a/krynn/lang/ro/messages.po-e +++ /dev/null @@ -1,32 +0,0 @@ -# ADDON planets -# Copyright (C) -# This file is distributed under the same license as the Friendica planets addon package. -# -# -# Translators: -# Doru DEACONU , 2014 -msgid "" -msgstr "" -"Project-Id-Version: friendica\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-02-27 05:01-0500\n" -"PO-Revision-Date: 2014-11-27 14:16+0000\n" -"Last-Translator: Doru DEACONU \n" -"Language-Team: Romanian (Romania) (http://www.transifex.com/projects/p/friendica/language/ro_RO/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Language: ro_RO\n" -"Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));\n" - -#: planets.php:150 -msgid "Planets Settings" -msgstr "Configurări Planets" - -#: planets.php:152 -msgid "Enable Planets Plugin" -msgstr "Activare Modul Planets" - -#: planets.php:158 -msgid "Submit" -msgstr "Trimite" diff --git a/krynn/lang/ro/strings.php b/krynn/lang/ro/strings.php index 93736aad..88a84ee8 100644 --- a/krynn/lang/ro/strings.php +++ b/krynn/lang/ro/strings.php @@ -5,6 +5,6 @@ function string_plural_select_ro($n){ return ($n==1?0:((($n%100>19)||(($n%100==0)&&($n!=0)))?2:1));; }} ; -$a->strings["Planets Settings"] = "Configurări Planets"; -$a->strings["Enable Planets Plugin"] = "Activare Modul Planets"; +$a->strings["Krynn Settings"] = "Configurări Krynn"; +$a->strings["Enable Krynn Plugin"] = "Activare Modul Krynn"; $a->strings["Submit"] = "Trimite"; diff --git a/krynn/lang/ro/strings.php-e b/krynn/lang/ro/strings.php-e deleted file mode 100644 index 93736aad..00000000 --- a/krynn/lang/ro/strings.php-e +++ /dev/null @@ -1,10 +0,0 @@ -19)||(($n%100==0)&&($n!=0)))?2:1));; -}} -; -$a->strings["Planets Settings"] = "Configurări Planets"; -$a->strings["Enable Planets Plugin"] = "Activare Modul Planets"; -$a->strings["Submit"] = "Trimite"; diff --git a/krynn/lang/ru/strings.php b/krynn/lang/ru/strings.php index 1902b826..8fd1069b 100644 --- a/krynn/lang/ru/strings.php +++ b/krynn/lang/ru/strings.php @@ -1,5 +1,5 @@ strings["Planets Settings"] = ""; -$a->strings["Enable Planets Plugin"] = ""; +$a->strings["Krynn Settings"] = ""; +$a->strings["Enable Krynn Plugin"] = ""; $a->strings["Submit"] = "Подтвердить"; diff --git a/krynn/lang/ru/strings.php-e b/krynn/lang/ru/strings.php-e deleted file mode 100644 index 1902b826..00000000 --- a/krynn/lang/ru/strings.php-e +++ /dev/null @@ -1,5 +0,0 @@ -strings["Planets Settings"] = ""; -$a->strings["Enable Planets Plugin"] = ""; -$a->strings["Submit"] = "Подтвердить"; diff --git a/krynn/lang/sv/strings.php-e b/krynn/lang/sv/strings.php-e deleted file mode 100644 index 3ec569a7..00000000 --- a/krynn/lang/sv/strings.php-e +++ /dev/null @@ -1,3 +0,0 @@ -strings["Submit"] = "Spara"; diff --git a/krynn/lang/zh-cn/strings.php b/krynn/lang/zh-cn/strings.php index ac066c77..dcbfbeb7 100644 --- a/krynn/lang/zh-cn/strings.php +++ b/krynn/lang/zh-cn/strings.php @@ -1,5 +1,5 @@ strings["Planets Settings"] = "行星设置"; -$a->strings["Enable Planets Plugin"] = "使行星插件可用"; +$a->strings["Krynn Settings"] = "行星设置"; +$a->strings["Enable Krynn Plugin"] = "使行星插件可用"; $a->strings["Submit"] = "提交"; diff --git a/krynn/lang/zh-cn/strings.php-e b/krynn/lang/zh-cn/strings.php-e deleted file mode 100644 index ac066c77..00000000 --- a/krynn/lang/zh-cn/strings.php-e +++ /dev/null @@ -1,5 +0,0 @@ -strings["Planets Settings"] = "行星设置"; -$a->strings["Enable Planets Plugin"] = "使行星插件可用"; -$a->strings["Submit"] = "提交"; -- 2.43.4 From e8b6618c1436a29a965d8081ffdc28f18e7efe44 Mon Sep 17 00:00:00 2001 From: Dylan Thiedeke Date: Tue, 7 Jul 2015 11:25:04 +1000 Subject: [PATCH 04/44] Fixed spelling in krynn.php --- krynn/krynn.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krynn/krynn.php b/krynn/krynn.php index bfc9e42f..2a291104 100755 --- a/krynn/krynn.php +++ b/krynn/krynn.php @@ -1,6 +1,6 @@ -- 2.43.4 From 8190ad724ef9ebb20de52aa87a3d7e460686d351 Mon Sep 17 00:00:00 2001 From: Dylan Thiedeke Date: Tue, 7 Jul 2015 11:26:49 +1000 Subject: [PATCH 05/44] Fixed locale spelling --- krynn/krynn.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/krynn/krynn.php b/krynn/krynn.php index 2a291104..fb75689c 100755 --- a/krynn/krynn.php +++ b/krynn/krynn.php @@ -1,7 +1,7 @@ * Planets Author: Tony Baldwin @@ -95,7 +95,7 @@ function krynn_post_hook($a, &$item) { * */ - $krynn = array('Ansalon','Abanasinia','Solace','Haven','Gateway','Qualinost','Ankatavaka','Pax Tharkas','Ergoth','Newsea','Straights of Schallsea','Plains of Dust','Tarsis','Barren Hills','Que Shu','Citadel of Light','Solinari','Hedge Maze','Tower of High Sorcery','Inn of the Last Home','Last Heroes Tomb','Academy of Sorcery','Gods Row','Temple of Majere','Temple of Kiri-Jolith','Temple of Mishakal','Temple of Zeboim,','The Trough','Sad Town','Xak Tsaroth','ZHaman','SKullcap',); + $krynn = array('Ansalon','Abanasinia','Solace','Haven','Gateway','Qualinost','Ankatavaka','Pax Tharkas','Ergoth','Newsea','Straights of Schallsea','Plains of Dust','Tarsis','Barren Hills','Que Shu','Citadel of Light','Solinari','Hedge Maze','Tower of High Sorcery','Inn of the Last Home','Last Heroes Tomb','Academy of Sorcery','Gods Row','Temple of Majere','Temple of Kiri-Jolith','Temple of Mishakal','Temple of Zeboim,','The Trough','Sad Town','Xak Tsaroth','Zhaman','Skullcap',); $planet = array_rand($krynn,1); $item['location'] = $krynn[$planet]; -- 2.43.4 From 5b804ab5c155e970159ea263a7147b2402056cbf Mon Sep 17 00:00:00 2001 From: Dylan Thiedeke Date: Tue, 7 Jul 2015 12:14:08 +1000 Subject: [PATCH 06/44] edit krynn.php --- krynn/krynn.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/krynn/krynn.php b/krynn/krynn.php index fb75689c..19bc39d9 100755 --- a/krynn/krynn.php +++ b/krynn/krynn.php @@ -1,7 +1,7 @@ * Planets Author: Tony Baldwin @@ -95,7 +95,7 @@ function krynn_post_hook($a, &$item) { * */ - $krynn = array('Ansalon','Abanasinia','Solace','Haven','Gateway','Qualinost','Ankatavaka','Pax Tharkas','Ergoth','Newsea','Straights of Schallsea','Plains of Dust','Tarsis','Barren Hills','Que Shu','Citadel of Light','Solinari','Hedge Maze','Tower of High Sorcery','Inn of the Last Home','Last Heroes Tomb','Academy of Sorcery','Gods Row','Temple of Majere','Temple of Kiri-Jolith','Temple of Mishakal','Temple of Zeboim,','The Trough','Sad Town','Xak Tsaroth','Zhaman','Skullcap',); + $krynn = array('Ansalon','Abanasinia','Solace','Haven','Gateway','Qualinost','Ankatavaka','Pax Tharkas','Ergoth','Newsea','Straights of Schallsea','Plains of Dust','Tarsis','Barren Hills','Que Shu','Citadel of Light','Solinari','Hedge Maze','Tower of High Sorcery','Inn of the Last Home','Last Heroes Tomb','Academy of Sorcery','Gods Row','Temple of Majere','Temple of Kiri-Jolith','Temple of Mishakal','Temple of Zeboim,','The Trough','Sad Town','Xak Tsaroth','Zhaman','Skullcap','Saifhum','Karthay','Mithas','Kothas','Silver Dragon Mountain','Silvanesti'); $planet = array_rand($krynn,1); $item['location'] = $krynn[$planet]; -- 2.43.4 From 3c38480998b6a3a23159a70a6d1df675c6f03148 Mon Sep 17 00:00:00 2001 From: Dylan Thiedeke Date: Tue, 7 Jul 2015 15:36:23 +1000 Subject: [PATCH 07/44] Fixed Author context in krynn.php --- krynn/krynn.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krynn/krynn.php b/krynn/krynn.php index 19bc39d9..f6153842 100755 --- a/krynn/krynn.php +++ b/krynn/krynn.php @@ -5,7 +5,7 @@ * Version: 1.0 * Planets Author: Mike Macgirvin * Planets Author: Tony Baldwin - * Krynn modifications: Dylan Thiedeke + * Kryn Authoer: Dylan Thiedeke * *"My body was my sacrifice... for my magic. This damage is permanent." - Raistlin Majere */ -- 2.43.4 From da02eb1b10c78a5b0e1145a669b7bbede30a34de Mon Sep 17 00:00:00 2001 From: Dylan Thiedeke Date: Tue, 7 Jul 2015 16:06:41 +1000 Subject: [PATCH 08/44] Added HTML code for minimized setting header --- krynn/krynn.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/krynn/krynn.php b/krynn/krynn.php index f6153842..530764be 100755 --- a/krynn/krynn.php +++ b/krynn/krynn.php @@ -149,7 +149,16 @@ function krynn_settings(&$a,&$s) { /* Add some HTML to the existing form */ - $s .= '
'; + $s .= ''; + $s .= '

' . t('Krynn') . '

'; + $s .= '
'; + $s .= ''; -- 2.43.4 From 946602e3d9d3127a1b8b2e4e1e5a7fc4036a0b6b Mon Sep 17 00:00:00 2001 From: Dylan Thiedeke Date: Wed, 8 Jul 2015 08:28:32 +1000 Subject: [PATCH 11/44] Add HTML code to planets.php as requested to match spec --- planets/planets.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/planets/planets.php b/planets/planets.php index 72698cb9..a64b2abb 100755 --- a/planets/planets.php +++ b/planets/planets.php @@ -146,12 +146,20 @@ function planets_settings(&$a,&$s) { /* Add some HTML to the existing form */ - $s .= '
'; + $s .= ''; + $s .= '

' . t('Planets') . '

'; + $s .= '
'; + $s .= ''; /* provide a submit button */ -- 2.43.4 From e8a01cada181bde91d202460049c8c3678c044c3 Mon Sep 17 00:00:00 2001 From: Dylan Thiedeke Date: Wed, 8 Jul 2015 08:35:44 +1000 Subject: [PATCH 12/44] Fixed spelling for Kashyyk and Dagobah --- planets/planets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/planets/planets.php b/planets/planets.php index a64b2abb..d40e6c61 100755 --- a/planets/planets.php +++ b/planets/planets.php @@ -92,7 +92,7 @@ function planets_post_hook($a, &$item) { * */ - $planets = array('Alderaan','Tatooine','Dagoba','Polis Massa','Coruscant','Hoth','Endor','Kamino','Rattatak','Mustafar','Iego','Geonosis','Felucia','Dantooine','Ansion','Artaru','Bespin','Boz Pity','Cato Neimoidia','Christophsis','Kashyyk','Kessel','Malastare','Mygeeto','Nar Shaddaa','Ord Mantell','Saleucami','Subterrel','Death Star','Teth','Tund','Utapau','Yavin'); + $planets = array('Alderaan','Tatooine','Dagobah','Polis Massa','Coruscant','Hoth','Endor','Kamino','Rattatak','Mustafar','Iego','Geonosis','Felucia','Dantooine','Ansion','Artaru','Bespin','Boz Pity','Cato Neimoidia','Christophsis','Kashyyyk','Kessel','Malastare','Mygeeto','Nar Shaddaa','Ord Mantell','Saleucami','Subterrel','Death Star','Teth','Tund','Utapau','Yavin'); $planet = array_rand($planets,1); $item['location'] = $planets[$planet]; -- 2.43.4 From 631476ff6e3f75a06cc5da7cfa6e9e5517d8d079 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sat, 11 Jul 2015 20:17:33 +0200 Subject: [PATCH 13/44] use smarty3 for config forms --- curweather/templates/admin.tpl | 2 ++ curweather/templates/settings.tpl | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 curweather/templates/admin.tpl create mode 100644 curweather/templates/settings.tpl diff --git a/curweather/templates/admin.tpl b/curweather/templates/admin.tpl new file mode 100644 index 00000000..5f0c11bf --- /dev/null +++ b/curweather/templates/admin.tpl @@ -0,0 +1,2 @@ +{{include file="field_input.tpl" field=$appid}} +
diff --git a/curweather/templates/settings.tpl b/curweather/templates/settings.tpl new file mode 100644 index 00000000..1453b210 --- /dev/null +++ b/curweather/templates/settings.tpl @@ -0,0 +1,17 @@ + +

{{$header}}

+
+ -- 2.43.4 From cda0d59060f8b9228b723d3118b51f9a799fa1cc Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sat, 11 Jul 2015 20:17:54 +0200 Subject: [PATCH 14/44] added README for curweather --- curweather/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 curweather/README.md diff --git a/curweather/README.md b/curweather/README.md new file mode 100644 index 00000000..720f92cf --- /dev/null +++ b/curweather/README.md @@ -0,0 +1,27 @@ +Current Weather +=============== + +If activated by your user this addon adds a widget to the users network tab +sidebar showing current weather informations from +[OpenWeatherMap](http://openweathermap.org). The user can configure the +location as e.g. *Berlin,DE* or the zip code "14476,DE". + +The language for the request at OpenWeatherMap is set to the UI language of +friendica. If the string for the description of the current weather conditions +is available in this language depends on OpenWeatherMap. + +**You should get an APPID from OpenWeatherMap if you want to use this widget.** +You can register [here](http://openweathermap.org/register). + +Credits +------- + +* Tony Baldvin wrote the original addon for Friendica +* Fabio Comuni +* Tobias Diekershoff switched the sources to OpenWeatherMap after the original + provider turned off support for locations outside of the USA. + +To access the API of OpenWeatherMap the library +[OpenWeatherMap-PHP-Api](https://github.com/cmfcmf/OpenWeatherMap-PHP-Api) by +Christian Flach is used (MIT license). + -- 2.43.4 From 4f1fb007c58df8b943ba7a337a20d7e160cc4102 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sat, 11 Jul 2015 20:20:09 +0200 Subject: [PATCH 15/44] remove unneded files --- curweather/getweather.php | 230 -------------------------------------- curweather/test.php | 5 - 2 files changed, 235 deletions(-) delete mode 100644 curweather/getweather.php delete mode 100644 curweather/test.php diff --git a/curweather/getweather.php b/curweather/getweather.php deleted file mode 100644 index b4660b9e..00000000 --- a/curweather/getweather.php +++ /dev/null @@ -1,230 +0,0 @@ -$i){ - $a=explode(" | ",$i); - if(is_numeric(array_search($wx,$a))){ - self::$wxdata['ICON']="$imgpath/$k.jpg"; - break; - } - } - - // Replace any null elements with "Not available" - foreach(array_keys(self::$wxdata) as $key){ - self::$wxdata[$key]=self::$wxdata[$key]=="NULL"?"Not available":self::$wxdata[$key]; - } - - // If we got humidity - if(is_numeric(self::$wxdata['RELATIVE_HUMIDITY'])) - // Append a percent sign - self::$wxdata['RELATIVE_HUMIDITY'].="%"; - - // Do some formatting to make the output a little friendlier - if(self::$wxdata['VISIBILITY_MI']=="NA") - self::$wxdata['VISIBILITY']="Not available"; - if(self::$wxdata['VISIBILITY']!="Not available") - self::$wxdata['VISIBILITY']=(1*self::$wxdata['VISIBILITY_MI'])." miles"; - - // If we got wind data - if(is_numeric(self::$wxdata['WIND_MPH'])){ - // We're going to output wind data as both MPH from a cardinal direction - // and as Knots from a direction in degrees - - // Calculate the value for Knots - self::$wxdata['WIND_KNOTS']=self::$wxdata['WIND_MPH']/1.15; - - // Format the output - $wind=sprintf("From the %s at %d mph (%03.0f° at %d knots)",self::$wxdata['WIND_DIR'],self::$wxdata['WIND_MPH'],self::$wxdata['WIND_DEGREES'],self::$wxdata['WIND_KNOTS']); - - // If we got a value for wind gusts - if(is_numeric(self::$wxdata['WIND_GUST_MPH']) && self::$wxdata['WIND_GUST_MPH']>0){ - // add it into the wind string - $wind=str_replace("mph","gusting to ".self::$wxdata['WIND_GUST_MPH']." mph
", $wind); - $knots=sprintf("%d",self::$wxdata['WIND_GUST_MPH']/1.15); - $wind=str_replace("knots","gusting to $knots knots",$wind); - } - } else { - // Otherwise, if wind is zero, we'll show "Calm" - $wind=self::$wxdata['WIND_MPH']=="Not available"?"Not available":"Calm"; - } // Done with wind - self::$wxdata['WIND_STRING']=$wind; - - } // Done getting and formatting the data - return self::$wxdata; - } - - function startElement($parser, $name, $attrs) { - self::$itemname=$name; - self::$itemdata=""; - } - - function endElement($parser, $name) { - self::$wxdata[self::$itemname]=self::$itemdata; - self::$itemdata=""; - } - - function characterData($parser, $data) { - self::$itemdata.=$data; - } - - function defineIcons(){ - // See http://weather.gov/data/current_obs/weather.php for source data for this function - $retVal['bkn']="Mostly Cloudy | Mostly Cloudy with Haze | Mostly Cloudy and Breezy"; - $retVal['skc']="Fair | Clear | Fair with Haze | Clear with Haze | Fair and Breezy | Clear and Breezy"; - $retVal['few']="A Few Clouds | A Few Clouds with Haze | A Few Clouds and Breezy"; - $retVal['sct']="Partly Cloudy | Party Cloudy with Haze | Partly Cloudy and Breezy"; - $retVal['ovc']="Overcast | Overcast with Haze | Overcast and Breezy"; - $retVal['nfg']="Fog/Mist | Fog | Freezing Fog | Shallow Fog | Partial Fog | Patches of Fog | Fog in Vicinity | Freezing Fog in Vicinity | Shallow Fog in Vicinity | Partial Fog in Vicinity | Patches of Fog in Vicinity | Showers in Vicinity Fog | Light Freezing Fog | Heavy Freezing Fog"; - $retVal['smoke']="Smoke"; - $retVal['fzra']="Freezing Rain | Freezing Drizzle | Light Freezing Rain | Light Freezing Drizzle | Heavy Freezing Rain | Heavy Freezing Drizzle | Freezing Rain in Vicinity | Freezing Drizzle in Vicinity"; - $retVal['ip']="Ice Pellets | Light Ice Pellets | Heavy Ice Pellets | Ice Pellets in Vicinity | Showers Ice Pellets | Thunderstorm Ice Pellets | Ice Crystals | Hail | Small Hail/Snow Pellets | Light Small Hail/Snow Pellets | Heavy Small Hail/Snow Pellets | Showers Hail | Hail Showers"; - $retVal['mix']="Freezing Rain Snow | Light Freezing Rain Snow | Heavy Freezing Rain Snow | Freezing Drizzle Snow | Light Freezing Drizzle Snow | Heavy Freezing Drizzle Snow | Snow Freezing Rain| Light Snow Freezing Rain | Heavy Snow Freezing Rain | Snow Freezing Drizzle | Light Snow Freezing Drizzle | Heavy Snow Freezing Drizzle"; - $retVal['raip']="Rain Ice Pellets | Light Rain Ice Pellets | Heavy Rain Ice Pellets | Drizzle Ice Pellets | Light Drizzle Ice Pellets | Heavy Drizzle Ice Pellets | Ice Pellets Rain | Light Ice Pellets Rain | Heavy Ice Pellets Rain | Ice Pellets Drizzle | Light Ice Pellets Drizzle | Heavy Ice Pellets Drizzle"; - $retVal['rasn']="Rain Snow | Light Rain Snow | Heavy Rain Snow | Snow Rain | Light Snow Rain | Heavy Snow Rain | Drizzle Snow | Light Drizzle Snow | Heavy Drizzle Snow | Snow Drizzle | Light Snow Drizzle | Heavy Snow Drizzle"; - $retVal['shra']="Rain Showers | Light Rain Showers | Heavy Rain Showers | Rain Showers in Vicinity | Light Showers Rain | Heavy Showers Rain | Showers Rain | Showers Rain in Vicinity | Rain Showers Fog/Mist | Light Rain Showers Fog/Mist | Heavy Rain Showers Fog/Mist | Rain Showers in Vicinity Fog/Mist | Light Showers Rain Fog/Mist | Heavy Showers Rain Fog/Mist | Showers Rain Fog/Mist | Showers Rain in Vicinity Fog/Mist"; - $retVal['tsra']="Thunderstorm | Light Thunderstorm Rain | Heavy Thunderstorm Rain | Thunderstorm Rain Fog/Mist | Light Thunderstorm Rain Fog/Mist | Heavy Thunderstorm Rain Fog/Mist | Thunderstorm Showers in Vicinity | | Light Thunderstorm Rain Haze | Heavy Thunderstorm Rain Haze | Thunderstorm Fog | Light Thunderstorm Rain Fog | Heavy Thunderstorm Rain Fog | Thunderstorm Light Rain | Thunderstorm Heavy Rain | Thunderstorm Rain Fog/Mist | Thunderstorm Light Rain Fog/Mist | Thunderstorm Heavy Rain Fog/Mist | Thunderstorm in Vicinity Fog/Mist | Thunderstorm Showers in Vicinity | Thunderstorm in Vicinity | Thunderstorm in Vicinity Haze | Thunderstorm Haze in Vicinity | Thunderstorm Light Rain Haze | Thunderstorm Heavy Rain Haze | Thunderstorm Fog | Thunderstorm Light Rain Fog | Thunderstorm Heavy Rain Fog | Thunderstorm Hail | Light Thunderstorm Rain Hail | Heavy Thunderstorm Rain Hail | Thunderstorm Rain Hail Fog/Mist | Light Thunderstorm Rain Hail Fog/Mist | Heavy Thunderstorm Rain Hail Fog/Mist | Thunderstorm Showers in Vicinity Hail | | Light Thunderstorm Rain Hail Haze | Heavy Thunderstorm Rain Hail Haze | Thunderstorm Hail Fog | Light Thunderstorm Rain Hail Fog | Heavy Thunderstorm Rain Hail Fog | Thunderstorm Light Rain Hail | Thunderstorm Heavy Rain Hail | Thunderstorm Rain Hail Fog/Mist | Thunderstorm Light Rain Hail Fog/Mist | Thunderstorm Heavy Rain Hail Fog/Mist | Thunderstorm in Vicinity Hail Fog/Mist | Thunderstorm Showers in Vicinity Hail | Thunderstorm in Vicinity Hail | Thunderstorm in Vicinity Hail Haze | Thunderstorm Haze in Vicinity Hail | Thunderstorm Light Rain Hail Haze | Thunderstorm Heavy Rain Hail Haze | Thunderstorm Hail Fog | Thunderstorm Light Rain Hail Fog | Thunderstorm Heavy Rain Hail Fog | Thunderstorm Small Hail/Snow Pellets | Thunderstorm Rain Small Hail/Snow Pellets | Light Thunderstorm Rain Small Hail/Snow Pellets | Heavy Thunderstorm Rain Small Hail/Snow Pellets"; - $retVal['sn']="Snow | Light Snow | Heavy Snow | Snow Showers | Light Snow Showers | Heavy Snow Showers | Showers Snow | Light Showers Snow | Heavy Showers Snow | Snow Fog/Mist | Light Snow Fog/Mist | Heavy Snow Fog/Mist | Snow Showers Fog/Mist | Light Snow Showers Fog/Mist | Heavy Snow Showers Fog/Mist | Showers Snow Fog/Mist | Light Showers Snow Fog/Mist | Heavy Showers Snow Fog/Mist | Snow Fog | Light Snow Fog | Heavy Snow Fog | Snow Showers Fog | Light Snow Showers Fog | Heavy Snow Showers Fog | Showers Snow Fog | Light Showers Snow Fog | Heavy Showers Snow Fog | Showers in Vicinity Snow | Snow Showers in Vicinity | Snow Showers in Vicinity Fog/Mist | Snow Showers in Vicinity Fog | Low Drifting Snow | Blowing Snow | Snow Low Drifting Snow | Snow Blowing Snow | Light Snow Low Drifting Snow | Light Snow Blowing Snow | Heavy Snow Low Drifting Snow | Heavy Snow Blowing Snow | Thunderstorm Snow | Light Thunderstorm Snow | Heavy Thunderstorm Snow | Snow Grains | Light Snow Grains | Heavy Snow Grains | Heavy Blowing Snow | Blowing Snow in Vicinity"; - $retVal['wind']="Windy | Fair and Windy | A Few Clouds and Windy | Partly Cloudy and Windy | Mostly Cloudy and Windy | Overcast and Windy"; - $retVal['hi_shwrs']="Showers in Vicinity | Showers in Vicinity Fog/Mist | Showers in Vicinity Fog | Showers in Vicinity Haze"; - $retVal['fzrara']="Freezing Rain Rain | Light Freezing Rain Rain | Heavy Freezing Rain Rain | Rain Freezing Rain | Light Rain Freezing Rain | Heavy Rain Freezing Rain | Freezing Drizzle Rain | Light Freezing Drizzle Rain | Heavy Freezing Drizzle Rain | Rain Freezing Drizzle | Light Rain Freezing Drizzle | Heavy Rain Freezing Drizzle"; - $retVal['hi_tsra']="Thunderstorm in Vicinity | Thunderstorm in Vicinity Fog/Mist | Thunderstorm in Vicinity Fog | Thunderstorm Haze in Vicinity | Thunderstorm in Vicinity Haze"; - $retVal['ra1']="Light Rain | Drizzle | Light Drizzle | Heavy Drizzle | Light Rain Fog/Mist | Drizzle Fog/Mist | Light Drizzle Fog/Mist | Heavy Drizzle Fog/Mist | Light Rain Fog | Drizzle Fog | Light Drizzle Fog | Heavy Drizzle Fog"; - $retVal['ra']="Rain | Heavy Rain | Rain Fog/Mist | Heavy Rain Fog/Mist | Rain Fog | Heavy Rain Fog"; - $retVal['nsvrtsra']="Funnel Cloud | Funnel Cloud in Vicinity | Tornado/Water Spout"; - $retVal['dust']="Dust | Low Drifting Dust | Blowing Dust | Sand | Blowing Sand | Low Drifting Sand | Dust/Sand Whirls | Dust/Sand Whirls in Vicinity | Dust Storm | Heavy Dust Storm | Dust Storm in Vicinity | Sand Storm | Heavy Sand Storm | Sand Storm in Vicinity"; - $retVal['mist']="Haze"; - return $retVal; - } -// end CLASS -} -?> diff --git a/curweather/test.php b/curweather/test.php deleted file mode 100644 index cd51c23c..00000000 --- a/curweather/test.php +++ /dev/null @@ -1,5 +0,0 @@ - Date: Sat, 11 Jul 2015 20:21:09 +0200 Subject: [PATCH 16/44] added composer.json and needed libs --- curweather/composer.json | 5 + curweather/vendor/autoload.php | 7 + .../cmfcmf/openweathermap-php-api/.gitignore | 1 + .../cmfcmf/openweathermap-php-api/.travis.yml | 22 + .../Cmfcmf/OpenWeatherMap.php | 598 +++++++++++ .../Cmfcmf/OpenWeatherMap/AbstractCache.php | 69 ++ .../Cmfcmf/OpenWeatherMap/CurrentWeather.php | 117 +++ .../Cmfcmf/OpenWeatherMap/Exception.php | 27 + .../OpenWeatherMap/Fetcher/CurlFetcher.php | 42 + .../Fetcher/FetcherInterface.php | 37 + .../Fetcher/FileGetContentsFetcher.php | 34 + .../Cmfcmf/OpenWeatherMap/Forecast.php | 83 ++ .../Cmfcmf/OpenWeatherMap/History.php | 104 ++ .../Cmfcmf/OpenWeatherMap/Util/City.php | 76 ++ .../Cmfcmf/OpenWeatherMap/Util/Sun.php | 52 + .../OpenWeatherMap/Util/Temperature.php | 105 ++ .../Cmfcmf/OpenWeatherMap/Util/Time.php | 65 ++ .../Cmfcmf/OpenWeatherMap/Util/Unit.php | 128 +++ .../Cmfcmf/OpenWeatherMap/Util/Weather.php | 82 ++ .../Cmfcmf/OpenWeatherMap/Util/Wind.php | 48 + .../Cmfcmf/OpenWeatherMap/WeatherForecast.php | 136 +++ .../Cmfcmf/OpenWeatherMap/WeatherHistory.php | 118 +++ .../openweathermap-php-api/Examples/Cache.php | 95 ++ .../Examples/CurrentWeather.php | 236 +++++ .../Examples/WeatherForecast.php | 69 ++ .../Examples/WeatherHistory.php | 43 + .../cmfcmf/openweathermap-php-api/LICENSE | 19 + .../cmfcmf/openweathermap-php-api/README.md | 83 ++ .../openweathermap-php-api/composer.json | 30 + .../openweathermap-php-api/composer.lock | 973 ++++++++++++++++++ .../openweathermap-php-api/phpunit.xml.dist | 22 + .../tests/Fetcher/CurlFetcherTest.php | 53 + .../Fetcher/FileGetContentsFetcherTest.php | 59 ++ .../tests/Util/SunTest.php | 62 ++ .../tests/Util/UnitTest.php | 159 +++ .../tests/bootstrap.php | 12 + curweather/vendor/composer/ClassLoader.php | 413 ++++++++ .../vendor/composer/autoload_classmap.php | 9 + .../vendor/composer/autoload_namespaces.php | 10 + curweather/vendor/composer/autoload_psr4.php | 9 + curweather/vendor/composer/autoload_real.php | 50 + curweather/vendor/composer/installed.json | 51 + 42 files changed, 4413 insertions(+) create mode 100644 curweather/composer.json create mode 100644 curweather/vendor/autoload.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/.gitignore create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/.travis.yml create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/AbstractCache.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/CurrentWeather.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Exception.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Fetcher/CurlFetcher.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Fetcher/FetcherInterface.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Fetcher/FileGetContentsFetcher.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Forecast.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/History.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/City.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Sun.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Temperature.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Time.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Unit.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Weather.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Wind.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherForecast.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherHistory.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Examples/Cache.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Examples/CurrentWeather.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherForecast.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherHistory.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/LICENSE create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/README.md create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/composer.json create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/composer.lock create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/phpunit.xml.dist create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/CurlFetcherTest.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/FileGetContentsFetcherTest.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/SunTest.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/UnitTest.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/tests/bootstrap.php create mode 100644 curweather/vendor/composer/ClassLoader.php create mode 100644 curweather/vendor/composer/autoload_classmap.php create mode 100644 curweather/vendor/composer/autoload_namespaces.php create mode 100644 curweather/vendor/composer/autoload_psr4.php create mode 100644 curweather/vendor/composer/autoload_real.php create mode 100644 curweather/vendor/composer/installed.json diff --git a/curweather/composer.json b/curweather/composer.json new file mode 100644 index 00000000..d54ac721 --- /dev/null +++ b/curweather/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "cmfcmf/openweathermap-php-api": "~2.0" + } +} diff --git a/curweather/vendor/autoload.php b/curweather/vendor/autoload.php new file mode 100644 index 00000000..9e1325a6 --- /dev/null +++ b/curweather/vendor/autoload.php @@ -0,0 +1,7 @@ +OpenWeatherMap.org"; + + /** + * @var \Cmfcmf\OpenWeatherMap\AbstractCache|bool $cacheClass The cache class. + */ + private $cacheClass = false; + + /** + * @var int + */ + private $seconds; + + /** + * @var FetcherInterface The url fetcher. + */ + private $fetcher; + + /** + * Constructs the OpenWeatherMap object. + * + * @param null|FetcherInterface $fetcher The interface to fetch the data from OpenWeatherMap. Defaults to + * CurlFetcher() if cURL is available. Otherwise defaults to + * FileGetContentsFetcher() using 'file_get_contents()'. + * @param bool|string $cacheClass If set to false, caching is disabled. Otherwise this must be a class + * extending AbstractCache. Defaults to false. + * @param int $seconds How long weather data shall be cached. Default 10 minutes. + * + * @throws \Exception If $cache is neither false nor a valid callable extending Cmfcmf\OpenWeatherMap\Util\Cache. + * @api + */ + public function __construct($fetcher = null, $cacheClass = false, $seconds = 600) + { + if ($cacheClass !== false && !($cacheClass instanceof AbstractCache)) { + throw new \Exception("The cache class must implement the FetcherInterface!"); + } + if (!is_numeric($seconds)) { + throw new \Exception("\$seconds must be numeric."); + } + if (!isset($fetcher)) { + $fetcher = (function_exists('curl_version')) ? new CurlFetcher() : new FileGetContentsFetcher(); + } + if ($seconds == 0) { + $cacheClass = false; + } + + $this->cacheClass = $cacheClass; + $this->seconds = $seconds; + $this->fetcher = $fetcher; + } + + /** + * Returns the current weather at the place you specified as an object. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * + * @throws OpenWeatherMap\Exception If OpenWeatherMap returns an error. + * @throws \InvalidArgumentException If an argument error occurs. + * + * @return CurrentWeather The weather object. + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getWeather($query, $units = 'imperial', $lang = 'en', $appid = '') + { + // Disable default error handling of SimpleXML (Do not throw E_WARNINGs). + libxml_use_internal_errors(true); + libxml_clear_errors(); + + $answer = $this->getRawWeatherData($query, $units, $lang, $appid, 'xml'); + + try { + $xml = new \SimpleXMLElement($answer); + } catch (\Exception $e) { + // Invalid xml format. This happens in case OpenWeatherMap returns an error. + // OpenWeatherMap always uses json for errors, even if one specifies xml as format. + $error = json_decode($answer, true); + if (isset($error['message'])) { + throw new OWMException($error['message'], $error['cod']); + } else { + throw new OWMException('Unknown fatal error: OpenWeatherMap returned the following json object: ' . $answer); + } + } + + return new CurrentWeather($xml, $units); + } + + /** + * Returns the current weather at the place you specified as an object. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * @param int $days For how much days you want to get a forecast. Default 1, maximum: 16. + * + * @throws OpenWeatherMap\Exception If OpenWeatherMap returns an error. + * @throws \InvalidArgumentException If an argument error occurs. + * + * @return WeatherForecast The WeatherForecast object. + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getWeatherForecast($query, $units = 'imperial', $lang = 'en', $appid = '', $days = 1) + { + // Disable default error handling of SimpleXML (Do not throw E_WARNINGs). + libxml_use_internal_errors(true); + libxml_clear_errors(); + + if ($days <= 5) { + $answer = $this->getRawHourlyForecastData($query, $units, $lang, $appid, 'xml'); + } else if ($days <= 16) { + $answer = $this->getRawDailyForecastData($query, $units, $lang, $appid, 'xml', $days); + } else { + throw new \InvalidArgumentException('Error: forecasts are only available for the next 16 days. $days must be lower than 17.'); + } + + try { + $xml = new \SimpleXMLElement($answer); + } catch (\Exception $e) { + // Invalid xml format. This happens in case OpenWeatherMap returns an error. + // OpenWeatherMap always uses json for errors, even if one specifies xml as format. + $error = json_decode($answer, true); + if (isset($error['message'])) { + throw new OWMException($error['message'], $error['cod']); + } else { + throw new OWMException('Unknown fatal error: OpenWeatherMap returned the following json object: ' . $answer); + } + } + + return new WeatherForecast($xml, $units, $days); + } + + /** + * Returns the weather history for the place you specified as an object. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param \DateTime $start + * @param int $endOrCount + * @param string $type + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * + * @throws OpenWeatherMap\Exception If OpenWeatherMap returns an error. + * @throws \InvalidArgumentException If an argument error occurs. + * + * @return WeatherHistory The WeatherHistory object. + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getWeatherHistory($query, \DateTime $start, $endOrCount = 1, $type = 'hour', $units = 'imperial', $lang = 'en', $appid = '') + { + if (!in_array($type, array('tick', 'hour', 'day'))) { + throw new \InvalidArgumentException('$type must be either "tick", "hour" or "day"'); + } + + $xml = json_decode($this->getRawWeatherHistory($query, $start, $endOrCount, $type, $units, $lang, $appid), true); + + if ($xml['cod'] != 200) { + throw new OWMException($xml['message'], $xml['cod']); + } + + return new WeatherHistory($xml, $query); + } + + /** + * @deprecated Use {@link self::getRawWeatherData()} instead. + */ + public function getRawData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml') + { + return $this->getRawWeatherData($query, $units, $lang, $appid, $mode); + } + + /** + * Directly returns the xml/json/html string returned by OpenWeatherMap for the current weather. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * @param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default). + * + * @return string Returns false on failure and the fetched data in the format you specified on success. + * + * Warning If an error occurred, OpenWeatherMap returns data in json format ALWAYS + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getRawWeatherData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml') + { + $url = $this->buildUrl($query, $units, $lang, $appid, $mode, $this->weatherUrl); + + return $this->cacheOrFetchResult($url); + } + + /** + * Directly returns the xml/json/html string returned by OpenWeatherMap for the hourly forecast. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * @param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default). + * + * @return string Returns false on failure and the fetched data in the format you specified on success. + * + * Warning If an error occurred, OpenWeatherMap returns data in json format ALWAYS + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getRawHourlyForecastData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml') + { + $url = $this->buildUrl($query, $units, $lang, $appid, $mode, $this->weatherHourlyForecastUrl); + + return $this->cacheOrFetchResult($url); + } + + /** + * Directly returns the xml/json/html string returned by OpenWeatherMap for the daily forecast. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * @param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default) + * @param int $cnt How many days of forecast shall be returned? Maximum (and default): 16 + * + * @throws \InvalidArgumentException If $cnt is higher than 16. + * @return string Returns false on failure and the fetched data in the format you specified on success. + * + * Warning If an error occurred, OpenWeatherMap returns data in json format ALWAYS + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getRawDailyForecastData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml', $cnt = 16) + { + if ($cnt > 16) { + throw new \InvalidArgumentException('$cnt must be 16 or below!'); + } + $url = $this->buildUrl($query, $units, $lang, $appid, $mode, $this->weatherDailyForecastUrl) . "&cnt=$cnt"; + + return $this->cacheOrFetchResult($url); + } + + /** + * Directly returns the xml/json/html string returned by OpenWeatherMap for the daily forecast. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param \DateTime $start The \DateTime object of the date to get the first weather information from. + * @param \DateTime|int $endOrCount Can be either a \DateTime object representing the end of the period to + * receive weather history data for or an integer counting the number of + * reports requested. + * @param string $type The period of the weather history requested. Can be either be either "tick", + * "hour" or "day". + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * + * @throws \InvalidArgumentException + * + * @return string Returns false on failure and the fetched data in the format you specified on success. + * + * Warning If an error occurred, OpenWeatherMap returns data in json format ALWAYS + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getRawWeatherHistory($query, \DateTime $start, $endOrCount = 1, $type = 'hour', $units = 'imperial', $lang = 'en', $appid = '') + { + if (!in_array($type, array('tick', 'hour', 'day'))) { + throw new \InvalidArgumentException('$type must be either "tick", "hour" or "day"'); + } + + $queryUrl = $this->weatherHistoryUrl . $this->buildQueryUrlParameter($query) . "&start={$start->format('U')}"; + + if ($endOrCount instanceof \DateTime) { + $queryUrl .= "&end={$endOrCount->format('U')}"; + } else if (is_numeric($endOrCount) && $endOrCount > 0) { + $queryUrl .= "&cnt=$endOrCount"; + } else { + throw new \InvalidArgumentException('$endOrCount must be either a \DateTime or a positive integer.'); + } + $queryUrl .= "&type=$type&units=$units&lang=$lang"; + + if (!empty($appid)) { + $queryUrl .= "&APPID=$appid"; + } + + return $this->cacheOrFetchResult($queryUrl); + } + + /** + * Fetches the result or delivers a cached version of the result. + * + * @param $url + * + * @return string + * + * @internal + */ + private function cacheOrFetchResult($url) + { + if ($this->cacheClass !== false) { + /** @var \Cmfcmf\OpenWeatherMap\AbstractCache $cache */ + $cache = $this->cacheClass; + $cache->setSeconds($this->seconds); + if ($cache->isCached($url)) { + return $cache->getCached($url); + } + $result = $this->fetcher->fetch($url); + $cache->setCached($url, $result); + } else { + $result = $this->fetcher->fetch($url); + } + + return $result; + } + + /** + * Build the url to fetch weather data from. + * + * @param $query + * @param $units + * @param $lang + * @param $appid + * @param $mode + * @param string $url The url to prepend. + * + * @return bool|string The fetched url, false on failure. + * + * @internal + */ + private function buildUrl($query, $units, $lang, $appid, $mode, $url) + { + $queryUrl = $this->buildQueryUrlParameter($query); + + $url = $url . "$queryUrl&units=$units&lang=$lang&mode=$mode"; + if (!empty($appid)) { + $url .= "&APPID=$appid"; + } + + return $url; + } + + /** + * Builds the query string for the url. + * + * @param $query + * + * @return string The built query string for the url. + * @throws \InvalidArgumentException If the query parameter is invalid. + * + * @internal + */ + private function buildQueryUrlParameter($query) + { + switch ($query) { + case (is_array($query) && isset($query['lat']) && isset($query['lon']) && is_numeric($query['lat']) && is_numeric($query['lon'])): + return "lat={$query['lat']}&lon={$query['lon']}"; + case (is_numeric($query)): + return "id=$query"; + case (is_string($query)): + return "q=" . urlencode($query); + default: + throw new \InvalidArgumentException('Error: $query has the wrong format. See the documentation of OpenWeatherMap::getRawData() to read about valid formats.'); + } + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/AbstractCache.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/AbstractCache.php new file mode 100644 index 00000000..c9b66ebe --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/AbstractCache.php @@ -0,0 +1,69 @@ +seconds = $seconds; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/CurrentWeather.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/CurrentWeather.php new file mode 100644 index 00000000..7ce2e2a1 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/CurrentWeather.php @@ -0,0 +1,117 @@ +city = new City($xml->city['id'], $xml->city['name'], $xml->city->coord['lon'], $xml->city->coord['lat'], $xml->city->country); + $this->temperature = new Temperature(new Unit($xml->temperature['value'], $xml->temperature['unit']), new Unit($xml->temperature['min'], $xml->temperature['unit']), new Unit($xml->temperature['max'], $xml->temperature['unit'])); + $this->humidity = new Unit($xml->humidity['value'], $xml->humidity['unit']); + $this->pressure = new Unit($xml->pressure['value'], $xml->pressure['unit']); + + // This is kind of a hack, because the units are missing in the xml document. + if ($units == 'metric') { + $windSpeedUnit = 'm/s'; + } else { + $windSpeedUnit = 'mph'; + } + $this->wind = new Wind(new Unit($xml->wind->speed['value'], $windSpeedUnit, $xml->wind->speed['name']), new Unit($xml->wind->direction['value'], $xml->wind->direction['code'], $xml->wind->direction['name'])); + + $this->clouds = new Unit($xml->clouds['value'], null, $xml->clouds['name']); + $this->precipitation = new Unit($xml->precipitation['value'], $xml->precipitation['unit'], $xml->precipitation['mode']); + $utctz = new \DateTimeZone('UTC'); + $this->sun = new Sun(new \DateTime($xml->city->sun['rise'], $utctz), new \DateTime($xml->city->sun['set'], $utctz)); + $this->weather = new WeatherObj($xml->weather['number'], $xml->weather['value'], $xml->weather['icon']); + $this->lastUpdate = new \DateTime($xml->lastupdate['value'], $utctz); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Exception.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Exception.php new file mode 100644 index 00000000..20f3a871 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Exception.php @@ -0,0 +1,27 @@ +city = new City($xml->city['id'], $xml->city['name'], $xml->city->coord['lon'], $xml->city->coord['lat'], $xml->city->country); + + if ($units == 'metric') { + $temperatureUnit = "°C"; + } else { + $temperatureUnit = 'F'; + } + + $xml->temperature['value'] = ($xml->temperature['max'] + $xml->temperature['min']) / 2; + + $this->temperature = new Temperature(new Unit($xml->temperature['value'], $temperatureUnit), new Unit($xml->temperature['min'], $temperatureUnit), new Unit($xml->temperature['max'], $temperatureUnit)); + $this->humidity = new Unit($xml->humidity['value'], $xml->humidity['unit']); + $this->pressure = new Unit($xml->pressure['value'], $xml->pressure['unit']); + + // This is kind of a hack, because the units are missing in the xml document. + if ($units == 'metric') { + $windSpeedUnit = 'm/s'; + } else { + $windSpeedUnit = 'mps'; + } + + $this->wind = new Wind(new Unit($xml->windSpeed['mps'], $windSpeedUnit, $xml->windSpeed['name']), new Unit($xml->windDirection['value'], $xml->windDirection['code'], $xml->windDirection['name'])); + $this->clouds = new Unit($xml->clouds['all'], $xml->clouds['unit'], $xml->clouds['value']); + $this->precipitation = new Unit($xml->precipitation['value'], null, $xml->precipitation['type']); + $this->sun = new Sun(new \DateTime($xml->city->sun['rise']), new \DateTime($xml->city->sun['set'])); + $this->weather = new WeatherObj($xml->symbol['number'], $xml->symbol['name'], $xml->symbol['var']); + $this->lastUpdate = new \DateTime($xml->lastupdate['value']); + + if (isset($xml['from'])) { + $this->time = new Time($xml['from'], $xml['to']); + } else { + $this->time = new Time($xml['day']); + } + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/History.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/History.php new file mode 100644 index 00000000..6601a840 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/History.php @@ -0,0 +1,104 @@ +city = $city; + $this->weather = new Weather($weather['id'], $weather['description'], $weather['icon']); + $this->temperature = new Temperature(new Unit($temperature['now'] - 273.15, "\xB0C"), new Unit($temperature['min'] - 273.15, "\xB0C"), new Unit($temperature['max'] - 273.15, "\xB0C")); + $this->pressure = new Unit($pressure, 'kPa'); + $this->humidity = new Unit($humidity, '%'); + $this->clouds = new Unit($clouds, '%'); + $this->precipitation = new Unit($rain['val'], $rain['unit']); + $this->wind = new Wind(new Unit($wind['speed']), new Unit($wind['deg'])); + $this->time = $time; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/City.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/City.php new file mode 100644 index 00000000..b5dceb2b --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/City.php @@ -0,0 +1,76 @@ +id = (int)$id; + $this->name = isset($name) ? (string)$name : null; + $this->lon = isset($lon) ? (float)$lon : null; + $this->lat = isset($lat) ? (float)$lat : null; + $this->country = isset($country) ? (string)$country : null; + $this->population = isset($population) ? (int)$population : null; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Sun.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Sun.php new file mode 100644 index 00000000..dc0f0104 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Sun.php @@ -0,0 +1,52 @@ +rise = $rise; + $this->set = $set; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Temperature.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Temperature.php new file mode 100644 index 00000000..14146c06 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Temperature.php @@ -0,0 +1,105 @@ +now->__toString(); + } + + /** + * Returns the current temperature's unit. + * + * @return string The current temperature's unit. + */ + public function getUnit() + { + return $this->now->getUnit(); + } + + /** + * Returns the current temperature. + * + * @return string The current temperature. + */ + public function getValue() + { + return $this->now->getValue(); + } + + /** + * Returns the current temperature's description. + * + * @return string The current temperature's description. + */ + public function getDescription() + { + return $this->now->getDescription(); + } + + /** + * Returns the current temperature as formatted string. + * + * @return string The current temperature as formatted string. + */ + public function getFormatted() + { + return $this->now->getFormatted(); + } + + /** + * Create a new temperature object. + * + * @param Unit $now The current temperature. + * @param Unit $min The minimal temperature. + * @param Unit $max The maximal temperature. + * + * @internal + */ + public function __construct(Unit $now, Unit $min, Unit $max) + { + $this->now = $now; + $this->min = $min; + $this->max = $max; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Time.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Time.php new file mode 100644 index 00000000..517b4c30 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Time.php @@ -0,0 +1,65 @@ +format('Y-m-d')); + } else { + $from = ($from instanceof \DateTime) ? $from : new \DateTime((string)$from); + $day = clone $from; + $to = clone $from; + $to = $to->add(new \DateInterval('PT23H59M59S')); + } + + $this->from = $from; + $this->to = $to; + $this->day = $day; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Unit.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Unit.php new file mode 100644 index 00000000..017ff05e --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Unit.php @@ -0,0 +1,128 @@ +value = (float)$value; + $this->unit = (string)$unit; + $this->description = (string)$description; + } + + /** + * Get the value as formatted string with unit. + * + * @return string The value as formatted string with unit. + * + * The unit is not included if it is empty. + */ + public function __toString() + { + return $this->getFormatted(); + } + + /** + * Get the value's unit. + * + * @return string The value's unit. + * + * This also converts 'celsius' to '°C' and 'fahrenheit' to 'F'. + */ + public function getUnit() + { + // Units are inconsistent. Only celsius and fahrenheit are not abbreviated. This check fixes that. + if ($this->unit == 'celsius') { + return "°C"; + } else if ($this->unit == 'fahrenheit') { + return 'F'; + } else { + return $this->unit; + } + } + + /** + * Get the value. + * + * @return float The value. + */ + public function getValue() + { + return $this->value; + } + + /** + * Get the value's description. + * + * @return string The value's description. + */ + public function getDescription() + { + return $this->description; + } + + /** + * Get the value as formatted string with unit. + * + * @return string The value as formatted string with unit. + * + * The unit is not included if it is empty. + */ + public function getFormatted() + { + if ($this->getUnit() != "") { + return "{$this->getValue()} {$this->getUnit()}"; + } else { + return "{$this->getValue()}"; + } + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Weather.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Weather.php new file mode 100644 index 00000000..a9d848eb --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Weather.php @@ -0,0 +1,82 @@ +id = (int)$id; + $this->description = (string)$description; + $this->icon = (string)$icon; + } + + /** + * Get the weather description. + * + * @return string + */ + public function __toString() + { + return $this->description; + } + + /** + * Get the icon url. + * + * @return string The icon url. + */ + public function getIconUrl() + { + return str_replace("%s", $this->icon, $this->iconUrl); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Wind.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Wind.php new file mode 100644 index 00000000..02209600 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Wind.php @@ -0,0 +1,48 @@ +speed = $speed; + $this->direction = $direction; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherForecast.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherForecast.php new file mode 100644 index 00000000..8230989e --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherForecast.php @@ -0,0 +1,136 @@ +getWeather(). + * + * @see Cmfcmf\OpenWeatherMap::getWeather() The function using it. + */ +class WeatherForecast implements \Iterator +{ + /** + * A city object. + * + * @var Util\City + */ + public $city; + + /** + * A sun object + * + * @var Util\Sun + */ + public $sun; + + /** + * The time of the last update of this weather data. + * + * @var \DateTime + */ + public $lastUpdate; + + /** + * An array of {@link WeatherForecast} objects. + * + * @var array + * + * @see WeatherForecast The WeatherForecast class. + */ + private $forecasts; + + /** + * @internal + */ + private $position = 0; + + /** + * Create a new Forecast object. + * + * @param $xml + * @param string $units + * @param int $days How many days of forecast to receive. + * + * @internal + */ + public function __construct($xml, $units, $days) + { + $this->city = new City(-1, $xml->location->name, $xml->location->location['longitude'], $xml->location->location['latitude'], $xml->location->country); + $this->sun = new Sun(new \DateTime($xml->sun['rise']), new \DateTime($xml->sun['set'])); + $this->lastUpdate = new \DateTime($xml->meta->lastupdate); + + $counter = 0; + foreach ($xml->forecast->time as $time) { + $forecast = new Forecast($time, $units); + $forecast->city = $this->city; + $this->forecasts[] = $forecast; + + $counter++; + // Make sure to only return the requested number of days. + if ($days <= 5 && $counter == $days * 8) { + break; + } else if ($days > 5 && $counter == $days) { + break; + } + } + } + + /** + * @internal + */ + public function rewind() + { + $this->position = 0; + } + + /** + * @internal + */ + public function current() + { + return $this->forecasts[$this->position]; + } + + /** + * @internal + */ + public function key() + { + return $this->position; + } + + /** + * @internal + */ + public function next() + { + ++$this->position; + } + + /** + * @internal + */ + public function valid() + { + return isset($this->forecasts[$this->position]); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherHistory.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherHistory.php new file mode 100644 index 00000000..7ee4084a --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherHistory.php @@ -0,0 +1,118 @@ +city = new OpenWeatherMap\Util\City($weatherHistory['city_id'], (is_string($query)) ? $query : null, (isset($query['lon'])) ? $query['lon'] : null, (isset($query['lat'])) ? $query['lat'] : null, $country, $population); + $this->calctime = $weatherHistory['calctime']; + + foreach ($weatherHistory['list'] as $history) { + if (isset($history['rain'])) { + $units = array_keys($history['rain']); + } else { + $units = array(0 => null); + } + + $this->histories[] = new History($this->city, $history['weather'][0], array('now' => $history['main']['temp'], 'min' => $history['main']['temp_min'], 'max' => $history['main']['temp_max']), $history['main']['pressure'], $history['main']['humidity'], $history['clouds']['all'], isset($history['rain']) ? array('val' => $history['rain'][($units[0])], 'unit' => $units[0]) : null, $history['wind'], \DateTime::createFromFormat('U', $history['dt'])); + } + } + + /** + * @internal + */ + public function rewind() + { + $this->position = 0; + } + + /** + * @internal + */ + public function current() + { + return $this->histories[$this->position]; + } + + /** + * @internal + */ + public function key() + { + return $this->position; + } + + /** + * @internal + */ + public function next() + { + ++$this->position; + } + + /** + * @internal + */ + public function valid() + { + return isset($this->histories[$this->position]); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/Cache.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/Cache.php new file mode 100644 index 00000000..61869f2e --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/Cache.php @@ -0,0 +1,95 @@ +urlToPath($url); + if (!file_exists($path) || filectime($path) + $this->seconds < time()) { + echo "Weather data is NOT cached!\n"; + + return false; + } + + echo "Weather data is cached!\n"; + + return true; + } + + /** + * @inheritdoc + */ + public function getCached($url) + { + return file_get_contents($this->urlToPath($url)); + } + + /** + * @inheritdoc + */ + public function setCached($url, $content) + { + file_put_contents($this->urlToPath($url), $content); + } +} + +// Language of data (try your own language here!): +$lang = 'de'; + +// Units (can be 'metric' or 'imperial' [default]): +$units = 'metric'; + +// Example 1: Use your own cache implementation. Cache for 10 seconds only in this example. +$owm = new OpenWeatherMap(null, new ExampleCache(), 10); + +$weather = $owm->getWeather('Berlin', $units, $lang); +echo "EXAMPLE 1
\n\n\n"; +echo $weather->temperature; diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/CurrentWeather.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/CurrentWeather.php new file mode 100644 index 00000000..46a6c517 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/CurrentWeather.php @@ -0,0 +1,236 @@ +getWeather('Berlin', $units, $lang); +echo "EXAMPLE 1
\n\n\n"; + +// $weather contains all available weather information for Berlin. +// Let's get the temperature: + +// Returns it as formatted string (using __toString()): +echo $weather->temperature; +echo "
\n"; + +// Returns it as formatted string (using a method): +echo $weather->temperature->getFormatted(); +echo "
\n"; + +// Returns the value only: +echo $weather->temperature->getValue(); +echo "
\n"; + +// Returns the unit only: +echo $weather->temperature->getUnit(); +echo "
\n"; + +/** + * In the example above we're using a "shortcut". OpenWeatherMap returns the minimum temperature of a day, + * the maximum temperature and the temperature right now. If you don't specify which temperature you want, it will default + * to the current temperature. See below how to access the other values. Notice that each of them has implemented the methods + * "getFormatted()", "getValue()", "getUnit()". + */ + +// Returns the current temperature: +echo "Current: " . $weather->temperature->now; +echo "
\n"; + +// Returns the minimum temperature: +echo "Minimum: " . $weather->temperature->min; +echo "
\n"; + +// Returns the maximum temperature: +echo "Maximum: " . $weather->temperature->max; +echo "
\n"; + +/** + * When speaking about "current" and "now", this means when the weather data was last updated. You can get this + * via a DateTime object: + */ +echo "Last update: " . $weather->lastUpdate->format('r'); +echo "
\n"; + +// Example 2: Get current pressure and humidity in Hongkong. +$weather = $owm->getWeather('Hongkong', $units, $lang); +echo "

\n\n\nEXAMPLE 2
\n\n\n"; + +/** + * You can use the methods above to only get the value or the unit. + */ + +echo "Pressure: " . $weather->pressure; +echo "
\n"; +echo "Humidity: " . $weather->humidity; +echo "
\n"; + +// Example 3: Get today's sunrise and sunset times. +echo "

\n\n\nEXAMPLE 3
\n\n\n"; + +/** + * These functions return a DateTime object. + */ + +echo "Sunrise: " . $weather->sun->rise->format('r'); +echo "
\n"; +echo "Sunset: " . $weather->sun->set->format('r'); +echo "
\n"; + +// Example 4: Get current temperature from coordinates (Greenland :-) ). +$weather = $owm->getWeather(array('lat' => 77.73038, 'lon' => 41.89604), $units, $lang); +echo "

\n\n\nEXAMPLE 4
\n\n\n"; + +echo "Temperature: " . $weather->temperature; +echo "
\n"; + +// Example 5: Get current temperature from city id. The city is an internal id used by OpenWeatherMap. See example 6 too. +$weather = $owm->getWeather(2172797, $units, $lang); +echo "

\n\n\nEXAMPLE 5
\n\n\n"; + +echo "City: " . $weather->city->name; +echo "
\n"; + +echo "Temperature: " . $weather->temperature; +echo "
\n"; + +// Example 6: Get information about a city. +$weather = $owm->getWeather('Paris', $units, $lang); +echo "

\n\n\nEXAMPLE 6
\n\n\n"; + +echo "Id: " . $weather->city->id; +echo "
\n"; + +echo "Name: " . $weather->city->name; +echo "
\n"; + +echo "Lon: " . $weather->city->lon; +echo "
\n"; + +echo "Lat: " . $weather->city->lat; +echo "
\n"; + +echo "Country: " . $weather->city->country; +echo "
\n"; + +// Example 7: Get wind information. +echo "

\n\n\nEXAMPLE 7
\n\n\n"; + +echo "Speed: " . $weather->wind->speed; +echo "
\n"; + +echo "Direction: " . $weather->wind->direction; +echo "
\n"; + +/** + * For speed and direction there is a description available, which isn't always translated. + */ + +echo "Speed: " . $weather->wind->speed->getDescription(); +echo "
\n"; + +echo "Direction: " . $weather->wind->direction->getDescription(); +echo "
\n"; + +// Example 8: Get information about the clouds. +echo "

\n\n\nEXAMPLE 8
\n\n\n"; + +// The number in braces seems to be an indicator how cloudy the sky is. +echo "Clouds: " . $weather->clouds->getDescription() . " (" . $weather->clouds . ")"; +echo "
\n"; + +// Example 9: Get information about precipitation. +echo "

\n\n\nEXAMPLE 9
\n\n\n"; + +echo "Precipation: " . $weather->precipitation->getDescription() . " (" . $weather->precipitation . ")"; +echo "
\n"; + +// Example 10: Show copyright notice. WARNING: This is no offical text. This hint was created regarding to http://www.http://openweathermap.org/copyright . +echo "

\n\n\nEXAMPLE 10
\n\n\n"; + +echo $owm::COPYRIGHT; +echo "
\n"; + +// Example 11: Get raw xml data. +echo "

\n\n\nEXAMPLE 11
\n\n\n"; + +echo "
" . htmlspecialchars($owm->getRawWeatherData('Berlin', $units, $lang, null, 'xml')) . "
"; +echo "
\n"; + +// Example 12: Get raw json data. +echo "

\n\n\nEXAMPLE 12
\n\n\n"; + +echo "" . htmlspecialchars($owm->getRawWeatherData('Berlin', $units, $lang, null, 'json')) . ""; +echo "
\n"; + +// Example 13: Get raw html data. +echo "

\n\n\nEXAMPLE 13
\n\n\n"; + +echo $owm->getRawWeatherData('Berlin', $units, $lang, null, 'html'); +echo "
\n"; + +// Example 14: Error handling. +echo "

\n\n\nEXAMPLE 14
\n\n\n"; + +// Try wrong city name. +try { + $weather = $owm->getWeather("ThisCityNameIsNotValidAndDoesNotExist", $units, $lang); +} catch (OWMException $e) { + echo $e->getMessage() . ' (Code ' . $e->getCode() . ').'; + echo "
\n"; +} + +// Try invalid $query. +try { + $weather = $owm->getWeather(new \DateTime('now'), $units, $lang); +} catch (\Exception $e) { + echo $e->getMessage() . ' (Code ' . $e->getCode() . ').'; + echo "
\n"; +} + +// Full error handling would look like this: +try { + $weather = $owm->getWeather(-1, $units, $lang); +} catch (OWMException $e) { + echo 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'; + echo "
\n"; +} catch (\Exception $e) { + echo 'General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'; + echo "
\n"; +} + +// Example 15: Using an api key: +$owm->getWeather('Berlin', $units, $lang, 'Your-Api-Key-Here'); diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherForecast.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherForecast.php new file mode 100644 index 00000000..833425bb --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherForecast.php @@ -0,0 +1,69 @@ +getWeatherForecast('Berlin', $units, $lang, '', 10); +echo "EXAMPLE 1
\n\n\n"; + +echo "City: " . $forecast->city->name; +echo "
\n"; +echo "LastUpdate: " . $forecast->lastUpdate->format('d.m.Y H:i'); +echo "
\n"; +echo "Sunrise : " . $forecast->sun->rise->format("H:i:s") . " Sunset : " . $forecast->sun->set->format("H:i:s"); +echo "
\n"; +echo "
\n"; + +foreach ($forecast as $weather) { + // Each $weather contains a Cmfcmf\ForecastWeather object which is almost the same as the Cmfcmf\Weather object. + // Take a look into 'Examples_Current.php' to see the available options. + echo "Weather forecast at " . $weather->time->day->format('d.m.Y') . " from " . $weather->time->from->format('H:i') . " to " . $weather->time->to->format('H:i'); + echo "
\n"; + echo $weather->temperature; + echo "
\n"; + echo "---"; + echo "
\n"; +} + +// Example 2: Get forecast for the next 3 days for Berlin. +$forecast = $owm->getWeatherForecast('Berlin', $units, $lang, '', 3); +echo "EXAMPLE 2
\n\n\n"; + +foreach ($forecast as $weather) { + echo "Weather forecast at " . $weather->time->day->format('d.m.Y') . " from " . $weather->time->from->format('H:i') . " to " . $weather->time->to->format('H:i') . "
"; + echo $weather->temperature . "
\n"; + echo "---
\n"; +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherHistory.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherHistory.php new file mode 100644 index 00000000..c64ee524 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherHistory.php @@ -0,0 +1,43 @@ +getWeatherHistory('Berlin', new \DateTime('2014-01-01'), new \DateTime('now'), 'hour', $units, $lang); + +foreach ($history as $weather) { + echo "Average temperature at " . $weather->time->format('d.m.Y H:i') . ": " . $weather->temperature . "\n\r
"; +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/LICENSE b/curweather/vendor/cmfcmf/openweathermap-php-api/LICENSE new file mode 100644 index 00000000..1d2c3966 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013 Christian Flach + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/README.md b/curweather/vendor/cmfcmf/openweathermap-php-api/README.md new file mode 100644 index 00000000..ea452611 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/README.md @@ -0,0 +1,83 @@ +OpenWeatherMap-PHP-Api +====================== +A php api to parse weather data from [OpenWeatherMap.org](http://www.OpenWeatherMap.org). This api tries to normalise and abstract the data and remove inconsistencies. + +[![Build Status](https://travis-ci.org/cmfcmf/OpenWeatherMap-PHP-Api.png?branch=master)](https://travis-ci.org/cmfcmf/OpenWeatherMap-PHP-Api)[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/cmfcmf/OpenWeatherMap-PHP-Api/badges/quality-score.png?s=f31ca08aa8896416cf162403d34362f0a5da0966)](https://scrutinizer-ci.com/g/cmfcmf/OpenWeatherMap-PHP-Api/)[![Code Coverage](https://scrutinizer-ci.com/g/cmfcmf/OpenWeatherMap-PHP-Api/badges/coverage.png?s=65153e7cfb13e050d734c645e38f2dd7ea7a6860)](https://scrutinizer-ci.com/g/cmfcmf/OpenWeatherMap-PHP-Api/) +[![SensioLabsInsight](https://insight.sensiolabs.com/projects/0addfb24-e2b4-4feb-848e-86b2078ca104/big.png)](https://insight.sensiolabs.com/projects/0addfb24-e2b4-4feb-848e-86b2078ca104) +----------- + +For example code and how to use this api, please take a look into `Examples_*.php` files and run them in your browser. +- `Examples_Current.php` Shows how to receive the current weather. +- `Examples_Forecast.php` Shows how to receive weather forecasts. +- [*NEW*] `Examples_History.php` Shows how to receive weather history. +- `Examples_Cache.php` Shows how to implement a cache. + +**Notice:** This api is not made by OpenWeatherMap, nor their official php api. + +Contribute! +=========== +I'm very happy if you open **pull requests** or **issues** to help making this API **more awesome**. + +Installation +============ +This library can be found on [Packagist](https://packagist.org/packages/cmfcmf/openweathermap-php-api). +The recommended way to install this is through [composer](http://getcomposer.org). + +Edit your `composer.json` and add: + +```json +{ + "require": { + "cmfcmf/openweathermap-php-api": "~2.0" + } +} +``` + +And install dependencies: + +```bash +$ curl -sS https://getcomposer.org/installer | php +$ php composer.phar install +``` + + +Example call +============ +```php +getWeather('Berlin', $units, $lang); +} catch(OWMException $e) { + echo 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'; + echo "
\n"; +} catch(\Exception $e) { + echo 'General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'; + echo "
\n"; +} + +echo $weather->temperature; +``` + +License +======= +MIT — Please see the [LICENSE file](https://github.com/Cmfcmf/OpenWeatherMap-PHP-Api/blob/master/LICENSE) distributed with this source code for further information regarding copyright and licensing. + +**Please check out the following links to read about the usage policies and the license of OpenWeatherMap before using the service.** +- [OpenWeatherMap.org](http://www.OpenWeatherMap.org) +- [OpenWeatherMap.org/terms](http://www.OpenWeatherMap.org/terms) +- [OpenWeatherMap.org/appid](http://www.OpenWeatherMap.org/appid) diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/composer.json b/curweather/vendor/cmfcmf/openweathermap-php-api/composer.json new file mode 100644 index 00000000..687cd4f4 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/composer.json @@ -0,0 +1,30 @@ +{ + "name": "cmfcmf/openweathermap-php-api", + "description": "A php api to parse weather data from OpenWeatherMap.org. This api tries to normalise and abstract the data and remove inconsistencies.", + "keywords": ["weather", "OpenWeatherMap", "weather api"], + "homepage": "https://github.com/cmfcmf/OpenWeatherMap-PHP-Api", + "license": "MIT", + "authors": [ + { + "name": "Christian Flach (cmfcmf)", + "email": "cmfcmf.flach@gmail.com", + "homepage": "http://cmfcmf.github.io", + "role": "Developer" + } + ], + "support": { + "issues": "https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/issues", + "source": "https://github.com/cmfcmf/OpenWeatherMap-PHP-Api.git" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.7.0" + }, + "autoload": { + "psr-0": { + "Cmfcmf\\": "" + } + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/composer.lock b/curweather/vendor/cmfcmf/openweathermap-php-api/composer.lock new file mode 100644 index 00000000..5ef16474 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/composer.lock @@ -0,0 +1,973 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "23a2734069dc5af143bb0e0a09160885", + "packages": [], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14 21:17:01" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2015-02-03 12:10:50" + }, + { + "name": "phpspec/prophecy", + "version": "v1.4.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "phpdocumentor/reflection-docblock": "~2.0", + "sebastian/comparator": "~1.1" + }, + "require-dev": { + "phpspec/phpspec": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2015-04-27 22:15:08" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.1.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "631e365cf26bb2c078683e8d9bcf8bc631ac4d44" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/631e365cf26bb2c078683e8d9bcf8bc631ac4d44", + "reference": "631e365cf26bb2c078683e8d9bcf8bc631ac4d44", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-06-19 07:11:55" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2015-04-02 05:19:05" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/83fe1bdc5d47658b727595c14da140da92b3d66d", + "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2015-06-13 07:35:30" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/7a9b0969488c3c54fd62b4d504b3ec758fd005d9", + "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2015-06-19 03:43:16" + }, + { + "name": "phpunit/phpunit", + "version": "4.7.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "e5f851f324f7add846316f39e668e9deac97a103" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e5f851f324f7add846316f39e668e9deac97a103", + "reference": "e5f851f324f7add846316f39e668e9deac97a103", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpspec/prophecy": "~1.3,>=1.3.1", + "phpunit/php-code-coverage": "~2.1", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": ">=1.0.6", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.1", + "sebastian/diff": "~1.2", + "sebastian/environment": "~1.2", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.1|~3.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.7.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2015-06-18 13:33:26" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/92408bb1968a81b3217a6fdf6c1a198da83caa35", + "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "~1.0,>=1.0.2", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2015-06-11 15:55:48" + }, + { + "name": "sebastian/comparator", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2015-01-29 16:28:08" + }, + { + "name": "sebastian/diff", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-02-22 15:13:53" + }, + { + "name": "sebastian/environment", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2015-01-01 10:01:08" + }, + { + "name": "sebastian/exporter", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "84839970d05254c73cde183a721c7af13aede943" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", + "reference": "84839970d05254c73cde183a721c7af13aede943", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2015-01-27 07:23:06" + }, + { + "name": "sebastian/global-state", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2014-10-06 09:23:50" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-01-24 09:48:32" + }, + { + "name": "sebastian/version", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", + "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2015-02-24 06:35:25" + }, + { + "name": "symfony/yaml", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/9808e75c609a14f6db02f70fccf4ca4aab53c160", + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2015-06-10 15:30:22" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.3.0" + }, + "platform-dev": [] +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/phpunit.xml.dist b/curweather/vendor/cmfcmf/openweathermap-php-api/phpunit.xml.dist new file mode 100644 index 00000000..cceb148d --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/phpunit.xml.dist @@ -0,0 +1,22 @@ + + + + + + + + ./tests + + + + + + ./ + + ./ + ./ + ./vendor + + + + diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/CurlFetcherTest.php b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/CurlFetcherTest.php new file mode 100644 index 00000000..7f2cfe9a --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/CurlFetcherTest.php @@ -0,0 +1,53 @@ +fetch('http://notexisting.example.com'); + + $this->assertSame(false, $content); + } + + public function testEmptyUrl() + { + $fetcher = new CurlFetcher(); + + $content = $fetcher->fetch(''); + + $this->assertSame(false, $content); + } + + public function testValidUrl() + { + $fetcher = new CurlFetcher(); + + $content = $fetcher->fetch('http://httpbin.org/html'); + + $this->assertContains('Herman Melville', $content); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/FileGetContentsFetcherTest.php b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/FileGetContentsFetcherTest.php new file mode 100644 index 00000000..f556c09f --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/FileGetContentsFetcherTest.php @@ -0,0 +1,59 @@ +markTestSkipped('"allow_url_fopen" is set to off.'); + } + } + + /** + * @expectedException \PHPUnit_Framework_Error_Warning + */ + public function testInvalidUrl() + { + $fetcher = new FileGetContentsFetcher(); + + $fetcher->fetch('http://notexisting.example.com'); + } + + /** + * @expectedException \PHPUnit_Framework_Error_Warning + */ + public function testEmptyUrl() + { + $fetcher = new FileGetContentsFetcher(); + + $fetcher->fetch(''); + } + + public function testValidUrl() + { + $fetcher = new FileGetContentsFetcher(); + + $content = $fetcher->fetch('http://httpbin.org/html'); + + $this->assertContains('Herman Melville', $content); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/SunTest.php b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/SunTest.php new file mode 100644 index 00000000..516a796d --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/SunTest.php @@ -0,0 +1,62 @@ +givenThereIsASunObject($rise, $set); + + $this->assertSame($rise, $this->sun->rise); + } + + public function testSunSet() + { + $rise = new \DateTime('2014-01-01 08:00:00'); + $set = new \DateTime('2014-01-01 20:00:00'); + + $this->givenThereIsASunObject($rise, $set); + + $this->assertSame($set, $this->sun->set); + } + + + private function givenThereIsASunObject($rise, $set) + { + $this->sun = new Sun($rise, $set); + } + + /** + * @expectedException \LogicException + */ + public function testSunSetBeforeSunRiseException() + { + $rise = new \DateTime('2014-01-01 08:00:00'); + $set = new \DateTime('2014-01-01 7:00:00'); + + $this->givenThereIsASunObject($rise, $set); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/UnitTest.php b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/UnitTest.php new file mode 100644 index 00000000..bd85e16f --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/UnitTest.php @@ -0,0 +1,159 @@ +givenThereIsAUnitWithValue(self::POSITIVE_INT_VALUE); + + $this->assertSame((float)self::POSITIVE_INT_VALUE, $this->unit->getValue()); + } + + public function testGetValueWithPositiveFloatValue() + { + $this->givenThereIsAUnitWithValue(self::POSITIVE_FLOAT_VALUE); + + $this->assertSame(self::POSITIVE_FLOAT_VALUE, $this->unit->getValue()); + } + + public function testGetValueWithNegativeIntValue() + { + $this->givenThereIsAUnitWithValue(self::NEGATIVE_INT_VALUE); + + $this->assertSame((float)self::NEGATIVE_INT_VALUE, $this->unit->getValue()); + } + + public function testGetValueWithNegativeFloatValue() + { + $this->givenThereIsAUnitWithValue(self::NEGATIVE_FLOAT_VALUE); + + $this->assertSame(self::NEGATIVE_FLOAT_VALUE, $this->unit->getValue()); + } + + public function testGetValueWithZeroIntValue() + { + $this->givenThereIsAUnitWithValue(self::ZERO_INT_VALUE); + + $this->assertSame((float)self::ZERO_INT_VALUE, $this->unit->getValue()); + } + + public function testGetValueWithZeroFloatValue() + { + $this->givenThereIsAUnitWithValue(self::ZERO_FLOAT_VALUE); + + $this->assertSame(self::ZERO_FLOAT_VALUE, $this->unit->getValue()); + } + + private function givenThereIsAUnitWithValue($value, $unit = null) + { + $this->unit = $unit === null ? new Unit($value) : new Unit($value, $unit); + } + + public function testGetUnitWithEmptyUnit() + { + $this->givenThereIsAUnitWithUnit(""); + + $this->assertSame("", $this->unit->getUnit()); + } + + public function testGetUnitWithStringAsUnit() + { + $this->givenThereIsAUnitWithUnit("Hey! I'm cmfcmf"); + + $this->assertSame("Hey! I'm cmfcmf", $this->unit->getUnit()); + } + + public function testCelsiusFixture() + { + $this->givenThereIsAUnitWithUnit("celsius"); + + $this->assertSame("°C", $this->unit->getUnit()); + } + + public function testFahrenheitFixture() + { + $this->givenThereIsAUnitWithUnit("fahrenheit"); + + $this->assertSame("F", $this->unit->getUnit()); + } + + private function givenThereIsAUnitWithUnit($unit) + { + $this->unit = new Unit(0, $unit); + } + + public function testGetDescriptionWithEmptyDescription() + { + $this->givenThereIsAUnitWithDescription(""); + + $this->assertSame("", $this->unit->getDescription()); + } + + public function testGetDescriptionWithStringAsDescription() + { + $this->givenThereIsAUnitWithDescription("Hey! I'm cmfcmf"); + + $this->assertSame("Hey! I'm cmfcmf", $this->unit->getDescription()); + } + + private function givenThereIsAUnitWithDescription($description) + { + $this->unit = new Unit(0, "", $description); + } + + public function testGetFormattedWithoutUnit() + { + $this->givenThereIsAUnitWithValue(self::POSITIVE_INT_VALUE); + + $this->assertEquals(self::POSITIVE_INT_VALUE, $this->unit->getFormatted()); + $this->assertEquals($this->unit->getValue(), $this->unit->getFormatted()); + } + + public function testGetFormattedWithUnit() + { + $this->givenThereIsAUnitWithValue(self::POSITIVE_INT_VALUE, 'K'); + + $this->assertEquals(self::POSITIVE_INT_VALUE . ' K', $this->unit->getFormatted()); + $this->assertEquals($this->unit->getValue() . ' ' . $this->unit->getUnit(), $this->unit->getFormatted()); + } + + public function testToString() + { + $this->givenThereIsAUnitWithValue(self::POSITIVE_INT_VALUE, 'K'); + + $this->assertEquals($this->unit->getFormatted(), $this->unit); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/tests/bootstrap.php b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/bootstrap.php new file mode 100644 index 00000000..a844cc5a --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/bootstrap.php @@ -0,0 +1,12 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0 class loader + * + * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + + private $classMapAuthoritative = false; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-0 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 + if ('\\' == $class[0]) { + $class = substr($class, 1); + } + + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative) { + return false; + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if ($file === null && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if ($file === null) { + // Remember that this class does not exist. + return $this->classMap[$class] = false; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + if (is_file($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/curweather/vendor/composer/autoload_classmap.php b/curweather/vendor/composer/autoload_classmap.php new file mode 100644 index 00000000..7a91153b --- /dev/null +++ b/curweather/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + array($vendorDir . '/cmfcmf/openweathermap-php-api'), +); diff --git a/curweather/vendor/composer/autoload_psr4.php b/curweather/vendor/composer/autoload_psr4.php new file mode 100644 index 00000000..b265c64a --- /dev/null +++ b/curweather/vendor/composer/autoload_psr4.php @@ -0,0 +1,9 @@ + $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + + $loader->register(true); + + return $loader; + } +} + +function composerRequire6bf0e42f34a65c53928f3dc22e5b93d3($file) +{ + require $file; +} diff --git a/curweather/vendor/composer/installed.json b/curweather/vendor/composer/installed.json new file mode 100644 index 00000000..cdba81cc --- /dev/null +++ b/curweather/vendor/composer/installed.json @@ -0,0 +1,51 @@ +[ + { + "name": "cmfcmf/openweathermap-php-api", + "version": "v2.0.7", + "version_normalized": "2.0.7.0", + "source": { + "type": "git", + "url": "https://github.com/cmfcmf/OpenWeatherMap-PHP-Api.git", + "reference": "ab387ebcad332b1e58be443f760e1235e7976443" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cmfcmf/OpenWeatherMap-PHP-Api/zipball/ab387ebcad332b1e58be443f760e1235e7976443", + "reference": "ab387ebcad332b1e58be443f760e1235e7976443", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.7.0" + }, + "time": "2015-06-23 21:07:37", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Cmfcmf\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Flach (cmfcmf)", + "email": "cmfcmf.flach@gmail.com", + "homepage": "http://cmfcmf.github.io", + "role": "Developer" + } + ], + "description": "A php api to parse weather data from OpenWeatherMap.org. This api tries to normalise and abstract the data and remove inconsistencies.", + "homepage": "https://github.com/cmfcmf/OpenWeatherMap-PHP-Api", + "keywords": [ + "OpenWeatherMap", + "weather", + "weather api" + ] + } +] -- 2.43.4 From 4d6cfe14d0c93c93567ca7e73f7740a5a77a4c24 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sat, 11 Jul 2015 20:54:40 +0200 Subject: [PATCH 17/44] curweather update message.po --- curweather/lang/C/messages.po | 76 ++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 11 deletions(-) diff --git a/curweather/lang/C/messages.po b/curweather/lang/C/messages.po index b462719c..cea93891 100644 --- a/curweather/lang/C/messages.po +++ b/curweather/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-02-27 05:01-0500\n" +"POT-Creation-Date: 2015-07-11 20:54+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,26 +17,80 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: curweather.php:46 +#: curweather.php:75 msgid "Current Weather" msgstr "" -#: curweather.php:67 +#: curweather.php:78 +msgid "Relative Humidity" +msgstr "" + +#: curweather.php:79 +msgid "Pressure" +msgstr "" + +#: curweather.php:80 +msgid "Wind" +msgstr "" + +#: curweather.php:81 +msgid "Data by" +msgstr "" + +#: curweather.php:81 +msgid "Show on map" +msgstr "" + +#: curweather.php:97 msgid "Current Weather settings updated." msgstr "" -#: curweather.php:90 -msgid "Current Weather Settings" +#: curweather.php:112 curweather.php:124 +msgid "No APPID found, please contact your admin to optain one." msgstr "" -#: curweather.php:93 -msgid "Weather Location: " +#: curweather.php:122 curweather.php:147 +msgid "Save Settings" msgstr "" -#: curweather.php:96 -msgid "Enable Current Weather" +#: curweather.php:123 +msgid "curweather Settings" msgstr "" -#: curweather.php:104 -msgid "Submit" +#: curweather.php:125 +msgid "Enter either the name of your location or the zip code." +msgstr "" + +#: curweather.php:126 +msgid "Your Location" +msgstr "" + +#: curweather.php:126 +msgid "" +"Identifier of your location (name or zip code), e.g. Berlin,DE or " +"14476,DE." +msgstr "" + +#: curweather.php:127 +msgid "Units" +msgstr "" + +#: curweather.php:127 +msgid "select if the temperatur should be displayed in °C or °F" +msgstr "" + +#: curweather.php:128 +msgid "Show weather data" +msgstr "" + +#: curweather.php:140 +msgid "Curweather settings saved." +msgstr "" + +#: curweather.php:148 +msgid "Your APPID" +msgstr "" + +#: curweather.php:148 +msgid "Your API key provided by OpenWeatherMap" msgstr "" -- 2.43.4 From c1f26a22c361cd20a2b8b2367c9b5005457433e7 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sat, 11 Jul 2015 20:59:00 +0200 Subject: [PATCH 18/44] typo --- curweather/curweather.php | 130 +++++++++++++++++++++++++------------- 1 file changed, 87 insertions(+), 43 deletions(-) diff --git a/curweather/curweather.php b/curweather/curweather.php index 67d5939e..9ad74b48 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -1,13 +1,18 @@ - Find the location code for the station or airport nearest you here. - * Version: 1.0 + * Description: Shows current weather conditions for user's location on their network page. + * Version: 1.1 * Author: Tony Baldwin * Author: Fabio Comuni + * Author: Tobias Diekershoff * */ -require_once('addon/curweather/getweather.php'); +use Cmfcmf\OpenWeatherMap; +use Cmfcmf\OpenWeatherMap\Exception as OWMException; + +// Must point to composer's autoload file. +require('vendor/autoload.php'); function curweather_install() { register_hook('network_mod_init', 'addon/curweather/curweather.php', 'curweather_network_mod_init'); @@ -35,21 +40,45 @@ function curweather_network_mod_init(&$fk_app,&$b) { // the $rpt value is needed for location // which getweather uses to fetch the weather data for weather and temp $rpt = get_pconfig(local_user(), 'curweather', 'curweather_loc'); - $wxdata = GetWeather::get($rpt); - $temp = $wxdata['TEMPERATURE_STRING']; - $weather = $wxdata['WEATHER']; - $rhumid = $wxdata['RELATIVE_HUMIDITY']; - $pressure = $wxdata['PRESSURE_STRING']; - $wind = $wxdata['WIND_STRING']; - $curweather = '
-
-

'.t("Current Weather").'

'; - $curweather .= "Weather: $weather
- Temperature: $temp
- Relative Humidity: $rhumid
- Pressure: $pressure
- Wind: $wind"; + + // set the language to the browsers language and use metric units + $lang = $_SESSION['language']; + $units = get_pconfig( local_user(), 'curweather', 'curweather_units'); + $appid = get_config('curweather','appid'); + if ($units==="") + $units = 'metric'; + // Get OpenWeatherMap object. Don't use caching (take a look into + // Example_Cache.php to see how it works). + $owm = new OpenWeatherMap(); + + try { + $weather = $owm->getWeather($rpt, $units, $lang, $appid); + $temp = $weather->temperature->getValue(); + if ( $units === 'metric') { + $temp .= '°C'; + } else { + $temp .= '°F'; + }; + $rhumid = $weather->humidity; + $pressure = $weather->pressure; + $wind = $weather->wind->speed . " " . $weather->wind->direction; + $description = $weather->clouds->getDescription(); + } catch(OWMException $e) { + alert ( 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'); + } catch(\Exception $e) { + alert ('General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'); + } + + $curweather = '
+
+

'.t("Current Weather").': '.$weather->city->name.'

'; + + $curweather .= "$description; $temp
"; + $curweather .= t('Relative Humidity').": $rhumid
"; + $curweather .= t('Pressure').": $pressure
"; + $curweather .= t('Wind').": $wind
"; + $curweather .= ''. t('Data by').': OpenWeatherMap. '.t('Show on map').''; $curweather .= '
'; @@ -63,6 +92,7 @@ function curweather_plugin_settings_post($a,$post) { return; set_pconfig(local_user(),'curweather','curweather_loc',trim($_POST['curweather_loc'])); set_pconfig(local_user(),'curweather','curweather_enable',intval($_POST['curweather_enable'])); + set_pconfig(local_user(),'curweather','curweather_units',trim($_POST['curweather_units'])); info( t('Current Weather settings updated.') . EOL); } @@ -73,36 +103,50 @@ function curweather_plugin_settings(&$a,&$s) { if(! local_user()) return; - /* Add our stylesheet to the curweather so we can make our settings look nice */ - - $a->page['htmlhead'] .= '' . "\r\n"; - /* Get the current state of our config variable */ $curweather_loc = get_pconfig(local_user(), 'curweather', 'curweather_loc'); + $curweather_units = get_pconfig(local_user(), 'curweather', 'curweather_units'); + $appid = get_config('curweather','appid'); + if (x($appid)) { + $noappidtext = t('No APPID found, please contact your admin to optain one.'); + } else { + $noappidtext = ''; + } $enable = intval(get_pconfig(local_user(),'curweather','curweather_enable')); $enable_checked = (($enable) ? ' checked="checked" ' : ''); - - /* Add some HTML to the existing form */ - - $s .= '
'; - $s .= '

' . t('Current Weather') . '

'; - $s .= '
'; - $s .= '

Find the location code for the airport/weather station nearest you here.

'; - $s .= ''; - $s .= ''; - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - $s .= '
'; - - /* provide a submit button */ - - $s .= '
'; + // load template and replace the macros + $t = get_markup_template("settings.tpl", "addon/curweather/" ); + $s = replace_macros ($t, array( + '$submit' => t('Save Settings'), + '$header' => t('curweather Settings'), + '$noappidtext' => t('No APPID found, please contact your admin to optain one.'), + '$info' => t('Enter either the name of your location or the zip code.'), + '$curweather_loc' => array( 'curweather_loc', t('Your Location'), $curweather_loc, t('Identifier of your location (name or zip code), e.g. Berlin,DE or 14476,DE.') ), + '$curweather_units' => array( 'curweather_units', t('Units'), $curweather_units, t('select if the temperatur should be displayed in °C or °F'), array('metric'=>'°C', 'imperial'=>'°F')), + '$enabled' => array( 'curweather_enable', t('Show weather data'), $enable, '') + )); + return; } - - +// Config stuff for the admin panel to let the admin of the node set a APPID +// for accessing the API of openweathermap +function curweather_plugin_admin_post (&$a) { + if(! is_site_admin()) + return; + if ($_POST['curweather-submit']) { + set_config('curweather','appid',trim($_POST['appid'])); + info( t('Curweather settings saved.'.EOL)); + } +} +function curweather_plugin_admin (&$a, &$o) { + if(! is_site_admin()) + return; + $appid = get_config('curweather','appid'); + $t = get_markup_template("admin.tpl", "addon/curweather/" ); + $o = replace_macros ($t, array( + '$submit' => t('Save Settings'), + '$appid' => array('appid', t('Your APPID'), $appid, t('Your API key provided by OpenWeatherMap')) + )); +} -- 2.43.4 From 1c720a682444bc26cf5c15a37223878afc40f6bf Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 12 Jul 2015 08:18:24 +0200 Subject: [PATCH 19/44] cache OWM data --- curweather/curweather.php | 63 +++++++++++++++++++++++++++++++--- curweather/templates/admin.tpl | 1 + 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/curweather/curweather.php b/curweather/curweather.php index 9ad74b48..33b1df67 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -9,6 +9,7 @@ * */ use Cmfcmf\OpenWeatherMap; +use Cmfcmf\OpenWeatherMap\AbstractCache; use Cmfcmf\OpenWeatherMap\Exception as OWMException; // Must point to composer's autoload file. @@ -28,6 +29,51 @@ function curweather_uninstall() { } +// The caching mechanism is taken from the cache example of the +// OpenWeatherMap-PHP-API library and a bit customized to allow admins to set +// the caching time depending on the plans they got from openweathermap.org + +class ExampleCache extends AbstractCache +{ + private function urlToPath($url) + { + $tmp = sys_get_temp_dir(); + $dir = $tmp . DIRECTORY_SEPARATOR . "OpenWeatherMapPHPAPI"; + if (!is_dir($dir)) { + mkdir($dir); + } + + $path = $dir . DIRECTORY_SEPARATOR . md5($url); + return $path; + } + + /** + * @inheritdoc + */ + public function isCached($url) + { + $path = $this->urlToPath($url); + if (!file_exists($path) || filectime($path) + $this->seconds < time()) { + return false; + } + return true; + } + /** + * @inheritdoc + */ + public function getCached($url) + { + return file_get_contents($this->urlToPath($url)); + } + /** + * @inheritdoc + */ + public function setCached($url, $content) + { + file_put_contents($this->urlToPath($url), $content); + } +} + function curweather_network_mod_init(&$fk_app,&$b) { @@ -36,9 +82,14 @@ function curweather_network_mod_init(&$fk_app,&$b) { $fk_app->page['htmlhead'] .= '' . "\r\n"; - // the getweather file does all the work here + // the OpenWeatherMap-PHP-APIlib does all the work here // the $rpt value is needed for location - // which getweather uses to fetch the weather data for weather and temp + // $lang will be taken from the browser session to honour user settings + // $units can be set in the settings by the user + // $appid is configured by the admin in the admin panel + // those parameters will be used to get: cloud status, temperature, preassure + // and relative humidity for display, also the relevent area of the map is + // linked from lat/log of the reply of OWMp $rpt = get_pconfig(local_user(), 'curweather', 'curweather_loc'); @@ -46,11 +97,13 @@ function curweather_network_mod_init(&$fk_app,&$b) { $lang = $_SESSION['language']; $units = get_pconfig( local_user(), 'curweather', 'curweather_units'); $appid = get_config('curweather','appid'); + $cachetime = intval(get_config('curweather','cachetime')); if ($units==="") $units = 'metric'; // Get OpenWeatherMap object. Don't use caching (take a look into // Example_Cache.php to see how it works). - $owm = new OpenWeatherMap(); + //$owm = new OpenWeatherMap(); + $owm = new OpenWeatherMap(null, new ExampleCache(), $cachetime); try { $weather = $owm->getWeather($rpt, $units, $lang, $appid); @@ -62,7 +115,7 @@ function curweather_network_mod_init(&$fk_app,&$b) { }; $rhumid = $weather->humidity; $pressure = $weather->pressure; - $wind = $weather->wind->speed . " " . $weather->wind->direction; + $wind = $weather->wind->speed->getDescription().', '.$weather->wind->speed . " " . $weather->wind->direction; $description = $weather->clouds->getDescription(); } catch(OWMException $e) { alert ( 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'); @@ -137,6 +190,7 @@ function curweather_plugin_admin_post (&$a) { return; if ($_POST['curweather-submit']) { set_config('curweather','appid',trim($_POST['appid'])); + set_config('curweather','cachetime',trim($_POST['cachetime'])); info( t('Curweather settings saved.'.EOL)); } } @@ -147,6 +201,7 @@ function curweather_plugin_admin (&$a, &$o) { $t = get_markup_template("admin.tpl", "addon/curweather/" ); $o = replace_macros ($t, array( '$submit' => t('Save Settings'), + '$cachetime' => array('cachetime', t('Caching Interval'), $cachetime, t('For how long should the weather data be cached? Choose according your OpenWeatherMap account type.'), array('0'=>t('no cache'), '300'=>'5 '.t('minutes'), '900'=>'15 '.t('minutes'), '1800'=>'30 '.t('minutes'), '3600'=>'60 '.t('minutes'))), '$appid' => array('appid', t('Your APPID'), $appid, t('Your API key provided by OpenWeatherMap')) )); } diff --git a/curweather/templates/admin.tpl b/curweather/templates/admin.tpl index 5f0c11bf..0d43ae57 100644 --- a/curweather/templates/admin.tpl +++ b/curweather/templates/admin.tpl @@ -1,2 +1,3 @@ {{include file="field_input.tpl" field=$appid}} +{{include file="field_select.tpl" field=$cachetime}}
-- 2.43.4 From cf06804bc82cbf78198bfa0bfa1304391248417c Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 12 Jul 2015 08:33:49 +0200 Subject: [PATCH 20/44] include the last time updates as title of the header of the widget --- curweather/curweather.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curweather/curweather.php b/curweather/curweather.php index 33b1df67..48457fe0 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -125,7 +125,7 @@ function curweather_network_mod_init(&$fk_app,&$b) { $curweather = '
-

'.t("Current Weather").': '.$weather->city->name.'

'; +

'.t("Current Weather").': '.$weather->city->name.'

'; $curweather .= "$description; $temp
"; $curweather .= t('Relative Humidity').": $rhumid
"; -- 2.43.4 From 7b1c6557f327383d3a57b9811abdbf9f45d71c58 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 12 Jul 2015 08:52:29 +0200 Subject: [PATCH 21/44] show selected cachetime in admin panel --- curweather/curweather.php | 1 + 1 file changed, 1 insertion(+) diff --git a/curweather/curweather.php b/curweather/curweather.php index 48457fe0..557a10aa 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -198,6 +198,7 @@ function curweather_plugin_admin (&$a, &$o) { if(! is_site_admin()) return; $appid = get_config('curweather','appid'); + $cachetime = get_config('curweather','cachetime'); $t = get_markup_template("admin.tpl", "addon/curweather/" ); $o = replace_macros ($t, array( '$submit' => t('Save Settings'), -- 2.43.4 From 040a6be3658e4fe86403697e2396d0a1f82129ce Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 12 Jul 2015 08:57:22 +0200 Subject: [PATCH 22/44] updating the message.po for the caching times --- curweather/lang/C/messages.po | 58 +++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/curweather/lang/C/messages.po b/curweather/lang/C/messages.po index cea93891..0a34eb2b 100644 --- a/curweather/lang/C/messages.po +++ b/curweather/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-11 20:54+0200\n" +"POT-Creation-Date: 2015-07-12 08:56+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,80 +17,98 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: curweather.php:75 +#: curweather.php:128 msgid "Current Weather" msgstr "" -#: curweather.php:78 +#: curweather.php:131 msgid "Relative Humidity" msgstr "" -#: curweather.php:79 +#: curweather.php:132 msgid "Pressure" msgstr "" -#: curweather.php:80 +#: curweather.php:133 msgid "Wind" msgstr "" -#: curweather.php:81 +#: curweather.php:134 msgid "Data by" msgstr "" -#: curweather.php:81 +#: curweather.php:134 msgid "Show on map" msgstr "" -#: curweather.php:97 +#: curweather.php:150 msgid "Current Weather settings updated." msgstr "" -#: curweather.php:112 curweather.php:124 +#: curweather.php:165 curweather.php:177 msgid "No APPID found, please contact your admin to optain one." msgstr "" -#: curweather.php:122 curweather.php:147 +#: curweather.php:175 curweather.php:204 msgid "Save Settings" msgstr "" -#: curweather.php:123 +#: curweather.php:176 msgid "curweather Settings" msgstr "" -#: curweather.php:125 +#: curweather.php:178 msgid "Enter either the name of your location or the zip code." msgstr "" -#: curweather.php:126 +#: curweather.php:179 msgid "Your Location" msgstr "" -#: curweather.php:126 +#: curweather.php:179 msgid "" "Identifier of your location (name or zip code), e.g. Berlin,DE or " "14476,DE." msgstr "" -#: curweather.php:127 +#: curweather.php:180 msgid "Units" msgstr "" -#: curweather.php:127 +#: curweather.php:180 msgid "select if the temperatur should be displayed in °C or °F" msgstr "" -#: curweather.php:128 +#: curweather.php:181 msgid "Show weather data" msgstr "" -#: curweather.php:140 +#: curweather.php:194 msgid "Curweather settings saved." msgstr "" -#: curweather.php:148 +#: curweather.php:205 +msgid "Caching Interval" +msgstr "" + +#: curweather.php:205 +msgid "" +"For how long should the weather data be cached? Choose according your " +"OpenWeatherMap account type." +msgstr "" + +#: curweather.php:205 +msgid "no cache" +msgstr "" + +#: curweather.php:205 +msgid "minutes" +msgstr "" + +#: curweather.php:206 msgid "Your APPID" msgstr "" -#: curweather.php:148 +#: curweather.php:206 msgid "Your API key provided by OpenWeatherMap" msgstr "" -- 2.43.4 From 22cc81cbc5b422d2d4a6d5660c15dcc4574f1484 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 12 Jul 2015 14:30:09 +0200 Subject: [PATCH 23/44] had to remove the time for the last update again --- curweather/curweather.php | 8 ++++---- curweather/lang/C/messages.po | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/curweather/curweather.php b/curweather/curweather.php index 557a10aa..120545fd 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -118,14 +118,14 @@ function curweather_network_mod_init(&$fk_app,&$b) { $wind = $weather->wind->speed->getDescription().', '.$weather->wind->speed . " " . $weather->wind->direction; $description = $weather->clouds->getDescription(); } catch(OWMException $e) { - alert ( 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'); + info ( 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'); } catch(\Exception $e) { - alert ('General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'); + info ('General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'); } $curweather = '
-

'.t("Current Weather").': '.$weather->city->name.'

'; +

'.t("Current Weather").': '.$weather->city->name.'

'; $curweather .= "$description; $temp
"; $curweather .= t('Relative Humidity').": $rhumid
"; @@ -173,7 +173,7 @@ function curweather_plugin_settings(&$a,&$s) { $t = get_markup_template("settings.tpl", "addon/curweather/" ); $s = replace_macros ($t, array( '$submit' => t('Save Settings'), - '$header' => t('curweather Settings'), + '$header' => t('Current Weather').' '.t('Settings'), '$noappidtext' => t('No APPID found, please contact your admin to optain one.'), '$info' => t('Enter either the name of your location or the zip code.'), '$curweather_loc' => array( 'curweather_loc', t('Your Location'), $curweather_loc, t('Identifier of your location (name or zip code), e.g. Berlin,DE or 14476,DE.') ), diff --git a/curweather/lang/C/messages.po b/curweather/lang/C/messages.po index 0a34eb2b..1b57a529 100644 --- a/curweather/lang/C/messages.po +++ b/curweather/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-12 08:56+0200\n" +"POT-Creation-Date: 2015-07-12 14:29+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,7 +17,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: curweather.php:128 +#: curweather.php:128 curweather.php:176 msgid "Current Weather" msgstr "" @@ -54,7 +54,7 @@ msgid "Save Settings" msgstr "" #: curweather.php:176 -msgid "curweather Settings" +msgid "Settings" msgstr "" #: curweather.php:178 -- 2.43.4 From 867f48aebe52423107dc904c8713621290498df4 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 12 Jul 2015 15:09:04 +0200 Subject: [PATCH 24/44] no appid logic not followed --- curweather/curweather.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/curweather/curweather.php b/curweather/curweather.php index 120545fd..056a5aa3 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -161,7 +161,7 @@ function curweather_plugin_settings(&$a,&$s) { $curweather_loc = get_pconfig(local_user(), 'curweather', 'curweather_loc'); $curweather_units = get_pconfig(local_user(), 'curweather', 'curweather_units'); $appid = get_config('curweather','appid'); - if (x($appid)) { + if ($appid=="") { $noappidtext = t('No APPID found, please contact your admin to optain one.'); } else { $noappidtext = ''; @@ -174,7 +174,7 @@ function curweather_plugin_settings(&$a,&$s) { $s = replace_macros ($t, array( '$submit' => t('Save Settings'), '$header' => t('Current Weather').' '.t('Settings'), - '$noappidtext' => t('No APPID found, please contact your admin to optain one.'), + '$noappidtext' => $noappidtext, '$info' => t('Enter either the name of your location or the zip code.'), '$curweather_loc' => array( 'curweather_loc', t('Your Location'), $curweather_loc, t('Identifier of your location (name or zip code), e.g. Berlin,DE or 14476,DE.') ), '$curweather_units' => array( 'curweather_units', t('Units'), $curweather_units, t('select if the temperatur should be displayed in °C or °F'), array('metric'=>'°C', 'imperial'=>'°F')), -- 2.43.4 From 02b29b2a6a5e9c8c10999feec9b270967c4050ba Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 12 Jul 2015 15:39:49 +0200 Subject: [PATCH 25/44] use friendica temppath settings for cache data --- curweather/curweather.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/curweather/curweather.php b/curweather/curweather.php index 056a5aa3..6db89428 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -32,12 +32,13 @@ function curweather_uninstall() { // The caching mechanism is taken from the cache example of the // OpenWeatherMap-PHP-API library and a bit customized to allow admins to set // the caching time depending on the plans they got from openweathermap.org +// and the usage of the friendica temppath class ExampleCache extends AbstractCache { private function urlToPath($url) { - $tmp = sys_get_temp_dir(); + $tmp = get_config('system','temppath'); $dir = $tmp . DIRECTORY_SEPARATOR . "OpenWeatherMapPHPAPI"; if (!is_dir($dir)) { mkdir($dir); -- 2.43.4 From 4cd0e377b0055d6e9535609b73af6fbf567c11fd Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 12 Jul 2015 21:43:08 +0200 Subject: [PATCH 26/44] snautofollow is deprecated since it moved into the core. --- snautofollow/snautofollow.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/snautofollow/snautofollow.php b/snautofollow/snautofollow.php index ca19d650..2d953d5b 100644 --- a/snautofollow/snautofollow.php +++ b/snautofollow/snautofollow.php @@ -4,8 +4,7 @@ * Description: Automatic follow/friend of statusnet people who mention/follow you * Version: 1.0 * Author: Mike Macgirvin - * - * + * Status: Unsupported */ -- 2.43.4 From f453561594d55f54f7837843a98853d1f50d3bb3 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 12 Jul 2015 21:43:59 +0200 Subject: [PATCH 27/44] Statusnet is now GNU Social (but Raider is still Twix) --- statusnet/statusnet.php | 88 ++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index bda26a57..7041c399 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -1,7 +1,7 @@ * Author: Michael Vogel @@ -35,7 +35,7 @@ /*** - * We have to alter the TwitterOAuth class a little bit to work with any StatusNet + * We have to alter the TwitterOAuth class a little bit to work with any GNU Social * installation abroad. Basically it's only make the API path variable and be happy. * * Thank you guys for the Twitter compatible API! @@ -119,7 +119,7 @@ function statusnet_install() { register_hook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets'); register_hook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron'); register_hook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body'); - logger("installed statusnet"); + logger("installed GNU Social"); } @@ -148,20 +148,20 @@ function statusnet_jot_nets(&$a,&$b) { $statusnet_defpost = get_pconfig(local_user(),'statusnet','post_by_default'); $selected = ((intval($statusnet_defpost) == 1) ? ' checked="checked" ' : ''); $b .= '
' - . t('Post to StatusNet') . '
'; + . t('Post to GNU Social') . '
'; } } function statusnet_settings_post ($a,$post) { if(! local_user()) return; - // don't check statusnet settings if statusnet submit button is not clicked + // don't check GNU Social settings if GNU Social submit button is not clicked if (!x($_POST,'statusnet-submit')) return; if (isset($_POST['statusnet-disconnect'])) { /*** - * if the statusnet-disconnect checkbox is set, clear the statusnet configuration + * if the GNU Social-disconnect checkbox is set, clear the GNU Social configuration */ del_pconfig(local_user(), 'statusnet', 'consumerkey'); del_pconfig(local_user(), 'statusnet', 'consumersecret'); @@ -178,7 +178,7 @@ function statusnet_settings_post ($a,$post) { } else { if (isset($_POST['statusnet-preconf-apiurl'])) { /*** - * If the user used one of the preconfigured StatusNet server credentials + * If the user used one of the preconfigured GNU Social server credentials * use them. All the data are available in the global config. * Check the API Url never the less and blame the admin if it's not working ^^ */ @@ -200,7 +200,7 @@ function statusnet_settings_post ($a,$post) { goaway($a->get_baseurl().'/settings/connectors'); } else { if (isset($_POST['statusnet-consumersecret'])) { - // check if we can reach the API of the StatusNet server + // check if we can reach the API of the GNU Social server // we'll check the API Version for that, if we don't get one we'll try to fix the path but will // resign quickly after this one try to fix the path ;-) $apibase = $_POST['statusnet-baseapi']; @@ -222,18 +222,18 @@ function statusnet_settings_post ($a,$post) { set_pconfig(local_user(), 'statusnet', 'baseapi', $apibase ); } else { // still not the correct API base, let's do noting - notice( t('We could not contact the StatusNet API with the Path you entered.').EOL ); + notice( t('We could not contact the GNU Social API with the Path you entered.').EOL ); } } goaway($a->get_baseurl().'/settings/connectors'); } else { if (isset($_POST['statusnet-pin'])) { - // if the user supplied us with a PIN from StatusNet, let the magic of OAuth happen + // if the user supplied us with a PIN from GNU Social, let the magic of OAuth happen $api = get_pconfig(local_user(), 'statusnet', 'baseapi'); $ckey = get_pconfig(local_user(), 'statusnet', 'consumerkey' ); $csecret = get_pconfig(local_user(), 'statusnet', 'consumersecret' ); // the token and secret for which the PIN was generated were hidden in the settings - // form as token and token2, we need a new connection to StatusNet using these token + // form as token and token2, we need a new connection to GNU Social using these token // and secret to request a Access Token with the PIN $connection = new StatusNetOAuth($api, $ckey, $csecret, $_POST['statusnet-token'], $_POST['statusnet-token2']); $token = $connection->getAccessToken( $_POST['statusnet-pin'] ); @@ -256,7 +256,7 @@ function statusnet_settings_post ($a,$post) { if (!intval($_POST['statusnet-mirror'])) del_pconfig(local_user(),'statusnet','lastid'); - info( t('StatusNet settings updated.') . EOL); + info( t('GNU Social settings updated.') . EOL); }}}} } function statusnet_settings(&$a,&$s) { @@ -291,11 +291,11 @@ function statusnet_settings(&$a,&$s) { $css = (($enabled) ? '' : '-disabled'); $s .= ''; - $s .= '

'. t('StatusNet Import/Export/Mirror').'

'; + $s .= '

'. t('GNU Social Import/Export/Mirror').'

'; $s .= '
'; $s .= '