Commit a541740d authored by lphuberdeau's avatar lphuberdeau

[MOD] Add a value formatter for tracker fields

parent 0577ec8e
......@@ -1864,6 +1864,7 @@ lib/core/Search/Formatter/ValueFormatter/Date.php -text
lib/core/Search/Formatter/ValueFormatter/Interface.php -text
lib/core/Search/Formatter/ValueFormatter/Objectlink.php -text
lib/core/Search/Formatter/ValueFormatter/Plain.php -text
lib/core/Search/Formatter/ValueFormatter/Trackerrender.php -text
lib/core/Search/GlobalSource/AdvancedRatingSource.php -text
lib/core/Search/GlobalSource/CategorySource.php -text
lib/core/Search/GlobalSource/FileAttachmentSource.php -text
......
......@@ -24,13 +24,13 @@ class Search_Formatter_ValueFormatter
$name = array_shift($arguments);
if (empty($this->valueSet[$name])) {
return '';
return tr("No value for '%0'", $name);
}
$class = 'Search_Formatter_ValueFormatter_' . ucfirst($format);
if (class_exists($class)) {
$formatter = new $class;
return $formatter->render($this->valueSet[$name], $this->valueSet);
return $formatter->render($name, $this->valueSet[$name], $this->valueSet);
} else {
return tr("Unknown formatting rule '%0' for '%1'", $format, $name);
}
......
......@@ -7,7 +7,7 @@
class Search_Formatter_ValueFormatter_Date implements Search_Formatter_ValueFormatter_Interface
{
function render($value, array $entry)
function render($name, $value, array $entry)
{
global $prefs, $tikilib;
return $tikilib->date_format($prefs['short_date_format'], $value);
......
......@@ -7,6 +7,6 @@
interface Search_Formatter_ValueFormatter_Interface
{
function render($value, array $entry);
function render($name, $value, array $entry);
}
......@@ -7,7 +7,7 @@
class Search_Formatter_ValueFormatter_Objectlink implements Search_Formatter_ValueFormatter_Interface
{
function render($value, array $entry)
function render($name, $value, array $entry)
{
global $smarty;
require_once $smarty->_get_plugin_filepath('function', 'object_link');
......
......@@ -7,7 +7,7 @@
class Search_Formatter_ValueFormatter_Plain implements Search_Formatter_ValueFormatter_Interface
{
function render($value, array $entry)
function render($name, $value, array $entry)
{
return $value;
}
......
<?php
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
class Search_Formatter_ValueFormatter_Trackerrender implements Search_Formatter_ValueFormatter_Interface
{
function render($name, $value, array $entry)
{
if (substr($name, 0, 14) !== 'tracker_field_') {
return $value;
}
$tracker = Tracker_Definition::get($entry['tracker_id']);
$field = $tracker->getField(substr($name, 14));
$field['value'] = $value;
$trklib = TikiLib::lib('trk');
return '~np~' . $trklib->field_render_value(array(
'field' => $field,
'process' => 'y',
)) . '~/np~';
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment