X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=gpluspost%2Fgpluspost.php;h=92ee83751c9b42ddcbdf252ce319a95e030c202a;hb=2e96c60a478156a9dae89d9ab9d35c6eebf543e6;hp=0880a4245e4f855caf33a85212d83802243fd9dc;hpb=67244bb9eac2983cd160774d310b428efcdd4ce5;p=friendica-addons.git diff --git a/gpluspost/gpluspost.php b/gpluspost/gpluspost.php index 0880a424..92ee8375 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,17 +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" ' : ''); @@ -58,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/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']); + // Looking for the first image $image = ''; if(preg_match("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/is",$item['body'],$matches)) @@ -327,10 +592,13 @@ 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); + // At first convert the text to html + $html = bbcode($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 == '') { @@ -380,7 +648,7 @@ 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;