Filter:   InfoImg
download SearchParameters.php
Language: PHP
LOC: 42
Project Info
Virtual Photo Album(vphotoalb)
Server: SourceForge
Type: cvs
...alb\vphotoalb\html\include\
   .htaccess
   antispam.php
   constants.php
   db.php
   db_my.php
   db_pg.php
   db_schema.php
   faq_strings.php
   form.php
   functions.php
   globals.php
   html.php
   html_verifier.php
   ImageProcessing.php
   input.php
   mime.php
   originals.php
   PictureFinder.php
   queries.php
   read_exif_data.php
   read_tiff_data.php
   SearchParameters.php
   security.php
   strings.en.php
   strings.fr.php
   strings.php
   tables.php

<?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;
    }
}
?>