Fix EOL and EOF in Admin modules

This commit is contained in:
Hypolite Petovan 2019-05-02 00:01:43 -04:00
parent 2a035b9b2f
commit 92b415bc36
19 changed files with 1770 additions and 1760 deletions

View file

@ -1,126 +1,126 @@
<?php
namespace Friendica\Module\Admin\Themes;
use Friendica\Content\Text\Markdown;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Theme;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings;
class Details extends BaseAdminModule
{
public static function post()
{
parent::post();
$a = self::getApp();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
$theme = $a->argv[2];
$theme = Strings::sanitizeFilePathItem($theme);
if (is_file("view/theme/$theme/config.php")) {
require_once "view/theme/$theme/config.php";
if (function_exists('theme_admin_post')) {
theme_admin_post($a);
}
}
info(L10n::t('Theme settings updated.'));
if ($a->isAjax()) {
return;
}
$a->internalRedirect('admin/themes/' . $theme);
}
}
public static function content()
{
parent::content();
$a = self::getApp();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
$theme = $a->argv[2];
$theme = Strings::sanitizeFilePathItem($theme);
if (!is_dir("view/theme/$theme")) {
notice(L10n::t("Item not found."));
return '';
}
$isEnabled = in_array($theme, Theme::getAllowedList());
if ($isEnabled) {
$status = "on";
$action = L10n::t("Disable");
} else {
$status = "off";
$action = L10n::t("Enable");
}
if (!empty($_GET['action']) && $_GET['action'] == 'toggle') {
parent::checkFormSecurityTokenRedirectOnError('/admin/themes', 'admin_themes', 't');
if ($isEnabled) {
Theme::uninstall($theme);
info(L10n::t('Theme %s disabled.', $theme));
} elseif (Theme::install($theme)) {
info(L10n::t('Theme %s successfully enabled.', $theme));
} else {
info(L10n::t('Theme %s failed to install.', $theme));
}
$a->internalRedirect('admin/themes/' . $theme);
}
$readme = null;
if (is_file("view/theme/$theme/README.md")) {
$readme = Markdown::convert(file_get_contents("view/theme/$theme/README.md"), false);
} elseif (is_file("view/theme/$theme/README")) {
$readme = "<pre>" . file_get_contents("view/theme/$theme/README") . "</pre>";
}
$admin_form = '';
if (is_file("view/theme/$theme/config.php")) {
require_once "view/theme/$theme/config.php";
if (function_exists('theme_admin')) {
$admin_form = '<iframe onload="resizeIframe(this);" src="/admin/themes/' . $theme . '/embed?mode=minimal" width="100%" height="600px" frameborder="no"></iframe>';
}
}
$screenshot = [Theme::getScreenshot($theme), L10n::t('Screenshot')];
if (!stristr($screenshot[0], $theme)) {
$screenshot = null;
}
$t = Renderer::getMarkupTemplate('admin/addons/details.tpl');
return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Themes'),
'$toggle' => L10n::t('Toggle'),
'$settings' => L10n::t('Settings'),
'$baseurl' => $a->getBaseURL(true),
'$addon' => $theme,
'$status' => $status,
'$action' => $action,
'$info' => Theme::getInfo($theme),
'$function' => 'themes',
'$admin_form' => $admin_form,
'$str_author' => L10n::t('Author: '),
'$str_maintainer' => L10n::t('Maintainer: '),
'$screenshot' => $screenshot,
'$readme' => $readme,
'$form_security_token' => parent::getFormSecurityToken("admin_themes"),
]);
}
$a->internalRedirect('admin/themes');
}
}
<?php
namespace Friendica\Module\Admin\Themes;
use Friendica\Content\Text\Markdown;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Theme;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings;
class Details extends BaseAdminModule
{
public static function post()
{
parent::post();
$a = self::getApp();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
$theme = $a->argv[2];
$theme = Strings::sanitizeFilePathItem($theme);
if (is_file("view/theme/$theme/config.php")) {
require_once "view/theme/$theme/config.php";
if (function_exists('theme_admin_post')) {
theme_admin_post($a);
}
}
info(L10n::t('Theme settings updated.'));
if ($a->isAjax()) {
return;
}
$a->internalRedirect('admin/themes/' . $theme);
}
}
public static function content()
{
parent::content();
$a = self::getApp();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
$theme = $a->argv[2];
$theme = Strings::sanitizeFilePathItem($theme);
if (!is_dir("view/theme/$theme")) {
notice(L10n::t("Item not found."));
return '';
}
$isEnabled = in_array($theme, Theme::getAllowedList());
if ($isEnabled) {
$status = "on";
$action = L10n::t("Disable");
} else {
$status = "off";
$action = L10n::t("Enable");
}
if (!empty($_GET['action']) && $_GET['action'] == 'toggle') {
parent::checkFormSecurityTokenRedirectOnError('/admin/themes', 'admin_themes', 't');
if ($isEnabled) {
Theme::uninstall($theme);
info(L10n::t('Theme %s disabled.', $theme));
} elseif (Theme::install($theme)) {
info(L10n::t('Theme %s successfully enabled.', $theme));
} else {
info(L10n::t('Theme %s failed to install.', $theme));
}
$a->internalRedirect('admin/themes/' . $theme);
}
$readme = null;
if (is_file("view/theme/$theme/README.md")) {
$readme = Markdown::convert(file_get_contents("view/theme/$theme/README.md"), false);
} elseif (is_file("view/theme/$theme/README")) {
$readme = "<pre>" . file_get_contents("view/theme/$theme/README") . "</pre>";
}
$admin_form = '';
if (is_file("view/theme/$theme/config.php")) {
require_once "view/theme/$theme/config.php";
if (function_exists('theme_admin')) {
$admin_form = '<iframe onload="resizeIframe(this);" src="/admin/themes/' . $theme . '/embed?mode=minimal" width="100%" height="600px" frameborder="no"></iframe>';
}
}
$screenshot = [Theme::getScreenshot($theme), L10n::t('Screenshot')];
if (!stristr($screenshot[0], $theme)) {
$screenshot = null;
}
$t = Renderer::getMarkupTemplate('admin/addons/details.tpl');
return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Themes'),
'$toggle' => L10n::t('Toggle'),
'$settings' => L10n::t('Settings'),
'$baseurl' => $a->getBaseURL(true),
'$addon' => $theme,
'$status' => $status,
'$action' => $action,
'$info' => Theme::getInfo($theme),
'$function' => 'themes',
'$admin_form' => $admin_form,
'$str_author' => L10n::t('Author: '),
'$str_maintainer' => L10n::t('Maintainer: '),
'$screenshot' => $screenshot,
'$readme' => $readme,
'$form_security_token' => parent::getFormSecurityToken("admin_themes"),
]);
}
$a->internalRedirect('admin/themes');
}
}

View file

@ -1,90 +1,90 @@
<?php
namespace Friendica\Module\Admin\Themes;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings;
class Embed extends BaseAdminModule
{
public static function init()
{
$a = self::getApp();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
$theme = $a->argv[2];
$theme = Strings::sanitizeFilePathItem($theme);
if (is_file("view/theme/$theme/config.php")) {
$a->setCurrentTheme($theme);
}
}
}
public static function post()
{
parent::post();
$a = self::getApp();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
$theme = $a->argv[2];
$theme = Strings::sanitizeFilePathItem($theme);
if (is_file("view/theme/$theme/config.php")) {
self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings');
require_once "view/theme/$theme/config.php";
if (function_exists('theme_admin_post')) {
theme_admin_post($a);
}
}
info(L10n::t('Theme settings updated.'));
if ($a->isAjax()) {
return;
}
$a->internalRedirect('admin/themes/' . $theme . '/embed?mode=minimal');
}
}
public static function content()
{
parent::content();
$a = self::getApp();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
$theme = $a->argv[2];
$theme = Strings::sanitizeFilePathItem($theme);
if (!is_dir("view/theme/$theme")) {
notice(L10n::t('Unknown theme.'));
return '';
}
$admin_form = '';
if (is_file("view/theme/$theme/config.php")) {
require_once "view/theme/$theme/config.php";
if (function_exists('theme_admin')) {
$admin_form = theme_admin($a);
}
}
$t = Renderer::getMarkupTemplate('admin/addons/embed.tpl');
return Renderer::replaceMacros($t, [
'$action' => '/admin/themes/' . $theme . '/embed?mode=minimal',
'$form' => $admin_form,
'$form_security_token' => parent::getFormSecurityToken("admin_theme_settings"),
]);
}
return '';
}
}
<?php
namespace Friendica\Module\Admin\Themes;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings;
class Embed extends BaseAdminModule
{
public static function init()
{
$a = self::getApp();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
$theme = $a->argv[2];
$theme = Strings::sanitizeFilePathItem($theme);
if (is_file("view/theme/$theme/config.php")) {
$a->setCurrentTheme($theme);
}
}
}
public static function post()
{
parent::post();
$a = self::getApp();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
$theme = $a->argv[2];
$theme = Strings::sanitizeFilePathItem($theme);
if (is_file("view/theme/$theme/config.php")) {
self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings');
require_once "view/theme/$theme/config.php";
if (function_exists('theme_admin_post')) {
theme_admin_post($a);
}
}
info(L10n::t('Theme settings updated.'));
if ($a->isAjax()) {
return;
}
$a->internalRedirect('admin/themes/' . $theme . '/embed?mode=minimal');
}
}
public static function content()
{
parent::content();
$a = self::getApp();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
$theme = $a->argv[2];
$theme = Strings::sanitizeFilePathItem($theme);
if (!is_dir("view/theme/$theme")) {
notice(L10n::t('Unknown theme.'));
return '';
}
$admin_form = '';
if (is_file("view/theme/$theme/config.php")) {
require_once "view/theme/$theme/config.php";
if (function_exists('theme_admin')) {
$admin_form = theme_admin($a);
}
}
$t = Renderer::getMarkupTemplate('admin/addons/embed.tpl');
return Renderer::replaceMacros($t, [
'$action' => '/admin/themes/' . $theme . '/embed?mode=minimal',
'$form' => $admin_form,
'$form_security_token' => parent::getFormSecurityToken("admin_theme_settings"),
]);
}
return '';
}
}

View file

@ -1,107 +1,107 @@
<?php
namespace Friendica\Module\Admin\Themes;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Theme;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings;
class Index extends BaseAdminModule
{
public static function content()
{
parent::content();
$a = self::getApp();
$allowed_themes = Theme::getAllowedList();
// reload active themes
if (!empty($_GET['action'])) {
parent::checkFormSecurityTokenRedirectOnError($a->getBaseURL() . '/admin/themes', 'admin_themes', 't');
switch ($_GET['action']) {
case 'reload':
foreach ($allowed_themes as $theme) {
Theme::uninstall($theme['name']);
Theme::install($theme['name']);
}
info('Themes reloaded');
break;
case 'toggle' :
$theme = defaults($_GET, 'addon', '');
if ($theme) {
$theme = Strings::sanitizeFilePathItem($theme);
if (!is_dir("view/theme/$theme")) {
notice(L10n::t('Item not found.'));
return '';
}
if (in_array($theme, Theme::getAllowedList())) {
Theme::uninstall($theme);
info(L10n::t('Theme %s disabled.', $theme));
} elseif (Theme::install($theme)) {
info(L10n::t('Theme %s successfully enabled.', $theme));
} else {
info(L10n::t('Theme %s failed to install.', $theme));
}
}
break;
}
$a->internalRedirect('admin/themes');
}
$themes = [];
$files = glob('view/theme/*');
if (is_array($files)) {
foreach ($files as $file) {
$theme = basename($file);
// Is there a style file?
$theme_files = glob('view/theme/' . $theme . '/style.*');
// If not then quit
if (count($theme_files) == 0) {
continue;
}
$is_experimental = intval(file_exists($file . '/experimental'));
$is_supported = 1 - (intval(file_exists($file . '/unsupported')));
$is_allowed = intval(in_array($theme, $allowed_themes));
if ($is_allowed || $is_supported || Config::get('system', 'show_unsupported_themes')) {
$themes[] = ['name' => $theme, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed];
}
}
}
$addons = [];
foreach ($themes as $theme) {
$addons[] = [$theme['name'], (($theme['allowed']) ? 'on' : 'off'), Theme::getInfo($theme['name'])];
}
$t = Renderer::getMarkupTemplate('admin/addons/index.tpl');
return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Themes'),
'$submit' => L10n::t('Save Settings'),
'$reload' => L10n::t('Reload active themes'),
'$baseurl' => $a->getBaseURL(true),
'$function' => 'themes',
'$addons' => $addons,
'$pcount' => count($themes),
'$noplugshint' => L10n::t('No themes found on the system. They should be placed in %1$s', '<code>/view/themes</code>'),
'$experimental' => L10n::t('[Experimental]'),
'$unsupported' => L10n::t('[Unsupported]'),
'$form_security_token' => parent::getFormSecurityToken('admin_themes'),
]);
}
}
<?php
namespace Friendica\Module\Admin\Themes;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Theme;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings;
class Index extends BaseAdminModule
{
public static function content()
{
parent::content();
$a = self::getApp();
$allowed_themes = Theme::getAllowedList();
// reload active themes
if (!empty($_GET['action'])) {
parent::checkFormSecurityTokenRedirectOnError($a->getBaseURL() . '/admin/themes', 'admin_themes', 't');
switch ($_GET['action']) {
case 'reload':
foreach ($allowed_themes as $theme) {
Theme::uninstall($theme['name']);
Theme::install($theme['name']);
}
info('Themes reloaded');
break;
case 'toggle' :
$theme = defaults($_GET, 'addon', '');
if ($theme) {
$theme = Strings::sanitizeFilePathItem($theme);
if (!is_dir("view/theme/$theme")) {
notice(L10n::t('Item not found.'));
return '';
}
if (in_array($theme, Theme::getAllowedList())) {
Theme::uninstall($theme);
info(L10n::t('Theme %s disabled.', $theme));
} elseif (Theme::install($theme)) {
info(L10n::t('Theme %s successfully enabled.', $theme));
} else {
info(L10n::t('Theme %s failed to install.', $theme));
}
}
break;
}
$a->internalRedirect('admin/themes');
}
$themes = [];
$files = glob('view/theme/*');
if (is_array($files)) {
foreach ($files as $file) {
$theme = basename($file);
// Is there a style file?
$theme_files = glob('view/theme/' . $theme . '/style.*');
// If not then quit
if (count($theme_files) == 0) {
continue;
}
$is_experimental = intval(file_exists($file . '/experimental'));
$is_supported = 1 - (intval(file_exists($file . '/unsupported')));
$is_allowed = intval(in_array($theme, $allowed_themes));
if ($is_allowed || $is_supported || Config::get('system', 'show_unsupported_themes')) {
$themes[] = ['name' => $theme, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed];
}
}
}
$addons = [];
foreach ($themes as $theme) {
$addons[] = [$theme['name'], (($theme['allowed']) ? 'on' : 'off'), Theme::getInfo($theme['name'])];
}
$t = Renderer::getMarkupTemplate('admin/addons/index.tpl');
return Renderer::replaceMacros($t, [
'$title' => L10n::t('Administration'),
'$page' => L10n::t('Themes'),
'$submit' => L10n::t('Save Settings'),
'$reload' => L10n::t('Reload active themes'),
'$baseurl' => $a->getBaseURL(true),
'$function' => 'themes',
'$addons' => $addons,
'$pcount' => count($themes),
'$noplugshint' => L10n::t('No themes found on the system. They should be placed in %1$s', '<code>/view/themes</code>'),
'$experimental' => L10n::t('[Experimental]'),
'$unsupported' => L10n::t('[Unsupported]'),
'$form_security_token' => parent::getFormSecurityToken('admin_themes'),
]);
}
}