Skip to content

Commit

Permalink
Item1936: re-use the existing Foswiki::Render::renderRevisionInfo met…
Browse files Browse the repository at this point in the history
…hod to render that information in SEARCH - rather than more custom hacked code.

git-svn-id: http://svn.foswiki.org/branches/Release01x00@5372 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Oct 24, 2009
1 parent 3899844 commit 8fae6f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
8 changes: 4 additions & 4 deletions core/data/TestCases/TestCaseAutoSearchOrder.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,17 @@ SearchTestTopic2; Value_2; 2; 14 Dec 2005 - 21:58; 14 Dec 2005 - 22:23<br />

---+++ Search ordered by editby, limited to 2
<!-- expected rex ORDER BY LASTEDITOR LIMITED TO 2 -->
SearchTestTopic2; Value_2; 2; 14 Dec 2005 - 21:58; 14 Dec 2005 - 22:23; <nop>UnknownUser<br />
SearchTestTopic1; Value_1; 3; 14 Dec 2005 - 21:56; 14 Dec 2005 - 21:56; <nop>UnknownUser<br />
SearchTestTopic2; Value_2; 2; 14 Dec 2005 - 21:58; 14 Dec 2005 - 22:23; <nop>AnnaAncher<br />
SearchTestTopic1; Value_1; 3; 14 Dec 2005 - 21:56; 14 Dec 2005 - 21:56; <nop>KennethLavrsen<br />
<!-- /expected -->
---++++ Actual
<!-- actual -->
%SEARCH{ "SearchTestTopic" scope="topic" scope="topic" nototal="on" nosearch="on" header="" format="!$topic; $formfield(Text Item); $formfield(Number Item); $createdate; $date; <nop>$wikiname<br />" order="editby" limit="2"}%
<!-- /actual -->
---+++ Search ordered by editby, reversed, limited to 2
<!-- expected rex ORDER BY REV LASTEDITOR LIMITED TO 2 -->
SearchTestTopic3; Value_3; 1; 14 Dec 2005 - 21:59; 14 Dec 2005 - 21:59; <nop>UnknownUser<br />
SearchTestTopic1; Value_1; 3; 14 Dec 2005 - 21:56; 14 Dec 2005 - 21:56; <nop>UnknownUser<br />
SearchTestTopic3; Value_3; 1; 14 Dec 2005 - 21:59; 14 Dec 2005 - 21:59; <nop>MichaelAncher<br />
SearchTestTopic1; Value_1; 3; 14 Dec 2005 - 21:56; 14 Dec 2005 - 21:56; <nop>KennethLavrsen<br />
<!-- /expected -->
---++++ Actual
<!-- actual -->
Expand Down
29 changes: 7 additions & 22 deletions core/lib/Foswiki/Search.pm
Original file line number Diff line number Diff line change
Expand Up @@ -793,14 +793,6 @@ sub searchWeb {
my $ru = $topicInfo->{$topic}->{editby} || 'UnknownUser';
my $revNum = $topicInfo->{$topic}->{revNum} || 0;

my $cUID = $users->getCanonicalUserID($ru);
if ( !$cUID ) {

# Not a login name or a wiki name. Is it a valid cUID?
my $ln = $users->getLoginName($ru);
$cUID = $ru if defined $ln && $ln ne 'unknown';
}

# Check security
my $allowView = $topicInfo->{$topic}->{allowView};
next unless $allowView;
Expand Down Expand Up @@ -850,10 +842,6 @@ sub searchWeb {

$text = pop(@multipleHitLines) if ( scalar(@multipleHitLines) );

my $wikiusername = $users->webDotWikiName($cUID);
$wikiusername = "$Foswiki::cfg{UsersWebName}.UnknownUser"
unless defined $wikiusername;

if ( $formatDefined ) {
$out = $format;
$out =~ s/\$web/$web/gs;
Expand All @@ -863,17 +851,12 @@ sub searchWeb {
$out =~ s/\$date/$revDate/gs;
$out =~ s/\$isodate/$isoDate/gs;
$out =~ s/\$rev/$revNum/gs;
$out =~ s/\$wikiusername/$wikiusername/ges;
$out =~ s/\$ntopics/$ntopics/gs;
$out =~ s/\$nhits/$nhits/gs;
my $wikiname = $users->getWikiName($cUID);
$wikiname = 'UnknownUser' unless defined $wikiname;
$out =~ s/\$wikiname/$wikiname/ges;
my $username = $users->getLoginName($cUID);
$username = 'unknown' unless defined $username;
$out =~ s/\$username/$username/ges;
#TODO: replace this with a single call to renderRevisionInfo
$out =~ s/(\$wikiusername|\$wikiname|\$username)/$session->renderer->renderRevisionInfo(
$web, $topic, $meta, $revNum, $1 )/ges;
my $r1info = {};
$out =~ s/\$createdate/_getRev1Info(
Expand Down Expand Up @@ -911,7 +894,8 @@ sub searchWeb {
( $this->{session}->i18n->maketext('NEW') ) );
}
$out =~ s/%REVISION%/$srev/o;
$out =~ s/%AUTHOR%/$wikiusername/e;
$out =~ s/%AUTHOR%/$session->renderer->renderRevisionInfo(
$web, $topic, $meta, $revNum, '$wikiusername' )/e;
if ($doBookView) {
Expand All @@ -937,8 +921,9 @@ sub searchWeb {
elsif ( $formatDefined ) {
$out =~
s/\$summary(?:\(([^\)]*)\))?/$renderer->makeTopicSummary( $text, $topic, $web, $1 )/ges;
$out =~
s/\$changes(?:\(([^\)]*)\))?/$renderer->summariseChanges($cUID,$web,$topic,$1,$revNum)/ges;
s/\$changes(?:\(([^\)]*)\))?/$renderer->summariseChanges($session->{user},$web,$topic,$1,$revNum)/ges;
$out =~
s/\$formfield\(\s*([^\)]*)\s*\)/displayFormField( $meta, $1 )/ges;
$out =~
Expand Down

0 comments on commit 8fae6f1

Please sign in to comment.