Merge branch '3.6-rc'

This commit is contained in:
Tobias Diekershoff 2018-03-23 08:00:37 +01:00
commit 39dd3dffe0
733 changed files with 10943 additions and 8237 deletions

View file

@ -5,16 +5,23 @@
* Version: 0.1
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
use Friendica\Core\Addon;
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Util\Network;
function geocoordinates_install() {
register_hook('post_local', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
register_hook('post_remote', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
function geocoordinates_install()
{
Addon::registerHook('post_local', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
Addon::registerHook('post_remote', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
}
function geocoordinates_uninstall() {
unregister_hook('post_local', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
unregister_hook('post_remote', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
function geocoordinates_uninstall()
{
Addon::unregisterHook('post_local', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
Addon::unregisterHook('post_remote', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
}
function geocoordinates_resolve_item(&$item) {
@ -43,7 +50,7 @@ function geocoordinates_resolve_item(&$item) {
return;
}
$s = fetch_url("https://api.opencagedata.com/geocode/v1/json?q=".$coords[0].",".$coords[1]."&key=".$key."&language=".$language);
$s = Network::fetchUrl("https://api.opencagedata.com/geocode/v1/json?q=".$coords[0].",".$coords[1]."&key=".$key."&language=".$language);
if (!$s) {
logger("API could not be queried", LOGGER_DEBUG);
@ -74,22 +81,24 @@ function geocoordinates_post_hook($a, &$item) {
geocoordinates_resolve_item($item);
}
function geocoordinates_plugin_admin(&$a,&$o) {
function geocoordinates_addon_admin(&$a, &$o)
{
$t = get_markup_template("admin.tpl", "addon/geocoordinates/");
$o = replace_macros($t, array(
'$submit' => t('Save Settings'),
'$api_key' => array('api_key', t('API Key'), get_config('geocoordinates', 'api_key' ), ''),
'$language' => array('language', t('Language code (IETF format)'), get_config('geocoordinates', 'language' ), ''),
));
$o = replace_macros($t, [
'$submit' => L10n::t('Save Settings'),
'$api_key' => ['api_key', L10n::t('API Key'), Config::get('geocoordinates', 'api_key'), ''],
'$language' => ['language', L10n::t('Language code (IETF format)'), Config::get('geocoordinates', 'language'), ''],
]);
}
function geocoordinates_plugin_admin_post(&$a) {
$api_key = ((x($_POST,'api_key')) ? notags(trim($_POST['api_key'])) : '');
set_config('geocoordinates','api_key',$api_key);
function geocoordinates_addon_admin_post(&$a)
{
$api_key = ((x($_POST, 'api_key')) ? notags(trim($_POST['api_key'])) : '');
Config::set('geocoordinates', 'api_key', $api_key);
$language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : '');
set_config('geocoordinates','language',$language);
info(t('Settings updated.'). EOL);
$language = ((x($_POST, 'language')) ? notags(trim($_POST['language'])) : '');
Config::set('geocoordinates', 'language', $language);
info(L10n::t('Settings updated.'). EOL);
}