Skip to content

Commit

Permalink
Item11178: Fix SEARCH connector, AuthScripts notes
Browse files Browse the repository at this point in the history
   * Broken SEARCH connector using trunk-only QUERY syntax. Oops.
   * Let JQGridPlugin work even if Config.spec settings are missing in LocalSite.cfg
   * Add a note & conditional warning/check in System topic regarding {AuthScripts}
   * Added an example showing FAQ grid, because not user topics aren't always form.name='UserForm', so often the example grid is empty

git-svn-id: http://svn.foswiki.org/trunk/JQGridPlugin@12796 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
PaulHarvey authored and PaulHarvey committed Oct 19, 2011
1 parent 0e99dab commit e697695
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 11 deletions.
25 changes: 25 additions & 0 deletions data/System/JQGridPlugin.txt
Expand Up @@ -84,6 +84,18 @@ When [[Foswiki:Extesions/ImagePlugin][ImagePlugin]] is installed, each Image/Pho
=%IMAGE= expression to render thumbnails.

---++ Examples
%IF{
"{AuthScripts}=~'\brest\b'"
then="<blockquote class='foswikiHelp'>
$percntX$percnt Users of this wiki need to be logged in to use %TOPIC%.

If guests are to make use of %TOPIC% without being logged in, remove the =rest= script from ={AuthScripts}= in [[%SCRIPTURLPATH{"configure"}%#Login$SecurityAndAuthentication][configure]] under Security and Authentication -> Login. See also: [[UserAuthentication]]
$percntIF{
\"NOT context authenticated\"
then=\"$n$dollarpercntX$dollarpercnt You are not logged in, so the examples below will not work\"
}$percnt</blockquote>"
}%
*Users:*
%GRID{
form="UserForm"
web="%USERSWEB%"
Expand All @@ -102,6 +114,16 @@ When [[Foswiki:Extesions/ImagePlugin][ImagePlugin]] is installed, each Image/Pho
Topic_format="<a href='%SCRIPTURLPATH{"view"}%/${web}/${value}'>${FirstName} ${LastName}</a>"
}%

*FAQ topics:*
%GRID{
form="FAQForm"
filterbar="on"
toolbar="on"
pager="on"
width="auto"
height="auto"
}%

---++ Installation Instructions

%$INSTALL_INSTRUCTIONS%
Expand All @@ -113,6 +135,9 @@ When [[Foswiki:Extesions/ImagePlugin][ImagePlugin]] is installed, each Image/Pho
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order --> |
| 19 Oct 2011: | (2.02) Fixed bugs with SEARCH connector: broken on Foswiki 1.1.x, corrected column sorting quirks;\
added some code to help when =LocalSite.cfg= settings are missing;\
added notes regarding ={AuthScripts}= |
| 28 Sep 2011: | (2.01) removed spurious =console.log()= which of course breaks jqgrid on some browsers |
| 12 Sep 2011: | (1.0) upgraded to jqgrid-4.1.2;\
added =rownumwidth=, =colname_formatter=, =colname_format=, =colname_formatoptions=, =colname_hidden=; \
Expand Down
6 changes: 3 additions & 3 deletions lib/Foswiki/Plugins/JQGridPlugin.pm
Expand Up @@ -17,7 +17,7 @@ use strict;
use warnings;

our $VERSION = '$Rev$';
our $RELEASE = '2.01';
our $RELEASE = '2.02';
our $SHORTDESCRIPTION = 'jQuery grid widget for Foswiki';
our $NO_PREFS_IN_TOPIC = 1;
our $doInit = 0;
Expand Down Expand Up @@ -66,8 +66,8 @@ sub restGridConnector {

my $request = Foswiki::Func::getCgiQuery();

my $connectorID = $request->param('connector') || $Foswiki::cfg{JQGridPlugin}{DefaultConnector};
my $connectorClass = $Foswiki::cfg{JQGridPlugin}{Connector}{$connectorID};
my $connectorID = $request->param('connector') || $Foswiki::cfg{JQGridPlugin}{DefaultConnector} || 'search';
my $connectorClass = $Foswiki::cfg{JQGridPlugin}{Connector}{$connectorID} || 'Foswiki::Plugins::JQGridPlugin::SearchConnector';


unless ($connectorClass) {
Expand Down
9 changes: 9 additions & 0 deletions lib/Foswiki/Plugins/JQGridPlugin/GRID.pm
Expand Up @@ -46,6 +46,15 @@ sub new {
my $class = shift;
my $session = shift || $Foswiki::Plugins::SESSION;

$Foswiki::cfg{JQGridPlugin}{DefaultConnector} = 'search'
unless defined $Foswiki::cfg{JQGridPlugin}{DefaultConnector};
$Foswiki::cfg{JQGridPlugin}{Connector}{search} = 'Foswiki::Plugins::JQGridPlugin::SearchConnector'
unless defined $Foswiki::cfg{JQGridPlugin}{Connector}{search};
$Foswiki::cfg{JQGridPlugin}{Connector}{dbcache} = 'Foswiki::Plugins::JQGridPlugin::DBCacheConnector'
unless defined $Foswiki::cfg{JQGridPlugin}{Connector}{dbcache};
$Foswiki::cfg{JQGridPlugin}{Connector}{solr} = 'Foswiki::Plugins::JQGridPlugin::SolrConnector'
unless defined $Foswiki::cfg{JQGridPlugin}{Connector}{solr};

my $this = bless($class->SUPER::new(
$session,
name => 'Grid',
Expand Down
26 changes: 18 additions & 8 deletions lib/Foswiki/Plugins/JQGridPlugin/SearchConnector.pm
Expand Up @@ -50,11 +50,18 @@ sub new {
'By' => 'info.author',
'Author' => 'info.author'
};
# maps column names to accessors appropriate for sorting
$this->{sortPropertyMap} = {
'Topic' => 'topic',
'Modified' => 'modified',
'Changed' => 'modified',
'By' => 'editby',
'Author' => 'editby'
};

return $this;
}


=begin TML
---++ ClassMethod restHandleSearch( $request, $response )
Expand Down Expand Up @@ -115,6 +122,12 @@ sub restHandleSearch {
$this->{session}->writeCompletePage($result, 'view', 'text/xml');
}

sub column2SortProperty {
my ($this, $column) = @_;

return $this->{sortPropertyMap}{$column} || "formfield($column)";
}

=begin TML
---++ ClassMethod search( $web, %params ) -> $xml
Expand All @@ -129,10 +142,7 @@ sub search {
my $context = Foswiki::Func::getContext();

# TODO: get this sorted out
my $order = $this->column2Property($params{sort});
if ($order =~ /^[a-zA-Z-_]+$/) { # SMELL: poor-man's formfield check
$order = "formfield($order)";
}
my $order = $this->column2SortProperty($params{sort});

my $tml = <<"HERE";
<literal><noautolink>%SEARCH{
Expand All @@ -148,10 +158,10 @@ sub search {
pagerformat=" "
pagerformat2="<page>\$currentpage</page>
<total>\$numberofpages</total>
<records>\$percntQUERY{\$numberofpages * \$pagesize}\$percnt</records>\$n"
<records>\$percntCALC{\$EVAL(\$numberofpages * \$pagesize)}\$percnt</records>\$n"
footer="\$n</rows>"
header="<?xml version='1.0' encoding='utf-8'?><rows>
<page>\$currentpage</page><total>\$numberofpages</total><records>\$percntQUERY{\$numberofpages * \$pagesize}\$percnt</records>\$n"
<page>\$currentpage</page><total>\$numberofpages</total><records>\$percntCALC{\$EVAL(\$numberofpages * \$pagesize)}\$percnt</records>\$n"
format="<row id='\$web.\$topic'>
HERE

Expand All @@ -166,7 +176,7 @@ HERE
} else {
$cell .= '$percntQUERY{\"\'$web.$topic\'/' . $propertyName . '\"}$percnt';
}
$tml .= '<cell name="'.$columnName.'"><![CDATA[<nop>' . $cell . ']]></cell>' . "\n"; # SMELL extra space behind cell needed to work around bug in Render::getRenderedVerision
$tml .= '<cell name=\"'.$columnName.'\"><![CDATA[<nop>' . $cell . ']]></cell>' . "\n"; # SMELL extra space behind cell needed to work around bug in Render::getRenderedVerision
}
$tml .= '</row>"}%</noautolink></literal>';

Expand Down

0 comments on commit e697695

Please sign in to comment.