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.
 
 
 
 
 
 

153 rivejä
7.7 KiB

  1. <?php
  2. use Friendica\App;
  3. use Friendica\Core\Config;
  4. use Friendica\Core\L10n;
  5. use Friendica\Core\Renderer;
  6. use Friendica\DI;
  7. require_once 'view/theme/frio/php/Image.php';
  8. function theme_post(App $a)
  9. {
  10. if (!local_user()) {
  11. return;
  12. }
  13. if (isset($_POST['frio-settings-submit'])) {
  14. DI::pConfig()->set(local_user(), 'frio', 'scheme', $_POST['frio_scheme'] ?? '');
  15. DI::pConfig()->set(local_user(), 'frio', 'nav_bg', $_POST['frio_nav_bg'] ?? '');
  16. DI::pConfig()->set(local_user(), 'frio', 'nav_icon_color', $_POST['frio_nav_icon_color'] ?? '');
  17. DI::pConfig()->set(local_user(), 'frio', 'link_color', $_POST['frio_link_color'] ?? '');
  18. DI::pConfig()->set(local_user(), 'frio', 'background_color', $_POST['frio_background_color'] ?? '');
  19. DI::pConfig()->set(local_user(), 'frio', 'contentbg_transp', $_POST['frio_contentbg_transp'] ?? '');
  20. DI::pConfig()->set(local_user(), 'frio', 'background_image', $_POST['frio_background_image'] ?? '');
  21. DI::pConfig()->set(local_user(), 'frio', 'bg_image_option', $_POST['frio_bg_image_option'] ?? '');
  22. DI::pConfig()->set(local_user(), 'frio', 'css_modified', time());
  23. DI::pConfig()->set(local_user(), 'frio', 'enable_compose', $_POST['frio_enable_compose'] ?? 0);
  24. }
  25. }
  26. function theme_admin_post(App $a)
  27. {
  28. if (!is_site_admin()) {
  29. return;
  30. }
  31. if (isset($_POST['frio-settings-submit'])) {
  32. Config::set('frio', 'scheme', $_POST['frio_scheme'] ?? '');
  33. Config::set('frio', 'nav_bg', $_POST['frio_nav_bg'] ?? '');
  34. Config::set('frio', 'nav_icon_color', $_POST['frio_nav_icon_color'] ?? '');
  35. Config::set('frio', 'link_color', $_POST['frio_link_color'] ?? '');
  36. Config::set('frio', 'background_color', $_POST['frio_background_color'] ?? '');
  37. Config::set('frio', 'contentbg_transp', $_POST['frio_contentbg_transp'] ?? '');
  38. Config::set('frio', 'background_image', $_POST['frio_background_image'] ?? '');
  39. Config::set('frio', 'bg_image_option', $_POST['frio_bg_image_option'] ?? '');
  40. Config::set('frio', 'login_bg_image', $_POST['frio_login_bg_image'] ?? '');
  41. Config::set('frio', 'login_bg_color', $_POST['frio_login_bg_color'] ?? '');
  42. Config::set('frio', 'css_modified', time());
  43. Config::set('frio', 'enable_compose', $_POST['frio_enable_compose'] ?? 0);
  44. }
  45. }
  46. function theme_content(App $a)
  47. {
  48. if (!local_user()) {
  49. return;
  50. }
  51. $arr = [];
  52. $node_scheme = Config::get('frio', 'scheme', Config::get('frio', 'scheme'));
  53. $arr['scheme'] = DI::pConfig()->get(local_user(), 'frio', 'scheme', DI::pConfig()->get(local_user(), 'frio', 'schema', $node_scheme));
  54. $arr['share_string'] = '';
  55. $arr['nav_bg'] = DI::pConfig()->get(local_user(), 'frio', 'nav_bg' , Config::get('frio', 'nav_bg'));
  56. $arr['nav_icon_color'] = DI::pConfig()->get(local_user(), 'frio', 'nav_icon_color' , Config::get('frio', 'nav_icon_color'));
  57. $arr['link_color'] = DI::pConfig()->get(local_user(), 'frio', 'link_color' , Config::get('frio', 'link_color'));
  58. $arr['background_color'] = DI::pConfig()->get(local_user(), 'frio', 'background_color', Config::get('frio', 'background_color'));
  59. $arr['contentbg_transp'] = DI::pConfig()->get(local_user(), 'frio', 'contentbg_transp', Config::get('frio', 'contentbg_transp'));
  60. $arr['background_image'] = DI::pConfig()->get(local_user(), 'frio', 'background_image', Config::get('frio', 'background_image'));
  61. $arr['bg_image_option'] = DI::pConfig()->get(local_user(), 'frio', 'bg_image_option' , Config::get('frio', 'bg_image_option'));
  62. $arr['enable_compose'] = DI::pConfig()->get(local_user(), 'frio', 'enable_compose' , Config::get('frio', 'enable_compose'));
  63. return frio_form($arr);
  64. }
  65. function theme_admin(App $a)
  66. {
  67. if (!local_user()) {
  68. return;
  69. }
  70. $arr = [];
  71. $arr['scheme'] = Config::get('frio', 'scheme', Config::get('frio', 'schema'));
  72. $arr['share_string'] = '';
  73. $arr['nav_bg'] = Config::get('frio', 'nav_bg');
  74. $arr['nav_icon_color'] = Config::get('frio', 'nav_icon_color');
  75. $arr['link_color'] = Config::get('frio', 'link_color');
  76. $arr['background_color'] = Config::get('frio', 'background_color');
  77. $arr['contentbg_transp'] = Config::get('frio', 'contentbg_transp');
  78. $arr['background_image'] = Config::get('frio', 'background_image');
  79. $arr['bg_image_option'] = Config::get('frio', 'bg_image_option');
  80. $arr['login_bg_image'] = Config::get('frio', 'login_bg_image');
  81. $arr['login_bg_color'] = Config::get('frio', 'login_bg_color');
  82. $arr['enable_compose'] = Config::get('frio', 'enable_compose');
  83. return frio_form($arr);
  84. }
  85. function frio_form($arr)
  86. {
  87. require_once 'view/theme/frio/php/scheme.php';
  88. $scheme_info = get_scheme_info($arr['scheme']);
  89. $disable = $scheme_info['overwrites'];
  90. if (!is_array($disable)) {
  91. $disable = [];
  92. }
  93. $scheme_choices = [];
  94. $scheme_choices['---'] = L10n::t('Custom');
  95. $files = glob('view/theme/frio/scheme/*.php');
  96. if ($files) {
  97. foreach ($files as $file) {
  98. $f = basename($file, '.php');
  99. if ($f != 'default') {
  100. $scheme_name = ucfirst($f);
  101. $scheme_choices[$f] = $scheme_name;
  102. }
  103. }
  104. }
  105. $background_image_help = '<strong>' . L10n::t('Note') . ': </strong>' . L10n::t('Check image permissions if all users are allowed to see the image');
  106. $t = Renderer::getMarkupTemplate('theme_settings.tpl');
  107. $ctx = [
  108. '$submit' => L10n::t('Submit'),
  109. '$title' => L10n::t('Theme settings'),
  110. '$scheme' => ['frio_scheme', L10n::t('Select color scheme'), $arr['scheme'], '', $scheme_choices],
  111. '$share_string' => ['frio_share_string', L10n::t('Copy or paste schemestring'), $arr['share_string'], L10n::t('You can copy this string to share your theme with others. Pasting here applies the schemestring'), false, false],
  112. '$nav_bg' => array_key_exists('nav_bg', $disable) ? '' : ['frio_nav_bg', L10n::t('Navigation bar background color'), $arr['nav_bg'], '', false],
  113. '$nav_icon_color' => array_key_exists('nav_icon_color', $disable) ? '' : ['frio_nav_icon_color', L10n::t('Navigation bar icon color '), $arr['nav_icon_color'], '', false],
  114. '$link_color' => array_key_exists('link_color', $disable) ? '' : ['frio_link_color', L10n::t('Link color'), $arr['link_color'], '', false],
  115. '$background_color' => array_key_exists('background_color', $disable) ? '' : ['frio_background_color', L10n::t('Set the background color'), $arr['background_color'], '', false],
  116. '$contentbg_transp' => array_key_exists('contentbg_transp', $disable) ? '' : ['frio_contentbg_transp', L10n::t('Content background opacity'), ($arr['contentbg_transp'] ?? 0) ?: 100, ''],
  117. '$background_image' => array_key_exists('background_image', $disable) ? '' : ['frio_background_image', L10n::t('Set the background image'), $arr['background_image'], $background_image_help, false],
  118. '$bg_image_options_title' => L10n::t('Background image style'),
  119. '$bg_image_options' => Image::get_options($arr),
  120. '$enable_compose' => ['frio_enable_compose', L10n::t('Enable Compose page'), $arr['enable_compose'], L10n::t('This replaces the jot modal window for writing new posts with a link to <a href="compose">the new Compose page</a>.')],
  121. ];
  122. if (array_key_exists('login_bg_image', $arr) && !array_key_exists('login_bg_image', $disable)) {
  123. $ctx['$login_bg_image'] = ['frio_login_bg_image', L10n::t('Login page background image'), $arr['login_bg_image'], $background_image_help, false];
  124. }
  125. if (array_key_exists('login_bg_color', $arr) && !array_key_exists('login_bg_color', $disable)) {
  126. $ctx['$login_bg_color'] = ['frio_login_bg_color', L10n::t('Login page background color'), $arr['login_bg_color'], L10n::t('Leave background image and color empty for theme defaults'), false];
  127. }
  128. $o = Renderer::replaceMacros($t, $ctx);
  129. return $o;
  130. }