This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
forked from sjsrey/gtd-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreferences.php
217 lines (216 loc) · 9.55 KB
/
preferences.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?php
/*
======================================================================================
*/
function makeOptionsTab($array,$values,$tabname,$varprefix='',$textsize=10) {
global $checkboxes;
?>
<h2><?php echo $tabname; ?></h2>
<div class='tabsheet' id='<?php echo $tabname; ?>'>
<a id='opt<?php echo $tabname; ?>' name='opt<?php echo $tabname; ?>'></a>
<?php
log_array(array('values'=>$values,'array'=>$array));
foreach ($array as $option) {
$name=$varprefix.$option[0];
$val=(isset($values[$option[0]])) ? $values[$option[0]] : null;
echo "<div class='formrow'>\n";
$for=" for='opt$name'";
switch ($option[1]) {
case 'checkbox':
echo "<input type='checkbox' name='$name' id='opt$name' "
,($val) ? " checked='checked' ": ''
,"/>";
$checkboxes.="$name,";
break;
case 'heading':
echo '<hr />';
$for='';
break;
case 'text': // deliberately flows through
echo "<input type='text' name='$name' size='$textsize' id='opt$name' value='"
,makeclean($val)
,"' />\n";
break;
default: // it's a select
echo "<select name='$name' id='opt$name'>";
foreach ($option[1] as $optval=>$opttext)
echo "<option value='$optval'"
,($val==$optval) ? " selected='selected' ": ''
,">",makeclean($opttext),"</option>\n";
echo "</select>";
break;
}
echo "<label$for>{$option[2]}</label></div>\n";
}
?>
<div class='formbuttons'>
<input type='submit' value='Apply all sections' name='submit' />
<input type='reset' value='Reset all' name='reset' />
</div>
</div>
<?php
}
/*
======================================================================================
*/
$menu='';
require_once 'headerHtml.inc.php';
if ($_SESSION['useLiveEnhancements']) {
?>
<script>
$(document).ready(GTD.setTabs);
</script>
<?php
}
include_once 'header.inc.php';
retrieveConfig(); // force retrieval of preferences from db upon entering this screen, to avoid inter-session contamination
$checkboxes='';
// get a list of theme sub-directories, to go into the dropdown selector
$themes=array();
$dir = "./themes";
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file[0] !== "." && is_dir($dir. "/" . $file)) {
$file=makeclean($file);
$themes[$file] = $file;
}
}
closedir($handle);
}
// get a list of addons present
$addons=array();
if ($handle = opendir($_SESSION['addonsdir'])) {
while (false !== ($file = readdir($handle))) {
if ($file[0] !== "." && is_dir($_SESSION['addonsdir'] . $file)) {
$file=makeclean($file);
$addons[$file] = $file;
}
}
closedir($handle);
}
$config=$_SESSION['config'];
$hidden='';
?>
<form action="processPreferences.php" method="post" id='optionsform'>
<?php
/* ------------------------------------------------------------------------
basic options
*/
$array=array(
array('title','text','Title'),
array('trimLength','text','Maximum length of descriptions in lists of items (0=display all)'),
array('trimLengthInReport','text','Maximum length of descriptions of children in item reports (0=display all)'),
array('ReportMaxCompleteChildren','text','Maximum number of completed children of each type to display in item reports (0=display all)'),
array('theme',$themes,'Theme'),
array('firstDayOfWeek',array(0=>'Sunday',1=>'Monday',2=>'Tuesday',
3=>'Wednesday',4=>'Thursday',5=>'Friday',6=>'Saturday'
),'First day of week'),
array('contextsummary','checkbox','In the space contexts report, show only <b>next</b> actions'),
array('useLiveEnhancements','checkbox','Use Live enhancements'),
array('reviewProjectsWithoutOutcomes','checkbox','In the weekly review, identify projects without outcomes'),
array('storeRecurrences','checkbox','When recurring items are completed, store each occurrence as a completed item')
);
makeOptionsTab($array,$config,'Options');
/* ------------------------------------------------------------------------
Addons: scan for add-ons, grab auto-config file, and offer option of enabling / disabling
*/
$array=array();
foreach ($addons as $addon) {
$desc=makeclean(@file_get_contents($_SESSION['addonsdir'].$addon.'/description'));
if (!empty($desc)) $desc="($desc)";
$array[]=array($addon,'checkbox',"<b>$addon</b> $desc");
}
$live=array();
if (array_key_exists('addons',$_SESSION) && is_array($_SESSION['addons']))
foreach ($_SESSION['addons'] as $where)
if (is_array($where)) foreach ($where as $page)
if ($page) foreach ($page as $addonname=>$how)
$live[$addonname]=true;
makeOptionsTab($array,$live,'Addons','addons','50');
/* ------------------------------------------------------------------------
Default actions after creating items
*/
$array=array();
$buttonselect=array('another'=>'Create another','child'=>'Create a child','item'=>'View item','list'=>'List all','parent'=>'View parent');
foreach (getTypes() as $type=>$typename)
$array[]=array("afterCreate$type",$buttonselect,"After creating $typename");
makeOptionsTab($array,$config,'Workflow');
/* ------------------------------------------------------------------------
advanced settings
*/
$array=array(
array('datemask','text','PHP mask for date format'),
array('charset','text','PHP name of character set (codepage) to use (WARNING: UTF-8 support is experimental)'),
array('title_suffix','checkbox','Add filename to page title'),
array('radioButtonsForNextPage','checkbox','When editing an item, display choice of next page as a radio group rather than as submit buttons'),
array('useTypesForTimeContexts','checkbox','Bind each time-context to a particular item type (action, project, etc'),
array('forceAllFields','checkbox','Display all possible fields, when editing any item'),
array('allowChangingTypes','checkbox','Enable option of changing the types of <b>any</b> item (rather than just inbox items)'),
array('withholdVersionInfo','checkbox','When you file a bug report, withhold information about the versions of PHP and database software you are using'),
array('suppressAdmin','checkbox','Suppress administrator options in menus'),
array('suppressCustomRecurrences','checkbox','Suppress entry of rfc2445 text directly to specify item recurrence patterns'),
array('showTreeInSummary', 'checkbox', 'Show the tree of projects on the front page' ),
array('show7','checkbox','Show the Seven Habits of Highly Effective People and Sharpening the Saw in Weekly Review'),
array('showRelativeDeadlines','checkbox','Show deadlines as relative days (e.g. "due in 5 days") rather than as dates'),
array('separator','text','Separator string for MySQL GROUP queries'),
array('basepath','text','Base path for installation (default is: '.getAbsolutePath().')')
);
makeOptionsTab($array,$config,'Advanced','',25);
/* ------------------------------------------------------------------------
sort options
*/
$array=array(
array('categoryselectbox','text','Categories'),
array('getchildren','text','Children in item view'),
array('getitems','text','Projects and someday/maybes on the summary page'),
array('getitemsandparent','text','Lists of items and their parents'),
array('getorphaneditems','text','Orphans'),
array('spacecontextselectbox','text','Space contexts'),
array('timecontextselectbox','text','Time contexts')
);
makeOptionsTab($array,$_SESSION['sort'],'Sort','sort',50);
/* ------------------------------------------------------------------------
shortcut keys: cycle through all options in $menu, for shortcut keys
*/
$keylist=$array=array();
$mainmenu='';
$keyentry=0;
foreach ($menu as $menuitem) { // Store keyprefs against link in db.
if (empty($menuitem['link'])) { // if link is blank, then label is a main menu
if($menuitem['label']==='separator') continue;
$mainmenu=$menuitem['label'];
$array[]=array('','heading',$menuitem['label']);
continue;
}
// keys are link, title, label
$array[]=array($keyentry,'text',$menuitem['title']);
$link=$menuitem['link'];
$hidden.="<input type='hidden' name='lkeys$keyentry' value='".makeclean($link)."' />\n";
$keylist[$keyentry]=(isset($_SESSION['keys'][$link])) ? $_SESSION['keys'][$link] : null;
$keyentry++;
}
makeOptionsTab($array,$keylist,'Shortcuts','keys',1);
/* ------------------------------------------------------------------------
debug options
*/
$array=array(
array('key','text','Key to press to toggle display of detailed debugging information'),
array('notice','checkbox','Report PHP notices'),
array('debug','checkbox','Show detailed debugging information'),
array('wait','checkbox','Wait after updating an item, rather than progressing to the next screen automatically'),
array('freeze','checkbox','Suppress any changes to the gtd-php database')
);
makeOptionsTab($array,$_SESSION['debug'],'Debugging','debug',1);
/* ------------------------------------------------------------------------
finish form
*/
?>
<div class='formbuttons'>
<input type='submit' name='restoredefaults' value='Restore default preferences' />
<?php
$hidden.="<input type='hidden' name='checkboxes' value='$checkboxes' />\n";
echo $hidden;
?>
</div>
</form>
<?php include_once 'footer.inc.php'; ?>