<?php
/* Class to handle search parameters.
*
* Written by: Chris Studholme
* Last Update: 31-Jan-2001
* Copyright: GPL (http://www.fsf.org/copyleft/gpl.html)
*/
class SearchParameters {
// associative array of parameter values
var $params;
// associative array of parameter names
var $names =
array("ts"=>"type_search", // (int) limit results to photos of this type
"ks"=>"key_search", // (csv) search for these keywords
"kd"=>"key_deny", // (csv) censor photos with these keywords
"ps"=>"person_search", // (csv) search for these people
"pa"=>"person_all", // (bool) all people must appear
"wc"=>"whole_collection", // (bool) display whole matching photo collection
"st"=>"skip_toc", // (bool) just show pictures
);
function SearchParameters($search=false) {
$this->params=array();
while (ereg("^([a-z][a-z])([0-9,a-z]*);(.*)$",$search,$regs)) {
$search = $regs[3];
$this->params[$this->names[$regs[1]]] = $regs[2]?$regs[2]:true;
}
}
function isSearch() {
reset($this->names);
while (list($key,$name)=each($this->names)) {
if ($this->params[$name])
return true;
}
return false;
}
function toString() {
$result="";
reset($this->names);
while (list($key,$name)=each($this->names)) {
if ($this->params[$name]) {
if (is_bool($this->params[$name]))
$result.=$key.";";
else
$result.=$key.$this->params[$name].";";
}
}
return $result;
}
}
?>