]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/php/schema.php
Issue-#3873
[friendica.git] / view / theme / frio / php / schema.php
1 <?php
2
3
4 /**
5  * @brief: Get info header of the shema
6  * 
7  * This function parses the header of the shemename.php file for inormations like
8  * Author, Description and Overwrites. Most of the code comes from the get_plugin_info()
9  * function. We use this to get the variables which get overwritten through the shema.
10  * All color variables which get overwritten through the theme have to be
11  * listed (comma seperated) in the shema header under Overwrites:
12  * This seemst not to be the best solution. We need to investigate further.
13  * 
14  * @param string $schema Name of the shema
15  * @return array With theme information
16  *    'author' => Author Name
17  *    'description' => Schema description
18  *    'version' => Schema version
19  *    'overwrites' => Variables which overwriting custom settings
20  */
21
22 use Friendica\Core\PConfig;
23
24 function get_schema_info($schema){
25
26         $theme = current_theme();
27         $themepath = "view/theme/" . $theme . "/";
28         $schema = PConfig::get(local_user(),'frio', 'schema');
29
30         $info=Array(
31                 'name' => $schema,
32                 'description' => "",
33                 'author' => array(),
34                 'version' => "",
35                 'overwrites' => ""
36         );
37
38         if (!is_file($themepath . "schema/" . $schema . ".php")) return $info;
39
40         $f = file_get_contents($themepath . "schema/" . $schema . ".php");
41
42         $r = preg_match("|/\*.*\*/|msU", $f, $m);
43
44         if ($r){
45                 $ll = explode("\n", $m[0]);
46                 foreach( $ll as $l ) {
47                         $l = trim($l,"\t\n\r */");
48                         if ($l!=""){
49                                 list($k,$v) = array_map("trim", explode(":",$l,2));
50                                 $k= strtolower($k);
51                                 if ($k=="author"){
52                                         $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
53                                         if ($r) {
54                                                 $info['author'][] = array('name'=>$m[1], 'link'=>$m[2]);
55                                         } else {
56                                                 $info['author'][] = array('name'=>$v);
57                                         }
58                                 } elseif ($k == "overwrites") {
59                                         $theme_settings = explode(',',str_replace(' ','', $v));
60                                         foreach ($theme_settings as $key => $value) {
61                                                 $info["overwrites"][$value] = true;
62                                         }
63                                 } else {
64                                         if (array_key_exists($k,$info)){
65                                                 $info[$k]=$v;
66                                         }
67                                 }
68
69                         }
70                 }
71
72         }
73         return $info;
74 }