Merge pull request #273 from swathe/master

Krynn Plugin addition
This commit is contained in:
Tobias Diekershoff 2015-07-07 12:52:37 +02:00
commit bb08318aea
22 changed files with 439 additions and 0 deletions

14
krynn/krynn.css Executable file
View file

@ -0,0 +1,14 @@
#krynn-enable-label {
float: left;
width: 200px;
margin-bottom: 25px;
}
#krynn-checkbox {
float: left;
}

173
krynn/krynn.php Executable file
View file

@ -0,0 +1,173 @@
<?php
/**
* Name: Dragonlance Krynn locales
* Description: Set a random locale from the Dragonlance Realm of Krynn when posting. Based on the planets frindica addon by Mike Macgirvin and Tony Baldwin
* Version: 1.0
* Planets Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
* Planets Author: Tony Baldwin <https://free-haven.org/profile/tony>
* Author: Dylan Thiedeke <https://theronin.net/profile/swathe>
*
*"My body was my sacrifice... for my magic. This damage is permanent." - Raistlin 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','Saifhum','Karthay','Mithas','Kothas','Silver Dragon Mountain','Silvanesti');
$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'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/krynn/krynn.css' . '" media="all" />' . "\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 .= '<span id="settings_krynn_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_krynn_expanded\'); openClose(\'settings_krynn_inflated\');">';
$s .= '<h3>' . t('Krynn') . '</h3>';
$s .= '</span>';
$s .= '<div id="settings_krynn_expanded" class="settings-block" style="display: none;">';
$s .= '<span class="fakelink" onclick="openClose(\'settings_krynn_expanded\'); openClose(\'settings_krynn_inflated\');">';
$s .= '<h3>' . t('Krynn') . '</h3>';
$s .= '</span>';
$s .= '<div class="settings-block">';
$s .= '<h3>' . t('Krynn Settings') . '</h3>';
$s .= '<div id="krynn-enable-wrapper">';
$s .= '<label id="krynn-enable-label" for="krynn-checkbox">' . t('Enable Krynn Plugin') . '</label>';
$s .= '<input id="krynn-checkbox" type="checkbox" name="krynn" value="1" ' . $checked . '/>';
$s .= '</div><div class="clear"></div></div>';
/* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="krynn-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
}

30
krynn/lang/C/messages.po Normal file
View file

@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 ""

View file

@ -0,0 +1,5 @@
<?php
$a->strings["Krynn Settings"] = "Ajustos de Krynn";
$a->strings["Enable Krynn Plugin"] = "Activa Plugin de Krynn";
$a->strings["Submit"] = "Enviar";

32
krynn/lang/cs/messages.po Normal file
View file

@ -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 <msupler@gmail.com>, 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 <msupler@gmail.com>\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"

10
krynn/lang/cs/strings.php Normal file
View file

@ -0,0 +1,10 @@
<?php
if(! function_exists("string_plural_select_cs")) {
function string_plural_select_cs($n){
return ($n==1) ? 0 : ($n>=2 && $n<=4) ? 1 : 2;;
}}
;
$a->strings["Krynn Settings"] = "Krynn Nastavení";
$a->strings["Enable Krynn Plugin"] = "Povolit Krynn plugin";
$a->strings["Submit"] = "Odeslat";

33
krynn/lang/de/messages.po Normal file
View file

@ -0,0 +1,33 @@
# ADDON Krynn
# Copyright (C)
# This file is distributed under the same license as the Friendica Krynn addon package.
#
#
# Translators:
# Abrax <webmaster@a-zwenkau.de>, 2014
# bavatar <tobias.diekershoff@gmx.net>, 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 <webmaster@a-zwenkau.de>\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"

10
krynn/lang/de/strings.php Normal file
View file

@ -0,0 +1,10 @@
<?php
if(! function_exists("string_plural_select_de")) {
function string_plural_select_de($n){
return ($n != 1);;
}}
;
$a->strings["Krynn Settings"] = "Krynn Einstellungen";
$a->strings["Enable Krynn Plugin"] = "Krynn-Plugin aktivieren";
$a->strings["Submit"] = "Senden";

View file

@ -0,0 +1,5 @@
<?php
$a->strings["Krynn Settings"] = "Agordo pri Krynn";
$a->strings["Enable Krynn Plugin"] = "Ŝalti la Krynn kromprogamon";
$a->strings["Submit"] = "Sendi";

View file

@ -0,0 +1,5 @@
<?php
$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";

View file

@ -0,0 +1,5 @@
<?php
$a->strings["Krynn Settings"] = "Réglages des Krynn";
$a->strings["Enable Krynn Plugin"] = "Activer Krynn";
$a->strings["Submit"] = "Envoyer";

View file

@ -0,0 +1,5 @@
<?php
$a->strings["Krynn Settings"] = "";
$a->strings["Enable Krynn Plugin"] = "";
$a->strings["Submit"] = "Senda inn";

32
krynn/lang/it/messages.po Normal file
View file

@ -0,0 +1,32 @@
# ADDON krynn
# Copyright (C)
# This file is distributed under the same license as the Friendica krynn addon package.
#
#
# Translators:
# fabrixxm <fabrix.xm@gmail.com>, 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 <fabrix.xm@gmail.com>\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"
#: krynn.php:150
msgid "Krynn Settings"
msgstr "Impostazioni \"Pianeti\""
#: krynn.php:152
msgid "Enable Krynn Plugin"
msgstr "Abilita il plugin \"Pianeti\""
#: krynn.php:158
msgid "Submit"
msgstr ""

10
krynn/lang/it/strings.php Normal file
View file

@ -0,0 +1,10 @@
<?php
if(! function_exists("string_plural_select_it")) {
function string_plural_select_it($n){
return ($n != 1);;
}}
;
$a->strings["Krynn Settings"] = "Impostazioni \"Kryn";
$a->strings["Enable Krynn Plugin"] = "Abilita il plugin \"Krynn\"";
$a->strings["Submit"] = "";

View file

@ -0,0 +1,5 @@
<?php
$a->strings["Krynn Settings"] = "";
$a->strings["Enable Krynn Plugin"] = "";
$a->strings["Submit"] = "Lagre";

View file

@ -0,0 +1,5 @@
<?php
$a->strings["Krynn Settings"] = "";
$a->strings["Enable Krynn Plugin"] = "";
$a->strings["Submit"] = "Potwierdź";

View file

@ -0,0 +1,5 @@
<?php
$a->strings["Krynn Settings"] = "Configuração dos Krynn";
$a->strings["Enable Krynn Plugin"] = "Habilita configuração dos Krynn";
$a->strings["Submit"] = "Enviar";

32
krynn/lang/ro/messages.po Normal file
View file

@ -0,0 +1,32 @@
# ADDON krynn
# Copyright (C)
# This file is distributed under the same license as the Friendica krynn addon package.
#
#
# Translators:
# Doru DEACONU <dumitrudeaconu@yahoo.com>, 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 <dumitrudeaconu@yahoo.com>\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"
#: krynn.php:150
msgid "Krynn Settings"
msgstr "Configurări Krynn"
#: krynn.php:152
msgid "Enable Krynn Plugin"
msgstr "Activare Modul Krynn"
#: krynn.php:158
msgid "Submit"
msgstr "Trimite"

10
krynn/lang/ro/strings.php Normal file
View file

@ -0,0 +1,10 @@
<?php
if(! function_exists("string_plural_select_ro")) {
function string_plural_select_ro($n){
return ($n==1?0:((($n%100>19)||(($n%100==0)&&($n!=0)))?2:1));;
}}
;
$a->strings["Krynn Settings"] = "Configurări Krynn";
$a->strings["Enable Krynn Plugin"] = "Activare Modul Krynn";
$a->strings["Submit"] = "Trimite";

View file

@ -0,0 +1,5 @@
<?php
$a->strings["Krynn Settings"] = "";
$a->strings["Enable Krynn Plugin"] = "";
$a->strings["Submit"] = "Подтвердить";

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Submit"] = "Spara";

View file

@ -0,0 +1,5 @@
<?php
$a->strings["Krynn Settings"] = "行星设置";
$a->strings["Enable Krynn Plugin"] = "使行星插件可用";
$a->strings["Submit"] = "提交";