]> 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 e127b8c19f9e4e03da170cec394e40dda0801374..5054da3fb4fef39686958bf52c90643363df7c0a 100644 (file)
@@ -1,79 +1,92 @@
-<?php\r
-\r
-namespace Friendica\Module\Admin;\r
-\r
-use Friendica\Content\Feature;\r
-use Friendica\Core\Config;\r
-use Friendica\Core\L10n;\r
-use Friendica\Core\Logger;\r
-use Friendica\Core\Renderer;\r
-use Friendica\Module\BaseAdminModule;\r
-\r
-class Features extends BaseAdminModule\r
-{\r
-       public static function post()\r
-       {\r
-               parent::post();\r
-\r
-               parent::checkFormSecurityTokenRedirectOnError('/admin/features', 'admin_manage_features');\r
-\r
-               $features = Feature::get(false);\r
-\r
-               foreach ($features as $fname => $fdata) {\r
-                       foreach (array_slice($fdata, 1) as $f) {\r
-                               $feature = $f[0];\r
-                               $feature_state = 'feature_' . $feature;\r
-                               $featurelock = 'featurelock_' . $feature;\r
-\r
-                               if (!empty($_POST[$feature_state])) {\r
-                                       $val = intval($_POST[$feature_state]);\r
-                               } else {\r
-                                       $val = 0;\r
-                               }\r
-                               Config::set('feature', $feature, $val);\r
-\r
-                               if (!empty($_POST[$featurelock])) {\r
-                                       Config::set('feature_lock', $feature, $val);\r
-                               } else {\r
-                                       Config::delete('feature_lock', $feature);\r
-                               }\r
-                       }\r
-               }\r
-\r
-               self::getApp()->internalRedirect('admin/features');\r
-       }\r
-\r
-       public static function content()\r
-       {\r
-               parent::content();\r
-\r
-               $a = self::getApp();\r
-\r
-               if (($a->argc > 1) && ($a->getArgumentValue(1) === 'features')) {\r
-                       $arr = [];\r
-                       $features = Feature::get(false);\r
-\r
-                       foreach ($features as $fname => $fdata) {\r
-                               $arr[$fname] = [];\r
-                               $arr[$fname][0] = $fdata[0];\r
-                               foreach (array_slice($fdata, 1) as $f) {\r
-                                       $set = Config::get('feature', $f[0], $f[3]);\r
-                                       $arr[$fname][1][] = [\r
-                                               ['feature_' . $f[0], $f[1], $set, $f[2], [L10n::t('Off'), L10n::t('On')]],\r
-                                               ['featurelock_' . $f[0], L10n::t('Lock feature %s', $f[1]), (($f[4] !== false) ? "1" : ''), '', [L10n::t('Off'), L10n::t('On')]]\r
-                                       ];\r
-                               }\r
-                       }\r
-\r
-                       $tpl = Renderer::getMarkupTemplate('admin/features.tpl');\r
-                       $o = Renderer::replaceMacros($tpl, [\r
-                               '$form_security_token' => parent::getFormSecurityToken("admin_manage_features"),\r
-                               '$title' => L10n::t('Manage Additional Features'),\r
-                               '$features' => $arr,\r
-                               '$submit' => L10n::t('Save Settings'),\r
-                       ]);\r
-\r
-                       return $o;\r
-               }\r
-       }\r
-}
\ No newline at end of file
+<?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\Renderer;
+use Friendica\DI;
+use Friendica\Module\BaseAdmin;
+
+class Features extends BaseAdmin
+{
+       public static function post(array $parameters = [])
+       {
+               self::checkAdminAccess();
+
+               self::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;
+                               }
+                               DI::config()->set('feature', $feature, $val);
+
+                               if (!empty($_POST[$featurelock])) {
+                                       DI::config()->set('feature_lock', $feature, $val);
+                               } else {
+                                       DI::config()->delete('feature_lock', $feature);
+                               }
+                       }
+               }
+
+               DI::baseUrl()->redirect('admin/features');
+       }
+
+       public static function content(array $parameters = [])
+       {
+               parent::content($parameters);
+
+               $features = [];
+
+               foreach (Feature::get(false) as $fname => $fdata) {
+                       $features[$fname] = [];
+                       $features[$fname][0] = $fdata[0];
+                       foreach (array_slice($fdata, 1) as $f) {
+                               $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' => 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;
+       }
+}