X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=pumpio%2Fpumpio.php;h=d0fe09d568e070fe6f2e730762a232faa28ac22e;hb=ffa36da2c95867dec4acb6a3d4a9975bf65140d3;hp=be4db5fafdcd9b82c49823f7d4d3276c932e4919;hpb=96c41e56233765571870b56081efc366655bead4;p=friendica-addons.git diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index be4db5fa..d0fe09d5 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -7,6 +7,7 @@ */ use Friendica\Core\Addon; use Friendica\Core\Config; +use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Core\Worker; use Friendica\Model\Contact; @@ -14,6 +15,8 @@ use Friendica\Model\GContact; use Friendica\Model\Group; use Friendica\Model\User; use Friendica\Model\Item; +use Friendica\Model\Queue; +use Friendica\Util\Network; require 'addon/pumpio/oauth/http.php'; require 'addon/pumpio/oauth/oauth_client.php'; @@ -49,7 +52,7 @@ function pumpio_module() {} function pumpio_content(&$a) { if(! local_user()) { - notice( t('Permission denied.') . EOL); + notice(L10n::t('Permission denied.') . EOL); return ''; } @@ -145,7 +148,7 @@ function pumpio_connect(&$a) { if (($consumer_key == "") || ($consumer_secret == "")) { logger("pumpio_connect: ".sprintf("Unable to register the client at the pump.io server '%s'.", $hostname)); - $o .= sprintf(t("Unable to register the client at the pump.io server '%s'."), $hostname); + $o .= L10n::t("Unable to register the client at the pump.io server '%s'.", $hostname); return($o); } @@ -185,8 +188,8 @@ function pumpio_connect(&$a) { if($success) { logger("pumpio_connect: authenticated"); - $o .= t("You are now authenticated to pumpio."); - $o .= '
'.t("return to the connector page").''; + $o .= L10n::t("You are now authenticated to pumpio."); + $o .= '
'.L10n::t("return to the connector page").''; } else { logger("pumpio_connect: could not connect"); $o = 'Could not connect to pumpio. Refresh the page or try again later.'; @@ -204,7 +207,7 @@ function pumpio_jot_nets(&$a,&$b) { $pumpio_defpost = PConfig::get(local_user(),'pumpio','post_by_default'); $selected = ((intval($pumpio_defpost) == 1) ? ' checked="checked" ' : ''); $b .= '
' - . t('Post to pumpio') . '
'; + . L10n::t('Post to pumpio') . ''; } } @@ -242,20 +245,20 @@ function pumpio_settings(&$a,&$s) { /* Add some HTML to the existing form */ $s .= ''; - $s .= '

'. t('Pump.io Import/Export/Mirror').'

'; + $s .= '

'. L10n::t('Pump.io Import/Export/Mirror').'

'; $s .= '
'; $s .= ''; } @@ -551,11 +554,10 @@ function pumpio_send(&$a,&$b) { $a->contact = $r[0]["id"]; $s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $params]); - require_once('include/queue_fn.php'); - add_to_queue($a->contact,NETWORK_PUMPIO,$s); - notice(t('Pump.io post failed. Queued for retry.').EOL); + + Queue::add($a->contact, NETWORK_PUMPIO, $s); + notice(L10n::t('Pump.io post failed. Queued for retry.').EOL); } - } } @@ -628,9 +630,9 @@ function pumpio_action(&$a, $uid, $uri, $action, $content = "") { $a->contact = $r[0]["id"]; $s = serialize(['url' => $url, 'item' => $orig_post["id"], 'post' => $params]); - require_once('include/queue_fn.php'); - add_to_queue($a->contact,NETWORK_PUMPIO,$s); - notice(t('Pump.io like failed. Queued for retry.').EOL); + + Queue::add($a->contact, NETWORK_PUMPIO, $s); + notice(L10n::t('Pump.io like failed. Queued for retry.').EOL); } } @@ -719,7 +721,7 @@ function pumpio_fetchtimeline(&$a, $uid) { // get the application name for the pump.io app // 1st try personal config, then system config and fallback to the // hostname of the node if neither one is set. - $application_name = PConfig::get( $uid, 'pumpio', 'application_name'); + $application_name = PConfig::get($uid, 'pumpio', 'application_name'); if ($application_name == "") $application_name = Config::get('pumpio', 'application_name'); if ($application_name == "") @@ -963,16 +965,16 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = tru $author = '[url=' . $likedata['author-link'] . ']' . $likedata['author-name'] . '[/url]'; $objauthor = '[url=' . $orig_post['author-link'] . ']' . $orig_post['author-name'] . '[/url]'; - $post_type = t('status'); + $post_type = L10n::t('status'); $plink = '[url=' . $orig_post['plink'] . ']' . $post_type . '[/url]'; $likedata['object-type'] = ACTIVITY_OBJ_NOTE; - $likedata['body'] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink); + $likedata['body'] = L10n::t('%1$s likes %2$s\'s %3$s', $author, $objauthor, $plink); $likedata['object'] = '' . ACTIVITY_OBJ_NOTE . '1' . '' . $orig_post['uri'] . '' . xmlify('') . '' . $orig_post['title'] . '' . $orig_post['body'] . ''; - $ret = item_store($likedata); + $ret = Item::insert($likedata); logger("pumpio_dolike: ".$ret." User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']); } @@ -1248,7 +1250,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet if (trim($postarray['body']) == "") return false; - $top_item = item_store($postarray); + $top_item = Item::insert($postarray); $postarray["id"] = $top_item; if (($top_item == 0) && ($post->verb == "update")) { @@ -1304,7 +1306,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet 'to_email' => $user[0]['email'], 'uid' => $user[0]['uid'], 'item' => $postarray, - 'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($top_item)), + 'link' => $a->get_baseurl().'/display/'.urlencode(Item::getGuidById($top_item)), 'source_name' => $postarray['author-name'], 'source_link' => $postarray['author-link'], 'source_photo' => $postarray['author-avatar'], @@ -1433,8 +1435,6 @@ function pumpio_queue_hook(&$a,&$b) { if(! count($qi)) return; - require_once('include/queue_fn.php'); - foreach($qi as $x) { if($x['network'] !== NETWORK_PUMPIO) continue; @@ -1494,7 +1494,7 @@ function pumpio_queue_hook(&$a,&$b) { intval($z['item']) ); } - remove_queue_item($x['id']); + Queue::removeItem($x['id']); } else logger('pumpio_queue: send '.$username.': '.$url.' general error: ' . print_r($user,true)); } else @@ -1502,7 +1502,7 @@ function pumpio_queue_hook(&$a,&$b) { if (!$success) { logger('pumpio_queue: delayed'); - update_queue_time($x['id']); + Queue::updateTime($x['id']); } } } @@ -1699,7 +1699,7 @@ function pumpio_fetchallcomments(&$a, $uid, $id) { function pumpio_reachable($url) { - $data = z_fetch_url($url, false, $redirects, ['timeout'=>10]); + $data = Network::curl($url, false, $redirects, ['timeout'=>10]); return(intval($data['return_code']) != 0); }