3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 * Get info header of the scheme
22 * This function parses the header of the schemename.php file for informations like
23 * Author, Description and Overwrites. Most of the code comes from the Addon::getInfo()
24 * function. We use this to get the variables which get overwritten through the scheme.
25 * All color variables which get overwritten through the theme have to be
26 * listed (comma separated) in the scheme header under Overwrites:
27 * This seems not to be the best solution. We need to investigate further.
29 * @param string $scheme Name of the scheme
30 * @return array With theme information
31 * 'author' => Author Name
32 * 'description' => Scheme description
33 * 'version' => Scheme version
34 * 'overwrites' => Variables which overwriting custom settings
38 use Friendica\Util\Strings;
40 function get_scheme_info($scheme)
42 $theme = DI::app()->getCurrentTheme();
43 $themepath = 'view/theme/' . $theme . '/';
45 $scheme = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'frio', 'scheme', DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'frio', 'schema', '---'));
48 $scheme = Strings::sanitizeFilePathItem($scheme);
59 if (!is_file($themepath . 'scheme/' . $scheme . '.php')) {
63 $f = file_get_contents($themepath . 'scheme/' . $scheme . '.php');
65 $r = preg_match('|/\*.*\*/|msU', $f, $m);
68 $ll = explode("\n", $m[0]);
70 $l = trim($l, "\t\n\r */");
72 $values = array_map('trim', explode(':', $l, 2));
73 if (count($values) < 2) {
76 list($k, $v) = $values;
79 $r = preg_match('|([^<]+)<([^>]+)>|', $v, $m);
81 $info['author'][] = ['name' => $m[1], 'link' => $m[2]];
83 $info['author'][] = ['name' => $v];
85 } elseif ($k == 'overwrites') {
86 $theme_settings = explode(',', str_replace(' ', '', $v));
87 foreach ($theme_settings as $key => $value) {
88 $info['overwrites'][$value] = true;
90 } elseif ($k == 'accented') {
91 $info['accented'] = $v && $v != 'false' && $v != 'no';
93 if (array_key_exists($k, $info)) {