define('FROMGPLUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes
+use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
+use Friendica\Object\Image;
-require_once('mod/share.php');
-require_once('mod/parse_url.php');
-require_once('include/text.php');
+require_once 'mod/share.php';
+require_once 'mod/parse_url.php';
+require_once 'include/text.php';
function fromgplus_install() {
- register_hook('connector_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings');
- register_hook('connector_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post');
- register_hook('cron', 'addon/fromgplus/fromgplus.php', 'fromgplus_cron');
+ Addon::registerHook('connector_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings');
+ Addon::registerHook('connector_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post');
+ Addon::registerHook('cron', 'addon/fromgplus/fromgplus.php', 'fromgplus_cron');
}
function fromgplus_uninstall() {
- unregister_hook('connector_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings');
- unregister_hook('connector_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post');
- unregister_hook('cron', 'addon/fromgplus/fromgplus.php', 'fromgplus_cron');
+ Addon::unregisterHook('connector_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings');
+ Addon::unregisterHook('connector_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post');
+ Addon::unregisterHook('cron', 'addon/fromgplus/fromgplus.php', 'fromgplus_cron');
// Old hooks
- unregister_hook('plugin_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings');
- unregister_hook('plugin_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post');
+ Addon::unregisterHook('plugin_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings');
+ Addon::unregisterHook('plugin_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post');
}
function fromgplus_addon_settings(&$a,&$s) {
PConfig::set(local_user(),'fromgplus', 'keywords', $keywords);
if (!$enable)
- del_pconfig(local_user(),'fromgplus','lastdate');
+ PConfig::delete(local_user(),'fromgplus','lastdate');
info( t('Google+ Import Settings saved.') . EOL);
}
function fromgplus_plugin_admin(&$a, &$o){
$t = get_markup_template("admin.tpl", "addon/fromgplus/");
- $o = replace_macros($t, array(
+ $o = replace_macros($t, [
'$submit' => t('Save Settings'),
- '$key' => array('key', t('Key'), trim(Config::get('fromgplus', 'key')), t('')),
- ));
+ '$key' => ['key', t('Key'), trim(Config::get('fromgplus', 'key')), t('')],
+ ]);
}
function fromgplus_plugin_admin_post(&$a){
$bbcode = html_entity_decode($html, ENT_QUOTES, 'UTF-8');
- $bbcode = str_ireplace(array("\n"), array(""), $bbcode);
- $bbcode = str_ireplace(array("<b>", "</b>"), array("[b]", "[/b]"), $bbcode);
- $bbcode = str_ireplace(array("<i>", "</i>"), array("[i]", "[/i]"), $bbcode);
- $bbcode = str_ireplace(array("<s>", "</s>"), array("[s]", "[/s]"), $bbcode);
- $bbcode = str_ireplace(array("<br />"), array("\n"), $bbcode);
- $bbcode = str_ireplace(array("<br/>"), array("\n"), $bbcode);
- $bbcode = str_ireplace(array("<br>"), array("\n"), $bbcode);
+ $bbcode = str_ireplace(["\n"], [""], $bbcode);
+ $bbcode = str_ireplace(["<b>", "</b>"], ["[b]", "[/b]"], $bbcode);
+ $bbcode = str_ireplace(["<i>", "</i>"], ["[i]", "[/i]"], $bbcode);
+ $bbcode = str_ireplace(["<s>", "</s>"], ["[s]", "[/s]"], $bbcode);
+ $bbcode = str_ireplace(["<br />"], ["\n"], $bbcode);
+ $bbcode = str_ireplace(["<br/>"], ["\n"], $bbcode);
+ $bbcode = str_ireplace(["<br>"], ["\n"], $bbcode);
$bbcode = trim(strip_tags($bbcode));
return($bbcode);
$var = parse_url($var, PHP_URL_QUERY);
$var = html_entity_decode($var);
$var = explode('&', $var);
- $arr = array();
+ $arr = [];
foreach($var as $val) {
$x = explode('=', $val);
//$image = str_replace(array($preview, $preview2), array("/", "/"), $image->url);
$image = $image->url;
- $cleaned = array();
+ $cleaned = [];
$queryvar = fromgplus_parse_query($fullImage);
if ($queryvar['url'] != "")
}
if ($cleaned["full"] != "")
- $infoFull = get_photo_info($cleaned["full"]);
+ $infoFull = Image::getInfoFromURL($cleaned["full"]);
else
- $infoFull = array("0" => 0, "1" => 0);
+ $infoFull = ["0" => 0, "1" => 0];
if ($cleaned["preview"] != "")
- $infoPreview = get_photo_info($cleaned["preview"]);
+ $infoPreview = Image::getInfoFromURL($cleaned["preview"]);
else
- $infoFull = array("0" => 0, "1" => 0);
+ $infoFull = ["0" => 0, "1" => 0];
if (($infoPreview[0] >= $infoFull[0]) && ($infoPreview[1] >= $infoFull[1])) {
$temp = $cleaned["full"];
$text = strip_tags($text);
$text = html_entity_decode($text, ENT_QUOTES);
$text = trim($text);
- $text = str_replace(array("\n", "\r", " ", $trash), array("", "", "", ""), $text);
+ $text = str_replace(["\n", "\r", " ", $trash], ["", "", "", ""], $text);
return($text);
}
function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
- require_once("include/Photo.php");
require_once("include/items.php");
require_once("include/network.php");
$post = "";
$quote = "";
- $pagedata = array();
+ $pagedata = [];
$pagedata["type"] = "";
foreach ($item->object->attachments as $attachment) {
case "photo":
// Don't store shared pictures in your wall photos (to prevent a possible violating of licenses)
- if ($shared)
+ if ($shared) {
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
- else {
- if ($attachment->fullImage->url != "")
- $images = store_photo($a, $uid, "", $attachment->fullImage->url);
- elseif ($attachment->image->url != "")
- $images = store_photo($a, $uid, "", $attachment->image->url);
+ } else {
+ if ($attachment->fullImage->url != "") {
+ $images = Image::storePhoto($a, $uid, "", $attachment->fullImage->url);
+ } elseif ($attachment->image->url != "") {
+ $images = Image::storePhoto($a, $uid, "", $attachment->image->url);
+ }
}
if ($images["preview"] != "") {
$post .= "\n[img]".$images["full"]."[/img]\n";
$pagedata["images"][0]["src"] = $images["full"];
- if ($images["preview"] != "")
+ if ($images["preview"] != "") {
$pagedata["images"][1]["src"] = $images["preview"];
+ }
}
if (($attachment->displayName != "") && (fromgplus_cleantext($attachment->displayName) != fromgplus_cleantext($displaytext))) {