* it get's registered by MTrackWeb as the link handler..
*
*/
-require_once 'MTrack/Interface/WikiLinkHandler.php';
+//require_once 'MTrack/Interface/WikiLinkHandler.php';
-class MTrackWeb_LinkHandler implements MTrack_Interface_WikiLinkHandler
+class MTrackWeb_LinkHandler //implements MTrack_Interface_WikiLinkHandler
{
function MTrackWeb_LinkHandler()
{
function ticket($no, $extras=array())
{
- if ($no instanceof MTrackIssue) {
+ if ($no instanceof DB_DataObject) {
$tkt = $no;
} else if (is_string($no) || is_int($no)) {
static $cache = array();
}
if (!isset($cache[$no])) {
- $tkt = MTrackIssue::loadByNSIdent($no);
- if (!$tkt) {
- $tkt = MTrackIssue::loadById($no);
- }
+ $tkt = DB_DataOBject::Factory('mtrack_ticket');
+ $tkt->get($no);
+
$cache[$no] = $tkt;
} else {
$tkt = $cache[$no];
} else {
// FIXME: hinted data from reports
$tkt = new stdClass;
- $tkt->tid = $no['ticket'];
+ $tkt->id = $no['ticket'];
$tkt->summary = $no['summary'];
$tkt->status = '';
}
if ($tkt == NULL) {
$tkt = new stdClass;
- $tkt->tid = $no;
+ $tkt->id = $no;
$tkt->summary = 'No such ticket';
$tkt->status = 'No such ticket';
}
if ($tkt->status == 'closed') {
$html .= ' completed';
}
- if (!empty($tkt->nsident)) {
- $ident = $tkt->nsident;
- } else {
- $ident = $tkt->tid;
- }
+
+ $ident = $tkt->id;
+
if (isset($extras['#'])) {
$anchor = '#' . $extras['#'];
} else {
return $html;
}
- function milestone( $target, $label)
+ function milestone( $id, $label = '')
{
// silly but we assume target is urlencoded???...
- $ms = MTrack_Milestone::loadByName($target);
+ $ms = DB_DataObjecT::factory('mtrack_milestone');
+ if (empty($label)) {
+ if (empty($id) || !$ms->get($id)) {
+ return '???';
+ }
+ } else {
+ $ms->id = $id;
+ $ms->name = $label;
+ }
+
return '<span class="milestone' .
(($ms->deleted || $ms->completed) ? ' completed' : '') .
- '"><a href="'. $this->baseURL . '/Milestone/'. $target .'">'.
- htmlspecialchars(urldecode($target)) .
+ '"><a href="'. $this->baseURL . '/Milestone/'. $ms->id.'">'.
+ htmlspecialchars(urldecode($ms->name)) .
'</a></span>';
}
function username($target, $opts=array())
{
if (is_object($target)) {
- $userinfo = $target;
- $target = $userinfo->id;
+ $person = $target;
+ $target = $person->id;
} else {
- $userinfo = DB_DataObject::factory('Person');
- $userinfo->get(($target);
+ $person = DB_DataObject::factory('core_person');
+ $person->get($target);
}
if (is_string($opts)) {
parse_str($opts, $opts);
}
+ //print_r($opts);
- //print_R($userinfo);
- if (!$userinfo) {
+ //print_R($person);
+ if (!$person->id) {
// we did not find the ysers...
// we currently ignore all the formating....
return '<a
$open_a =
- '<a title="' . htmlspecialchars($userinfo->fullname) . '"
+ '<a title="' . htmlspecialchars($person->name) . '"
href="' .
$this->baseURL .'/User/'.
- urlencode($userinfo->userid) .
+ urlencode($person->id) .
(empty($opts['edit']) ? '' : '?edit=1') .
'"
class="userlink' .
(isset($opts['class']) ? ' ' . $opts['class'] : '') .
'">';
- $dispname = $userinfo->fullname;
- //$dispname = preg_match("/^([^+]*)(\+.*)?@(.*)$/", $target) ? $target : $userinfo->userid;
+ $dispname = $person->name;
+ //$dispname = preg_match("/^([^+]*)(\+.*)?@(.*)$/", $target) ? $target : $person->id;
$size = empty($opts['size']) ? 24 : (int) $opts['size'];
'<img class="gravatar"
width="' . $size . '" height="' . $size . '"
src="' . $this->baseURL . '/Avatar.png?u=' .
- urlencode($userinfo->userid) . '&s='. $size . '">
+ urlencode($person->id) . '&s='. $size . '">
</a>')) .
// at this point the old code tries to chop it...
function wiki($pagename, $extras = array())
{
-
+ return htmlspecialchars($pagename);
if ($pagename instanceof MTrack_Wiki_Item) {
$wiki = $pagename;
} else if (is_string($pagename)) {