Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

133 rivejä
4.5 KiB

  1. <?php
  2. /**
  3. * Theme settings
  4. */
  5. use Friendica\App;
  6. use Friendica\Core\Config;
  7. use Friendica\Core\L10n;
  8. use Friendica\Core\Renderer;
  9. use Friendica\DI;
  10. require_once __DIR__ . '/theme.php';
  11. function theme_content(App $a)
  12. {
  13. if (!local_user()) {
  14. return;
  15. }
  16. if (!function_exists('get_vier_config')) {
  17. return;
  18. }
  19. $style = DI::pConfig()->get(local_user(), 'vier', 'style');
  20. if ($style == "") {
  21. $style = Config::get('vier', 'style');
  22. }
  23. if ($style == "") {
  24. $style = "plus";
  25. }
  26. $show_pages = get_vier_config('show_pages', true);
  27. $show_profiles = get_vier_config('show_profiles', true);
  28. $show_helpers = get_vier_config('show_helpers', true);
  29. $show_services = get_vier_config('show_services', true);
  30. $show_friends = get_vier_config('show_friends', true);
  31. $show_lastusers = get_vier_config('show_lastusers', true);
  32. return vier_form($a,$style, $show_pages, $show_profiles, $show_helpers,
  33. $show_services, $show_friends, $show_lastusers);
  34. }
  35. function theme_post(App $a)
  36. {
  37. if (! local_user()) {
  38. return;
  39. }
  40. if (isset($_POST['vier-settings-submit'])) {
  41. DI::pConfig()->set(local_user(), 'vier', 'style', $_POST['vier_style']);
  42. DI::pConfig()->set(local_user(), 'vier', 'show_pages', $_POST['vier_show_pages']);
  43. DI::pConfig()->set(local_user(), 'vier', 'show_profiles', $_POST['vier_show_profiles']);
  44. DI::pConfig()->set(local_user(), 'vier', 'show_helpers', $_POST['vier_show_helpers']);
  45. DI::pConfig()->set(local_user(), 'vier', 'show_services', $_POST['vier_show_services']);
  46. DI::pConfig()->set(local_user(), 'vier', 'show_friends', $_POST['vier_show_friends']);
  47. DI::pConfig()->set(local_user(), 'vier', 'show_lastusers', $_POST['vier_show_lastusers']);
  48. }
  49. }
  50. function theme_admin(App $a) {
  51. if (!function_exists('get_vier_config'))
  52. return;
  53. $style = Config::get('vier', 'style');
  54. $helperlist = Config::get('vier', 'helperlist');
  55. if ($helperlist == "")
  56. $helperlist = "https://forum.friendi.ca/profile/helpers";
  57. $t = Renderer::getMarkupTemplate("theme_admin_settings.tpl");
  58. $o = Renderer::replaceMacros($t, [
  59. '$helperlist' => ['vier_helperlist', L10n::t('Comma separated list of helper forums'), $helperlist, '', ''],
  60. ]);
  61. $show_pages = get_vier_config('show_pages', true, true);
  62. $show_profiles = get_vier_config('show_profiles', true, true);
  63. $show_helpers = get_vier_config('show_helpers', true, true);
  64. $show_services = get_vier_config('show_services', true, true);
  65. $show_friends = get_vier_config('show_friends', true, true);
  66. $show_lastusers = get_vier_config('show_lastusers', true, true);
  67. $o .= vier_form($a,$style, $show_pages, $show_profiles, $show_helpers, $show_services,
  68. $show_friends, $show_lastusers);
  69. return $o;
  70. }
  71. function theme_admin_post(App $a) {
  72. if (isset($_POST['vier-settings-submit'])){
  73. Config::set('vier', 'style', $_POST['vier_style']);
  74. Config::set('vier', 'show_pages', $_POST['vier_show_pages']);
  75. Config::set('vier', 'show_profiles', $_POST['vier_show_profiles']);
  76. Config::set('vier', 'show_helpers', $_POST['vier_show_helpers']);
  77. Config::set('vier', 'show_services', $_POST['vier_show_services']);
  78. Config::set('vier', 'show_friends', $_POST['vier_show_friends']);
  79. Config::set('vier', 'show_lastusers', $_POST['vier_show_lastusers']);
  80. Config::set('vier', 'helperlist', $_POST['vier_helperlist']);
  81. }
  82. }
  83. /// @TODO $a is no longer used
  84. function vier_form(App $a, $style, $show_pages, $show_profiles, $show_helpers, $show_services, $show_friends, $show_lastusers) {
  85. $styles = [
  86. "breathe"=>"Breathe",
  87. "netcolour"=>"Coloured Networks",
  88. "dark"=>"Dark",
  89. "flat"=>"Flat",
  90. "plus"=>"Plus",
  91. "plusminus"=>"Plus Minus",
  92. "shadow"=>"Shadow"
  93. ];
  94. $show_or_not = ['0' => L10n::t("don't show"), '1' => L10n::t("show"),];
  95. $t = Renderer::getMarkupTemplate("theme_settings.tpl");
  96. $o = Renderer::replaceMacros($t, [
  97. '$submit' => L10n::t('Submit'),
  98. '$title' => L10n::t("Theme settings"),
  99. '$style' => ['vier_style', L10n::t('Set style'), $style, '', $styles],
  100. '$show_pages' => ['vier_show_pages', L10n::t('Community Pages'), $show_pages, '', $show_or_not],
  101. '$show_profiles' => ['vier_show_profiles', L10n::t('Community Profiles'), $show_profiles, '', $show_or_not],
  102. '$show_helpers' => ['vier_show_helpers', L10n::t('Help or @NewHere ?'), $show_helpers, '', $show_or_not],
  103. '$show_services' => ['vier_show_services', L10n::t('Connect Services'), $show_services, '', $show_or_not],
  104. '$show_friends' => ['vier_show_friends', L10n::t('Find Friends'), $show_friends, '', $show_or_not],
  105. '$show_lastusers' => ['vier_show_lastusers', L10n::t('Last users'), $show_lastusers, '', $show_or_not]
  106. ]);
  107. return $o;
  108. }