mirror of
https://github.com/friendica/friendica
synced 2025-04-24 23:10:11 +00:00
Move admin/features to src/Module
- Add Module\Admin\Features class - Add route for admin/features - Add features admin aside menu entry - Move templates/admin/settings_features.tpl to templates/admin/features.tpl - Remove admin_page_features and admin_page_features_post from mod/admin.php
This commit is contained in:
parent
f3f055758c
commit
446cb905e4
5 changed files with 81 additions and 90 deletions
79
src/Module/Admin/Features.php
Normal file
79
src/Module/Admin/Features.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Module\Admin;
|
||||
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Module\BaseAdminModule;
|
||||
|
||||
class Features extends BaseAdminModule
|
||||
{
|
||||
public static function post()
|
||||
{
|
||||
parent::post();
|
||||
|
||||
parent::checkFormSecurityTokenRedirectOnError('/admin/features', 'admin_manage_features');
|
||||
|
||||
$features = Feature::get(false);
|
||||
|
||||
foreach ($features as $fname => $fdata) {
|
||||
foreach (array_slice($fdata, 1) as $f) {
|
||||
$feature = $f[0];
|
||||
$feature_state = 'feature_' . $feature;
|
||||
$featurelock = 'featurelock_' . $feature;
|
||||
|
||||
if (!empty($_POST[$feature_state])) {
|
||||
$val = intval($_POST[$feature_state]);
|
||||
} else {
|
||||
$val = 0;
|
||||
}
|
||||
Config::set('feature', $feature, $val);
|
||||
|
||||
if (!empty($_POST[$featurelock])) {
|
||||
Config::set('feature_lock', $feature, $val);
|
||||
} else {
|
||||
Config::delete('feature_lock', $feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self::getApp()->internalRedirect('admin/features');
|
||||
}
|
||||
|
||||
public static function content()
|
||||
{
|
||||
parent::content();
|
||||
|
||||
$a = self::getApp();
|
||||
|
||||
if (($a->argc > 1) && ($a->getArgumentValue(1) === 'features')) {
|
||||
$arr = [];
|
||||
$features = Feature::get(false);
|
||||
|
||||
foreach ($features as $fname => $fdata) {
|
||||
$arr[$fname] = [];
|
||||
$arr[$fname][0] = $fdata[0];
|
||||
foreach (array_slice($fdata, 1) as $f) {
|
||||
$set = Config::get('feature', $f[0], $f[3]);
|
||||
$arr[$fname][1][] = [
|
||||
['feature_' . $f[0], $f[1], $set, $f[2], [L10n::t('Off'), L10n::t('On')]],
|
||||
['featurelock_' . $f[0], L10n::t('Lock feature %s', $f[1]), (($f[4] !== false) ? "1" : ''), '', [L10n::t('Off'), L10n::t('On')]]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('admin/features.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$form_security_token' => parent::getFormSecurityToken("admin_manage_features"),
|
||||
'$title' => L10n::t('Manage Additional Features'),
|
||||
'$features' => $arr,
|
||||
'$submit' => L10n::t('Save Settings'),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue