]> git.mxchange.org Git - friendica.git/blob - php/schema.php
be3a3bcd9721a1e21f2e8d3806c1de2e4e063f1c
[friendica.git] / 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 function get_schema_info($schema){
22
23         $theme = current_theme();
24         $themepath = "view/theme/" . $theme . "/";
25         $schema = get_pconfig(local_user(),'frio', 'schema');
26
27         $info=Array(
28                 'name' => $schema,
29                 'description' => "",
30                 'author' => array(),
31                 'version' => "",
32                 'overwrites' => ""
33         );
34
35         if (!is_file($themepath . "schema/" . $schema . ".php")) return $info;
36
37         $f = file_get_contents($themepath . "schema/" . $schema . ".php");
38
39         $r = preg_match("|/\*.*\*/|msU", $f, $m);
40
41         if ($r){
42                 $ll = explode("\n", $m[0]);
43                 foreach( $ll as $l ) {
44                         $l = trim($l,"\t\n\r */");
45                         if ($l!=""){
46                                 list($k,$v) = array_map("trim", explode(":",$l,2));
47                                 $k= strtolower($k);
48                                 if ($k=="author"){
49                                         $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
50                                         if ($r) {
51                                                 $info['author'][] = array('name'=>$m[1], 'link'=>$m[2]);
52                                         } else {
53                                                 $info['author'][] = array('name'=>$v);
54                                         }
55                                 } elseif ($k == "overwrites") {
56                                         $theme_settings = explode(',',str_replace(' ','', $v));
57                                         foreach ($theme_settings as $key => $value) {
58                                                 $info["overwrites"][$value] = true;
59                                         }
60                                 } else {
61                                         if (array_key_exists($k,$info)){
62                                                 $info[$k]=$v;
63                                         }
64                                 }
65
66                         }
67                 }
68
69         }
70         return $info;
71 }