From 6cf6029ff5b240efa6af23223b04c9218e43ab93 Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Mon, 15 Jan 2018 09:50:06 -0500 Subject: [PATCH] Rename functions and calls Rename functions and update calls --- include/acl_selectors.php | 4 ++-- mod/contacts.php | 12 +++++----- mod/directory.php | 10 ++++---- mod/dirfind.php | 6 ++--- mod/match.php | 6 ++--- mod/network.php | 10 ++++---- mod/profile.php | 7 +++--- mod/suggest.php | 11 +++------ src/Content/Widget.php | 50 ++++++++++++++++++++++++++++++++------- view/theme/frio/theme.php | 5 ++-- 10 files changed, 73 insertions(+), 48 deletions(-) diff --git a/include/acl_selectors.php b/include/acl_selectors.php index b71173e251..a93393d80f 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -4,12 +4,12 @@ */ use Friendica\App; use Friendica\Content\Feature; +use Friendica\Content\Widget; use Friendica\Core\Config; use Friendica\Database\DBM; use Friendica\Model\Contact; use Friendica\Model\GContact; -require_once "include/contact_widgets.php"; require_once "mod/proxy.php"; /** @@ -425,7 +425,7 @@ function acl_lookup(App $a, $out_type = 'json') $group_count = 0; } - $sql_extra2 .= " ".unavailable_networks(); + $sql_extra2 .= " ".Widget::unavailableNetworks(); if ($type == '' || $type == 'c') { // autocomplete for editor mentions diff --git a/mod/contacts.php b/mod/contacts.php index 22b5b87e76..7089cf05a5 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -4,6 +4,7 @@ */ use Friendica\App; use Friendica\Content\ContactSelector; +use Friendica\Content\Widget; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBM; @@ -13,7 +14,6 @@ use Friendica\Model\Group; use Friendica\Model\Profile; use Friendica\Network\Probe; -require_once 'include/contact_widgets.php'; require_once 'mod/proxy.php'; function contacts_init(App $a) @@ -63,14 +63,14 @@ function contacts_init(App $a) $networks_widget = ''; } else { $vcard_widget = ''; - $networks_widget = networks_widget('contacts', $nets); + $networks_widget = Widget::networks('contacts', $nets); if (isset($_GET['add'])) { - $follow_widget = follow_widget($_GET['add']); + $follow_widget = Widget::follow($_GET['add']); } 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); @@ -781,7 +781,7 @@ function contacts_content(App $a) $total = $r[0]['total']; } - $sql_extra3 = unavailable_networks(); + $sql_extra3 = Widget::unavailableNetworks(); $contacts = array(); diff --git a/mod/directory.php b/mod/directory.php index 9dc08f0fbc..a711f72314 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -3,6 +3,7 @@ * @file mod/directory.php */ use Friendica\App; +use Friendica\Content\Widget; use Friendica\Core\Config; use Friendica\Database\DBM; use Friendica\Model\Contact; @@ -12,13 +13,10 @@ function directory_init(App $a) { $a->set_pager_itemspage(60); if(local_user()) { - require_once('include/contact_widgets.php'); + $a->page['aside'] .= Widget::findPeople(); - $a->page['aside'] .= findpeople_widget(); - - $a->page['aside'] .= follow_widget(); - } - else { + $a->page['aside'] .= Widget::follow(); + } else { unset($_SESSION['theme']); unset($_SESSION['mobile-theme']); } diff --git a/mod/dirfind.php b/mod/dirfind.php index 4260ce827a..9a91d0652c 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -4,6 +4,7 @@ */ use Friendica\App; use Friendica\Content\ContactSelector; +use Friendica\Content\Widget; use Friendica\Core\Config; use Friendica\Core\System; use Friendica\Core\Worker; @@ -13,7 +14,6 @@ use Friendica\Model\Profile; use Friendica\Network\Probe; use Friendica\Protocol\PortableContact; -require_once 'include/contact_widgets.php'; require_once 'mod/contacts.php'; function dirfind_init(App $a) { @@ -27,9 +27,9 @@ function dirfind_init(App $a) { $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 = "") { diff --git a/mod/match.php b/mod/match.php index 7da56bffae..9ccf5a955b 100644 --- a/mod/match.php +++ b/mod/match.php @@ -3,6 +3,7 @@ * @file mod/match.php */ use Friendica\App; +use Friendica\Content\Widget; use Friendica\Core\Config; use Friendica\Core\System; use Friendica\Database\DBM; @@ -10,7 +11,6 @@ use Friendica\Model\Contact; use Friendica\Model\Profile; require_once 'include/text.php'; -require_once 'include/contact_widgets.php'; require_once 'mod/proxy.php'; /** @@ -30,8 +30,8 @@ function match_content(App $a) return; } - $a->page['aside'] .= findpeople_widget(); - $a->page['aside'] .= follow_widget(); + $a->page['aside'] .= Widget::findPeople(); + $a->page['aside'] .= Widget::follow(); $_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd; diff --git a/mod/network.php b/mod/network.php index b9c908caaf..ef5437213e 100644 --- a/mod/network.php +++ b/mod/network.php @@ -5,6 +5,7 @@ use Friendica\App; use Friendica\Content\Feature; use Friendica\Content\ForumManager; +use Friendica\Content\Widget; use Friendica\Core\System; use Friendica\Core\Config; use Friendica\Core\PConfig; @@ -15,7 +16,6 @@ use Friendica\Model\Profile; use Friendica\Module\Login; require_once 'include/conversation.php'; -require_once 'include/contact_widgets.php'; require_once 'include/items.php'; require_once 'include/acl_selectors.php'; @@ -159,12 +159,12 @@ function network_init(App $a) { $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'] .= posted_date_widget('network',local_user(),false); - $a->page['aside'] .= networks_widget('network',(x($_GET, 'nets') ? $_GET['nets'] : '')); + $a->page['aside'] .= posted_date_widget('network', local_user(),false); + $a->page['aside'] .= Widget::networks('network', (x($_GET, 'nets') ? $_GET['nets'] : '')); $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) { diff --git a/mod/profile.php b/mod/profile.php index 59762f4790..77f8e069d3 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -3,6 +3,7 @@ * @file mod/profile.php */ use Friendica\App; +use Friendica\Content\Widget; use Friendica\Core\Config; use Friendica\Core\PConfig; use Friendica\Core\System; @@ -12,8 +13,6 @@ use Friendica\Model\Profile; use Friendica\Module\Login; use Friendica\Protocol\DFRN; -require_once 'include/contact_widgets.php'; - function profile_init(App $a) { if (!x($a->page, 'aside')) { @@ -184,7 +183,7 @@ function profile_content(App $a, $update = 0) 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) { $o .= '' . t('Tips for New Members') . '' . EOL; @@ -194,7 +193,7 @@ function profile_content(App $a, $update = 0) $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'] .= 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(); if (can_write_wall($a->profile['profile_uid'])) { diff --git a/mod/suggest.php b/mod/suggest.php index a3da9a445e..c3986e2555 100644 --- a/mod/suggest.php +++ b/mod/suggest.php @@ -4,14 +4,13 @@ */ use Friendica\App; use Friendica\Content\ContactSelector; +use Friendica\Content\Widget; use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Contact; use Friendica\Model\GContact; use Friendica\Model\Profile; -require_once 'include/contact_widgets.php'; - function suggest_init(App $a) { if (! local_user()) { return; @@ -51,10 +50,6 @@ function suggest_init(App $a) { } - - - - function suggest_content(App $a) { require_once("mod/proxy.php"); @@ -67,8 +62,8 @@ function suggest_content(App $a) { $_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd; - $a->page['aside'] .= findpeople_widget(); - $a->page['aside'] .= follow_widget(); + $a->page['aside'] .= Widget::findPeople(); + $a->page['aside'] .= Widget::follow(); $r = GContact::suggestionQuery(local_user()); diff --git a/src/Content/Widget.php b/src/Content/Widget.php index 4c7aecf95e..40579d7c4b 100644 --- a/src/Content/Widget.php +++ b/src/Content/Widget.php @@ -17,7 +17,12 @@ require_once 'boot.php'; class Widget { - function follow_widget($value = "") + /** + * 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'), @@ -28,7 +33,10 @@ class Widget )); } - function findpeople_widget() + /** + * Return Find People widget + */ + public static function findPeople() { $a = get_app(); $global_dir = Config::get('system', 'directory'); @@ -57,7 +65,10 @@ class Widget )); } - function unavailable_networks() + /** + * Return unavailable networks + */ + public static function unavailableNetworks() { $networks = array(); @@ -104,7 +115,13 @@ class Widget return $network_filter; } - function networks_widget($baseurl, $selected = '') + /** + * Return networks widget + * + * @param string $baseurl baseurl + * @param string $selected optional, default empty + */ + public static function networks($baseurl, $selected = '') { if (!local_user()) { return ''; @@ -114,7 +131,7 @@ class Widget return ''; } - $extra_sql = unavailable_networks(); + $extra_sql = self::unavailableNetworks(); $r = dba::p("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = ? AND `network` != '' $extra_sql ORDER BY `network`", local_user() @@ -143,7 +160,13 @@ class Widget )); } - function fileas_widget($baseurl, $selected = '') + /** + * Return file as widget + * + * @param string $baseurl baseurl + * @param string $selected optional, default empty + */ + public static function fileAs($baseurl, $selected = '') { if (!local_user()) { return ''; @@ -178,7 +201,13 @@ class Widget )); } - function categories_widget($baseurl, $selected = '') + /** + * Return categories widget + * + * @param string $baseurl baseurl + * @param string $selected optional, default empty + */ + public static function categories($baseurl, $selected = '') { $a = get_app(); @@ -212,7 +241,12 @@ class Widget )); } - function common_friends_visitor_widget($profile_uid) + /** + * Return common friends visitor widget + * + * @param string $profile_uid uid + */ + public static function commonFriendsVisitor($profile_uid) { if (local_user() == $profile_uid) { return; diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index b135fa0d66..18cc1aeefb 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -1,5 +1,4 @@ ReadMe. @@ -7,8 +6,8 @@ * Author: Rabuzarus * */ - use Friendica\App; +use Friendica\Content\Widget; use Friendica\Core\Config; use Friendica\Core\PConfig; use Friendica\Core\System; @@ -315,7 +314,7 @@ function frio_acl_lookup(App $a, &$results) $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 ", intval($_SESSION['uid']) -- 2.39.5