Merge branch '3.6-rc'
This commit is contained in:
commit
39dd3dffe0
733 changed files with 10943 additions and 8237 deletions
|
|
@ -12,36 +12,41 @@
|
|||
* $a->config['geonames']['username'] = 'your_username';
|
||||
* Also visit http://geonames.org/manageaccount and enable access to the free web services
|
||||
*
|
||||
* When plugin is installed, the system calls the plugin
|
||||
* When addon is installed, the system calls the addon
|
||||
* name_install() function, located in 'addon/name/name.php',
|
||||
* where 'name' is the name of the addon.
|
||||
* If the addon is removed from the configuration list, the
|
||||
* system will call the name_uninstall() function.
|
||||
*
|
||||
*/
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
function geonames_install() {
|
||||
|
||||
/**
|
||||
*
|
||||
* Our plugin will attach in three places.
|
||||
* Our addon will attach in three places.
|
||||
* The first is just prior to storing a local post.
|
||||
*
|
||||
*/
|
||||
|
||||
register_hook('post_local', 'addon/geonames/geonames.php', 'geonames_post_hook');
|
||||
Addon::registerHook('post_local', 'addon/geonames/geonames.php', 'geonames_post_hook');
|
||||
|
||||
/**
|
||||
*
|
||||
* Then we'll attach into the plugin settings page, and also the
|
||||
* Then we'll attach into the addon settings page, and also the
|
||||
* settings post hook so that we can create and update
|
||||
* user preferences.
|
||||
*
|
||||
*/
|
||||
|
||||
register_hook('plugin_settings', 'addon/geonames/geonames.php', 'geonames_plugin_admin');
|
||||
register_hook('plugin_settings_post', 'addon/geonames/geonames.php', 'geonames_plugin_admin_post');
|
||||
Addon::registerHook('addon_settings', 'addon/geonames/geonames.php', 'geonames_addon_admin');
|
||||
Addon::registerHook('addon_settings_post', 'addon/geonames/geonames.php', 'geonames_addon_admin_post');
|
||||
|
||||
logger("installed geonames");
|
||||
}
|
||||
|
|
@ -57,9 +62,9 @@ function geonames_uninstall() {
|
|||
*
|
||||
*/
|
||||
|
||||
unregister_hook('post_local', 'addon/geonames/geonames.php', 'geonames_post_hook');
|
||||
unregister_hook('plugin_settings', 'addon/geonames/geonames.php', 'geonames_plugin_admin');
|
||||
unregister_hook('plugin_settings_post', 'addon/geonames/geonames.php', 'geonames_plugin_admin_post');
|
||||
Addon::unregisterHook('post_local', 'addon/geonames/geonames.php', 'geonames_post_hook');
|
||||
Addon::unregisterHook('addon_settings', 'addon/geonames/geonames.php', 'geonames_addon_admin');
|
||||
Addon::unregisterHook('addon_settings_post', 'addon/geonames/geonames.php', 'geonames_addon_admin_post');
|
||||
|
||||
|
||||
logger("removed geonames");
|
||||
|
|
@ -74,7 +79,7 @@ function geonames_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
|
||||
* - The profile owner must have allowed our addon
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -108,12 +113,12 @@ function geonames_post_hook($a, &$item) {
|
|||
*
|
||||
*/
|
||||
|
||||
$s = fetch_url('http://api.geonames.org/findNearbyPlaceName?lat=' . $coords[0] . '&lng=' . $coords[1] . '&username=' . $geo_account);
|
||||
$s = Network::fetchUrl('http://api.geonames.org/findNearbyPlaceName?lat=' . $coords[0] . '&lng=' . $coords[1] . '&username=' . $geo_account);
|
||||
|
||||
if(! $s)
|
||||
return;
|
||||
|
||||
$xml = parse_xml_string($s);
|
||||
$xml = XML::parseString($s);
|
||||
|
||||
if($xml->geoname->name && $xml->geoname->countryName)
|
||||
$item['location'] = $xml->geoname->name . ', ' . $xml->geoname->countryName;
|
||||
|
|
@ -135,25 +140,25 @@ function geonames_post_hook($a, &$item) {
|
|||
*
|
||||
*/
|
||||
|
||||
function geonames_plugin_admin_post($a,$post) {
|
||||
function geonames_addon_admin_post($a,$post) {
|
||||
if(! local_user() || (! x($_POST,'geonames-submit')))
|
||||
return;
|
||||
set_pconfig(local_user(),'geonames','enable',intval($_POST['geonames']));
|
||||
|
||||
info( t('Geonames settings updated.') . EOL);
|
||||
info(L10n::t('Geonames settings updated.') . EOL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Called from the Plugin Setting form.
|
||||
* Called from the Addon Setting form.
|
||||
* Add our own settings info to the page.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function geonames_plugin_admin(&$a,&$s) {
|
||||
function geonames_addon_admin(&$a,&$s) {
|
||||
|
||||
if(! local_user())
|
||||
return;
|
||||
|
|
@ -176,14 +181,14 @@ function geonames_plugin_admin(&$a,&$s) {
|
|||
/* Add some HTML to the existing form */
|
||||
|
||||
$s .= '<div class="settings-block">';
|
||||
$s .= '<h3>' . t('Geonames Settings') . '</h3>';
|
||||
$s .= '<h3>' . L10n::t('Geonames Settings') . '</h3>';
|
||||
$s .= '<div id="geonames-enable-wrapper">';
|
||||
$s .= '<label id="geonames-enable-label" for="geonames-checkbox">' . t('Enable Geonames Plugin') . '</label>';
|
||||
$s .= '<label id="geonames-enable-label" for="geonames-checkbox">' . L10n::t('Enable Geonames Addon') . '</label>';
|
||||
$s .= '<input id="geonames-checkbox" type="checkbox" name="geonames" value="1" ' . $checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
/* provide a submit button */
|
||||
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="geonames-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="geonames-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue