]> git.mxchange.org Git - friendica.git/blob - view/theme/dispy/config.php
Implement Smarty3
[friendica.git] / view / theme / dispy / config.php
1 <?php
2 /**
3  * Theme settings
4  */
5
6 function theme_content(&$a) {
7         if(!local_user()) { return;     }
8
9         $font_size = get_pconfig(local_user(),'dispy', 'font_size' );
10         $line_height = get_pconfig(local_user(), 'dispy', 'line_height' );
11         $colour = get_pconfig(local_user(), 'dispy', 'colour' );
12         
13         return dispy_form($a, $font_size, $line_height, $colour);
14 }
15
16 function theme_post(&$a) {
17         if(!local_user()) { return; }
18         
19         if (isset($_POST['dispy-settings-submit'])) {
20                 set_pconfig(local_user(), 'dispy', 'font_size', $_POST['dispy_font_size']);
21                 set_pconfig(local_user(), 'dispy', 'line_height', $_POST['dispy_line_height']);
22                 set_pconfig(local_user(), 'dispy', 'colour', $_POST['dispy_colour']);   
23         }
24 }
25
26 function theme_admin(&$a) {
27         $font_size = get_config('dispy', 'font_size' );
28         $line_height = get_config('dispy', 'line_height' );
29         $colour = get_config('dispy', 'colour' );       
30         
31         return dispy_form($a, $font_size, $line_height, $colour);
32 }
33
34 function theme_admin_post(&$a) {
35         if (isset($_POST['dispy-settings-submit'])) {
36                 set_config('dispy', 'font_size', $_POST['dispy_font_size']);
37                 set_config('dispy', 'line_height', $_POST['dispy_line_height']);
38                 set_config('dispy', 'colour', $_POST['dispy_colour']);
39         }
40 }
41
42 function dispy_form(&$a, $font_size, $line_height, $colour) {
43         $line_heights = array(
44                 "1.3" => "1.3",
45                 "---" => "---",
46                 "1.6" => "1.6",                         
47                 "1.5" => "1.5",         
48                 "1.4" => "1.4",
49                 "1.2" => "1.2",
50                 "1.1" => "1.1",
51         );      
52         $font_sizes = array(
53                 '12' => '12',
54                 '14' => '14',
55                 "---" => "---",
56                 "16" => "16",           
57                 "15" => "15",
58                 '13.5' => '13.5',
59                 '13' => '13',           
60                 '12.5' => '12.5',
61                 '12' => '12',
62         );
63         $colours = array(
64                 'light' => 'light',             
65                 'dark' => 'dark',                                               
66         );
67
68         //$t = file_get_contents( dirname(__file__). "/theme_settings.tpl" );
69         $t = get_markup_template("theme_settings.tpl" );
70
71         $includes = array(
72                 '$field_select' => 'field_select.tpl',
73         );
74         $includes = set_template_includes($a->theme['template_engine'], $includes);
75
76         $o .= replace_macros($t, $includes + array(
77                 '$submit' => t('Submit'),
78                 '$baseurl' => $a->get_baseurl(),
79                 '$title' => t("Theme settings"),
80                 '$font_size' => array('dispy_font_size', t('Set font-size for posts and comments'), $font_size, '', $font_sizes),
81                 '$line_height' => array('dispy_line_height', t('Set line-height for posts and comments'), $line_height, '', $line_heights),
82                 '$colour' => array('dispy_colour', t('Set colour scheme'), $colour, '', $colours),      
83         ));
84
85         return $o;
86 }