From c1f65c614d8a562703d9fb8ad036c5cf1df6c51b Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 2 May 2007 18:07:57 +0000 Subject: [PATCH] Wiki titles not automatically linked --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Shortcut.pm | 20 +++++++++++--------- lib/WebGUI/Asset/Wobject/WikiMaster.pm | 7 +++++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index f34df9bab..37ec70469 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,4 +1,5 @@ 7.3.16 + - fix: Wiki titles not automatically linked - fix: Calendar Events Disappearing http://www.plainblack.com/bugs/tracker/calendar-events-disappearing - fix: Modified SQLForm.pm to handle MySQL null dates. Undefs them. Undef dates default to time(), i.e. today's date diff --git a/lib/WebGUI/Asset/Shortcut.pm b/lib/WebGUI/Asset/Shortcut.pm index 859dc3774..651b96029 100644 --- a/lib/WebGUI/Asset/Shortcut.pm +++ b/lib/WebGUI/Asset/Shortcut.pm @@ -398,16 +398,18 @@ sub getOverrides { } $orig->{_propertyDefinitions} = \%properties; } + $overrides{cacheNotExpired} = 1; + my $sth = $self->session->db->read("select fieldName, newValue from Shortcut_overrides where assetId=? order by fieldName",[$self->getId]); + while (my ($fieldName, $newValue) = $sth->array) { + $overrides{overrides}{$fieldName}{fieldType} = $orig->{_propertyDefinitions}{$fieldName}{fieldType}; + $overrides{overrides}{$fieldName}{origValue} = $orig->get($fieldName); + $overrides{overrides}{$fieldName}{newValue} = $newValue; + $overrides{overrides}{$fieldName}{parsedValue} = $newValue; + } + $sth->finish; + } else { + $self->session->errorHandler->warn("Original asset could not be instanciated by shortcut ".$self->getId); } - $overrides{cacheNotExpired} = 1; - my $sth = $self->session->db->read("select fieldName, newValue from Shortcut_overrides where assetId=".$self->session->db->quote($self->getId)." order by fieldName"); - while (my ($fieldName, $newValue) = $sth->array) { - $overrides{overrides}{$fieldName}{fieldType} = $orig->{_propertyDefinitions}{$fieldName}{fieldType}; - $overrides{overrides}{$fieldName}{origValue} = $self->getShortcutOriginal->get($fieldName); - $overrides{overrides}{$fieldName}{newValue} = $newValue; - $overrides{overrides}{$fieldName}{parsedValue} = $newValue; - } - $sth->finish; if ($self->isDashlet) { my $u = WebGUI::User->new($self->session, $self->discernUserId); my @userPrefs = $self->getPrefFieldsToImport; diff --git a/lib/WebGUI/Asset/Wobject/WikiMaster.pm b/lib/WebGUI/Asset/Wobject/WikiMaster.pm index 8960820e8..794011cf7 100644 --- a/lib/WebGUI/Asset/Wobject/WikiMaster.pm +++ b/lib/WebGUI/Asset/Wobject/WikiMaster.pm @@ -92,10 +92,12 @@ sub autolinkHtml { my %mapping = $self->session->db->buildHash("SELECT LOWER(d.title), d.url FROM asset AS i INNER JOIN assetData AS d ON i.assetId = d.assetId WHERE i.parentId = ? and className='WebGUI::Asset::WikiPage'", [$self->getId]); return $html unless %mapping; foreach my $key (keys %mapping) { - $mapping{$key} = $self->session->url->gateway(WebGUI::HTML::format('/'.$mapping{$key}, 'text')); + $key =~ s{\(}{\\\(}gxms; # escape parens + $key =~ s{\)}{\\\)}gxms; # escape parens + $mapping{$key} = $self->session->url->gateway($mapping{$key}); } my $matchString = join('|', map{quotemeta} keys %mapping); - my $regexp = qr/\b($matchString)\b/i; + my $regexp = qr/($matchString)/i; my @acc = (); my $in_a = 0; my $p = HTML::Parser->new; @@ -109,6 +111,7 @@ sub autolinkHtml { $p->handler(text => sub { my $text = $_[0]; unless ($in_a) { + $text =~ s{\&\#39\;}{\'}xms; # html entities for ' created by rich editor while ($text =~ s#^(.*?)$regexp##i) { push @acc, sprintf '%s%s', ($1, $mapping{lc $2}, $2);