Updated the timeline to link to the author profile.

This commit is contained in:
Loic d'Anterroches 2008-12-05 12:28:58 +01:00
parent 5bd4fed8f4
commit b660c6782f
8 changed files with 86 additions and 12 deletions

View File

@ -172,6 +172,8 @@ class IDF_Commit extends Pluf_Model
$out = '<tr class="log"><td><a href="'.$url.'">'. $out = '<tr class="log"><td><a href="'.$url.'">'.
Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')). Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')).
'</a></td><td>'; '</a></td><td>';
$stag = new IDF_Template_ShowUser();
$user = $stag->start($this->get_author(), $request, $this->origauthor, false);
$tag = new IDF_Template_IssueComment(); $tag = new IDF_Template_IssueComment();
$out .= $tag->start($this->summary, $request, false); $out .= $tag->start($this->summary, $request, false);
if (0 && $this->fullmessage) { if (0 && $this->fullmessage) {
@ -181,7 +183,7 @@ class IDF_Commit extends Pluf_Model
</tr> </tr>
<tr class="extra"> <tr class="extra">
<td colspan="2"> <td colspan="2">
<div class="helptext right">'.__('Commit').'&nbsp;<a href="'.$url.'" class="mono">'.$this->scm_id.'</a>, '.__('by').' '.strip_tags($this->origauthor).'</div></td></tr>'; <div class="helptext right">'.__('Commit').'&nbsp;<a href="'.$url.'" class="mono">'.$this->scm_id.'</a>, '.__('by').' '.$user.'</div></td></tr>';
return Pluf_Template::markSafe($out); return Pluf_Template::markSafe($out);
} }

View File

@ -188,11 +188,12 @@ class IDF_Issue extends Pluf_Model
$out = '<tr class="log"><td><a href="'.$url.'">'. $out = '<tr class="log"><td><a href="'.$url.'">'.
Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')). Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')).
'</a></td><td>'; '</a></td><td>';
$submitter = $this->get_submitter(); $stag = new IDF_Template_ShowUser();
$user = $stag->start($this->get_submitter(), $request, '', false);
$ic = (in_array($this->status, $request->project->getTagIdsByStatus('closed'))) ? 'issue-c' : 'issue-o'; $ic = (in_array($this->status, $request->project->getTagIdsByStatus('closed'))) ? 'issue-c' : 'issue-o';
$out .= sprintf(__('<a href="%1$s" class="%2$s" title="View issue">Issue %3$d</a>, %4$s'), $url, $ic, $this->id, Pluf_esc($this->summary)).'</td>'; $out .= sprintf(__('<a href="%1$s" class="%2$s" title="View issue">Issue %3$d</a>, %4$s'), $url, $ic, $this->id, Pluf_esc($this->summary)).'</td>';
$out .= "\n".'<tr class="extra"><td colspan="2"> $out .= "\n".'<tr class="extra"><td colspan="2">
<div class="helptext right">'.sprintf(__('Creation of <a href="%s" class="%s">issue&nbsp;%d</a>'), $url, $ic, $this->id).', '.__('by').' '.Pluf_esc($submitter).'</div></td></tr>'; <div class="helptext right">'.sprintf(__('Creation of <a href="%s" class="%s">issue&nbsp;%d</a>'), $url, $ic, $this->id).', '.__('by').' '.$user.'</div></td></tr>';
return Pluf_Template::markSafe($out); return Pluf_Template::markSafe($out);
} }

View File

@ -136,7 +136,9 @@ class IDF_IssueComment extends Pluf_Model
$out = "\n".'<tr class="log"><td><a href="'.$url.'">'. $out = "\n".'<tr class="log"><td><a href="'.$url.'">'.
Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')). Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')).
'</a></td><td>'; '</a></td><td>';
$submitter = $this->get_submitter(); $stag = new IDF_Template_ShowUser();
$user = $stag->start($this->get_submitter(), $request, '', false);
$ic = (in_array($issue->status, $request->project->getTagIdsByStatus('closed'))) ? 'issue-c' : 'issue-o'; $ic = (in_array($issue->status, $request->project->getTagIdsByStatus('closed'))) ? 'issue-c' : 'issue-o';
$out .= sprintf(__('<a href="%1$s" class="%2$s" title="View issue">Issue %3$d</a>, %4$s'), $url, $ic, $issue->id, Pluf_esc($issue->summary)); $out .= sprintf(__('<a href="%1$s" class="%2$s" title="View issue">Issue %3$d</a>, %4$s'), $url, $ic, $issue->id, Pluf_esc($issue->summary));
@ -168,7 +170,7 @@ class IDF_IssueComment extends Pluf_Model
$out .= "\n".'<tr class="extra"><td colspan="2"> $out .= "\n".'<tr class="extra"><td colspan="2">
<div class="helptext right">'.sprintf(__('Comment on <a href="%s" class="%s">issue&nbsp;%d</a>'), $url, $ic, $issue->id).', '.__('by').' '.Pluf_esc($submitter).'</div></td></tr>'; <div class="helptext right">'.sprintf(__('Comment on <a href="%s" class="%s">issue&nbsp;%d</a>'), $url, $ic, $issue->id).', '.__('by').' '.$user.'</div></td></tr>';
return Pluf_Template::markSafe($out); return Pluf_Template::markSafe($out);
} }

View File

@ -85,6 +85,7 @@ class IDF_Middleware
'issuetext' => 'IDF_Template_IssueComment', 'issuetext' => 'IDF_Template_IssueComment',
'timeline' => 'IDF_Template_TimelineFragment', 'timeline' => 'IDF_Template_TimelineFragment',
'markdown' => 'IDF_Template_Markdown', 'markdown' => 'IDF_Template_Markdown',
'showuser' => 'IDF_Template_ShowUser',
)); ));
$params['modifiers'] = array_merge($params['modifiers'], $params['modifiers'] = array_merge($params['modifiers'],
array( array(

View File

@ -0,0 +1,66 @@
<?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');
/**
* Show the name of a user in a template.
*
* It will automatically make the link to the profile if needed. In
* the future it will allow us to add little badges on the side of the
* user based on karma or whatever.
*
* This will also provide a consistent display of a user name in the
* application.
*/
class IDF_Template_ShowUser extends Pluf_Template_Tag
{
/**
* We need the user object and the request.
*
* If the user object is null (for example a non associated
* commit), we can use the $text value for an alternative display.
*
* @param Pluf_User
* @param Pluf_HTTP_Request
* @param string Alternate text ('')
*/
function start($user, $request, $text='', $echo=true)
{
if ($user == null) {
$out = (strlen($text)) ? strip_tags($text) : __('Anonymous');
} else {
$url = Pluf_HTTP_URL_urlForView('IDF_Views_User::view',
array($user->login));
if (!$user->isAnonymous() and $user->id == $request->user->id) {
$utext = __('Me');
} else {
$utext = Pluf_esc($user);
}
$out = sprintf('<a href="%s" class="username">%s</a>',
$url, $utext);
}
if ($echo) echo $out;
else return $out;
}
}

View File

@ -177,11 +177,12 @@ class IDF_Upload extends Pluf_Model
$out = '<tr class="log"><td><a href="'.$url.'">'. $out = '<tr class="log"><td><a href="'.$url.'">'.
Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')). Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')).
'</a></td><td>'; '</a></td><td>';
$submitter = $this->get_submitter(); $stag = new IDF_Template_ShowUser();
$user = $stag->start($this->get_submitter(), $request, '', false);
$out .= sprintf(__('<a href="%1$s" title="View download">Download %2$d</a>, %3$s'), $url, $this->id, Pluf_esc($this->summary)).'</td>'; $out .= sprintf(__('<a href="%1$s" title="View download">Download %2$d</a>, %3$s'), $url, $this->id, Pluf_esc($this->summary)).'</td>';
$out .= '</tr>'; $out .= '</tr>';
$out .= "\n".'<tr class="extra"><td colspan="2"> $out .= "\n".'<tr class="extra"><td colspan="2">
<div class="helptext right">'.sprintf(__('Addition of <a href="%s">download&nbsp;%d</a>'), $url, $this->id).', '.__('by').' '.Pluf_esc($submitter).'</div></td></tr>'; <div class="helptext right">'.sprintf(__('Addition of <a href="%s">download&nbsp;%d</a>'), $url, $this->id).', '.__('by').' '.$user.'</div></td></tr>';
return Pluf_Template::markSafe($out); return Pluf_Template::markSafe($out);
} }

View File

@ -192,10 +192,11 @@ class IDF_WikiPage extends Pluf_Model
$out = '<tr class="log"><td><a href="'.$url.'">'. $out = '<tr class="log"><td><a href="'.$url.'">'.
Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')). Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')).
'</a></td><td>'; '</a></td><td>';
$submitter = $this->get_submitter(); $stag = new IDF_Template_ShowUser();
$user = $stag->start($this->get_submitter(), $request, '', false);
$out .= sprintf(__('<a href="%1$s" title="View page">%2$s</a>, %3$s'), $url, Pluf_esc($this->title), Pluf_esc($this->summary)).'</td>'; $out .= sprintf(__('<a href="%1$s" title="View page">%2$s</a>, %3$s'), $url, Pluf_esc($this->title), Pluf_esc($this->summary)).'</td>';
$out .= "\n".'<tr class="extra"><td colspan="2"> $out .= "\n".'<tr class="extra"><td colspan="2">
<div class="helptext right">'.sprintf(__('Creation of <a href="%s">page&nbsp;%s</a>'), $url, Pluf_esc($this->title)).', '.__('by').' '.Pluf_esc($submitter).'</div></td></tr>'; <div class="helptext right">'.sprintf(__('Creation of <a href="%s">page&nbsp;%s</a>'), $url, Pluf_esc($this->title)).', '.__('by').' '.$user.'</div></td></tr>';
return Pluf_Template::markSafe($out); return Pluf_Template::markSafe($out);
} }

View File

@ -162,9 +162,9 @@ class IDF_WikiRevision extends Pluf_Model
$out = "\n".'<tr class="log"><td><a href="'.$url.'">'. $out = "\n".'<tr class="log"><td><a href="'.$url.'">'.
Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')). Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')).
'</a></td><td>'; '</a></td><td>';
$submitter = $this->get_submitter(); $stag = new IDF_Template_ShowUser();
$user = $stag->start($this->get_submitter(), $request, '', false);
$out .= sprintf(__('<a href="%1$s" title="View page">%2$s</a>, %3$s'), $url, Pluf_esc($page->title), Pluf_esc($this->summary)); $out .= sprintf(__('<a href="%1$s" title="View page">%2$s</a>, %3$s'), $url, Pluf_esc($page->title), Pluf_esc($this->summary));
//$out .= '<strong>'.__('Summary:').'</strong>&nbsp;'.Pluf_esc($this->summary).' ';
if ($this->changedRevision()) { if ($this->changedRevision()) {
$out .= '<div class="issue-changes-timeline">'; $out .= '<div class="issue-changes-timeline">';
$changes = $this->changes; $changes = $this->changes;
@ -186,7 +186,7 @@ class IDF_WikiRevision extends Pluf_Model
} }
$out .= '</td></tr>'; $out .= '</td></tr>';
$out .= "\n".'<tr class="extra"><td colspan="2"> $out .= "\n".'<tr class="extra"><td colspan="2">
<div class="helptext right">'.sprintf(__('Change of <a href="%s">%s</a>'), $url, Pluf_esc($page->title)).', '.__('by').' '.Pluf_esc($submitter).'</div></td></tr>'; <div class="helptext right">'.sprintf(__('Change of <a href="%s">%s</a>'), $url, Pluf_esc($page->title)).', '.__('by').' '.$user.'</div></td></tr>';
return Pluf_Template::markSafe($out); return Pluf_Template::markSafe($out);
} }