Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

82 lignes
2.3 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. function theme_content(App $a) {
  11. if (!local_user()) {
  12. return;
  13. }
  14. $align = DI::pConfig()->get(local_user(), 'quattro', 'align' );
  15. $color = DI::pConfig()->get(local_user(), 'quattro', 'color' );
  16. $tfs = DI::pConfig()->get(local_user(),"quattro","tfs");
  17. $pfs = DI::pConfig()->get(local_user(),"quattro","pfs");
  18. return quattro_form($a,$align, $color, $tfs, $pfs);
  19. }
  20. function theme_post(App $a) {
  21. if (! local_user()) {
  22. return;
  23. }
  24. if (isset($_POST['quattro-settings-submit'])){
  25. DI::pConfig()->set(local_user(), 'quattro', 'align', $_POST['quattro_align']);
  26. DI::pConfig()->set(local_user(), 'quattro', 'color', $_POST['quattro_color']);
  27. DI::pConfig()->set(local_user(), 'quattro', 'tfs', $_POST['quattro_tfs']);
  28. DI::pConfig()->set(local_user(), 'quattro', 'pfs', $_POST['quattro_pfs']);
  29. }
  30. }
  31. function theme_admin(App $a) {
  32. $align = Config::get('quattro', 'align' );
  33. $color = Config::get('quattro', 'color' );
  34. $tfs = Config::get("quattro","tfs");
  35. $pfs = Config::get("quattro","pfs");
  36. return quattro_form($a,$align, $color, $tfs, $pfs);
  37. }
  38. function theme_admin_post(App $a) {
  39. if (isset($_POST['quattro-settings-submit'])){
  40. Config::set('quattro', 'align', $_POST['quattro_align']);
  41. Config::set('quattro', 'color', $_POST['quattro_color']);
  42. Config::set('quattro', 'tfs', $_POST['quattro_tfs']);
  43. Config::set('quattro', 'pfs', $_POST['quattro_pfs']);
  44. }
  45. }
  46. /// @TODO $a is no longer used here
  47. function quattro_form(App $a, $align, $color, $tfs, $pfs) {
  48. $colors = [
  49. "dark" => "Quattro",
  50. "lilac" => "Lilac",
  51. "green" => "Green",
  52. ];
  53. if ($tfs === false) {
  54. $tfs = "20";
  55. }
  56. if ($pfs === false) {
  57. $pfs = "12";
  58. }
  59. $t = Renderer::getMarkupTemplate("theme_settings.tpl" );
  60. $o = Renderer::replaceMacros($t, [
  61. '$submit' => L10n::t('Submit'),
  62. '$title' => L10n::t("Theme settings"),
  63. '$align' => ['quattro_align', L10n::t('Alignment'), $align, '', ['left' => L10n::t('Left'), 'center' => L10n::t('Center')]],
  64. '$color' => ['quattro_color', L10n::t('Color scheme'), $color, '', $colors],
  65. '$pfs' => ['quattro_pfs', L10n::t('Posts font size'), $pfs],
  66. '$tfs' => ['quattro_tfs', L10n::t('Textareas font size'), $tfs],
  67. ]);
  68. return $o;
  69. }