Indefero

Indefero Commit Details


Date:2011-05-09 06:52:09 (13 years 7 months ago)
Author:Thomas Keller
Branch:develop, feature-issue_links, feature.content-md5, feature.diff-whitespace, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:9171bfd1abea5e00aea6a440c88919b3c31012a0
Parents: be4774c95cee73f69c783a64dec0a97733ebd993
Message:Start with issue 638 (issue links); nothing workable yet.

Changes:

File differences

src/IDF/Form/Admin/ProjectCreate.php
319319
320320
321321
322
322323
323324
324325
'labels_issue_closed' => IDF_Form_IssueTrackingConf::init_closed,
'labels_issue_predefined' => IDF_Form_IssueTrackingConf::init_predefined,
'labels_issue_one_max' => IDF_Form_IssueTrackingConf::init_one_max,
'issue_relations' => IDF_Form_IssueTrackingConf::init_relations,
'webhook_url' => '',
'downloads_access_rights' => 'all',
'review_access_rights' => 'all',
src/IDF/Form/IssueCreate.php
7676
7777
7878
79
79
8080
8181
8282
83
83
8484
8585
8686
......
109109
110110
111111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
112127
113128
114129
......
181196
182197
183198
184
199
185200
186201
187202
......
215230
216231
217232
218
233
219234
220235
221
236
222237
223238
224239
// case of someone allowing the upload path to be accessible
// to everybody.
for ($i=1;$i<4;$i++) {
$filename = substr($md5, 0, 2).'/'.substr($md5, 2, 2).'/'.substr($md5, 4).'/%s.dummy';
$filename = substr($md5, 0, 2).'/'.substr($md5, 2, 2).'/'.substr($md5, 4).'/%s.dummy';
$this->fields['attachment'.$i] = new Pluf_Form_Field_File(
array('required' => false,
'label' => __('Attach a file'),
'move_function_params' =>
'move_function_params' =>
array('upload_path' => $upload_path,
'upload_path_create' => true,
'file_name' => $filename,
),
));
$relation_types = $extra['project']->getRelationsFromConfig();
$this->fields['relation_type'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('This issue'),
'initial' => $relation_types[0],
'widget_attrs' => array('size' => 15),
));
$this->fields['relation_issue'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => null,
'initial' => '',
'widget_attrs' => array('size' => 10),
));
/*
* get predefined tags for issues from current project
*
$this->cleaned_data['label'.$i] = trim($this->cleaned_data['label'.$i]);
if (strpos($this->cleaned_data['label'.$i], ':') !== false) {
list($class, $name) = explode(':', $this->cleaned_data['label'.$i], 2);
list($class, $name) = array(mb_strtolower(trim($class)),
list($class, $name) = array(mb_strtolower(trim($class)),
trim($name));
} else {
$class = 'other';
function clean_status()
{
// Check that the status is in the list of official status
$tags = $this->project->getTagsFromConfig('labels_issue_open',
$tags = $this->project->getTagsFromConfig('labels_issue_open',
IDF_Form_IssueTrackingConf::init_open,
'Status');
$tags = array_merge($this->project->getTagsFromConfig('labels_issue_closed',
$tags = array_merge($this->project->getTagsFromConfig('labels_issue_closed',
IDF_Form_IssueTrackingConf::init_closed,
'Status')
, $tags);
src/IDF/Form/IssueTrackingConf.php
7272
7373
7474
75
76
77
7578
7679
7780
......
114117
115118
116119
117
120
118121
119122
120123
124
125
126
127
128
129
130
131
132
121133
122134
123135
Usability = Affects program usability
Maintainability = Hinders future changes';
const init_one_max = 'Type, Priority, Milestone';
const init_relations = 'is related to
blocks, is blocked by
duplicates, is duplicated by';
public function initFields($extra=array())
{
$this->fields['labels_issue_one_max'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('Each issue may have at most one label with each of these classes'),
'initial' => self::init_one_max,
'initial' => self::init_one_max,
'widget_attrs' => array('size' => 60),
));
$this->fields['issue_relations'] = new Pluf_Form_Field_Varchar(
array('required' => true,
'label' => __('Issue relations'),
'initial' => self::init_relations,
'help_text' => __('You can define bidirectional relations like "is related to" or "blocks, is blocked by".'),
'widget_attrs' => array('rows' => 7,
'cols' => 75),
'widget' => 'Pluf_Form_Widget_TextareaInput',
));
}
}
src/IDF/Project.php
234234
235235
236236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
237253
238254
239255
}
/**
* Returns a list of relations which are available in this project
*
* @return array List of relation names
*/
public function getRelationsFromConfig()
{
$conf = $this->getConf();
$rel = $conf->getVal('issue_relations', IDF_Form_IssueTrackingConf::init_relations);
$relations = array();
foreach (preg_split("/\015\012|\015|\012/", $rel, -1, PREG_SPLIT_NO_EMPTY) as $s) {
$relations = array_merge($relations, preg_split("/\s*,\s*/", $s, 2));
}
return $relations;
}
/**
* Return membership data.
*
* The array has 3 keys: 'members', 'owners' and 'authorized'.
src/IDF/Views/Issue.php
9090
9191
9292
93
93
9494
9595
9696
9797
9898
9999
100
100
101101
102
102
103103
104104
105105
106106
107107
108
108
109109
110110
111111
112112
113113
114
115
114
115
116116
117117
118118
119119
120120
121
121
122122
123
123
124124
125125
126126
......
170170
171171
172172
173
173
174174
175175
176
176
177177
178178
179179
180180
181181
182182
183
183
184184
185185
186186
......
194194
195195
196196
197
198
197
198
199199
200200
201201
202202
203203
204
204
205205
206
206
207207
208208
209209
......
453453
454454
455455
456
456
457457
458458
459459
......
644644
645645
646646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
647676
648677
649678
......
715744
716745
717746
747
748
749
750
751
752
753
754
755
718756
719757
720758
$ctags = $prj->getTagIdsByStatus('closed');
if (count($otags) == 0) $otags[] = 0;
if (count($ctags) == 0) $ctags[] = 0;
// Get the id list of issue in the user watch list (for all projects !)
$db =& Pluf::db();
$sql_results = $db->select('SELECT idf_issue_id as id FROM '.Pluf::f('db_table_prefix', '').'idf_issue_pluf_user_assoc WHERE pluf_user_id='.$request->user->id);
$issue_ids = array(0);
foreach ($sql_results as $id) {
$issue_ids[] = $id['id'];
}
}
$issue_ids = implode (',', $issue_ids);
// Count open and close issues
$sql = new Pluf_SQL('project=%s AND id IN ('.$issue_ids.') AND status IN ('.implode(', ', $otags).')', array($prj->id));
$nb_open = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
$sql = new Pluf_SQL('project=%s AND id IN ('.$issue_ids.') AND status IN ('.implode(', ', $ctags).')', array($prj->id));
$nb_closed = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
// Generate a filter for the paginator
switch ($match[2]) {
case 'closed':
$title = sprintf(__('Watch List: Closed Issues for %s'), (string) $prj);
$summary = __('This table shows the closed issues in your watch list for %s project.', (string) $prj);
$f_sql = new Pluf_SQL('project=%s AND id IN ('.$issue_ids.') AND status IN ('.implode(', ', $ctags).')', array($prj->id));
break;
$f_sql = new Pluf_SQL('project=%s AND id IN ('.$issue_ids.') AND status IN ('.implode(', ', $ctags).')', array($prj->id));
break;
case 'open':
default:
$title = sprintf(__('Watch List: Open Issues for %s'), (string) $prj);
$summary = __('This table shows the open issues in your watch list for %s project.', (string) $prj);
$f_sql = new Pluf_SQL('project=%s AND id IN ('.$issue_ids.') AND status IN ('.implode(', ', $otags).')', array($prj->id));
break;
break;
}
// Paginator to paginate the issues
$pag = new Pluf_Paginator(new IDF_Issue());
$pag->class = 'recent-issues';
}
foreach (IDF_Views::getProjects($request->user) as $project) {
$ctags = array_merge($ctags, $project->getTagIdsByStatus('closed'));
}
}
if (count($otags) == 0) $otags[] = 0;
if (count($ctags) == 0) $ctags[] = 0;
// Get the id list of issue in the user watch list (for all projects !)
$db =& Pluf::db();
$sql_results = $db->select('SELECT idf_issue_id as id FROM '.Pluf::f('db_table_prefix', '').'idf_issue_pluf_user_assoc WHERE pluf_user_id='.$request->user->id);
$issue_ids = array(0);
foreach ($sql_results as $id) {
$issue_ids[] = $id['id'];
}
}
$issue_ids = implode (',', $issue_ids);
// Count open and close issues
case 'closed':
$title = sprintf(__('Watch List: Closed Issues'));
$summary = __('This table shows the closed issues in your watch list.');
$f_sql = new Pluf_SQL('id IN ('.$issue_ids.') AND status IN ('.implode(', ', $ctags).')', array());
break;
$f_sql = new Pluf_SQL('id IN ('.$issue_ids.') AND status IN ('.implode(', ', $ctags).')', array());
break;
case 'open':
default:
$title = sprintf(__('Watch List: Open Issues'));
$summary = __('This table shows the open issues in your watch list.');
$f_sql = new Pluf_SQL('id IN ('.$issue_ids.') AND status IN ('.implode(', ', $otags).')', array());
break;
break;
}
// Paginator to paginate the issues
$pag = new Pluf_Paginator(new IDF_Issue());
$pag->class = 'recent-issues';
$next_issue = Pluf::factory('IDF_Issue')->getList(array('filter' => $sql_next->gen(),
'order' => 'id ASC',
'nb' => 1
));
));
$previous_issue_id = (isset($previous_issue[0])) ? $previous_issue[0]->id : 0;
$next_issue_id = (isset($next_issue[0])) ? $next_issue[0]->id : 0;
}
/**
* Renders a JSON string containing completed issue information
* based on the queried / partial string
*/
public $autoCompleteIssueList_precond = array('IDF_Precondition::accessIssues');
public function autoCompleteIssueList($request, $match)
{
$prj = $request->project;
// Autocomplete from jQuery UI works with JSON, this old one still
// expects a parsable string; since we'd need to bump jQuery beyond
// 1.2.6 for this to use as well, we're trying to cope with the old format.
// see http://www.learningjquery.com/2010/06/autocomplete-migration-guide
$arr = array(
'Fo|o' => 110,
'Bar' => 111,
'Baz' => 112,
);
$out = '';
foreach ($arr as $key => $val)
{
$out .= str_replace('|', '&#124;', $key).'|'.$val."\n";
}
return new Pluf_HTTP_Response($out);
}
/**
* Star/Unstar an issue.
*/
public $star_precond = array('IDF_Precondition::accessIssues',
}
$auto['auto_owner'] = substr($auto['auto_owner'], 0, -2);
unset($auto['_auto_owner']);
// Get issue relations
$r = $project->getRelationsFromConfig();
$auto['auto_relation_types'] = '';
foreach ($r as $rt) {
$esc = Pluf_esc($rt);
$auto['auto_relation_types'] .= sprintf('{ name: "%s", to: "%s" }, ',
$esc, $esc);
}
$auto['auto_relation_types'] = substr($auto['auto_relation_types'], 0, -2);
return $auto;
}
}
src/IDF/Views/Project.php
3838
3939
4040
41
41
4242
4343
4444
4545
4646
47
47
4848
4949
5050
5151
52
52
5353
5454
5555
......
291291
292292
293293
294
295
294
295
296296
297297
298298
299
299
300300
301301
302302
......
305305
306306
307307
308
308
309309
310
310
311311
312312
313313
......
316316
317317
318318
319
319
320320
321321
322322
......
344344
345345
346346
347
347
348
348349
349350
350351
public function logo($request, $match)
{
$prj = $request->project;
$logo = $prj->getConf()->getVal('logo');
if (empty($logo)) {
$url = Pluf::f('url_media') . '/idf/img/no_logo.png';
return new Pluf_HTTP_Response_Redirect($url);
}
$info = IDF_FileUtil::getMimeType($logo);
return new Pluf_HTTP_Response_File(Pluf::f('upload_path') . '/' . $prj->shortname . $logo,
$info[0]);
}
/**
* Home page of a project.
*/
public function admin($request, $match)
{
$prj = $request->project;
$title = sprintf(__('%s Project Summary'), (string) $prj);
$extra = array('project' => $prj);
$title = sprintf(__('%s Project Summary'), (string) $prj);
$extra = array('project' => $prj);
if ($request->method == 'POST') {
$form = new IDF_Form_ProjectConf(array_merge($request->POST,
$request->FILES),
$extra);
$extra);
if ($form->isValid()) {
$form->save();
$request->user->setMessage(__('The project has been updated.'));
return new Pluf_HTTP_Response_Redirect($url);
}
} else {
$form = new IDF_Form_ProjectConf($prj->getData(), $extra);
$form = new IDF_Form_ProjectConf($prj->getData(), $extra);
}
$logo = $prj->getConf()->getVal('logo');
return Pluf_Shortcuts_RenderToResponse('idf/admin/summary.html',
array(
'project' => $prj,
'logo' => $logo,
),
$request);
$request);
}
/**
$params = array();
$keys = array('labels_issue_template',
'labels_issue_open', 'labels_issue_closed',
'labels_issue_predefined', 'labels_issue_one_max');
'labels_issue_predefined', 'labels_issue_one_max',
'issue_relations');
foreach ($keys as $key) {
$_val = $conf->getVal($key, false);
if ($_val !== false) {
src/IDF/conf/urls.php
7373
7474
7575
76
76
7777
7878
7979
......
173173
174174
175175
176
177
178
179
180
176181
177182
178183
'base' => $base,
'model' => 'IDF_Views_Project',
'method' => 'home');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/logo/$#',
'base' => $base,
'model' => 'IDF_Views_Project',
'model' => 'IDF_Views_Issue',
'method' => 'forgeWatchList');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/issues/autocomplete/$#',
'base' => $base,
'model' => 'IDF_Views_Issue',
'method' => 'autoCompleteIssueList');
// ---------- SCM ----------------------------------------
$ctl[] = array('regex' => '#^/p/([\-\w]+)/source/help/$#',
src/IDF/templates/idf/admin/issue-tracking.html
3535
3636
3737
38
39
40
41
42
43
44
3845
39
46
4047
4148
4249
</td>
</tr>
<tr>
<td colspan="2"><strong>{$form.f.issue_relations.labelTag}:</strong><br />
{if $form.f.issue_relations.errors}{$form.f.issue_relations.fieldErrors}{/if}
{$form.f.issue_relations|unsafe}<br />
<span class="helptext">{$form.f.issue_relations.help_text}</span>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="{trans 'Save Changes'}" name="submit" />
<input type="submit" value="{trans 'Save Changes'}" name="submit" />
</td>
</tr>
</table>
src/IDF/templates/idf/issues/create.html
6363
6464
6565
66
67
68
69
70
71
72
73
74
6675
6776
6877
......
7685
7786
7887
79
80
88
89
8190
8291
8392
......
123132
124133
125134
126
127
128
129
130
135
136
137
138
139
131140
132141
133142
</td>
</tr>
<tr>
<th>{$form.f.relation_type.labelTag}:</th>
<td>
{if $form.f.relation_type.errors}{$form.f.relation_type.fieldErrors}{/if}
{if $form.f.relation_issue.errors}{$form.f.relation_issue.fieldErrors}{/if}
{$form.f.relation_type|unsafe}
{$form.f.relation_issue|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.label1.labelTag}:</th>
<td>
{if $form.f.label1.errors}{$form.f.label1.fieldErrors}{/if}{$form.f.label1|unsafe}
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" value="{trans 'Submit Issue'}" name="submit" />
<input type="submit" value="{trans 'Preview'}" name="preview" /> |
<input type="submit" value="{trans 'Submit Issue'}" name="submit" />
<input type="submit" value="{trans 'Preview'}" name="preview" /> |
<a href="{url 'IDF_Views_Issue::index', array($project.shortname)}">{trans 'Cancel'}</a>
</td>
</tr>
});
var j=0;
for (j=1;j<4;j=j+1) {
if($("tr#form-attachment-"+j+" > td > ul.errorlist").length == 0){
$("#form-attachment-"+j).hide();
}else{
$("#form-block-"+(j-1)).remove();
}
if($("tr#form-attachment-"+j+" > td > ul.errorlist").length == 0){
$("#form-attachment-"+j).hide();
}else{
$("#form-block-"+(j-1)).remove();
}
}
});
</script>
src/IDF/templates/idf/issues/js-autocomplete.html
22
33
44
5
5
66
77
8
9
8
9
10
11
1012
1113
1214
13
14
15
16
17
18
19
20
21
22
23
24
15
16
17
18
19
20
21
22
23
24
25
26
2527
2628
27
28
29
30
31
32
33
34
35
36
37
38
29
30
31
32
33
34
35
36
37
38
39
40
3941
40
41
42
43
44
45
46
47
48
49
50
51
52
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
5381
5482
5583
<script type="text/javascript" src="{media '/idf/js/jquery.bgiframe.min.js'}"></script>
<script type="text/javascript" src="{media '/idf/js/jquery.autocomplete.min.js'}"></script>
<script type="text/javascript" charset="utf-8">
// <!-- {literal}
// <!-- {literal}
$(document).ready(function(){
var auto_labels = [{/literal}{$auto_labels|safe}{literal}];
var auto_status = [{/literal}{$auto_status|safe}{literal}];
var auto_owner = [{/literal}{$auto_owner|safe}{literal}];
var auto_status = [{/literal}{$auto_status|safe}{literal}];
var auto_owner = [{/literal}{$auto_owner|safe}{literal}];
var auto_relation_types = [{/literal}{$auto_relation_types|safe}{literal}];
var j=0;
for (j=1;j<7;j=j+1) {
$("#id_label"+j).autocomplete(auto_labels, {
minChars: 0,
width: 310,
matchContains: true,
max: 50,
highlightItem: false,
formatItem: function(row, i, max, term) {
return row.to.replace(new RegExp("(" + term + ")", "gi"), "<strong>$1</strong>") + " <span style='font-size: 80%;'>" + row.name + "</span>";
},
formatResult: function(row) {
return row.to;
}
});
minChars: 0,
width: 310,
matchContains: true,
max: 50,
highlightItem: false,
formatItem: function(row, i, max, term) {
return row.to.replace(new RegExp("(" + term + ")", "gi"), "<strong>$1</strong>") + " <span style='font-size: 80%;'>" + row.name + "</span>";
},
formatResult: function(row) {
return row.to;
}
});
}
$("#id_status").autocomplete(auto_status, {
minChars: 0,
width: 310,
matchContains: true,
max: 50,
highlightItem: false,
formatItem: function(row, i, max, term) {
return row.to.replace(new RegExp("(" + term + ")", "gi"), "<strong>$1</strong>") + " <span style='font-size: 80%;'>" + row.name + "</span>";
},
formatResult: function(row) {
return row.to;
}
});
minChars: 0,
width: 310,
matchContains: true,
max: 50,
highlightItem: false,
formatItem: function(row, i, max, term) {
return row.to.replace(new RegExp("(" + term + ")", "gi"), "<strong>$1</strong>") + " <span style='font-size: 80%;'>" + row.name + "</span>";
},
formatResult: function(row) {
return row.to;
}
});
$("#id_owner").autocomplete(auto_owner, {
minChars: 0,
width: 310,
matchContains: true,
max: 50,
highlightItem: false,
formatItem: function(row, i, max, term) {
return row.to.replace(new RegExp("(" + term + ")", "gi"), "<strong>$1</strong>") + " <span style='font-size: 80%;'>" + row.name + "</span>";
},
formatResult: function(row) {
return row.to;
}
});
minChars: 0,
width: 310,
matchContains: true,
max: 50,
highlightItem: false,
formatItem: function(row, i, max, term) {
return row.to.replace(new RegExp("(" + term + ")", "gi"), "<strong>$1</strong>") + " <span style='font-size: 80%;'>" + row.name + "</span>";
},
formatResult: function(row) {
return row.to;
}
});
$("#id_relation_type").autocomplete(auto_relation_types, {
minChars: 0,
width: 310,
matchContains: true,
max: 50,
highlightItem: false,
formatItem: function(row, i, max, term) {
return row.to.replace(new RegExp("(" + term + ")", "gi"), "<strong>$1</strong>") + " <span style='font-size: 80%;'>" + row.name + "</span>";
},
formatResult: function(row) {
return row.to;
}
});
$("#id_relation_issue").autocomplete("{/literal}{url 'IDF_Views_Issue::autoCompleteIssueList', array($project.shortname)}{literal}", {
minChars: 0,
width: 310,
matchContains: true,
max: 10,
delay: 500,
highlightItem: false,
formatItem: function(row, i, max, term) {
return row[1].replace(new RegExp("(" + term + ")", "gi"), "<strong>$1</strong>") + " <span style='font-size: 80%;'>" + row[0] + "</span>";
},
formatResult: function(row) {
return row[1];
}
});
});
{/literal} //-->
</script>

Archive Download the corresponding diff file

Page rendered in 0.13668s using 14 queries.