]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Admin/Features.php
post/thread views are renamed, search bugs fixed
[friendica.git] / src / Module / Admin / Features.php
index c9a5a9813d25d1a275966a83bafbd3b60deab9b5..5054da3fb4fef39686958bf52c90643363df7c0a 100644 (file)
@@ -1,21 +1,38 @@
 <?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
 
 namespace Friendica\Module\Admin;
 
 use Friendica\Content\Feature;
-use Friendica\Core\Config;
-use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
 use Friendica\DI;
-use Friendica\Module\BaseAdminModule;
+use Friendica\Module\BaseAdmin;
 
-class Features extends BaseAdminModule
+class Features extends BaseAdmin
 {
        public static function post(array $parameters = [])
        {
-               parent::post($parameters);
+               self::checkAdminAccess();
 
-               parent::checkFormSecurityTokenRedirectOnError('/admin/features', 'admin_manage_features');
+               self::checkFormSecurityTokenRedirectOnError('/admin/features', 'admin_manage_features');
 
                $features = Feature::get(false);
 
@@ -30,44 +47,44 @@ class Features extends BaseAdminModule
                                } else {
                                        $val = 0;
                                }
-                               Config::set('feature', $feature, $val);
+                               DI::config()->set('feature', $feature, $val);
 
                                if (!empty($_POST[$featurelock])) {
-                                       Config::set('feature_lock', $feature, $val);
+                                       DI::config()->set('feature_lock', $feature, $val);
                                } else {
-                                       Config::delete('feature_lock', $feature);
+                                       DI::config()->delete('feature_lock', $feature);
                                }
                        }
                }
 
-               DI::app()->internalRedirect('admin/features');
+               DI::baseUrl()->redirect('admin/features');
        }
 
        public static function content(array $parameters = [])
        {
                parent::content($parameters);
 
-               $arr = [];
-               $features = Feature::get(false);
+               $features = [];
 
-               foreach ($features as $fname => $fdata) {
-                       $arr[$fname] = [];
-                       $arr[$fname][0] = $fdata[0];
+               foreach (Feature::get(false) as $fname => $fdata) {
+                       $features[$fname] = [];
+                       $features[$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')]]
+                               $set = DI::config()->get('feature', $f[0], $f[3]);
+                               $features[$fname][1][] = [
+                                       ['feature_' . $f[0], $f[1], $set, $f[2]],
+                                       ['featurelock_' . $f[0], DI::l10n()->t('Lock feature %s', $f[1]), $f[4], '']
                                ];
                        }
                }
 
                $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'),
+                       '$form_security_token' => self::getFormSecurityToken("admin_manage_features"),
+                       '$baseurl'             => DI::baseUrl()->get(true),
+                       '$title'               => DI::l10n()->t('Manage Additional Features'),
+                       '$features'            => $features,
+                       '$submit'              => DI::l10n()->t('Save Settings'),
                ]);
 
                return $o;