Indefero

Indefero Commit Details


Date:2009-10-29 07:54:44 (15 years 1 month ago)
Author:Loic d'Anterroches
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:6c5fde77b466f3aa041f224488234684db44e1e4
Parents: 646cf6479b61a9e8f5f9c6edc9ce18341420497c
Message:Added the ability to link to a review from the comments.

Changes:

File differences

src/IDF/Template/IssueComment.php
4646
4747
4848
49
50
51
52
4953
5054
5155
......
139143
140144
141145
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
142181
143182
144183
......
167206
168207
169208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
170223
$text = preg_replace_callback('#(issues?|bugs?|tickets?)\s+(\d+)(\#ic\d*){0,1}((\s+and|\s+or|,)\s+(\d+)(\#ic\d*){0,1}){0,}#im',
array($this, 'callbackIssues'), $text);
}
if ($request->rights['hasReviewAccess']) {
$text = preg_replace_callback('#(reviews?\s+)(\d+(?:(?:\s+and|\s+or|,)\s+\d+)*)\b#i',
array($this, 'callbackReviews'), $text);
}
if ($request->rights['hasSourceAccess']) {
$text = preg_replace_callback('#(commits?\s+)([0-9a-f]{1,40}(?:(?:\s+and|\s+or|,)\s+[0-9a-f]{1,40})*)\b#i',
array($this, 'callbackCommits'), $text);
.'">'.$m[0].'</a>';
}
/**
* General call back to convert reviews to HTML links.
*
* @param array $m Single regex match.
* @return string Content with converted reviews.
*/
function callbackReviews($m)
{
$keyword = rtrim($m[1]);
if ('reviews' === $keyword) {
return $m[1].preg_replace_callback('#\b(\d+)\b#i', array($this, 'callbackReview'), $m[2]);
} else if ('review' === $keyword) {
return $m[1].call_user_func(array($this, 'callbackReview'), array('', $m[2]));
}
return $m[0];
}
/**
* Convert plaintext commit to HTML link. Called from callbackReviews.
*
* Regex callback for {@link IDF_Template_IssueComment::callbackReviews()}.
*
* @param array Single regex match.
* @return string HTML A element with review.
*/
function callbackReview($m)
{
$review = new IDF_Review($m[1]);
if ($review->id > 0 and $review->project == $this->project->id) {
return $this->linkReview($review, $m[1]);
} else {
return $m[0]; // not existing issue.
}
}
function callbackSource($m)
{
if (!$this->scm->isAvailable()) return $m[0];
return '<a href="'.Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
array($this->project->shortname, $issue->id)).$anchor.'" class="'.$ic.'" title="'.Pluf_esc($issue->summary).'">'.Pluf_esc($title).'</a>';
}
/**
* Generate the link to a review.
*
* @param IDF_Review Review.
* @param string Name of the link.
* @return string Linked review.
*/
public function linkReview($review, $title, $anchor='')
{
$ic = (in_array($review->status, $this->project->getTagIdsByStatus('closed'))) ? 'issue-c' : 'issue-o';
return '<a href="'.Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
array($this->project->shortname, $review->id)).$anchor.'" class="'.$ic.'" title="'.Pluf_esc($review->summary).'">'.Pluf_esc($title).'</a>';
}
}

Archive Download the corresponding diff file

Page rendered in 0.07048s using 13 queries.