]> git.mxchange.org Git - friendica-addons.git/blobdiff - fromgplus/fromgplus.php
Addon class
[friendica-addons.git] / fromgplus / fromgplus.php
index 1a1ae682cfee3d8d4937a6df98b0d4ebe6c8d36a..b8910d5df98aff349ea80971b7db672a38c66dff 100644 (file)
@@ -9,28 +9,29 @@
 
 define('FROMGPLUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes
 
+use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
-use Friendica\Object\Photo;
+use Friendica\Object\Image;
 
 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) {
@@ -96,10 +97,10 @@ function fromgplus_addon_settings_post(&$a,&$b) {
 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){
@@ -198,13 +199,13 @@ function fromgplus_html2bbcode($html) {
 
        $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);
@@ -219,7 +220,7 @@ function fromgplus_parse_query($var)
        $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);
@@ -240,7 +241,7 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
        //$image = str_replace(array($preview, $preview2), array("/", "/"), $image->url);
        $image = $image->url;
 
-               $cleaned = array();
+               $cleaned = [];
 
        $queryvar = fromgplus_parse_query($fullImage);
        if ($queryvar['url'] != "")
@@ -264,14 +265,14 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
        }
 
        if ($cleaned["full"] != "")
-               $infoFull = Photo::getInfoFromURL($cleaned["full"]);
+               $infoFull = Image::getInfoFromURL($cleaned["full"]);
        else
-               $infoFull = array("0" => 0, "1" => 0);
+               $infoFull = ["0" => 0, "1" => 0];
 
        if ($cleaned["preview"] != "")
-               $infoPreview = Photo::getInfoFromURL($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"];
@@ -304,7 +305,7 @@ function fromgplus_cleantext($text) {
        $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);
 }
 
@@ -314,7 +315,7 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
 
        $post = "";
        $quote = "";
-       $pagedata = array();
+       $pagedata = [];
        $pagedata["type"] = "";
 
        foreach ($item->object->attachments as $attachment) {
@@ -352,9 +353,9 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
                                        $images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
                                } else {
                                        if ($attachment->fullImage->url != "") {
-                                               $images = Photo::storePhoto($a, $uid, "", $attachment->fullImage->url);
+                                               $images = Image::storePhoto($a, $uid, "", $attachment->fullImage->url);
                                        } elseif ($attachment->image->url != "") {
-                                               $images = Photo::storePhoto($a, $uid, "", $attachment->image->url);
+                                               $images = Image::storePhoto($a, $uid, "", $attachment->image->url);
                                        }
                                }