Просмотр исходного кода

Fix available templates configuration and adding custom themes

Michael Kuilboer 1 год назад
Родитель
Сommit
9221629d8d
4 измененных файлов с 24 добавлено и 25 удалено
  1. 10 11
      cfg/conf.sample.php
  2. 10 10
      lib/Configuration.php
  3. 1 1
      lib/Controller.php
  4. 3 3
      tst/TemplateSwitcherTest.php

+ 10 - 11
cfg/conf.sample.php

@@ -47,6 +47,16 @@ sizelimit = 10485760
 ; a session cookie to store the choice until the browser is closed.
 ; a session cookie to store the choice until the browser is closed.
 templateselection = false
 templateselection = false
 
 
+; List of available for selection templates when "templateselection" option is enabled
+availabletemplates[] = "bootstrap"
+availabletemplates[] = "bootstrap-page"
+availabletemplates[] = "bootstrap-dark"
+availabletemplates[] = "bootstrap-dark-page"
+availabletemplates[] = "bootstrap-compact"
+availabletemplates[] = "bootstrap-compact-page"
+availabletemplates[] = "bootstrap5"
+availabletemplates[] = "page"
+
 ; set the template your installs defaults to, defaults to "bootstrap" (tpl/bootstrap.php), also
 ; set the template your installs defaults to, defaults to "bootstrap" (tpl/bootstrap.php), also
 ; available are "page" (tpl/page.php), the classic ZeroBin style and several
 ; available are "page" (tpl/page.php), the classic ZeroBin style and several
 ; bootstrap variants: "bootstrap-dark", "bootstrap-compact", "bootstrap-page",
 ; bootstrap variants: "bootstrap-dark", "bootstrap-compact", "bootstrap-page",
@@ -151,17 +161,6 @@ plaintext = "Plain Text"
 syntaxhighlighting = "Source Code"
 syntaxhighlighting = "Source Code"
 markdown = "Markdown"
 markdown = "Markdown"
 
 
-[available_templates]
-; List of available for selection templates when "templateselection" option is enabled
-bootstrap
-bootstrap-page
-bootstrap-dark
-bootstrap-dark-page
-bootstrap-compact
-bootstrap-compact-page
-bootstrap5
-page
-
 [traffic]
 [traffic]
 ; time limit between calls from the same IP address in seconds
 ; time limit between calls from the same IP address in seconds
 ; Set this to 0 to disable rate limiting.
 ; Set this to 0 to disable rate limiting.

+ 10 - 10
lib/Configuration.php

@@ -47,6 +47,16 @@ class Configuration
             'sizelimit'                => 10485760,
             'sizelimit'                => 10485760,
             'templateselection'        => false,
             'templateselection'        => false,
             'template'                 => 'bootstrap',
             'template'                 => 'bootstrap',
+            'availabletemplates'       => array(
+                'bootstrap5',
+                'bootstrap',
+                'bootstrap-page',
+                'bootstrap-dark',
+                'bootstrap-dark-page',
+                'bootstrap-compact',
+                'bootstrap-compact-page',
+                'page',
+            ),
             'info'                     => 'More information on the <a href=\'https://privatebin.info/\'>project page</a>.',
             'info'                     => 'More information on the <a href=\'https://privatebin.info/\'>project page</a>.',
             'notice'                   => '',
             'notice'                   => '',
             'languageselection'        => false,
             'languageselection'        => false,
@@ -78,16 +88,6 @@ class Configuration
             'syntaxhighlighting' => 'Source Code',
             'syntaxhighlighting' => 'Source Code',
             'markdown'           => 'Markdown',
             'markdown'           => 'Markdown',
         ),
         ),
-        'available_templates' => array(
-            'bootstrap5',
-            'bootstrap',
-            'bootstrap-page',
-            'bootstrap-dark',
-            'bootstrap-dark-page',
-            'bootstrap-compact',
-            'bootstrap-compact-page',
-            'page',
-        ),
         'traffic' => array(
         'traffic' => array(
             'limit'     => 10,
             'limit'     => 10,
             'header'    => '',
             'header'    => '',

+ 1 - 1
lib/Controller.php

@@ -210,7 +210,7 @@ class Controller
     {
     {
         $this->_conf = new Configuration;
         $this->_conf = new Configuration;
 
 
-        $templates = $this->_conf->getSection('available_templates');
+        $templates = $this->_conf->getKey('availabletemplates');
         $template  = $this->_conf->getKey('template');
         $template  = $this->_conf->getKey('template');
         TemplateSwitcher::setAvailableTemplates($templates);
         TemplateSwitcher::setAvailableTemplates($templates);
         TemplateSwitcher::setTemplateFallback($template);
         TemplateSwitcher::setTemplateFallback($template);

+ 3 - 3
tst/TemplateSwitcherTest.php

@@ -13,7 +13,7 @@ class TemplateSwitcherTest extends TestCase
         $existingTemplateFallback = 'bootstrap-dark';
         $existingTemplateFallback = 'bootstrap-dark';
         $wrongTemplateFallback    = 'bootstrap-wrong';
         $wrongTemplateFallback    = 'bootstrap-wrong';
 
 
-        TemplateSwitcher::setAvailableTemplates($conf->getSection('available_templates'));
+        TemplateSwitcher::setAvailableTemplates($conf->getKey('availabletemplates'));
         TemplateSwitcher::setTemplateFallback($existingTemplateFallback);
         TemplateSwitcher::setTemplateFallback($existingTemplateFallback);
         $this->assertEquals($existingTemplateFallback, TemplateSwitcher::getTemplate(), 'Correct template fallback');
         $this->assertEquals($existingTemplateFallback, TemplateSwitcher::getTemplate(), 'Correct template fallback');
 
 
@@ -24,7 +24,7 @@ class TemplateSwitcherTest extends TestCase
     public function testSetAvailableTemplates()
     public function testSetAvailableTemplates()
     {
     {
         $conf               = new Configuration;
         $conf               = new Configuration;
-        $availableTemplates = $conf->getSection('available_templates');
+        $availableTemplates = $conf->getKey('availabletemplates');
 
 
         TemplateSwitcher::setAvailableTemplates($availableTemplates);
         TemplateSwitcher::setAvailableTemplates($availableTemplates);
         $this->assertEquals($availableTemplates, TemplateSwitcher::getAvailableTemplates(), 'Set available templates');
         $this->assertEquals($availableTemplates, TemplateSwitcher::getAvailableTemplates(), 'Set available templates');
@@ -57,7 +57,7 @@ class TemplateSwitcherTest extends TestCase
         $existingTemplate    = 'bootstrap';
         $existingTemplate    = 'bootstrap';
         $nonExistentTemplate = 'bootstrap-wrong';
         $nonExistentTemplate = 'bootstrap-wrong';
 
 
-        TemplateSwitcher::setAvailableTemplates($conf->getSection('available_templates'));
+        TemplateSwitcher::setAvailableTemplates($conf->getKey('availabletemplates'));
 
 
         $this->assertTrue(TemplateSwitcher::isTemplateAvailable($existingTemplate), 'Existing template');
         $this->assertTrue(TemplateSwitcher::isTemplateAvailable($existingTemplate), 'Existing template');
         $this->assertFalse(TemplateSwitcher::isTemplateAvailable($nonExistentTemplate), 'Non-existent template');
         $this->assertFalse(TemplateSwitcher::isTemplateAvailable($nonExistentTemplate), 'Non-existent template');