X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=gpluspost%2Fgpluspost.php;h=5b2b3bf6ee45e4a924fe381e54cb9037f88003d3;hb=9acc0c978527f0b40c33fba24ceaea3bca8b0747;hp=dae59efe9b188ebf199b92e7a319cb6da05ead2b;hpb=7b853e133ad7f6776e0d812e9a343876e30a0f87;p=friendica-addons.git diff --git a/gpluspost/gpluspost.php b/gpluspost/gpluspost.php index dae59efe..5b2b3bf6 100644 --- a/gpluspost/gpluspost.php +++ b/gpluspost/gpluspost.php @@ -13,6 +13,7 @@ function gpluspost_install() { register_hook('jot_networks', 'addon/gpluspost/gpluspost.php', 'gpluspost_jot_nets'); register_hook('connector_settings', 'addon/gpluspost/gpluspost.php', 'gpluspost_settings'); register_hook('connector_settings_post', 'addon/gpluspost/gpluspost.php', 'gpluspost_settings_post'); + register_hook('queue_predeliver', 'addon/gpluspost/gpluspost.php', 'gpluspost_queue_hook'); } @@ -22,6 +23,7 @@ function gpluspost_uninstall() { unregister_hook('jot_networks', 'addon/gpluspost/gpluspost.php', 'gpluspost_jot_nets'); unregister_hook('connector_settings', 'addon/gpluspost/gpluspost.php', 'gpluspost_settings'); unregister_hook('connector_settings_post', 'addon/gpluspost/gpluspost.php', 'gpluspost_settings_post'); + unregister_hook('queue_predeliver', 'addon/gpluspost/gpluspost.php', 'gpluspost_queue_hook'); } function gpluspost_jot_nets(&$a,&$b) { @@ -37,13 +39,26 @@ function gpluspost_jot_nets(&$a,&$b) { } } +function gpluspost_nextscripts() { + $a = get_app(); + return file_exists($a->get_basepath()."/addon/gpluspost/postToGooglePlus.php"); +} + function gpluspost_settings(&$a,&$s) { if(! local_user()) return; + $result = q("SELECT `installed` FROM `addon` WHERE `name` = 'fromgplus' AND `installed`"); + $fromgplus_enabled = count($result) > 0; + + /* Add our stylesheet to the page so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + $enabled = get_pconfig(local_user(),'gpluspost','post'); $checked = (($enabled) ? ' checked="checked" ' : ''); + $css = (($enabled) ? '' : '-disabled'); $def_enabled = get_pconfig(local_user(),'gpluspost','post_by_default'); $def_checked = (($def_enabled) ? ' checked="checked" ' : ''); @@ -54,13 +69,57 @@ function gpluspost_settings(&$a,&$s) { $skip_enabled = get_pconfig(local_user(),'gpluspost','skip_without_link'); $skip_checked = (($skip_enabled) ? ' checked="checked" ' : ''); - $s .= '
If the plugin doesn't work or if it stopped, please login to Google+, then unlock your account by following this link. "; + $s .= 'At this page please click on "Continue". Then your posts should arrive in several minutes.
'; + } else { + $s .= 'Register an account at Hootsuite, add your G+ page and add the feed-url there.
';
+ $s .= 'Feed-url: '.$a->get_baseurl().'/gpluspost/'.urlencode($a->user["nickname"]).'
".$match[2].""; - //$text = "\n\t".$match[2].":\t"; - $text = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').$author.": ".$match[2]; - - return($text); -} - function gpluspost_feeditem($pid, $uid) { global $a; + require_once('include/api.php'); require_once('include/bbcode.php'); require_once("include/html2plain.php"); + require_once("include/network.php"); $skipwithoutlink = get_pconfig($uid,'gpluspost','skip_without_link'); $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']); + + $item['body'] = bb_remove_share_information($item['body'], true); + + if ($item["title"] != "") + $item['body'] = "*".$item["title"]."*\n\n".$item['body']; + // Looking for the first image $image = ''; if(preg_match("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/is",$item['body'],$matches)) @@ -323,10 +484,17 @@ function gpluspost_feeditem($pid, $uid) { $multiplelinks = (strpos($item['body'], "[bookmark") != strrpos($item['body'], "[bookmark")); $body = $item['body']; - $body = preg_replace_callback("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]/ism","gpluspost_ShareAttributes", $body); - $html = bbcode($body, false, false); + $body = preg_replace("(\[b\](.*?)\[\/b\])ism",'*$1*',$body); + $body = preg_replace("(\[i\](.*?)\[\/i\])ism",'_$1_',$body); + $body = preg_replace("(\[s\](.*?)\[\/s\])ism",'-$1-',$body); + + // At first convert the text to html + $html = bbcode(api_clean_plain_items($body), false, false, 2); + + // Then convert it to plain text $msg = trim(html2plain($html, 0, true)); + $msg = html_entity_decode($msg,ENT_QUOTES,'UTF-8'); // If there is no bookmark element then take the first link if ($link == '') { @@ -376,13 +544,18 @@ function gpluspost_feeditem($pid, $uid) { $title = trim(str_replace($msglink, "", $title)); - $msglink = gpluspost_original_url($msglink); + $msglink = original_url($msglink); if ($uid == 0) $title = $item["author-name"].": ".$title; $msglink = htmlspecialchars(html_entity_decode($msglink)); + if (strpos($msg, $msglink) == 0) + $msg .= "\n".$msglink; + + $msg = nl2br($msg); + $title = str_replace("&", "&", $title); //$html = str_replace("&", "&", $html); @@ -396,7 +569,7 @@ function gpluspost_feeditem($pid, $uid) { echo "\t\t