Indefero

Indefero Commit Details


Date:2008-07-28 13:31:23 (16 years 4 months ago)
Author:Loic d'Anterroches
Branch:dev, 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, newdiff, release-1.1, release-1.2, release-1.3, svn
Commit:3fb47562ce0453af4481b1b470581f5bcbbc6b3b
Parents: 3dbae6272a9f239499038f069f6472dfceb5e73e
Message:Automatically create links in the issue description and comments.

Link to issues but also commits.
Changes:

File differences

src/IDF/Project.php
3030
3131
3232
33
3334
3435
3536
37
3638
3739
3840
......
147149
148150
149151
152
153
150154
155
151156
152157
153
158
154159
160
161
162
163
155164
156165
157166
......
167176
168177
169178
179
170180
171181
172182
class IDF_Project extends Pluf_Model
{
public $_model = __CLASS__;
public $_extra_cache = array();
function init()
{
$this->_extra_cache = array();
$this->_a['table'] = 'idf_projects';
$this->_a['model'] = __CLASS__;
$this->_a['cols'] = array(
* Get the open/closed tag ids as they are often used when doing
* listings.
*
* As this can be often used, the info are cached.
*
* @param string Status ('open') or 'closed'
* @param bool Force cache refresh (false)
* @return array Ids of the open/closed tags
*/
public function getTagIdsByStatus($status='open')
public function getTagIdsByStatus($status='open', $cache_refresh=false)
{
if (!$cache_refresh
and isset($this->_extra_cache['getTagIdsByStatus-'.$status])) {
return $this->_extra_cache['getTagIdsByStatus-'.$status];
}
switch ($status) {
case 'open':
$key = 'labels_issue_open';
foreach ($this->getTagsFromConfig($key, $default, 'Status') as $tag) {
$tags[] = (int) $tag->id;
}
$this->_extra_cache['getTagIdsByStatus-'.$status] = $tags;
return $tags;
}
src/IDF/Template/IssueComment.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
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008 CĂ©ondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
/**
* Make the links to issues and commits.
*/
class IDF_Template_IssueComment extends Pluf_Template_Tag
{
private $project = null;
private $git = null;
function start($text, $project)
{
$this->project = $project;
$this->git = new IDF_Git(Pluf::f('git_repository'));
$text = wordwrap($text, 80, "\n", true);
$text = Pluf_esc($text);
$text = ereg_replace('[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]',
'<a href="\\0" rel="nofollow">\\0</a>',
$text);
$text = preg_replace_callback('#(issues?|bugs?|tickets?)\s+(\d+)((\s+and|\s+or|,)\s+(\d+)){0,}#im',
array($this, 'callbackIssues'), $text);
$text = preg_replace_callback('#(commit\s+)([0-9a-f]{5,40})#im',
array($this, 'callbackCommit'), $text);
echo $text;
}
/**
* General call back for the issues.
*/
function callbackIssues($m)
{
if (count($m) == 3) {
$issue = new IDF_Issue($m[2]);
if ($issue->id > 0 and $issue->project == $this->project->id) {
return $this->linkIssue($issue, $m[1].' '.$m[2]);
} else {
return $m[0]; // not existing issue.
}
} else {
return preg_replace_callback('/(\d+)/',
array($this, 'callbackIssue'),
$m[0]);
}
}
/**
* Call back for the case of multiple issues like 'issues 1, 2 and 3'.
*
* Called from callbackIssues, it is linking only the number of
* the issues.
*/
function callbackIssue($m)
{
$issue = new IDF_Issue($m[1]);
if ($issue->id > 0 and $issue->project == $this->project->id) {
return $this->linkIssue($issue, $m[1]);
} else {
return $m[0]; // not existing issue.
}
}
function callbackCommit($m)
{
if ($this->git->testHash($m[2]) != 'commit') {
return $m[0];
}
$co = $this->git->getCommit($m[2]);
return '<a href="'.Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase', array($this->project->shortname, $co->commit)).'">'.$m[1].$m[2].'</a>';
}
/**
* Generate the link to an issue.
*
* @param IDF_Issue Issue.
* @param string Name of the link.
* @return string Linked issue.
*/
public function linkIssue($issue, $title)
{
$ic = (in_array($issue->status, $this->project->getTagIdsByStatus('closed'))) ? 'issue-c' : 'issue-o';
return '<a href="'.Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
array($this->project->shortname, $issue->id)).'" class="'.$ic.'" title="'.Pluf_esc($issue->summary).'">'.Pluf_esc($title).'</a>';
}
}
src/IDF/templates/issues/view.html
1313
1414
1515
16
16
1717
1818
1919
<p>{blocktrans}Comment <a href="{$url}">{$i}</a> by {$who}, {$c.creation_dtime|date}{/blocktrans}</p>
{/if}
<pre class="issue-comment-text">{if strlen($c.content) > 0}{$c.content|issuetext}{else}<i>{trans '(No comments were given for this change.)'}</i>{/if}</pre>
<pre class="issue-comment-text">{if strlen($c.content) > 0}{issuetext $c.content, $project}{else}<i>{trans '(No comments were given for this change.)'}</i>{/if}</pre>
{if $i> 0 and $c.changedIssue()}
<div class="issue-changes">
www/media/idf/css/style.css
123123
124124
125125
126
127
126
127
128
129
130
131
132
128133
129134
130135
/**
* Issue
*/
p.issue-comment-text {
font-family: monospace;
a.issue-c {
text-decoration: line-through;
}
pre.issue-comment-text {
font-family: monospace;
line-height: 1.2; /* to be nice also with links */
}
div.issue-comment {

Archive Download the corresponding diff file

Page rendered in 0.09392s using 13 queries.