mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-07 07:44:27 +02:00
Merge pull request #14909 from Art4/replace-addon-class-with-addonhelper
Replace Addon class with AddonHelper
This commit is contained in:
commit
38e89b152c
5 changed files with 149 additions and 115 deletions
|
@ -14,9 +14,8 @@
|
|||
* Description: "Vier" is a very compact and modern theme. It uses the font awesome font library: http://fortawesome.github.com/Font-Awesome/
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Content\GroupManager;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -35,7 +34,7 @@ function vier_init()
|
|||
$args = DI::args();
|
||||
|
||||
if (
|
||||
DI::mode()->has(App\Mode::MAINTENANCEDISABLED)
|
||||
DI::mode()->has(Mode::MAINTENANCEDISABLED)
|
||||
&& (
|
||||
$args->get(0) === 'profile' && $args->get(1) === (DI::userSession()->getLocalUserNickname() ?? '')
|
||||
|| $args->get(0) === 'network' && DI::userSession()->getLocalUserId()
|
||||
|
@ -93,7 +92,7 @@ EOT;
|
|||
// Hide the left menu bar
|
||||
/// @TODO maybe move this static array out where it should belong?
|
||||
if (empty(DI::page()['aside']) && in_array($args->get(0), ["community", "calendar", "help", "delegation", "notifications",
|
||||
"probe", "webfinger", "login", "invite", "credits"])) {
|
||||
"probe", "webfinger", "login", "invite", "credits"])) {
|
||||
DI::page()['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
|
||||
}
|
||||
}
|
||||
|
@ -117,12 +116,12 @@ function get_vier_config($key, $default = false, $admin = false)
|
|||
|
||||
function vier_community_info()
|
||||
{
|
||||
$show_pages = get_vier_config("show_pages", 1);
|
||||
$show_profiles = get_vier_config("show_profiles", 1);
|
||||
$show_helpers = get_vier_config("show_helpers", 1);
|
||||
$show_services = get_vier_config("show_services", 1);
|
||||
$show_friends = get_vier_config("show_friends", 1);
|
||||
$show_lastusers = get_vier_config("show_lastusers", 1);
|
||||
$show_pages = get_vier_config("show_pages", 1);
|
||||
$show_profiles = get_vier_config("show_profiles", 1);
|
||||
$show_helpers = get_vier_config("show_helpers", 1);
|
||||
$show_services = get_vier_config("show_services", 1);
|
||||
$show_friends = get_vier_config("show_friends", 1);
|
||||
$show_lastusers = get_vier_config("show_lastusers", 1);
|
||||
|
||||
// get_baseurl
|
||||
$aside['$url'] = $url = (string)DI::baseUrl();
|
||||
|
@ -138,10 +137,10 @@ function vier_community_info()
|
|||
|
||||
foreach ($contacts as $contact) {
|
||||
$entry = Renderer::replaceMacros($tpl, [
|
||||
'$id' => $contact['id'],
|
||||
'$id' => $contact['id'],
|
||||
'$profile_link' => 'contact/follow?url=' . urlencode($contact['url']),
|
||||
'$photo' => Contact::getMicro($contact),
|
||||
'$alt_text' => $contact['name'],
|
||||
'$photo' => Contact::getMicro($contact),
|
||||
'$alt_text' => $contact['name'],
|
||||
]);
|
||||
$aside['$community_profiles_items'][] = $entry;
|
||||
}
|
||||
|
@ -165,11 +164,11 @@ function vier_community_info()
|
|||
|
||||
foreach ($profiles as $profile) {
|
||||
$profile_link = 'profile/' . ((strlen($profile['nickname'])) ? $profile['nickname'] : $profile['uid']);
|
||||
$entry = Renderer::replaceMacros($tpl, [
|
||||
'$id' => $profile['id'],
|
||||
$entry = Renderer::replaceMacros($tpl, [
|
||||
'$id' => $profile['id'],
|
||||
'$profile_link' => $profile_link,
|
||||
'$photo' => DI::baseUrl()->remove($profile['thumb']),
|
||||
'$alt_text' => $profile['name']]);
|
||||
'$photo' => DI::baseUrl()->remove($profile['thumb']),
|
||||
'$alt_text' => $profile['name']]);
|
||||
$aside['$lastusers_items'][] = $entry;
|
||||
}
|
||||
}
|
||||
|
@ -177,18 +176,18 @@ function vier_community_info()
|
|||
|
||||
//right_aside FIND FRIENDS
|
||||
if ($show_friends && DI::userSession()->getLocalUserId()) {
|
||||
$nv = [];
|
||||
$nv['findpeople'] = DI::l10n()->t('Find People');
|
||||
$nv['desc'] = DI::l10n()->t('Enter name or interest');
|
||||
$nv['label'] = DI::l10n()->t('Connect/Follow');
|
||||
$nv['hint'] = DI::l10n()->t('Examples: Robert Morgenstein, Fishing');
|
||||
$nv['findthem'] = DI::l10n()->t('Find');
|
||||
$nv['suggest'] = DI::l10n()->t('Friend Suggestions');
|
||||
$nv['similar'] = DI::l10n()->t('Similar Interests');
|
||||
$nv['random'] = DI::l10n()->t('Random Profile');
|
||||
$nv['inv'] = DI::l10n()->t('Invite Friends');
|
||||
$nv['directory'] = DI::l10n()->t('Global Directory');
|
||||
$nv['global_dir'] = Search::getGlobalDirectory();
|
||||
$nv = [];
|
||||
$nv['findpeople'] = DI::l10n()->t('Find People');
|
||||
$nv['desc'] = DI::l10n()->t('Enter name or interest');
|
||||
$nv['label'] = DI::l10n()->t('Connect/Follow');
|
||||
$nv['hint'] = DI::l10n()->t('Examples: Robert Morgenstein, Fishing');
|
||||
$nv['findthem'] = DI::l10n()->t('Find');
|
||||
$nv['suggest'] = DI::l10n()->t('Friend Suggestions');
|
||||
$nv['similar'] = DI::l10n()->t('Similar Interests');
|
||||
$nv['random'] = DI::l10n()->t('Random Profile');
|
||||
$nv['inv'] = DI::l10n()->t('Invite Friends');
|
||||
$nv['directory'] = DI::l10n()->t('Global Directory');
|
||||
$nv['global_dir'] = Search::getGlobalDirectory();
|
||||
$nv['local_directory'] = DI::l10n()->t('Local Directory');
|
||||
|
||||
$aside['$nv'] = $nv;
|
||||
|
@ -224,14 +223,14 @@ function vier_community_info()
|
|||
$tpl = Renderer::getMarkupTemplate('ch_helpers.tpl');
|
||||
|
||||
if ($r) {
|
||||
$helpers = [];
|
||||
$helpers = [];
|
||||
$helpers['title'] = ["", DI::l10n()->t('Help'), "", ""];
|
||||
|
||||
$aside['$helpers_items'] = [];
|
||||
|
||||
foreach ($r as $rr) {
|
||||
$entry = Renderer::replaceMacros($tpl, [
|
||||
'$url' => $rr['url'],
|
||||
'$url' => $rr['url'],
|
||||
'$title' => $rr['name'],
|
||||
]);
|
||||
$aside['$helpers_items'][] = $entry;
|
||||
|
@ -244,55 +243,57 @@ function vier_community_info()
|
|||
|
||||
// connectable services
|
||||
if ($show_services) {
|
||||
$addonHelper = DI::addonHelper();
|
||||
|
||||
/// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
|
||||
$r = [];
|
||||
|
||||
if (Addon::isEnabled("buffer")) {
|
||||
if ($addonHelper->isAddonEnabled("buffer")) {
|
||||
$r[] = ["photo" => "images/buffer.png", "name" => "Buffer"];
|
||||
}
|
||||
|
||||
if (Addon::isEnabled("blogger")) {
|
||||
if ($addonHelper->isAddonEnabled("blogger")) {
|
||||
$r[] = ["photo" => "images/blogger.png", "name" => "Blogger"];
|
||||
}
|
||||
|
||||
if (Addon::isEnabled("dwpost")) {
|
||||
if ($addonHelper->isAddonEnabled("dwpost")) {
|
||||
$r[] = ["photo" => "images/dreamwidth.png", "name" => "Dreamwidth"];
|
||||
}
|
||||
|
||||
if (Addon::isEnabled("ifttt")) {
|
||||
if ($addonHelper->isAddonEnabled("ifttt")) {
|
||||
$r[] = ["photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT"];
|
||||
}
|
||||
|
||||
if (Addon::isEnabled("statusnet")) {
|
||||
if ($addonHelper->isAddonEnabled("statusnet")) {
|
||||
$r[] = ["photo" => "images/gnusocial.png", "name" => "GNU Social"];
|
||||
}
|
||||
|
||||
/// @TODO old-lost code (and below)?
|
||||
//if (Addon::isEnabled("ijpost")) {
|
||||
//if ($addonHelper->isAddonEnabled("ijpost")) {
|
||||
// $r[] = array("photo" => "images/", "name" => "");
|
||||
//}
|
||||
|
||||
if (Addon::isEnabled("libertree")) {
|
||||
if ($addonHelper->isAddonEnabled("libertree")) {
|
||||
$r[] = ["photo" => "images/libertree.png", "name" => "Libertree"];
|
||||
}
|
||||
|
||||
//if (Addon::isEnabled("ljpost")) {
|
||||
//if ($addonHelper->isAddonEnabled("ljpost")) {
|
||||
// $r[] = array("photo" => "images/", "name" => "");
|
||||
//}
|
||||
|
||||
if (Addon::isEnabled("pumpio")) {
|
||||
if ($addonHelper->isAddonEnabled("pumpio")) {
|
||||
$r[] = ["photo" => "images/pumpio.png", "name" => "pump.io"];
|
||||
}
|
||||
|
||||
if (Addon::isEnabled("tumblr")) {
|
||||
if ($addonHelper->isAddonEnabled("tumblr")) {
|
||||
$r[] = ["photo" => "images/tumblr.png", "name" => "Tumblr"];
|
||||
}
|
||||
|
||||
if (Addon::isEnabled("twitter")) {
|
||||
if ($addonHelper->isAddonEnabled("twitter")) {
|
||||
$r[] = ["photo" => "images/twitter.png", "name" => "Twitter"];
|
||||
}
|
||||
|
||||
if (Addon::isEnabled("wppost")) {
|
||||
if ($addonHelper->isAddonEnabled("wppost")) {
|
||||
$r[] = ["photo" => "images/wordpress.png", "name" => "Wordpress"];
|
||||
}
|
||||
|
||||
|
@ -303,14 +304,14 @@ function vier_community_info()
|
|||
$tpl = Renderer::getMarkupTemplate('ch_connectors.tpl');
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$con_services = [];
|
||||
$con_services['title'] = ["", DI::l10n()->t('Connect Services'), "", ""];
|
||||
$con_services = [];
|
||||
$con_services['title'] = ["", DI::l10n()->t('Connect Services'), "", ""];
|
||||
$aside['$con_services'] = $con_services;
|
||||
|
||||
foreach ($r as $rr) {
|
||||
$entry = Renderer::replaceMacros($tpl, [
|
||||
'$url' => $url,
|
||||
'$photo' => $rr['photo'],
|
||||
'$url' => $url,
|
||||
'$photo' => $rr['photo'],
|
||||
'$alt_text' => $rr['name'],
|
||||
]);
|
||||
$aside['$connector_items'][] = $entry;
|
||||
|
@ -320,7 +321,7 @@ function vier_community_info()
|
|||
//end connectable services
|
||||
|
||||
//print right_aside
|
||||
$tpl = Renderer::getMarkupTemplate('communityhome.tpl');
|
||||
$tpl = Renderer::getMarkupTemplate('communityhome.tpl');
|
||||
DI::page()['right_aside'] = Renderer::replaceMacros($tpl, $aside);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue