Indefero

Indefero Commit Details


Date:2010-10-09 06:53:01 (14 years 2 months ago)
Author:Thomas Keller
Branch:develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:5af2ab4d97e8fb99ae9d4c345b241a96d6c3ef52
Parents: b51838596248ee17b634f46943c9ec9e7d8b338d
Message:Make the timeline view and RSS feeds filterable by model (closes issue 543).

Changes:

File differences

src/IDF/Views/Project.php
6262
6363
6464
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
65125
66126
67127
68128
69129
70130
71
72
131
132
133
134
135
136
137
73138
74139
75140
76141
77142
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
143
144
145
103146
104147
105148
......
113156
114157
115158
116
117
118
119
120
121
122
123
124
125
126
159
127160
128161
129162
163
130164
131165
132166
133
167
134168
135169
136170
137171
138172
139173
140
141
174
175
142176
143177
144178
......
156190
157191
158192
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
193
194
195
196
197
198
182199
183
200
201
202
203
184204
185205
186206
......
203223
204224
205225
206
207226
208227
209228
}
/**
* Returns an associative array with available model filters
*
* @return array
*/
private static function getAvailableModelFilters()
{
return array(
'all' => __('All Updates'),
'commits' => __('Commits'),
'issues' => __('Issues and Comments'),
'downloads' => __('Downloads'),
'documents' => __('Documents'),
'reviews' => __('Reviews and Patches'),
);
}
/**
* Returns an array of model classes for which the current user
* has rights and which should be used according to his filter
*
* @param object $request
* @param string $model_filter
* @return array
*/
private static function determineModelClasses($request, $model_filter = 'all')
{
$classes = array();
if (true === IDF_Precondition::accessSource($request) &&
($model_filter == 'all' || $model_filter == 'commits')) {
$classes[] = '\'IDF_Commit\'';
// FIXME: this looks like a hack...
IDF_Scm::syncTimeline($request->project);
}
if (true === IDF_Precondition::accessIssues($request) &&
($model_filter == 'all' || $model_filter == 'issues')) {
$classes[] = '\'IDF_Issue\'';
$classes[] = '\'IDF_IssueComment\'';
}
if (true === IDF_Precondition::accessDownloads($request) &&
($model_filter == 'all' || $model_filter == 'downloads')) {
$classes[] = '\'IDF_Upload\'';
}
if (true === IDF_Precondition::accessWiki($request) &&
($model_filter == 'all' || $model_filter == 'documents')) {
$classes[] = '\'IDF_WikiPage\'';
$classes[] = '\'IDF_WikiRevision\'';
}
if (true === IDF_Precondition::accessReview($request) &&
($model_filter == 'all' || $model_filter == 'reviews')) {
$classes[] = '\'IDF_Review_Comment\'';
$classes[] = '\'IDF_Review_Patch\'';
}
if (count($classes) == 0) {
$classes[] = '\'IDF_Dummy\'';
}
return $classes;
}
/**
* Timeline of the project.
*/
public $timeline_precond = array('IDF_Precondition::baseAccess');
public function timeline($request, $match)
{
$prj = $request->project;
$title = sprintf(__('%s Updates'), (string) $prj);
$team = $prj->getMembershipData();
$model_filter = @$match[2];
$all_model_filters = self::getAvailableModelFilters();
if (!array_key_exists($model_filter, $all_model_filters)) {
$model_filter = 'all';
}
$title = (string)$prj . ' ' . $all_model_filters[$model_filter];
$pag = new IDF_Timeline_Paginator(new IDF_Timeline());
$pag->class = 'recent-issues';
$pag->item_extra_props = array('request' => $request);
$pag->summary = __('This table shows the project updates.');
// Need to check the rights
$rights = array();
if (true === IDF_Precondition::accessSource($request)) {
$rights[] = '\'IDF_Commit\'';
IDF_Scm::syncTimeline($request->project);
}
if (true === IDF_Precondition::accessIssues($request)) {
$rights[] = '\'IDF_Issue\'';
$rights[] = '\'IDF_IssueComment\'';
}
if (true === IDF_Precondition::accessDownloads($request)) {
$rights[] = '\'IDF_Upload\'';
}
if (true === IDF_Precondition::accessWiki($request)) {
$rights[] = '\'IDF_WikiPage\'';
$rights[] = '\'IDF_WikiRevision\'';
}
if (true === IDF_Precondition::accessReview($request)) {
$rights[] = '\'IDF_Review_Comment\'';
$rights[] = '\'IDF_Review_Patch\'';
}
if (count($rights) == 0) {
$rights[] = '\'IDF_Dummy\'';
}
$sql = sprintf('model_class IN (%s)', implode(', ', $rights));
$classes = self::determineModelClasses($request, $model_filter);
$sql = sprintf('model_class IN (%s)', implode(', ', $classes));
$pag->forced_where = new Pluf_SQL('project=%s AND '.$sql,
array($prj->id));
$pag->sort_order = array('creation_dtime', 'ASC');
$pag->items_per_page = 20;
$pag->no_results_text = __('No changes were found.');
$pag->setFromRequest($request);
$downloads = array();
if ($request->rights['hasDownloadsAccess']) {
$tags = IDF_Views_Download::getDownloadTags($prj);
// the first tag is the featured, the last is the deprecated.
$downloads = $tags[0]->get_idf_upload_list();
}
$pages = array();
if ($request->rights['hasWikiAccess']) {
$tags = IDF_Views_Wiki::getWikiTags($prj);
$pages = $tags[0]->get_idf_wikipage_list();
}
if (!$request->user->isAnonymous() and $prj->isRestricted()) {
$feedurl = Pluf_HTTP_URL_urlForView('idf_project_timeline_feed_auth',
array($prj->shortname,
$model_filter,
IDF_Precondition::genFeedToken($prj, $request->user)));
} else {
$feedurl = Pluf_HTTP_URL_urlForView('idf_project_timeline_feed',
array($prj->shortname));
array($prj->shortname, $model_filter));
}
return Pluf_Shortcuts_RenderToResponse('idf/project/timeline.html',
array(
'page_title' => $title,
'feedurl' => $feedurl,
'timeline' => $pag,
'team' => $team,
'downloads' => $downloads,
'model_filter' => $model_filter,
'all_model_filters' => $all_model_filters,
),
$request);
public function timelineFeed($request, $match)
{
$prj = $request->project;
// Need to check the rights
$rights = array();
if (true === IDF_Precondition::accessSource($request)) {
$rights[] = '\'IDF_Commit\'';
IDF_Scm::syncTimeline($request->project);
}
if (true === IDF_Precondition::accessIssues($request)) {
$rights[] = '\'IDF_Issue\'';
$rights[] = '\'IDF_IssueComment\'';
}
if (true === IDF_Precondition::accessDownloads($request)) {
$rights[] = '\'IDF_Upload\'';
}
if (true === IDF_Precondition::accessWiki($request)) {
$rights[] = '\'IDF_WikiPage\'';
$rights[] = '\'IDF_WikiRevision\'';
}
if (true === IDF_Precondition::accessReview($request)) {
$rights[] = '\'IDF_Review_Comment\'';
$rights[] = '\'IDF_Review_Patch\'';
}
if (count($rights) == 0) {
$rights[] = '\'IDF_Dummy\'';
$model_filter = @$match[2];
$model_filter = @$match[2];
$all_model_filters = self::getAvailableModelFilters();
if (!array_key_exists($model_filter, $all_model_filters)) {
$model_filter = 'all';
}
$sqls = sprintf('model_class IN (%s)', implode(', ', $rights));
$title = $all_model_filters[$model_filter];
$classes = self::determineModelClasses($request, $model_filter);
$sqls = sprintf('model_class IN (%s)', implode(', ', $classes));
$sql = new Pluf_SQL('project=%s AND '.$sqls, array($prj->id));
$params = array(
'filter' => $sql->gen(),
}
$out = Pluf_Template::markSafe(implode("\n", $out));
$tmpl = new Pluf_Template('idf/index.atom');
$title = __('Updates');
$feedurl = Pluf::f('url_base').Pluf::f('idf_base').$request->query;
$viewurl = Pluf_HTTP_URL_urlForView('IDF_Views_Project::timeline',
array($prj->shortname));
src/IDF/conf/urls.php
7474
7575
7676
77
77
7878
7979
8080
8181
82
82
8383
8484
8585
8686
8787
88
88
8989
9090
9191
'model' => 'IDF_Views_Project',
'method' => 'home');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/timeline/$#',
$ctl[] = array('regex' => '#^/p/([\-\w]+)/timeline/(\w+)/$#',
'base' => $base,
'model' => 'IDF_Views_Project',
'method' => 'timeline');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/feed/timeline/$#',
$ctl[] = array('regex' => '#^/p/([\-\w]+)/feed/timeline/(\w+)/$#',
'base' => $base,
'model' => 'IDF_Views_Project',
'method' => 'timelineFeed',
'name' => 'idf_project_timeline_feed');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/feed/timeline/token/(.*)/$#',
$ctl[] = array('regex' => '#^/p/([\-\w]+)/feed/timeline/(\w+)/token/(.*)/$#',
'base' => $base,
'model' => 'IDF_Views_Project',
'method' => 'timelineFeed',
src/IDF/templates/idf/js-hotkeys.html
33
44
55
6
6
77
88
99
// <!--
{hotkey 'Shift+h', 'IDF_Views::faq'}
{if $project}
{hotkey 'Shift+u', 'IDF_Views_Project::timeline', array($project.shortname)}
{hotkey 'Shift+u', 'IDF_Views_Project::timeline', array($project.shortname, 'all')}
{if $hasIssuesAccess}{hotkey 'Shift+a', 'IDF_Views_Issue::create', array($project.shortname)}
{hotkey 'Shift+i', 'IDF_Views_Issue::index', array($project.shortname)}{/if}
{if $hasDownloadsAccess}{hotkey 'Shift+d', 'IDF_Views_Download::index', array($project.shortname)}{/if}
src/IDF/templates/idf/project/home.html
33
44
55
6
6
77
88
99
{block tabhome} class="active"{/block}
{block subtabs}
<div id="sub-tabs">
{trans 'Welcome'} | <strong><a href="{url 'IDF_Views_Project::timeline', array($project.shortname)}">{trans 'Latest Updates'}</a></strong>{superblock}
{trans 'Welcome'} | <strong><a href="{url 'IDF_Views_Project::timeline', array($project.shortname, 'all')}">{trans 'Latest Updates'}</a></strong>{superblock}
</div>
{/block}
{block body}
src/IDF/templates/idf/project/timeline.html
44
55
66
7
7
88
99
1010
......
1313
1414
1515
16
17
18
19
16
17
18
2019
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
3620
3721
3822
{block tabhome} class="active"{/block}
{block subtabs}
<div id="sub-tabs">
<a href="{url 'IDF_Views_Project::home', array($project.shortname)}">{trans 'Welcome'}</a> | <strong><a href="{url 'IDF_Views_Project::timeline', array($project.shortname)}" class="active">{trans 'Latest Updates'}</a></strong>{superblock}
<a href="{url 'IDF_Views_Project::home', array($project.shortname)}">{trans 'Welcome'}</a> | <strong><a href="{url 'IDF_Views_Project::timeline', array($project.shortname, 'all')}" class="active">{trans 'Latest Updates'}</a></strong>{superblock}
</div>
{/block}
{/block}
{block context}
{if count($downloads) > 0}
<p><strong>{trans 'Featured Downloads'}</strong><br />
{foreach $downloads as $download}
<span class="label"><a href="{url 'IDF_Views_Download::view', array($project.shortname, $download.id)}" title="{$download.summary}">{$download}</a></span><br />
<p><strong>{trans 'Filter by type'}</strong><br />
{foreach $all_model_filters as $filter_key => $filter_name}
<span class="label{if $filter_key == $model_filter} active{/if}"><a href="{url 'IDF_Views_Project::timeline', array($project.shortname, $filter_key)}">{$filter_name}</a></span><br />
{/foreach}
<span class="label"> </span><span class="note"><a href="{url 'IDF_Views_Download::index', array($project.shortname)}">{trans 'show more...'}</a></span>
{/if}
{assign $ko = 'owners'}
{assign $km = 'members'}
<p><strong>{trans 'Development Team'}</strong><br />
{trans 'Admins'}<br />
{foreach $team[$ko] as $owner}{aurl 'url', 'IDF_Views_User::view', array($owner.login)}
<span class="label"><a class="label" href="{$url}">{$owner}</a></span><br />
{/foreach}
{if count($team[$km]) > 0}
{trans 'Happy Crew'}<br />
{foreach $team[$km] as $member}{aurl 'url', 'IDF_Views_User::view', array($member.login)}
<span class="label"><a class="label" href="{$url}">{$member}</a></span><br />
{/foreach}
{/if}
</p>
{/block}

Archive Download the corresponding diff file

Page rendered in 0.10188s using 14 queries.