Move Cache to src

Cache class moved to Friendica\Core namespace
pull/444/head
Adam Magness 2017-11-09 11:08:32 -05:00
parent aec554f4d9
commit 036754e455
4 changed files with 76 additions and 46 deletions

View File

@ -13,6 +13,7 @@ require_once('include/network.php');
require_once("mod/proxy.php");
require_once('include/text.php');
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\PConfig;

View File

@ -6,20 +6,24 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
use Friendica\Core\Cache;
use Friendica\Core\Config;
function geocoordinates_install() {
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_uninstall() {
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_resolve_item(&$item) {
function geocoordinates_resolve_item(&$item)
{
if((!$item["coord"]) || ($item["location"]))
return;
@ -72,11 +76,13 @@ function geocoordinates_resolve_item(&$item) {
Cache::set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]);
}
function geocoordinates_post_hook($a, &$item) {
function geocoordinates_post_hook($a, &$item)
{
geocoordinates_resolve_item($item);
}
function geocoordinates_plugin_admin(&$a,&$o) {
function geocoordinates_plugin_admin(&$a, &$o)
{
$t = get_markup_template("admin.tpl", "addon/geocoordinates/");
@ -87,7 +93,8 @@ function geocoordinates_plugin_admin(&$a,&$o) {
));
}
function geocoordinates_plugin_admin_post(&$a) {
function geocoordinates_plugin_admin_post(&$a)
{
$api_key = ((x($_POST,'api_key')) ? notags(trim($_POST['api_key'])) : '');
Config::set('geocoordinates','api_key',$api_key);

View File

@ -7,35 +7,40 @@
*
*/
require_once('include/cache.php');
use Friendica\Core\Cache;
function googlemaps_install() {
function googlemaps_install()
{
register_hook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
logger("installed googlemaps");
}
function googlemaps_uninstall() {
function googlemaps_uninstall()
{
unregister_hook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
logger("removed googlemaps");
}
function googlemaps_location($a, &$item) {
function googlemaps_location($a, &$item)
{
if(! (strlen($item['location']) || strlen($item['coord'])))
if(! (strlen($item['location']) || strlen($item['coord']))) {
return;
}
if ($item['coord'] != "")
if ($item['coord'] != ""){
$target = "http://maps.google.com/?q=".urlencode($item['coord']);
else
} else {
$target = "http://maps.google.com/?q=".urlencode($item['location']);
}
if ($item['location'] != "")
if ($item['location'] != "") {
$title = $item['location'];
else
} else {
$title = $item['coord'];
}
$item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
}

View File

@ -9,12 +9,12 @@
*
*/
require_once('include/cache.php');
use Friendica\Core\Cache;
use Friendica\Core\Config;
function openstreetmap_install() {
function openstreetmap_install()
{
register_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
register_hook('generate_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_map');
register_hook('generate_named_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_named_map');
@ -23,7 +23,8 @@ function openstreetmap_install() {
logger("installed openstreetmap");
}
function openstreetmap_uninstall() {
function openstreetmap_uninstall()
{
unregister_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
unregister_hook('generate_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_map');
unregister_hook('generate_named_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_named_map');
@ -32,7 +33,8 @@ function openstreetmap_uninstall() {
logger("removed openstreetmap");
}
function openstreetmap_alterheader($a, &$navHtml) {
function openstreetmap_alterheader($a, &$navHtml)
{
$addScriptTag = '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/openstreetmap/openstreetmap.js"></script>' . "\r\n";
$a->page['htmlhead'] .= $addScriptTag;
}
@ -48,8 +50,9 @@ function openstreetmap_alterheader($a, &$navHtml) {
*/
function openstreetmap_location($a, &$item) {
if(! (strlen($item['location']) || strlen($item['coord'])))
if(! (strlen($item['location']) || strlen($item['coord']))) {
return;
}
/*
* Get the configuration variables from the config.
@ -60,20 +63,24 @@ function openstreetmap_location($a, &$item) {
*/
$tmsserver = Config::get('openstreetmap', 'tmsserver');
if(! $tmsserver)
if(! $tmsserver) {
$tmsserver = 'http://www.openstreetmap.org';
}
$nomserver = Config::get('openstreetmap', 'nomserver');
if(! $nomserver)
if(! $nomserver) {
$nomserver = 'http://nominatim.openstreetmap.org/search.php';
}
$zoom = Config::get('openstreetmap', 'zoom');
if(! $zoom)
if(! $zoom) {
$zoom = 16;
}
$marker = Config::get('openstreetmap', 'marker');
if(! $marker)
if(! $marker) {
$marker = 0;
}
if ($item['coord'] != "") {
$coords = explode(' ', $item['coord']);
@ -87,21 +94,22 @@ function openstreetmap_location($a, &$item) {
}
}
if ($target == "")
if ($target == "") {
$target = $nomserver.'?q='.urlencode($item['location']);
}
if ($item['location'] != "")
if ($item['location'] != "") {
$title = $item['location'];
else
} else {
$title = $item['coord'];
}
$item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
}
function openstreetmap_generate_named_map(&$a,&$b) {
function openstreetmap_generate_named_map(&$a, &$b)
{
$nomserver = Config::get('openstreetmap', 'nomserver');
if(! $nomserver)
$nomserver = 'http://nominatim.openstreetmap.org/search.php';
@ -119,22 +127,26 @@ function openstreetmap_generate_named_map(&$a,&$b) {
}
}
function openstreetmap_generate_map(&$a,&$b) {
function openstreetmap_generate_map(&$a, &$b)
{
$tmsserver = Config::get('openstreetmap', 'tmsserver');
if(! $tmsserver)
if(! $tmsserver) {
$tmsserver = 'http://www.openstreetmap.org';
if(strpos(z_root(),'https:') !== false)
}
if(strpos(z_root(),'https:') !== false) {
$tmsserver = str_replace('http:','https:',$tmsserver);
}
$zoom = Config::get('openstreetmap', 'zoom');
if(! $zoom)
if(! $zoom) {
$zoom = 16;
}
$marker = Config::get('openstreetmap', 'marker');
if(! $marker)
if(! $marker) {
$marker = 0;
}
$lat = $b['lat']; // round($b['lat'], 5);
$lon = $b['lon']; // round($b['lon'], 5);
@ -151,20 +163,25 @@ function openstreetmap_generate_map(&$a,&$b) {
}
function openstreetmap_plugin_admin(&$a, &$o) {
function openstreetmap_plugin_admin(&$a, &$o)
{
$t = get_markup_template("admin.tpl", "addon/openstreetmap/");
$tmsserver = Config::get('openstreetmap', 'tmsserver');
if(! $tmsserver)
if(! $tmsserver) {
$tmsserver = 'http://www.openstreetmap.org';
}
$nomserver = Config::get('openstreetmap', 'nomserver');
if(! $nomserver)
if(! $nomserver) {
$nomserver = 'http://nominatim.openstreetmap.org/search.php';
}
$zoom = Config::get('openstreetmap', 'zoom');
if(! $zoom)
if(! $zoom) {
$zoom = 16;
}
$marker = Config::get('openstreetmap', 'marker');
if(! $marker)
if(! $marker) {
$marker = 0;
}
$o = replace_macros($t, array(
'$submit' => t('Submit'),
@ -174,7 +191,9 @@ function openstreetmap_plugin_admin(&$a, &$o) {
'$marker' => array('marker', t('Include marker on map'), $marker, t('Include a marker on the map.')),
));
}
function openstreetmap_plugin_admin_post(&$a) {
function openstreetmap_plugin_admin_post(&$a)
{
$urltms = ((x($_POST, 'tmsserver')) ? notags(trim($_POST['tmsserver'])) : '');
$urlnom = ((x($_POST, 'nomserver')) ? notags(trim($_POST['nomserver'])) : '');
$zoom = ((x($_POST, 'zoom')) ? intval(trim($_POST['zoom'])) : '16');
@ -185,5 +204,3 @@ function openstreetmap_plugin_admin_post(&$a) {
Config::set('openstreetmap', 'marker', $marker);
info( t('Settings updated.') . EOL);
}