mirror of
https://github.com/friendica/friendica
synced 2025-05-17 14:24:12 +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
|
@ -7,11 +7,9 @@
|
||||||
|
|
||||||
namespace Friendica\Model;
|
namespace Friendica\Model;
|
||||||
|
|
||||||
use Friendica\Core\Addon;
|
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,13 +24,14 @@ class Nodeinfo
|
||||||
*/
|
*/
|
||||||
public static function update()
|
public static function update()
|
||||||
{
|
{
|
||||||
$config = DI::config();
|
$config = DI::config();
|
||||||
$logger = DI::logger();
|
$logger = DI::logger();
|
||||||
|
$addonHelper = DI::addonHelper();
|
||||||
|
|
||||||
// If the addon 'statistics_json' is enabled then disable it and activate nodeinfo.
|
// If the addon 'statistics_json' is enabled then disable it and activate nodeinfo.
|
||||||
if (Addon::isEnabled('statistics_json')) {
|
if ($addonHelper->isAddonEnabled('statistics_json')) {
|
||||||
$config->set('system', 'nodeinfo', true);
|
$config->set('system', 'nodeinfo', true);
|
||||||
Addon::uninstall('statistics_json');
|
$addonHelper->uninstallAddon('statistics_json');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($config->get('system', 'nodeinfo'))) {
|
if (empty($config->get('system', 'nodeinfo'))) {
|
||||||
|
@ -50,12 +49,12 @@ class Nodeinfo
|
||||||
|
|
||||||
$logger->info('user statistics - done', $userStats);
|
$logger->info('user statistics - done', $userStats);
|
||||||
|
|
||||||
$posts = DBA::count('post-thread', ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE NOT `deleted` AND `origin`)"]);
|
$posts = DBA::count('post-thread', ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE NOT `deleted` AND `origin`)"]);
|
||||||
$comments = DBA::count('post', ["NOT `deleted` AND `gravity` = ? AND `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)", Item::GRAVITY_COMMENT]);
|
$comments = DBA::count('post', ["NOT `deleted` AND `gravity` = ? AND `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)", Item::GRAVITY_COMMENT]);
|
||||||
DI::keyValue()->set('nodeinfo_local_posts', $posts);
|
DI::keyValue()->set('nodeinfo_local_posts', $posts);
|
||||||
DI::keyValue()->set('nodeinfo_local_comments', $comments);
|
DI::keyValue()->set('nodeinfo_local_comments', $comments);
|
||||||
|
|
||||||
$posts = DBA::count('post', ['deleted' => false, 'gravity' => Item::GRAVITY_COMMENT]);
|
$posts = DBA::count('post', ['deleted' => false, 'gravity' => Item::GRAVITY_COMMENT]);
|
||||||
$comments = DBA::count('post', ['deleted' => false, 'gravity' => Item::GRAVITY_COMMENT]);
|
$comments = DBA::count('post', ['deleted' => false, 'gravity' => Item::GRAVITY_COMMENT]);
|
||||||
DI::keyValue()->set('nodeinfo_total_posts', $posts);
|
DI::keyValue()->set('nodeinfo_total_posts', $posts);
|
||||||
DI::keyValue()->set('nodeinfo_total_comments', $comments);
|
DI::keyValue()->set('nodeinfo_total_comments', $comments);
|
||||||
|
@ -66,21 +65,21 @@ class Nodeinfo
|
||||||
/**
|
/**
|
||||||
* Return the supported services
|
* Return the supported services
|
||||||
*
|
*
|
||||||
* @return Object with supported services
|
* @return stdClass with supported services
|
||||||
*/
|
*/
|
||||||
public static function getUsage(bool $version2 = false)
|
public static function getUsage(bool $version2 = false): stdClass
|
||||||
{
|
{
|
||||||
$config = DI::config();
|
$config = DI::config();
|
||||||
|
|
||||||
$usage = new stdClass();
|
$usage = new stdClass();
|
||||||
$usage->users = new \stdClass;
|
$usage->users = new stdClass();
|
||||||
|
|
||||||
if (!empty($config->get('system', 'nodeinfo'))) {
|
if (!empty($config->get('system', 'nodeinfo'))) {
|
||||||
$usage->users->total = intval(DI::keyValue()->get('nodeinfo_total_users'));
|
$usage->users->total = intval(DI::keyValue()->get('nodeinfo_total_users'));
|
||||||
$usage->users->activeHalfyear = intval(DI::keyValue()->get('nodeinfo_active_users_halfyear'));
|
$usage->users->activeHalfyear = intval(DI::keyValue()->get('nodeinfo_active_users_halfyear'));
|
||||||
$usage->users->activeMonth = intval(DI::keyValue()->get('nodeinfo_active_users_monthly'));
|
$usage->users->activeMonth = intval(DI::keyValue()->get('nodeinfo_active_users_monthly'));
|
||||||
$usage->localPosts = intval(DI::keyValue()->get('nodeinfo_local_posts'));
|
$usage->localPosts = intval(DI::keyValue()->get('nodeinfo_local_posts'));
|
||||||
$usage->localComments = intval(DI::keyValue()->get('nodeinfo_local_comments'));
|
$usage->localComments = intval(DI::keyValue()->get('nodeinfo_local_comments'));
|
||||||
|
|
||||||
if ($version2) {
|
if ($version2) {
|
||||||
$usage->users->activeWeek = intval(DI::keyValue()->get('nodeinfo_active_users_weekly'));
|
$usage->users->activeWeek = intval(DI::keyValue()->get('nodeinfo_active_users_weekly'));
|
||||||
|
@ -97,45 +96,47 @@ class Nodeinfo
|
||||||
*/
|
*/
|
||||||
public static function getServices(): array
|
public static function getServices(): array
|
||||||
{
|
{
|
||||||
|
$addonHelper = DI::addonHelper();
|
||||||
|
|
||||||
$services = [
|
$services = [
|
||||||
'inbound' => [],
|
'inbound' => [],
|
||||||
'outbound' => [],
|
'outbound' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (Addon::isEnabled('bluesky')) {
|
if ($addonHelper->isAddonEnabled('bluesky')) {
|
||||||
$services['inbound'][] = 'bluesky';
|
$services['inbound'][] = 'bluesky';
|
||||||
$services['outbound'][] = 'bluesky';
|
$services['outbound'][] = 'bluesky';
|
||||||
}
|
}
|
||||||
if (Addon::isEnabled('dwpost')) {
|
if ($addonHelper->isAddonEnabled('dwpost')) {
|
||||||
$services['outbound'][] = 'dreamwidth';
|
$services['outbound'][] = 'dreamwidth';
|
||||||
}
|
}
|
||||||
if (Addon::isEnabled('statusnet')) {
|
if ($addonHelper->isAddonEnabled('statusnet')) {
|
||||||
$services['inbound'][] = 'gnusocial';
|
$services['inbound'][] = 'gnusocial';
|
||||||
$services['outbound'][] = 'gnusocial';
|
$services['outbound'][] = 'gnusocial';
|
||||||
}
|
}
|
||||||
if (Addon::isEnabled('ijpost')) {
|
if ($addonHelper->isAddonEnabled('ijpost')) {
|
||||||
$services['outbound'][] = 'insanejournal';
|
$services['outbound'][] = 'insanejournal';
|
||||||
}
|
}
|
||||||
if (Addon::isEnabled('libertree')) {
|
if ($addonHelper->isAddonEnabled('libertree')) {
|
||||||
$services['outbound'][] = 'libertree';
|
$services['outbound'][] = 'libertree';
|
||||||
}
|
}
|
||||||
if (Addon::isEnabled('ljpost')) {
|
if ($addonHelper->isAddonEnabled('ljpost')) {
|
||||||
$services['outbound'][] = 'livejournal';
|
$services['outbound'][] = 'livejournal';
|
||||||
}
|
}
|
||||||
if (Addon::isEnabled('pumpio')) {
|
if ($addonHelper->isAddonEnabled('pumpio')) {
|
||||||
$services['inbound'][] = 'pumpio';
|
$services['inbound'][] = 'pumpio';
|
||||||
$services['outbound'][] = 'pumpio';
|
$services['outbound'][] = 'pumpio';
|
||||||
}
|
}
|
||||||
|
|
||||||
$services['outbound'][] = 'smtp';
|
$services['outbound'][] = 'smtp';
|
||||||
|
|
||||||
if (Addon::isEnabled('tumblr')) {
|
if ($addonHelper->isAddonEnabled('tumblr')) {
|
||||||
$services['outbound'][] = 'tumblr';
|
$services['outbound'][] = 'tumblr';
|
||||||
}
|
}
|
||||||
if (Addon::isEnabled('twitter')) {
|
if ($addonHelper->isAddonEnabled('twitter')) {
|
||||||
$services['outbound'][] = 'twitter';
|
$services['outbound'][] = 'twitter';
|
||||||
}
|
}
|
||||||
if (Addon::isEnabled('wppost')) {
|
if ($addonHelper->isAddonEnabled('wppost')) {
|
||||||
$services['outbound'][] = 'wordpress';
|
$services['outbound'][] = 'wordpress';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,10 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\App\Arguments;
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon\AddonHelper;
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -23,13 +25,27 @@ class Statistics extends BaseModule
|
||||||
protected $config;
|
protected $config;
|
||||||
/** @var IManageKeyValuePairs */
|
/** @var IManageKeyValuePairs */
|
||||||
protected $keyValue;
|
protected $keyValue;
|
||||||
|
private AddonHelper $addonHelper;
|
||||||
|
|
||||||
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, IManageConfigValues $config, IManageKeyValuePairs $keyValue, Response $response, array $server, array $parameters = [])
|
public function __construct(
|
||||||
{
|
L10n $l10n,
|
||||||
|
BaseURL $baseUrl,
|
||||||
|
Arguments $args,
|
||||||
|
LoggerInterface $logger,
|
||||||
|
Profiler $profiler,
|
||||||
|
IManageConfigValues $config,
|
||||||
|
IManageKeyValuePairs $keyValue,
|
||||||
|
AddonHelper $addonHelper,
|
||||||
|
Response $response,
|
||||||
|
array $server,
|
||||||
|
array $parameters = []
|
||||||
|
) {
|
||||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||||
|
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->keyValue = $keyValue;
|
$this->keyValue = $keyValue;
|
||||||
|
$this->addonHelper = $addonHelper;
|
||||||
|
|
||||||
if (!$this->config->get("system", "nodeinfo")) {
|
if (!$this->config->get("system", "nodeinfo")) {
|
||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
}
|
}
|
||||||
|
@ -37,22 +53,21 @@ class Statistics extends BaseModule
|
||||||
|
|
||||||
protected function rawContent(array $request = [])
|
protected function rawContent(array $request = [])
|
||||||
{
|
{
|
||||||
$registration_open =
|
$registration_open = Register::getPolicy() !== Register::CLOSED
|
||||||
Register::getPolicy() !== Register::CLOSED
|
|
||||||
&& !$this->config->get('config', 'invitation_only');
|
&& !$this->config->get('config', 'invitation_only');
|
||||||
|
|
||||||
/// @todo mark the "service" addons and load them dynamically here
|
/// @todo mark the "service" addons and load them dynamically here
|
||||||
$services = [
|
$services = [
|
||||||
'appnet' => Addon::isEnabled('appnet'),
|
'appnet' => $this->addonHelper->isAddonEnabled('appnet'),
|
||||||
'bluesky' => Addon::isEnabled('bluesky'),
|
'bluesky' => $this->addonHelper->isAddonEnabled('bluesky'),
|
||||||
'dreamwidth' => Addon::isEnabled('dreamwidth'),
|
'dreamwidth' => $this->addonHelper->isAddonEnabled('dreamwidth'),
|
||||||
'gnusocial' => Addon::isEnabled('gnusocial'),
|
'gnusocial' => $this->addonHelper->isAddonEnabled('gnusocial'),
|
||||||
'libertree' => Addon::isEnabled('libertree'),
|
'libertree' => $this->addonHelper->isAddonEnabled('libertree'),
|
||||||
'livejournal' => Addon::isEnabled('livejournal'),
|
'livejournal' => $this->addonHelper->isAddonEnabled('livejournal'),
|
||||||
'pumpio' => Addon::isEnabled('pumpio'),
|
'pumpio' => $this->addonHelper->isAddonEnabled('pumpio'),
|
||||||
'twitter' => Addon::isEnabled('twitter'),
|
'twitter' => $this->addonHelper->isAddonEnabled('twitter'),
|
||||||
'tumblr' => Addon::isEnabled('tumblr'),
|
'tumblr' => $this->addonHelper->isAddonEnabled('tumblr'),
|
||||||
'wordpress' => Addon::isEnabled('wordpress'),
|
'wordpress' => $this->addonHelper->isAddonEnabled('wordpress'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$statistics = array_merge([
|
$statistics = array_merge([
|
||||||
|
|
|
@ -8,8 +8,10 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\App\Arguments;
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon\AddonHelper;
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -40,14 +42,28 @@ class Stats extends BaseModule
|
||||||
protected $logger;
|
protected $logger;
|
||||||
/** @var IManageKeyValuePairs */
|
/** @var IManageKeyValuePairs */
|
||||||
protected $keyValue;
|
protected $keyValue;
|
||||||
|
private AddonHelper $addonHelper;
|
||||||
|
|
||||||
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, IManageConfigValues $config, IManageKeyValuePairs $keyValue, Database $dba, Response $response, array $server, array $parameters = [])
|
public function __construct(
|
||||||
{
|
L10n $l10n,
|
||||||
|
BaseURL $baseUrl,
|
||||||
|
Arguments $args,
|
||||||
|
LoggerInterface $logger,
|
||||||
|
Profiler $profiler,
|
||||||
|
IManageConfigValues $config,
|
||||||
|
IManageKeyValuePairs $keyValue,
|
||||||
|
Database $dba,
|
||||||
|
AddonHelper $addonHelper,
|
||||||
|
Response $response,
|
||||||
|
array $server,
|
||||||
|
array $parameters = []
|
||||||
|
) {
|
||||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||||
|
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->keyValue = $keyValue;
|
$this->keyValue = $keyValue;
|
||||||
$this->dba = $dba;
|
$this->dba = $dba;
|
||||||
|
$this->addonHelper = $addonHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
|
@ -85,14 +101,14 @@ class Stats extends BaseModule
|
||||||
'datetime' => DateTimeFormat::utc($this->keyValue->get('last_worker_execution'), DateTimeFormat::JSON),
|
'datetime' => DateTimeFormat::utc($this->keyValue->get('last_worker_execution'), DateTimeFormat::JSON),
|
||||||
'timestamp' => strtotime($this->keyValue->get('last_worker_execution')),
|
'timestamp' => strtotime($this->keyValue->get('last_worker_execution')),
|
||||||
],
|
],
|
||||||
'jpm' => [
|
'jpm' => [
|
||||||
1 => $this->dba->count('workerqueue', ["`done` AND `executed` > ?", DateTimeFormat::utc('now - 1 minute')]),
|
1 => $this->dba->count('workerqueue', ["`done` AND `executed` > ?", DateTimeFormat::utc('now - 1 minute')]),
|
||||||
3 => round($this->dba->count('workerqueue', ["`done` AND `executed` > ?", DateTimeFormat::utc('now - 3 minute')]) / 3),
|
3 => round($this->dba->count('workerqueue', ["`done` AND `executed` > ?", DateTimeFormat::utc('now - 3 minute')]) / 3),
|
||||||
5 => round($this->dba->count('workerqueue', ["`done` AND `executed` > ?", DateTimeFormat::utc('now - 5 minute')]) / 5),
|
5 => round($this->dba->count('workerqueue', ["`done` AND `executed` > ?", DateTimeFormat::utc('now - 5 minute')]) / 5),
|
||||||
],
|
],
|
||||||
'active' => [],
|
'active' => [],
|
||||||
'deferred' => [],
|
'deferred' => [],
|
||||||
'total' => [],
|
'total' => [],
|
||||||
],
|
],
|
||||||
'jetstream' => [
|
'jetstream' => [
|
||||||
'drift' => intval($this->keyValue->get('jetstream_drift')),
|
'drift' => intval($this->keyValue->get('jetstream_drift')),
|
||||||
|
@ -145,14 +161,14 @@ class Stats extends BaseModule
|
||||||
'closed' => $this->dba->count('report', ['status' => Report::STATUS_CLOSED]),
|
'closed' => $this->dba->count('report', ['status' => Report::STATUS_CLOSED]),
|
||||||
],
|
],
|
||||||
'update' => [
|
'update' => [
|
||||||
'available' => Update::isAvailable(),
|
'available' => Update::isAvailable(),
|
||||||
'available_version' => Update::getAvailableVersion(),
|
'available_version' => Update::getAvailableVersion(),
|
||||||
'status' => Update::getStatus(),
|
'status' => Update::getStatus(),
|
||||||
'db_status' => DBStructure::getUpdateStatus(),
|
'db_status' => DBStructure::getUpdateStatus(),
|
||||||
],
|
],
|
||||||
'server' => [
|
'server' => [
|
||||||
'version' => App::VERSION,
|
'version' => App::VERSION,
|
||||||
'php' => [
|
'php' => [
|
||||||
'version' => phpversion(),
|
'version' => phpversion(),
|
||||||
'upload_max_filesize' => ini_get('upload_max_filesize'),
|
'upload_max_filesize' => ini_get('upload_max_filesize'),
|
||||||
'post_max_size' => ini_get('post_max_size'),
|
'post_max_size' => ini_get('post_max_size'),
|
||||||
|
@ -164,12 +180,12 @@ class Stats extends BaseModule
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (Addon::isEnabled('bluesky')) {
|
if ($this->addonHelper->isAddonEnabled('bluesky')) {
|
||||||
$statistics['packets']['inbound'][Protocol::BLUESKY] = intval($this->keyValue->get('stats_packets_inbound_' . Protocol::BLUESKY) ?? 0);
|
$statistics['packets']['inbound'][Protocol::BLUESKY] = intval($this->keyValue->get('stats_packets_inbound_' . Protocol::BLUESKY) ?? 0);
|
||||||
$statistics['packets']['outbound'][Protocol::BLUESKY] = intval($this->keyValue->get('stats_packets_outbound_' . Protocol::BLUESKY) ?? 0);
|
$statistics['packets']['outbound'][Protocol::BLUESKY] = intval($this->keyValue->get('stats_packets_outbound_' . Protocol::BLUESKY) ?? 0);
|
||||||
}
|
}
|
||||||
if (Addon::isEnabled('tumblr')) {
|
if ($this->addonHelper->isAddonEnabled('tumblr')) {
|
||||||
$statistics['packets']['inbound'][Protocol::TUMBLR] = intval($this->keyValue->get('stats_packets_inbound_' . Protocol::TUMBLR) ?? 0);
|
$statistics['packets']['inbound'][Protocol::TUMBLR] = intval($this->keyValue->get('stats_packets_inbound_' . Protocol::TUMBLR) ?? 0);
|
||||||
$statistics['packets']['outbound'][Protocol::TUMBLR] = intval($this->keyValue->get('stats_packets_outbound_' . Protocol::TUMBLR) ?? 0);
|
$statistics['packets']['outbound'][Protocol::TUMBLR] = intval($this->keyValue->get('stats_packets_outbound_' . Protocol::TUMBLR) ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +218,7 @@ class Stats extends BaseModule
|
||||||
|
|
||||||
$jobs = $this->dba->p("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` WHERE NOT `done` AND `retrial` = ? GROUP BY `priority`", 0);
|
$jobs = $this->dba->p("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` WHERE NOT `done` AND `retrial` = ? GROUP BY `priority`", 0);
|
||||||
while ($entry = $this->dba->fetch($jobs)) {
|
while ($entry = $this->dba->fetch($jobs)) {
|
||||||
$running = $this->dba->count('workerqueue-view', ['priority' => $entry['priority']]);
|
$running = $this->dba->count('workerqueue-view', ['priority' => $entry['priority']]);
|
||||||
$statistics['worker']['active']['total'] += $running;
|
$statistics['worker']['active']['total'] += $running;
|
||||||
$statistics['worker']['active'][$entry['priority']] = $running;
|
$statistics['worker']['active'][$entry['priority']] = $running;
|
||||||
$statistics['worker']['total']['total'] += $entry['entries'];
|
$statistics['worker']['total']['total'] += $entry['entries'];
|
||||||
|
|
|
@ -9,7 +9,6 @@ namespace Friendica\Object;
|
||||||
|
|
||||||
use Friendica\Content\ContactSelector;
|
use Friendica\Content\ContactSelector;
|
||||||
use Friendica\Content\Feature;
|
use Friendica\Content\Feature;
|
||||||
use Friendica\Core\Addon;
|
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -1118,12 +1117,14 @@ class Post
|
||||||
$conv = $this->getThread();
|
$conv = $this->getThread();
|
||||||
|
|
||||||
if ($conv->isWritable() && $this->isWritable()) {
|
if ($conv->isWritable() && $this->isWritable()) {
|
||||||
|
$addonHelper = DI::addonHelper();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hmmm, code depending on the presence of a particular addon?
|
* Hmmm, code depending on the presence of a particular addon?
|
||||||
* This should be better if done by a hook
|
* This should be better if done by a hook
|
||||||
*/
|
*/
|
||||||
$qcomment = null;
|
$qcomment = null;
|
||||||
if (Addon::isEnabled('qcomment')) {
|
if ($addonHelper->isAddonEnabled('qcomment')) {
|
||||||
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
|
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
|
||||||
$qcomment = $words ? explode("\n", $words) : [];
|
$qcomment = $words ? explode("\n", $words) : [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -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/
|
* 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\Content\GroupManager;
|
||||||
use Friendica\Core\Addon;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Search;
|
use Friendica\Core\Search;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
@ -35,7 +34,7 @@ function vier_init()
|
||||||
$args = DI::args();
|
$args = DI::args();
|
||||||
|
|
||||||
if (
|
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) === 'profile' && $args->get(1) === (DI::userSession()->getLocalUserNickname() ?? '')
|
||||||
|| $args->get(0) === 'network' && DI::userSession()->getLocalUserId()
|
|| $args->get(0) === 'network' && DI::userSession()->getLocalUserId()
|
||||||
|
@ -93,7 +92,7 @@ EOT;
|
||||||
// Hide the left menu bar
|
// Hide the left menu bar
|
||||||
/// @TODO maybe move this static array out where it should belong?
|
/// @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",
|
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' />";
|
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()
|
function vier_community_info()
|
||||||
{
|
{
|
||||||
$show_pages = get_vier_config("show_pages", 1);
|
$show_pages = get_vier_config("show_pages", 1);
|
||||||
$show_profiles = get_vier_config("show_profiles", 1);
|
$show_profiles = get_vier_config("show_profiles", 1);
|
||||||
$show_helpers = get_vier_config("show_helpers", 1);
|
$show_helpers = get_vier_config("show_helpers", 1);
|
||||||
$show_services = get_vier_config("show_services", 1);
|
$show_services = get_vier_config("show_services", 1);
|
||||||
$show_friends = get_vier_config("show_friends", 1);
|
$show_friends = get_vier_config("show_friends", 1);
|
||||||
$show_lastusers = get_vier_config("show_lastusers", 1);
|
$show_lastusers = get_vier_config("show_lastusers", 1);
|
||||||
|
|
||||||
// get_baseurl
|
// get_baseurl
|
||||||
$aside['$url'] = $url = (string)DI::baseUrl();
|
$aside['$url'] = $url = (string)DI::baseUrl();
|
||||||
|
@ -138,10 +137,10 @@ function vier_community_info()
|
||||||
|
|
||||||
foreach ($contacts as $contact) {
|
foreach ($contacts as $contact) {
|
||||||
$entry = Renderer::replaceMacros($tpl, [
|
$entry = Renderer::replaceMacros($tpl, [
|
||||||
'$id' => $contact['id'],
|
'$id' => $contact['id'],
|
||||||
'$profile_link' => 'contact/follow?url=' . urlencode($contact['url']),
|
'$profile_link' => 'contact/follow?url=' . urlencode($contact['url']),
|
||||||
'$photo' => Contact::getMicro($contact),
|
'$photo' => Contact::getMicro($contact),
|
||||||
'$alt_text' => $contact['name'],
|
'$alt_text' => $contact['name'],
|
||||||
]);
|
]);
|
||||||
$aside['$community_profiles_items'][] = $entry;
|
$aside['$community_profiles_items'][] = $entry;
|
||||||
}
|
}
|
||||||
|
@ -165,11 +164,11 @@ function vier_community_info()
|
||||||
|
|
||||||
foreach ($profiles as $profile) {
|
foreach ($profiles as $profile) {
|
||||||
$profile_link = 'profile/' . ((strlen($profile['nickname'])) ? $profile['nickname'] : $profile['uid']);
|
$profile_link = 'profile/' . ((strlen($profile['nickname'])) ? $profile['nickname'] : $profile['uid']);
|
||||||
$entry = Renderer::replaceMacros($tpl, [
|
$entry = Renderer::replaceMacros($tpl, [
|
||||||
'$id' => $profile['id'],
|
'$id' => $profile['id'],
|
||||||
'$profile_link' => $profile_link,
|
'$profile_link' => $profile_link,
|
||||||
'$photo' => DI::baseUrl()->remove($profile['thumb']),
|
'$photo' => DI::baseUrl()->remove($profile['thumb']),
|
||||||
'$alt_text' => $profile['name']]);
|
'$alt_text' => $profile['name']]);
|
||||||
$aside['$lastusers_items'][] = $entry;
|
$aside['$lastusers_items'][] = $entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,18 +176,18 @@ function vier_community_info()
|
||||||
|
|
||||||
//right_aside FIND FRIENDS
|
//right_aside FIND FRIENDS
|
||||||
if ($show_friends && DI::userSession()->getLocalUserId()) {
|
if ($show_friends && DI::userSession()->getLocalUserId()) {
|
||||||
$nv = [];
|
$nv = [];
|
||||||
$nv['findpeople'] = DI::l10n()->t('Find People');
|
$nv['findpeople'] = DI::l10n()->t('Find People');
|
||||||
$nv['desc'] = DI::l10n()->t('Enter name or interest');
|
$nv['desc'] = DI::l10n()->t('Enter name or interest');
|
||||||
$nv['label'] = DI::l10n()->t('Connect/Follow');
|
$nv['label'] = DI::l10n()->t('Connect/Follow');
|
||||||
$nv['hint'] = DI::l10n()->t('Examples: Robert Morgenstein, Fishing');
|
$nv['hint'] = DI::l10n()->t('Examples: Robert Morgenstein, Fishing');
|
||||||
$nv['findthem'] = DI::l10n()->t('Find');
|
$nv['findthem'] = DI::l10n()->t('Find');
|
||||||
$nv['suggest'] = DI::l10n()->t('Friend Suggestions');
|
$nv['suggest'] = DI::l10n()->t('Friend Suggestions');
|
||||||
$nv['similar'] = DI::l10n()->t('Similar Interests');
|
$nv['similar'] = DI::l10n()->t('Similar Interests');
|
||||||
$nv['random'] = DI::l10n()->t('Random Profile');
|
$nv['random'] = DI::l10n()->t('Random Profile');
|
||||||
$nv['inv'] = DI::l10n()->t('Invite Friends');
|
$nv['inv'] = DI::l10n()->t('Invite Friends');
|
||||||
$nv['directory'] = DI::l10n()->t('Global Directory');
|
$nv['directory'] = DI::l10n()->t('Global Directory');
|
||||||
$nv['global_dir'] = Search::getGlobalDirectory();
|
$nv['global_dir'] = Search::getGlobalDirectory();
|
||||||
$nv['local_directory'] = DI::l10n()->t('Local Directory');
|
$nv['local_directory'] = DI::l10n()->t('Local Directory');
|
||||||
|
|
||||||
$aside['$nv'] = $nv;
|
$aside['$nv'] = $nv;
|
||||||
|
@ -224,14 +223,14 @@ function vier_community_info()
|
||||||
$tpl = Renderer::getMarkupTemplate('ch_helpers.tpl');
|
$tpl = Renderer::getMarkupTemplate('ch_helpers.tpl');
|
||||||
|
|
||||||
if ($r) {
|
if ($r) {
|
||||||
$helpers = [];
|
$helpers = [];
|
||||||
$helpers['title'] = ["", DI::l10n()->t('Help'), "", ""];
|
$helpers['title'] = ["", DI::l10n()->t('Help'), "", ""];
|
||||||
|
|
||||||
$aside['$helpers_items'] = [];
|
$aside['$helpers_items'] = [];
|
||||||
|
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$entry = Renderer::replaceMacros($tpl, [
|
$entry = Renderer::replaceMacros($tpl, [
|
||||||
'$url' => $rr['url'],
|
'$url' => $rr['url'],
|
||||||
'$title' => $rr['name'],
|
'$title' => $rr['name'],
|
||||||
]);
|
]);
|
||||||
$aside['$helpers_items'][] = $entry;
|
$aside['$helpers_items'][] = $entry;
|
||||||
|
@ -244,55 +243,57 @@ function vier_community_info()
|
||||||
|
|
||||||
// connectable services
|
// connectable services
|
||||||
if ($show_services) {
|
if ($show_services) {
|
||||||
|
$addonHelper = DI::addonHelper();
|
||||||
|
|
||||||
/// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
|
/// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
|
||||||
$r = [];
|
$r = [];
|
||||||
|
|
||||||
if (Addon::isEnabled("buffer")) {
|
if ($addonHelper->isAddonEnabled("buffer")) {
|
||||||
$r[] = ["photo" => "images/buffer.png", "name" => "Buffer"];
|
$r[] = ["photo" => "images/buffer.png", "name" => "Buffer"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Addon::isEnabled("blogger")) {
|
if ($addonHelper->isAddonEnabled("blogger")) {
|
||||||
$r[] = ["photo" => "images/blogger.png", "name" => "Blogger"];
|
$r[] = ["photo" => "images/blogger.png", "name" => "Blogger"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Addon::isEnabled("dwpost")) {
|
if ($addonHelper->isAddonEnabled("dwpost")) {
|
||||||
$r[] = ["photo" => "images/dreamwidth.png", "name" => "Dreamwidth"];
|
$r[] = ["photo" => "images/dreamwidth.png", "name" => "Dreamwidth"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Addon::isEnabled("ifttt")) {
|
if ($addonHelper->isAddonEnabled("ifttt")) {
|
||||||
$r[] = ["photo" => "addon/ifttt/ifttt.png", "name" => "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"];
|
$r[] = ["photo" => "images/gnusocial.png", "name" => "GNU Social"];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @TODO old-lost code (and below)?
|
/// @TODO old-lost code (and below)?
|
||||||
//if (Addon::isEnabled("ijpost")) {
|
//if ($addonHelper->isAddonEnabled("ijpost")) {
|
||||||
// $r[] = array("photo" => "images/", "name" => "");
|
// $r[] = array("photo" => "images/", "name" => "");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (Addon::isEnabled("libertree")) {
|
if ($addonHelper->isAddonEnabled("libertree")) {
|
||||||
$r[] = ["photo" => "images/libertree.png", "name" => "Libertree"];
|
$r[] = ["photo" => "images/libertree.png", "name" => "Libertree"];
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (Addon::isEnabled("ljpost")) {
|
//if ($addonHelper->isAddonEnabled("ljpost")) {
|
||||||
// $r[] = array("photo" => "images/", "name" => "");
|
// $r[] = array("photo" => "images/", "name" => "");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (Addon::isEnabled("pumpio")) {
|
if ($addonHelper->isAddonEnabled("pumpio")) {
|
||||||
$r[] = ["photo" => "images/pumpio.png", "name" => "pump.io"];
|
$r[] = ["photo" => "images/pumpio.png", "name" => "pump.io"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Addon::isEnabled("tumblr")) {
|
if ($addonHelper->isAddonEnabled("tumblr")) {
|
||||||
$r[] = ["photo" => "images/tumblr.png", "name" => "Tumblr"];
|
$r[] = ["photo" => "images/tumblr.png", "name" => "Tumblr"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Addon::isEnabled("twitter")) {
|
if ($addonHelper->isAddonEnabled("twitter")) {
|
||||||
$r[] = ["photo" => "images/twitter.png", "name" => "Twitter"];
|
$r[] = ["photo" => "images/twitter.png", "name" => "Twitter"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Addon::isEnabled("wppost")) {
|
if ($addonHelper->isAddonEnabled("wppost")) {
|
||||||
$r[] = ["photo" => "images/wordpress.png", "name" => "Wordpress"];
|
$r[] = ["photo" => "images/wordpress.png", "name" => "Wordpress"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,14 +304,14 @@ function vier_community_info()
|
||||||
$tpl = Renderer::getMarkupTemplate('ch_connectors.tpl');
|
$tpl = Renderer::getMarkupTemplate('ch_connectors.tpl');
|
||||||
|
|
||||||
if (DBA::isResult($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$con_services = [];
|
$con_services = [];
|
||||||
$con_services['title'] = ["", DI::l10n()->t('Connect Services'), "", ""];
|
$con_services['title'] = ["", DI::l10n()->t('Connect Services'), "", ""];
|
||||||
$aside['$con_services'] = $con_services;
|
$aside['$con_services'] = $con_services;
|
||||||
|
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$entry = Renderer::replaceMacros($tpl, [
|
$entry = Renderer::replaceMacros($tpl, [
|
||||||
'$url' => $url,
|
'$url' => $url,
|
||||||
'$photo' => $rr['photo'],
|
'$photo' => $rr['photo'],
|
||||||
'$alt_text' => $rr['name'],
|
'$alt_text' => $rr['name'],
|
||||||
]);
|
]);
|
||||||
$aside['$connector_items'][] = $entry;
|
$aside['$connector_items'][] = $entry;
|
||||||
|
@ -320,7 +321,7 @@ function vier_community_info()
|
||||||
//end connectable services
|
//end connectable services
|
||||||
|
|
||||||
//print right_aside
|
//print right_aside
|
||||||
$tpl = Renderer::getMarkupTemplate('communityhome.tpl');
|
$tpl = Renderer::getMarkupTemplate('communityhome.tpl');
|
||||||
DI::page()['right_aside'] = Renderer::replaceMacros($tpl, $aside);
|
DI::page()['right_aside'] = Renderer::replaceMacros($tpl, $aside);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue