source: sandbox/filemanager/preferences.php @ 1506

Revision 1506, 5.1 KB checked in by amuller, 15 years ago (diff)

Ticket #597 - Adicionando código do filemanager compatível com expresso

Line 
1<?php
2  /**************************************************************************\
3  * eGroupWare                                                               *
4  * http://www.egroupware.org                                                *
5  * --------------------------------------------                             *
6  *  This program is free software; you can redistribute it and/or modify it *
7  *  under the terms of the GNU General Public License as published by the   *
8  *  Free Software Foundation; either version 2 of the License, or (at your  *
9  *  option) any later version.                                              *
10  \**************************************************************************/
11
12        /* $Id: preferences.php 13612 2004-02-02 04:18:17Z milosch $ */
13
14        $GLOBALS['phpgw_info']['flags'] = array(
15                'currentapp' => 'filemanager',
16                'enable_nextmatchs_class' => True,
17                'noheader' => True,
18                'nonavbar' => True
19        );
20
21        //var_dump($file_attributes);
22        include('../header.inc.php');
23        /*
24           To add an on/off preference, just add it here.  Key is internal name, value is displayed name
25        */
26        $other_checkboxes = array ("viewinnewwin" => lang("View documents in new window"), "viewonserver" => lang("View documents on server (if available)"), "viewtextplain" => lang("Unknown MIME-type defaults to text/plain when viewing"), "dotdot" => lang("Show .."), "dotfiles" => lang("Show .files"), "show_help" => lang("Show help"), "show_command_line" => lang("Show command line (EXPERIMENTAL. DANGEROUS.)"));
27
28        /*
29           To add a dropdown preferences, add it here.  Key is internal name, value key is
30           displayed name, value values are choices in the dropdown
31        */
32        $other_dropdown = array ("show_upload_boxes" => array (lang("Default number of upload fields to show"), "5", "10", "20", "30"));
33
34        if ($submit)
35        {
36                $GLOBALS['phpgw']->preferences->read_repository ();
37
38                reset ($other_checkboxes);
39                while (list ($internal, $displayed) = each ($other_checkboxes))
40                {
41                        $GLOBALS['phpgw']->preferences->add ($GLOBALS['phpgw_info']["flags"]["currentapp"], $internal, $$internal);
42                }
43
44                reset ($other_dropdown);
45                while (list ($internal, $displayed) = each ($other_dropdown))
46                {
47                        $GLOBALS['phpgw']->preferences->add ($GLOBALS['phpgw_info']["flags"]["currentapp"], $internal, $$internal);
48                }
49
50                reset ($file_attributes);
51                while (list ($internal, $displayed) = each ($file_attributes))
52                {
53                        $GLOBALS['phpgw']->preferences->add ($GLOBALS['phpgw_info']["flags"]["currentapp"], $internal, $$internal);
54                }
55
56
57                $GLOBALS['phpgw']->preferences->save_repository (True);
58     
59                Header('Location: '.$GLOBALS['phpgw']->link('/preferences/index.php'));
60                $GLOBALS['phpgw']->common->phpgw_exit();
61        }
62
63        function display_item ($field,$data)
64        {
65                global $p, $tr_color;
66
67                $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color ($tr_color);
68                $var = array (
69                        'bg_color'      =>      $tr_color,
70                        'field'         =>      $field,
71                        'data'          =>      $data
72                );
73                $p->set_var ($var);
74                $p->parse ('row', 'pref_list', True);
75        }
76
77        $GLOBALS['phpgw']->common->phpgw_header ();
78        echo parse_navbar ();
79
80        $p = CreateObject ('phpgwapi.Template', $GLOBALS['phpgw']->common->get_tpl_dir ('filemanager'));
81        $templates = array (
82                'pref'                  => 'pref.tpl',
83                'pref_colspan'  => 'pref_colspan.tpl',
84                'pref_list'             =>      'pref_list.tpl'
85        );
86        $p->set_file ($templates);
87
88        $var = array (
89                'title'                 =>      lang ('FileManager preferences'),
90                'action_url'    =>      $GLOBALS['phpgw']->link ('/' . $GLOBALS['phpgw_info']['flags']['currentapp'] . '/preferences.php'),
91                'bg_color'              =>      $GLOBALS['phpgw_info']['theme']['th_bg'],
92                'submit_lang'   =>      lang ('submit')
93        );
94       
95        $p->set_var ($var);
96        $p->set_var ('text', '&nbsp;');
97        $p->parse ('row', 'pref_colspan', True);
98
99        if ($totalerrors)
100        {
101                echo '<p><center>' . $GLOBALS['phpgw']->common->error_list($errors) . '</center>';
102        }
103
104
105        while (list ($internal, $displayed) = each ($file_attributes))
106        {
107                unset ($checked);
108                if ($GLOBALS['phpgw_info']["user"]["preferences"]["filemanager"][$internal])
109                {
110                        $checked = 1;
111                }
112
113                $str .= html_form_input ("checkbox", $internal, NULL, NULL, NULL, $checked, NULL, 1) . " $displayed" . html_break (1, NULL, 1);
114        }
115
116        display_item (lang ('Display attributes'), $str);
117
118        reset ($other_checkboxes);
119        while (list ($internal, $displayed) = each ($other_checkboxes))
120        {
121                unset ($checked);
122                if ($GLOBALS['phpgw_info']["user"]["preferences"]["filemanager"][$internal])
123                {
124                        $checked = 1;
125                }
126
127                $str = html_form_input ("checkbox", $internal, NULL, NULL, NULL, $checked, NULL, 1);
128                display_item ($displayed, $str);
129        }
130
131        reset ($other_dropdown);
132        while (list ($internal, $value_array) = each ($other_dropdown))
133        {
134                reset ($value_array);
135                unset ($options);
136                while (list ($num, $value) = each ($value_array))
137                {
138                        if ($num == 0)
139                        {
140                                $displayed = $value;
141                                continue;
142                        }
143
144                        $options .= html_form_option ($value, $value, $GLOBALS['phpgw_info']["user"]["preferences"]["filemanager"][$internal] == $value, True);
145                }
146
147                $output = html_form_select_begin ($internal, True);
148                $output .= $options;
149                $output .= html_form_select_end (True);
150
151                display_item ($displayed, $output);
152        }
153
154        $p->pparse ('out', 'pref');
155        $GLOBALS['phpgw']->common->phpgw_footer ();
156?>
Note: See TracBrowser for help on using the repository browser.