2016-04-28 23:49:09 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief: Get info header of the shema
|
2018-01-15 13:05:12 +00:00
|
|
|
*
|
2016-04-28 23:49:09 +00:00
|
|
|
* This function parses the header of the shemename.php file for inormations like
|
2018-01-17 18:42:40 +00:00
|
|
|
* Author, Description and Overwrites. Most of the code comes from the Addon::getInfo()
|
2016-04-28 23:49:09 +00:00
|
|
|
* function. We use this to get the variables which get overwritten through the shema.
|
|
|
|
* All color variables which get overwritten through the theme have to be
|
|
|
|
* listed (comma seperated) in the shema header under Overwrites:
|
|
|
|
* This seemst not to be the best solution. We need to investigate further.
|
2018-01-15 13:05:12 +00:00
|
|
|
*
|
2016-04-28 23:49:09 +00:00
|
|
|
* @param string $schema Name of the shema
|
|
|
|
* @return array With theme information
|
|
|
|
* 'author' => Author Name
|
|
|
|
* 'description' => Schema description
|
|
|
|
* 'version' => Schema version
|
|
|
|
* 'overwrites' => Variables which overwriting custom settings
|
|
|
|
*/
|
2017-11-07 02:22:52 +00:00
|
|
|
use Friendica\Core\PConfig;
|
|
|
|
|
2018-04-25 00:05:20 +00:00
|
|
|
function get_schema_info($schema)
|
|
|
|
{
|
2016-04-28 23:49:09 +00:00
|
|
|
$theme = current_theme();
|
2018-04-25 00:12:43 +00:00
|
|
|
$themepath = 'view/theme/' . $theme . '/';
|
2018-04-25 00:05:20 +00:00
|
|
|
$schema = PConfig::get(local_user(), 'frio', 'schema');
|
2016-04-28 23:49:09 +00:00
|
|
|
|
2018-04-25 00:05:20 +00:00
|
|
|
$info = [
|
2016-04-28 23:49:09 +00:00
|
|
|
'name' => $schema,
|
2018-04-25 00:12:43 +00:00
|
|
|
'description' => '',
|
2018-01-15 13:05:12 +00:00
|
|
|
'author' => [],
|
2018-04-25 00:12:43 +00:00
|
|
|
'version' => '',
|
2018-03-21 22:53:41 +00:00
|
|
|
'overwrites' => []
|
2018-01-15 13:05:12 +00:00
|
|
|
];
|
2016-04-28 23:49:09 +00:00
|
|
|
|
2018-04-25 00:12:43 +00:00
|
|
|
if (!is_file($themepath . 'schema/' . $schema . '.php')) return $info;
|
2016-04-28 23:49:09 +00:00
|
|
|
|
2018-04-25 00:12:43 +00:00
|
|
|
$f = file_get_contents($themepath . 'schema/' . $schema . '.php');
|
2016-04-28 23:49:09 +00:00
|
|
|
|
2018-04-25 00:12:43 +00:00
|
|
|
$r = preg_match('|/\*.*\*/|msU', $f, $m);
|
2016-04-28 23:49:09 +00:00
|
|
|
|
2018-04-25 00:05:20 +00:00
|
|
|
if ($r) {
|
2016-04-28 23:49:09 +00:00
|
|
|
$ll = explode("\n", $m[0]);
|
2018-04-25 00:05:20 +00:00
|
|
|
foreach ($ll as $l) {
|
|
|
|
$l = trim($l, "\t\n\r */");
|
2018-04-25 00:12:43 +00:00
|
|
|
if ($l != '') {
|
|
|
|
list($k, $v) = array_map('trim', explode(':', $l, 2));
|
2018-04-25 00:05:20 +00:00
|
|
|
$k = strtolower($k);
|
2018-04-25 00:12:43 +00:00
|
|
|
if ($k == 'author') {
|
|
|
|
$r = preg_match('|([^<]+)<([^>]+)>|', $v, $m);
|
2016-04-28 23:49:09 +00:00
|
|
|
if ($r) {
|
2018-04-25 00:05:20 +00:00
|
|
|
$info['author'][] = ['name' => $m[1], 'link' => $m[2]];
|
2016-04-28 23:49:09 +00:00
|
|
|
} else {
|
2018-04-25 00:05:20 +00:00
|
|
|
$info['author'][] = ['name' => $v];
|
2016-04-28 23:49:09 +00:00
|
|
|
}
|
2018-04-25 00:12:43 +00:00
|
|
|
} elseif ($k == 'overwrites') {
|
2018-04-25 00:05:20 +00:00
|
|
|
$theme_settings = explode(',', str_replace(' ', '', $v));
|
2016-04-28 23:49:09 +00:00
|
|
|
foreach ($theme_settings as $key => $value) {
|
2018-04-25 00:12:43 +00:00
|
|
|
$info['overwrites'][$value] = true;
|
2016-04-28 23:49:09 +00:00
|
|
|
}
|
|
|
|
} else {
|
2018-04-25 00:05:20 +00:00
|
|
|
if (array_key_exists($k, $info)) {
|
|
|
|
$info[$k] = $v;
|
2016-04-28 23:49:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-25 00:05:20 +00:00
|
|
|
|
2016-04-28 23:49:09 +00:00
|
|
|
return $info;
|
|
|
|
}
|