[Xapian-discuss] For more UI functionality: OmegaScript, C++ or other?

Olly Betts olly at survex.com
Mon May 9 23:08:52 BST 2011


On Thu, May 05, 2011 at 06:18:58PM +0530, xapian at catcons.co.uk wrote:
> root at CW8vDS:/var/lib/omega/templates# cat inc/file_ext_checkboxes
> $if{$cgilist{B},$setmap{BE,ods,0,pdf,0,xls,0}$map{$cgilist{B},$setmap{BE,$su
> bstr{$_,1},1}},$setmap{BE,ods,1,pdf,1,xls,1}}
> Extensions: 
> ods:<INPUT TYPE=checkbox NAME=B VALUE=Eods $if{$eq{$opt{BE,ods},1},CHECKED}>
> pdf:<INPUT TYPE=checkbox NAME=B VALUE=Epdf $if{$eq{$opt{BE,pdf},1},CHECKED}>
> xls:<INPUT TYPE=checkbox NAME=B VALUE=Exls $if{$eq{$opt{BE,xls},1},CHECKED}>

There's no real need to set the elements to zero - if they aren't set,
then $opt{} returns an empty string - so you could just use:

$if{$cgilist{B},$map{$cgilist{B},$setmap{BE,$substr{$_,1},1}},$setmap{BE,ods,1,pdf,1,xls,1}}
Extensions: 
ods:<INPUT TYPE=checkbox NAME=B VALUE=Eods $if{$opt{BE,ods},CHECKED}>
pdf:<INPUT TYPE=checkbox NAME=B VALUE=Epdf $if{$opt{BE,pdf},CHECKED}>
xls:<INPUT TYPE=checkbox NAME=B VALUE=Exls $if{$opt{BE,xls},CHECKED}>

Or factor out the list of extensions, which makes it much simpler to
modify the list in the future:

$set{EXTS,$split{Eods Epdf Exls}}
$map{$or{$cgilist{B},$opt{EXTS}},$setmap{BE,$_,1}}
Extensions:
$map{$opt{EXTS},
$substr{$_,1}:<INPUT TYPE=checkbox NAME=B VALUE=$_ $if{$eq{$opt{BE,$_},1},CHECKED}>}

Cheers,
    Olly



More information about the Xapian-discuss mailing list