]> git.mxchange.org Git - friendica.git/blobdiff - view/theme/frio/php/scheme.php
Happy New Year 2023!
[friendica.git] / view / theme / frio / php / scheme.php
index 538839b2c256f8623b3b66a80c7acaa0816082aa..5140f33b2c71085b191c12b13f90d01681d9325b 100644 (file)
@@ -1,7 +1,23 @@
 <?php
-
 /**
- * @brief: Get info header of the scheme
+ * @copyright Copyright (C) 2010-2023, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ * Get info header of the scheme
  *
  * This function parses the header of the schemename.php file for informations like
  * Author, Description and Overwrites. Most of the code comes from the Addon::getInfo()
  *    'version' => Scheme version
  *    'overwrites' => Variables which overwriting custom settings
  */
-use Friendica\Core\PConfig;
 
-require_once 'boot.php';
+use Friendica\DI;
+use Friendica\Util\Strings;
 
 function get_scheme_info($scheme)
 {
-       $theme = get_app()->getCurrentTheme();
+       $theme = DI::app()->getCurrentTheme();
        $themepath = 'view/theme/' . $theme . '/';
-       $scheme = PConfig::get(local_user(), 'frio', 'scheme', PConfig::get(local_user(), 'frio', 'scheme'));
+       if (empty($scheme)) {
+               $scheme = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'frio', 'scheme', DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'frio', 'schema', '---'));
+       }
+
+       $scheme = Strings::sanitizeFilePathItem($scheme);
 
        $info = [
                'name' => $scheme,
                'description' => '',
                'author' => [],
                'version' => '',
-               'overwrites' => []
+               'overwrites' => [],
+               'accented' => false,
        ];
 
-       if (!is_file($themepath . 'scheme/' . $scheme . '.php')) return $info;
+       if (!is_file($themepath . 'scheme/' . $scheme . '.php')) {
+               return $info;
+       }
 
        $f = file_get_contents($themepath . 'scheme/' . $scheme . '.php');
 
@@ -46,7 +69,11 @@ function get_scheme_info($scheme)
                foreach ($ll as $l) {
                        $l = trim($l, "\t\n\r */");
                        if ($l != '') {
-                               list($k, $v) = array_map('trim', explode(':', $l, 2));
+                               $values = array_map('trim', explode(':', $l, 2));
+                               if (count($values) < 2) {
+                                       continue;
+                               }
+                               list($k, $v) = $values;
                                $k = strtolower($k);
                                if ($k == 'author') {
                                        $r = preg_match('|([^<]+)<([^>]+)>|', $v, $m);
@@ -60,6 +87,8 @@ function get_scheme_info($scheme)
                                        foreach ($theme_settings as $key => $value) {
                                                $info['overwrites'][$value] = true;
                                        }
+                               } elseif ($k == 'accented') {
+                                       $info['accented'] = $v && $v != 'false' && $v != 'no';
                                } else {
                                        if (array_key_exists($k, $info)) {
                                                $info[$k] = $v;