]> git.mxchange.org Git - friendica-addons.git/blobdiff - appnetpost/appnetpost.php
The connector settings are now with logo.
[friendica-addons.git] / appnetpost / appnetpost.php
index ca6d5d27ed02cd6347decfad5e0d7a0207c1f0e1..32312dd825cefde69343e984891fae6cd4ed01ed 100644 (file)
@@ -52,8 +52,14 @@ function appnetpost_settings(&$a,&$s) {
        $def_enabled = get_pconfig(local_user(),'appnetpost','post_by_default');
        $def_checked = (($def_enabled) ? ' checked="checked" ' : '');
 
-       $s .= '<div class="settings-block">';
-       $s .= '<h3>' . t('App.net Post Settings') . '</h3>';
+       $s .= '<span id="settings_appnetpost_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_appnetpost_expanded\'); openClose(\'settings_appnetpost_inflated\');">';
+       $s .= '<img class="connector" src="images/appnet.png" /><h3 class="connector">'. t('App.net Export').'</h3>';
+       $s .= '</span>';
+       $s .= '<div id="settings_appnetpost_expanded" class="settings-block" style="display: none;">';
+       $s .= '<span class="fakelink" onclick="openClose(\'settings_appnetpost_expanded\'); openClose(\'settings_appnetpost_inflated\');">';
+       $s .= '<img class="connector" src="images/appnet.png" /><h3 class="connector">'. t('App.net Export').'</h3>';
+       $s .= '</span>';
+
        $s .= '<div id="appnetpost-enable-wrapper">';
        $s .= '<label id="appnetpost-enable-label" for="appnetpost-checkbox">' . t('Enable App.net Post Plugin') . '</label>';
        $s .= '<input id="appnetpost-checkbox" type="checkbox" name="appnetpost" value="1" ' . $checked . '/>';
@@ -190,65 +196,6 @@ function appnetpost_init() {
        killme();
 }
 
-function appnetpost_original_url($url, $depth=1) {
-
-       if ($depth > 10)
-               return($url);
-
-       $siteinfo = array();
-       $ch = curl_init();
-       curl_setopt($ch, CURLOPT_URL, $url);
-       curl_setopt($ch, CURLOPT_HEADER, 1);
-       curl_setopt($ch, CURLOPT_NOBODY, 0);
-       curl_setopt($ch, CURLOPT_TIMEOUT, 3);
-       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-       curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0');
-
-       $header = curl_exec($ch);
-       $curl_info = @curl_getinfo($ch);
-       $http_code = $curl_info['http_code'];
-       curl_close($ch);
-
-       if ((($curl_info['http_code'] == "301") OR ($curl_info['http_code'] == "302"))
-               AND (($curl_info['redirect_url'] != "") OR ($curl_info['location'] != ""))) {
-               if ($curl_info['redirect_url'] != "")
-                       return(appnetpost_original_url($curl_info['redirect_url'], ++$depth));
-               else
-                       return(appnetpost_original_url($curl_info['location'], ++$depth));
-       }
-
-       $pos = strpos($header, "\r\n\r\n");
-
-       if ($pos)
-               $body = trim(substr($header, $pos));
-       else
-               $body = $header;
-
-       $doc = new DOMDocument();
-       @$doc->loadHTML($body);
-
-       $xpath = new DomXPath($doc);
-
-       $list = $xpath->query("//meta[@content]");
-       foreach ($list as $node) {
-               $attr = array();
-               if ($node->attributes->length)
-                       foreach ($node->attributes as $attribute)
-                               $attr[$attribute->name] = $attribute->value;
-
-               if (@$attr["http-equiv"] == 'refresh') {
-                       $path = $attr["content"];
-                       $pathinfo = explode(";", $path);
-                       $content = "";
-                       foreach ($pathinfo AS $value)
-                               if (substr(strtolower($value), 0, 4) == "url=")
-                                       return(appnetpost_original_url(substr($value, 4), ++$depth));
-               }
-       }
-
-       return($url);
-}
-
 if (! function_exists( 'short_link' )) {
 function short_link($url) {
        require_once('library/slinky.php');
@@ -282,6 +229,8 @@ function appnetpost_feeditem($pid, $uid) {
        $items = q("SELECT `uri`, `plink`, `author-link`, `author-name`, `created`, `edited`, `id`, `title`, `body` from `item` WHERE id=%d", intval($pid));
        foreach ($items AS $item) {
 
+               $item['body'] = bb_CleanPictureLinks($item['body']);
+
                // Looking for the first image
                $image = '';
                if(preg_match("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/is",$item['body'],$matches))
@@ -371,7 +320,7 @@ function appnetpost_feeditem($pid, $uid) {
                        $title = substr($title, 0, -3)."...";
                }
 
-               if (!strstr($title, $msglink))
+               if (($msglink != "") AND !strstr($title, $msglink))
                        $title = trim($title." ".$msglink);
                else
                        $title = trim($title);
@@ -379,7 +328,7 @@ function appnetpost_feeditem($pid, $uid) {
                if ($title == "")
                        continue;
 
-               //$origlink = appnetpost_original_url($origlink);
+               //$origlink = original_url($origlink);
 
                $html = nl2br($title);