Merge pull request #4246 from zeroadam/Widget-#3878
Move contact_widgets to src
This commit is contained in:
commit
0fe832ef8a
11 changed files with 342 additions and 310 deletions
|
@ -4,12 +4,12 @@
|
||||||
*/
|
*/
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\Feature;
|
use Friendica\Content\Feature;
|
||||||
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Model\GContact;
|
||||||
|
|
||||||
require_once "include/contact_widgets.php";
|
|
||||||
require_once "mod/proxy.php";
|
require_once "mod/proxy.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -425,7 +425,7 @@ function acl_lookup(App $a, $out_type = 'json')
|
||||||
$group_count = 0;
|
$group_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_extra2 .= " ".unavailable_networks();
|
$sql_extra2 .= " ".Widget::unavailableNetworks();
|
||||||
|
|
||||||
if ($type == '' || $type == 'c') {
|
if ($type == '' || $type == 'c') {
|
||||||
// autocomplete for editor mentions
|
// autocomplete for editor mentions
|
||||||
|
|
|
@ -1,270 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @file include/contact_widgets.php
|
|
||||||
*/
|
|
||||||
use Friendica\Content\ContactSelector;
|
|
||||||
use Friendica\Content\Feature;
|
|
||||||
use Friendica\Core\System;
|
|
||||||
use Friendica\Core\Config;
|
|
||||||
use Friendica\Core\PConfig;
|
|
||||||
use Friendica\Database\DBM;
|
|
||||||
use Friendica\Model\GContact;
|
|
||||||
use Friendica\Model\Profile;
|
|
||||||
|
|
||||||
function follow_widget($value = "")
|
|
||||||
{
|
|
||||||
return replace_macros(get_markup_template('follow.tpl'), array(
|
|
||||||
'$connect' => t('Add New Contact'),
|
|
||||||
'$desc' => t('Enter address or web location'),
|
|
||||||
'$hint' => t('Example: bob@example.com, http://example.com/barbara'),
|
|
||||||
'$value' => $value,
|
|
||||||
'$follow' => t('Connect')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
function findpeople_widget()
|
|
||||||
{
|
|
||||||
$a = get_app();
|
|
||||||
$global_dir = Config::get('system', 'directory');
|
|
||||||
|
|
||||||
if (Config::get('system', 'invitation_only')) {
|
|
||||||
$x = PConfig::get(local_user(), 'system', 'invites_remaining');
|
|
||||||
if ($x || is_site_admin()) {
|
|
||||||
$a->page['aside'] .= '<div class="side-link" id="side-invite-remain">'
|
|
||||||
. tt('%d invitation available', '%d invitations available', $x)
|
|
||||||
. '</div>' . $inv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return replace_macros(get_markup_template('peoplefind.tpl'), array(
|
|
||||||
'$findpeople' => t('Find People'),
|
|
||||||
'$desc' => t('Enter name or interest'),
|
|
||||||
'$label' => t('Connect/Follow'),
|
|
||||||
'$hint' => t('Examples: Robert Morgenstein, Fishing'),
|
|
||||||
'$findthem' => t('Find'),
|
|
||||||
'$suggest' => t('Friend Suggestions'),
|
|
||||||
'$similar' => t('Similar Interests'),
|
|
||||||
'$random' => t('Random Profile'),
|
|
||||||
'$inv' => t('Invite Friends'),
|
|
||||||
'$directory' => t('View Global Directory'),
|
|
||||||
'$global_dir' => $global_dir
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
function unavailable_networks()
|
|
||||||
{
|
|
||||||
$networks = array();
|
|
||||||
|
|
||||||
if (!plugin_enabled("appnet")) {
|
|
||||||
$networks[] = NETWORK_APPNET;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin_enabled("fbpost") && !plugin_enabled("facebook")) {
|
|
||||||
$networks[] = NETWORK_FACEBOOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin_enabled("statusnet")) {
|
|
||||||
$networks[] = NETWORK_STATUSNET;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin_enabled("pumpio")) {
|
|
||||||
$networks[] = NETWORK_PUMPIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin_enabled("twitter")) {
|
|
||||||
$networks[] = NETWORK_TWITTER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config::get("system", "ostatus_disabled")) {
|
|
||||||
$networks[] = NETWORK_OSTATUS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Config::get("system", "diaspora_enabled")) {
|
|
||||||
$networks[] = NETWORK_DIASPORA;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin_enabled("pnut")) {
|
|
||||||
$networks[] = NETWORK_PNUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sizeof($networks)) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
$network_filter = implode("','", $networks);
|
|
||||||
|
|
||||||
$network_filter = "AND `network` NOT IN ('$network_filter')";
|
|
||||||
|
|
||||||
return $network_filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
function networks_widget($baseurl, $selected = '')
|
|
||||||
{
|
|
||||||
if (!local_user()) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Feature::isEnabled(local_user(), 'networks')) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$extra_sql = unavailable_networks();
|
|
||||||
|
|
||||||
$r = dba::p("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = ? AND `network` != '' $extra_sql ORDER BY `network`",
|
|
||||||
local_user()
|
|
||||||
);
|
|
||||||
|
|
||||||
$nets = array();
|
|
||||||
while ($rr = dba::fetch($r)) {
|
|
||||||
/// @TODO If 'network' is not there, this triggers an E_NOTICE
|
|
||||||
if ($rr['network']) {
|
|
||||||
$nets[] = array('ref' => $rr['network'], 'name' => ContactSelector::networkToName($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dba::close($r);
|
|
||||||
|
|
||||||
if (count($nets) < 2) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return replace_macros(get_markup_template('nets.tpl'), array(
|
|
||||||
'$title' => t('Networks'),
|
|
||||||
'$desc' => '',
|
|
||||||
'$sel_all' => (($selected == '') ? 'selected' : ''),
|
|
||||||
'$all' => t('All Networks'),
|
|
||||||
'$nets' => $nets,
|
|
||||||
'$base' => $baseurl,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
function fileas_widget($baseurl, $selected = '')
|
|
||||||
{
|
|
||||||
if (!local_user()) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Feature::isEnabled(local_user(), 'filing')) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$saved = PConfig::get(local_user(), 'system', 'filetags');
|
|
||||||
if (!strlen($saved)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$matches = false;
|
|
||||||
$terms = array();
|
|
||||||
$cnt = preg_match_all('/\[(.*?)\]/', $saved, $matches, PREG_SET_ORDER);
|
|
||||||
if ($cnt) {
|
|
||||||
foreach ($matches as $mtch) {
|
|
||||||
$unescaped = xmlify(file_tag_decode($mtch[1]));
|
|
||||||
$terms[] = array('name' => $unescaped, 'selected' => (($selected == $unescaped) ? 'selected' : ''));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return replace_macros(get_markup_template('fileas_widget.tpl'), array(
|
|
||||||
'$title' => t('Saved Folders'),
|
|
||||||
'$desc' => '',
|
|
||||||
'$sel_all' => (($selected == '') ? 'selected' : ''),
|
|
||||||
'$all' => t('Everything'),
|
|
||||||
'$terms' => $terms,
|
|
||||||
'$base' => $baseurl,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
function categories_widget($baseurl, $selected = '')
|
|
||||||
{
|
|
||||||
$a = get_app();
|
|
||||||
|
|
||||||
if (!Feature::isEnabled($a->profile['profile_uid'], 'categories')) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$saved = PConfig::get($a->profile['profile_uid'], 'system', 'filetags');
|
|
||||||
if (!strlen($saved)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$matches = false;
|
|
||||||
$terms = array();
|
|
||||||
$cnt = preg_match_all('/<(.*?)>/', $saved, $matches, PREG_SET_ORDER);
|
|
||||||
|
|
||||||
if ($cnt) {
|
|
||||||
foreach ($matches as $mtch) {
|
|
||||||
$unescaped = xmlify(file_tag_decode($mtch[1]));
|
|
||||||
$terms[] = array('name' => $unescaped, 'selected' => (($selected == $unescaped) ? 'selected' : ''));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return replace_macros(get_markup_template('categories_widget.tpl'), array(
|
|
||||||
'$title' => t('Categories'),
|
|
||||||
'$desc' => '',
|
|
||||||
'$sel_all' => (($selected == '') ? 'selected' : ''),
|
|
||||||
'$all' => t('Everything'),
|
|
||||||
'$terms' => $terms,
|
|
||||||
'$base' => $baseurl,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
function common_friends_visitor_widget($profile_uid)
|
|
||||||
{
|
|
||||||
if (local_user() == $profile_uid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cid = $zcid = 0;
|
|
||||||
|
|
||||||
if (is_array($_SESSION['remote'])) {
|
|
||||||
foreach ($_SESSION['remote'] as $visitor) {
|
|
||||||
if ($visitor['uid'] == $profile_uid) {
|
|
||||||
$cid = $visitor['cid'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$cid) {
|
|
||||||
if (Profile::getMyURL()) {
|
|
||||||
$contact = dba::selectFirst('contact', ['id'],
|
|
||||||
['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $profile_uid]);
|
|
||||||
if (DBM::is_result($contact)) {
|
|
||||||
$cid = $contact['id'];
|
|
||||||
} else {
|
|
||||||
$gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
|
|
||||||
if (DBM::is_result($gcontact)) {
|
|
||||||
$zcid = $gcontact['id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($cid == 0 && $zcid == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($cid) {
|
|
||||||
$t = GContact::countCommonFriends($profile_uid, $cid);
|
|
||||||
} else {
|
|
||||||
$t = GContact::countCommonFriendsZcid($profile_uid, $zcid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$t) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($cid) {
|
|
||||||
$r = GContact::commonFriends($profile_uid, $cid, 0, 5, true);
|
|
||||||
} else {
|
|
||||||
$r = GContact::commonFriendsZcid($profile_uid, $zcid, 0, 5, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
|
|
||||||
'$desc' => tt("%d contact in common", "%d contacts in common", $t),
|
|
||||||
'$base' => System::baseUrl(),
|
|
||||||
'$uid' => $profile_uid,
|
|
||||||
'$cid' => (($cid) ? $cid : '0'),
|
|
||||||
'$linkmore' => (($t > 5) ? 'true' : ''),
|
|
||||||
'$more' => t('show more'),
|
|
||||||
'$items' => $r)
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -4,6 +4,7 @@
|
||||||
*/
|
*/
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\ContactSelector;
|
use Friendica\Content\ContactSelector;
|
||||||
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
|
@ -13,7 +14,6 @@ use Friendica\Model\Group;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
|
|
||||||
require_once 'include/contact_widgets.php';
|
|
||||||
require_once 'mod/proxy.php';
|
require_once 'mod/proxy.php';
|
||||||
|
|
||||||
function contacts_init(App $a)
|
function contacts_init(App $a)
|
||||||
|
@ -63,14 +63,14 @@ function contacts_init(App $a)
|
||||||
$networks_widget = '';
|
$networks_widget = '';
|
||||||
} else {
|
} else {
|
||||||
$vcard_widget = '';
|
$vcard_widget = '';
|
||||||
$networks_widget = networks_widget('contacts', $nets);
|
$networks_widget = Widget::networks('contacts', $nets);
|
||||||
if (isset($_GET['add'])) {
|
if (isset($_GET['add'])) {
|
||||||
$follow_widget = follow_widget($_GET['add']);
|
$follow_widget = Widget::follow($_GET['add']);
|
||||||
} else {
|
} else {
|
||||||
$follow_widget = follow_widget();
|
$follow_widget = Widget::follow();
|
||||||
}
|
}
|
||||||
|
|
||||||
$findpeople_widget = findpeople_widget();
|
$findpeople_widget = Widget::findPeople();
|
||||||
}
|
}
|
||||||
|
|
||||||
$groups_widget = Group::sidebarWidget('contacts', 'group', 'full', 0, $contact_id);
|
$groups_widget = Group::sidebarWidget('contacts', 'group', 'full', 0, $contact_id);
|
||||||
|
@ -781,7 +781,7 @@ function contacts_content(App $a)
|
||||||
$total = $r[0]['total'];
|
$total = $r[0]['total'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_extra3 = unavailable_networks();
|
$sql_extra3 = Widget::unavailableNetworks();
|
||||||
|
|
||||||
$contacts = array();
|
$contacts = array();
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* @file mod/directory.php
|
* @file mod/directory.php
|
||||||
*/
|
*/
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
@ -12,13 +13,10 @@ function directory_init(App $a) {
|
||||||
$a->set_pager_itemspage(60);
|
$a->set_pager_itemspage(60);
|
||||||
|
|
||||||
if(local_user()) {
|
if(local_user()) {
|
||||||
require_once('include/contact_widgets.php');
|
$a->page['aside'] .= Widget::findPeople();
|
||||||
|
|
||||||
$a->page['aside'] .= findpeople_widget();
|
$a->page['aside'] .= Widget::follow();
|
||||||
|
} else {
|
||||||
$a->page['aside'] .= follow_widget();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
unset($_SESSION['theme']);
|
unset($_SESSION['theme']);
|
||||||
unset($_SESSION['mobile-theme']);
|
unset($_SESSION['mobile-theme']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
*/
|
*/
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\ContactSelector;
|
use Friendica\Content\ContactSelector;
|
||||||
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
|
@ -13,7 +14,6 @@ use Friendica\Model\Profile;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Protocol\PortableContact;
|
use Friendica\Protocol\PortableContact;
|
||||||
|
|
||||||
require_once 'include/contact_widgets.php';
|
|
||||||
require_once 'mod/contacts.php';
|
require_once 'mod/contacts.php';
|
||||||
|
|
||||||
function dirfind_init(App $a) {
|
function dirfind_init(App $a) {
|
||||||
|
@ -27,9 +27,9 @@ function dirfind_init(App $a) {
|
||||||
$a->page['aside'] = '';
|
$a->page['aside'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->page['aside'] .= findpeople_widget();
|
$a->page['aside'] .= Widget::findPeople();
|
||||||
|
|
||||||
$a->page['aside'] .= follow_widget();
|
$a->page['aside'] .= Widget::follow();
|
||||||
}
|
}
|
||||||
|
|
||||||
function dirfind_content(App $a, $prefix = "") {
|
function dirfind_content(App $a, $prefix = "") {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* @file mod/match.php
|
* @file mod/match.php
|
||||||
*/
|
*/
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
|
@ -10,7 +11,6 @@ use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
|
|
||||||
require_once 'include/text.php';
|
require_once 'include/text.php';
|
||||||
require_once 'include/contact_widgets.php';
|
|
||||||
require_once 'mod/proxy.php';
|
require_once 'mod/proxy.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,8 +30,8 @@ function match_content(App $a)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->page['aside'] .= findpeople_widget();
|
$a->page['aside'] .= Widget::findPeople();
|
||||||
$a->page['aside'] .= follow_widget();
|
$a->page['aside'] .= Widget::follow();
|
||||||
|
|
||||||
$_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
|
$_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\Feature;
|
use Friendica\Content\Feature;
|
||||||
use Friendica\Content\ForumManager;
|
use Friendica\Content\ForumManager;
|
||||||
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
|
@ -15,7 +16,6 @@ use Friendica\Model\Profile;
|
||||||
use Friendica\Module\Login;
|
use Friendica\Module\Login;
|
||||||
|
|
||||||
require_once 'include/conversation.php';
|
require_once 'include/conversation.php';
|
||||||
require_once 'include/contact_widgets.php';
|
|
||||||
require_once 'include/items.php';
|
require_once 'include/items.php';
|
||||||
require_once 'include/acl_selectors.php';
|
require_once 'include/acl_selectors.php';
|
||||||
|
|
||||||
|
@ -159,12 +159,12 @@ function network_init(App $a) {
|
||||||
$a->page['aside'] = '';
|
$a->page['aside'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->page['aside'] .= (Feature::isEnabled(local_user(),'groups') ? Group::sidebarWidget('network/0','network','standard',$group_id) : '');
|
$a->page['aside'] .= (Feature::isEnabled(local_user(), 'groups') ? Group::sidebarWidget('network/0', 'network', 'standard', $group_id) : '');
|
||||||
$a->page['aside'] .= (Feature::isEnabled(local_user(), 'forumlist_widget') ? ForumManager::widget(local_user(), $cid) : '');
|
$a->page['aside'] .= (Feature::isEnabled(local_user(), 'forumlist_widget') ? ForumManager::widget(local_user(), $cid) : '');
|
||||||
$a->page['aside'] .= posted_date_widget('network',local_user(),false);
|
$a->page['aside'] .= posted_date_widget('network', local_user(),false);
|
||||||
$a->page['aside'] .= networks_widget('network',(x($_GET, 'nets') ? $_GET['nets'] : ''));
|
$a->page['aside'] .= Widget::networks('network', (x($_GET, 'nets') ? $_GET['nets'] : ''));
|
||||||
$a->page['aside'] .= saved_searches($search);
|
$a->page['aside'] .= saved_searches($search);
|
||||||
$a->page['aside'] .= fileas_widget('network',(x($_GET, 'file') ? $_GET['file'] : ''));
|
$a->page['aside'] .= Widget::fileAs('network', (x($_GET, 'file') ? $_GET['file'] : ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
function saved_searches($search) {
|
function saved_searches($search) {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* @file mod/profile.php
|
* @file mod/profile.php
|
||||||
*/
|
*/
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
|
@ -12,8 +13,6 @@ use Friendica\Model\Profile;
|
||||||
use Friendica\Module\Login;
|
use Friendica\Module\Login;
|
||||||
use Friendica\Protocol\DFRN;
|
use Friendica\Protocol\DFRN;
|
||||||
|
|
||||||
require_once 'include/contact_widgets.php';
|
|
||||||
|
|
||||||
function profile_init(App $a)
|
function profile_init(App $a)
|
||||||
{
|
{
|
||||||
if (!x($a->page, 'aside')) {
|
if (!x($a->page, 'aside')) {
|
||||||
|
@ -184,7 +183,7 @@ function profile_content(App $a, $update = 0)
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
$o .= common_friends_visitor_widget($a->profile['profile_uid']);
|
$o .= Widget::commonFriendsVisitor($a->profile['profile_uid']);
|
||||||
|
|
||||||
if (x($_SESSION, 'new_member') && $is_owner) {
|
if (x($_SESSION, 'new_member') && $is_owner) {
|
||||||
$o .= '<a href="newmember" id="newmember-tips" style="font-size: 1.2em;"><b>' . t('Tips for New Members') . '</b></a>' . EOL;
|
$o .= '<a href="newmember" id="newmember-tips" style="font-size: 1.2em;"><b>' . t('Tips for New Members') . '</b></a>' . EOL;
|
||||||
|
@ -194,7 +193,7 @@ function profile_content(App $a, $update = 0)
|
||||||
$commvisitor = $commpage && $remote_contact;
|
$commvisitor = $commpage && $remote_contact;
|
||||||
|
|
||||||
$a->page['aside'] .= posted_date_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);
|
$a->page['aside'] .= posted_date_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);
|
||||||
$a->page['aside'] .= categories_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], (x($category) ? xmlify($category) : ''));
|
$a->page['aside'] .= Widget::categories(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], (x($category) ? xmlify($category) : ''));
|
||||||
$a->page['aside'] .= tagcloud_wall_widget();
|
$a->page['aside'] .= tagcloud_wall_widget();
|
||||||
|
|
||||||
if (can_write_wall($a->profile['profile_uid'])) {
|
if (can_write_wall($a->profile['profile_uid'])) {
|
||||||
|
|
|
@ -4,14 +4,13 @@
|
||||||
*/
|
*/
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\ContactSelector;
|
use Friendica\Content\ContactSelector;
|
||||||
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Model\GContact;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
|
|
||||||
require_once 'include/contact_widgets.php';
|
|
||||||
|
|
||||||
function suggest_init(App $a) {
|
function suggest_init(App $a) {
|
||||||
if (! local_user()) {
|
if (! local_user()) {
|
||||||
return;
|
return;
|
||||||
|
@ -51,10 +50,6 @@ function suggest_init(App $a) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function suggest_content(App $a) {
|
function suggest_content(App $a) {
|
||||||
|
|
||||||
require_once("mod/proxy.php");
|
require_once("mod/proxy.php");
|
||||||
|
@ -67,8 +62,8 @@ function suggest_content(App $a) {
|
||||||
|
|
||||||
$_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
|
$_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
|
||||||
|
|
||||||
$a->page['aside'] .= findpeople_widget();
|
$a->page['aside'] .= Widget::findPeople();
|
||||||
$a->page['aside'] .= follow_widget();
|
$a->page['aside'] .= Widget::follow();
|
||||||
|
|
||||||
|
|
||||||
$r = GContact::suggestionQuery(local_user());
|
$r = GContact::suggestionQuery(local_user());
|
||||||
|
|
311
src/Content/Widget.php
Normal file
311
src/Content/Widget.php
Normal file
|
@ -0,0 +1,311 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @file src/Content/Widget.php
|
||||||
|
*/
|
||||||
|
namespace Friendica\Content;
|
||||||
|
|
||||||
|
use Friendica\Content\ContactSelector;
|
||||||
|
use Friendica\Content\Feature;
|
||||||
|
use Friendica\Core\System;
|
||||||
|
use Friendica\Core\Config;
|
||||||
|
use Friendica\Core\PConfig;
|
||||||
|
use Friendica\Database\DBM;
|
||||||
|
use Friendica\Model\GContact;
|
||||||
|
use Friendica\Model\Profile;
|
||||||
|
|
||||||
|
require_once 'boot.php';
|
||||||
|
|
||||||
|
class Widget
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Return the follow widget
|
||||||
|
*
|
||||||
|
* @param string $value optional, default empty
|
||||||
|
*/
|
||||||
|
public static function follow($value = "")
|
||||||
|
{
|
||||||
|
return replace_macros(get_markup_template('follow.tpl'), array(
|
||||||
|
'$connect' => t('Add New Contact'),
|
||||||
|
'$desc' => t('Enter address or web location'),
|
||||||
|
'$hint' => t('Example: bob@example.com, http://example.com/barbara'),
|
||||||
|
'$value' => $value,
|
||||||
|
'$follow' => t('Connect')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return Find People widget
|
||||||
|
*/
|
||||||
|
public static function findPeople()
|
||||||
|
{
|
||||||
|
$a = get_app();
|
||||||
|
$global_dir = Config::get('system', 'directory');
|
||||||
|
|
||||||
|
if (Config::get('system', 'invitation_only')) {
|
||||||
|
$x = PConfig::get(local_user(), 'system', 'invites_remaining');
|
||||||
|
if ($x || is_site_admin()) {
|
||||||
|
$a->page['aside'] .= '<div class="side-link" id="side-invite-remain">'
|
||||||
|
. tt('%d invitation available', '%d invitations available', $x)
|
||||||
|
. '</div>' . $inv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return replace_macros(get_markup_template('peoplefind.tpl'), array(
|
||||||
|
'$findpeople' => t('Find People'),
|
||||||
|
'$desc' => t('Enter name or interest'),
|
||||||
|
'$label' => t('Connect/Follow'),
|
||||||
|
'$hint' => t('Examples: Robert Morgenstein, Fishing'),
|
||||||
|
'$findthem' => t('Find'),
|
||||||
|
'$suggest' => t('Friend Suggestions'),
|
||||||
|
'$similar' => t('Similar Interests'),
|
||||||
|
'$random' => t('Random Profile'),
|
||||||
|
'$inv' => t('Invite Friends'),
|
||||||
|
'$directory' => t('View Global Directory'),
|
||||||
|
'$global_dir' => $global_dir
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return unavailable networks
|
||||||
|
*/
|
||||||
|
public static function unavailableNetworks()
|
||||||
|
{
|
||||||
|
$networks = array();
|
||||||
|
|
||||||
|
if (!plugin_enabled("appnet")) {
|
||||||
|
$networks[] = NETWORK_APPNET;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin_enabled("fbpost") && !plugin_enabled("facebook")) {
|
||||||
|
$networks[] = NETWORK_FACEBOOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin_enabled("statusnet")) {
|
||||||
|
$networks[] = NETWORK_STATUSNET;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin_enabled("pumpio")) {
|
||||||
|
$networks[] = NETWORK_PUMPIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin_enabled("twitter")) {
|
||||||
|
$networks[] = NETWORK_TWITTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config::get("system", "ostatus_disabled")) {
|
||||||
|
$networks[] = NETWORK_OSTATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config::get("system", "diaspora_enabled")) {
|
||||||
|
$networks[] = NETWORK_DIASPORA;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin_enabled("pnut")) {
|
||||||
|
$networks[] = NETWORK_PNUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sizeof($networks)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
$network_filter = implode("','", $networks);
|
||||||
|
|
||||||
|
$network_filter = "AND `network` NOT IN ('$network_filter')";
|
||||||
|
|
||||||
|
return $network_filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return networks widget
|
||||||
|
*
|
||||||
|
* @param string $baseurl baseurl
|
||||||
|
* @param string $selected optional, default empty
|
||||||
|
*/
|
||||||
|
public static function networks($baseurl, $selected = '')
|
||||||
|
{
|
||||||
|
if (!local_user()) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Feature::isEnabled(local_user(), 'networks')) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$extra_sql = self::unavailableNetworks();
|
||||||
|
|
||||||
|
$r = dba::p("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = ? AND `network` != '' $extra_sql ORDER BY `network`",
|
||||||
|
local_user()
|
||||||
|
);
|
||||||
|
|
||||||
|
$nets = array();
|
||||||
|
while ($rr = dba::fetch($r)) {
|
||||||
|
/// @TODO If 'network' is not there, this triggers an E_NOTICE
|
||||||
|
if ($rr['network']) {
|
||||||
|
$nets[] = array('ref' => $rr['network'], 'name' => ContactSelector::networkToName($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dba::close($r);
|
||||||
|
|
||||||
|
if (count($nets) < 2) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return replace_macros(get_markup_template('nets.tpl'), array(
|
||||||
|
'$title' => t('Networks'),
|
||||||
|
'$desc' => '',
|
||||||
|
'$sel_all' => (($selected == '') ? 'selected' : ''),
|
||||||
|
'$all' => t('All Networks'),
|
||||||
|
'$nets' => $nets,
|
||||||
|
'$base' => $baseurl,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return file as widget
|
||||||
|
*
|
||||||
|
* @param string $baseurl baseurl
|
||||||
|
* @param string $selected optional, default empty
|
||||||
|
*/
|
||||||
|
public static function fileAs($baseurl, $selected = '')
|
||||||
|
{
|
||||||
|
if (!local_user()) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Feature::isEnabled(local_user(), 'filing')) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$saved = PConfig::get(local_user(), 'system', 'filetags');
|
||||||
|
if (!strlen($saved)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$matches = false;
|
||||||
|
$terms = array();
|
||||||
|
$cnt = preg_match_all('/\[(.*?)\]/', $saved, $matches, PREG_SET_ORDER);
|
||||||
|
if ($cnt) {
|
||||||
|
foreach ($matches as $mtch) {
|
||||||
|
$unescaped = xmlify(file_tag_decode($mtch[1]));
|
||||||
|
$terms[] = array('name' => $unescaped, 'selected' => (($selected == $unescaped) ? 'selected' : ''));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return replace_macros(get_markup_template('fileas_widget.tpl'), array(
|
||||||
|
'$title' => t('Saved Folders'),
|
||||||
|
'$desc' => '',
|
||||||
|
'$sel_all' => (($selected == '') ? 'selected' : ''),
|
||||||
|
'$all' => t('Everything'),
|
||||||
|
'$terms' => $terms,
|
||||||
|
'$base' => $baseurl,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return categories widget
|
||||||
|
*
|
||||||
|
* @param string $baseurl baseurl
|
||||||
|
* @param string $selected optional, default empty
|
||||||
|
*/
|
||||||
|
public static function categories($baseurl, $selected = '')
|
||||||
|
{
|
||||||
|
$a = get_app();
|
||||||
|
|
||||||
|
if (!Feature::isEnabled($a->profile['profile_uid'], 'categories')) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$saved = PConfig::get($a->profile['profile_uid'], 'system', 'filetags');
|
||||||
|
if (!strlen($saved)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$matches = false;
|
||||||
|
$terms = array();
|
||||||
|
$cnt = preg_match_all('/<(.*?)>/', $saved, $matches, PREG_SET_ORDER);
|
||||||
|
|
||||||
|
if ($cnt) {
|
||||||
|
foreach ($matches as $mtch) {
|
||||||
|
$unescaped = xmlify(file_tag_decode($mtch[1]));
|
||||||
|
$terms[] = array('name' => $unescaped, 'selected' => (($selected == $unescaped) ? 'selected' : ''));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return replace_macros(get_markup_template('categories_widget.tpl'), array(
|
||||||
|
'$title' => t('Categories'),
|
||||||
|
'$desc' => '',
|
||||||
|
'$sel_all' => (($selected == '') ? 'selected' : ''),
|
||||||
|
'$all' => t('Everything'),
|
||||||
|
'$terms' => $terms,
|
||||||
|
'$base' => $baseurl,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return common friends visitor widget
|
||||||
|
*
|
||||||
|
* @param string $profile_uid uid
|
||||||
|
*/
|
||||||
|
public static function commonFriendsVisitor($profile_uid)
|
||||||
|
{
|
||||||
|
if (local_user() == $profile_uid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cid = $zcid = 0;
|
||||||
|
|
||||||
|
if (is_array($_SESSION['remote'])) {
|
||||||
|
foreach ($_SESSION['remote'] as $visitor) {
|
||||||
|
if ($visitor['uid'] == $profile_uid) {
|
||||||
|
$cid = $visitor['cid'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$cid) {
|
||||||
|
if (Profile::getMyURL()) {
|
||||||
|
$contact = dba::selectFirst('contact', ['id'],
|
||||||
|
['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $profile_uid]);
|
||||||
|
if (DBM::is_result($contact)) {
|
||||||
|
$cid = $contact['id'];
|
||||||
|
} else {
|
||||||
|
$gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
|
||||||
|
if (DBM::is_result($gcontact)) {
|
||||||
|
$zcid = $gcontact['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($cid == 0 && $zcid == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($cid) {
|
||||||
|
$t = GContact::countCommonFriends($profile_uid, $cid);
|
||||||
|
} else {
|
||||||
|
$t = GContact::countCommonFriendsZcid($profile_uid, $zcid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$t) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($cid) {
|
||||||
|
$r = GContact::commonFriends($profile_uid, $cid, 0, 5, true);
|
||||||
|
} else {
|
||||||
|
$r = GContact::commonFriendsZcid($profile_uid, $zcid, 0, 5, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
|
||||||
|
'$desc' => tt("%d contact in common", "%d contacts in common", $t),
|
||||||
|
'$base' => System::baseUrl(),
|
||||||
|
'$uid' => $profile_uid,
|
||||||
|
'$cid' => (($cid) ? $cid : '0'),
|
||||||
|
'$linkmore' => (($t > 5) ? 'true' : ''),
|
||||||
|
'$more' => t('show more'),
|
||||||
|
'$items' => $r)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Name: frio
|
* Name: frio
|
||||||
* Description: Bootstrap V3 theme. The theme is currently under construction, so it is far from finished. For further information have a look at the <a href="https://github.com/friendica/friendica/tree/develop/view/theme/frio/README.md">ReadMe</a>.
|
* Description: Bootstrap V3 theme. The theme is currently under construction, so it is far from finished. For further information have a look at the <a href="https://github.com/friendica/friendica/tree/develop/view/theme/frio/README.md">ReadMe</a>.
|
||||||
|
@ -7,8 +6,8 @@
|
||||||
* Author: Rabuzarus <https://friendica.kommune4.de/profile/rabuzarus>
|
* Author: Rabuzarus <https://friendica.kommune4.de/profile/rabuzarus>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
|
@ -315,7 +314,7 @@ function frio_acl_lookup(App $a, &$results)
|
||||||
$total = $r[0]["total"];
|
$total = $r[0]["total"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_extra3 = unavailable_networks();
|
$sql_extra3 = Widget::unavailableNetworks();
|
||||||
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `pending` $sql_extra $sql_extra3 ORDER BY `name` ASC LIMIT 100 ",
|
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `pending` $sql_extra $sql_extra3 ORDER BY `name` ASC LIMIT 100 ",
|
||||||
intval($_SESSION['uid'])
|
intval($_SESSION['uid'])
|
||||||
|
|
Loading…
Reference in a new issue