From af0be8f9546fb5dec947be33e465bb6d9e85d0a7 Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Thu, 27 Mar 2008 22:59:06 +0100 Subject: issue111, first try of auto completion for tag search box Signed-off-by: Andreas Unterkircher --- phpfspot.class.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'phpfspot.class.php') diff --git a/phpfspot.class.php b/phpfspot.class.php index 7e7d4dd..9c1126d 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -689,6 +689,45 @@ class PHPFSPOT { } // resetTags() + /** + * returns the value for the autocomplet tag-search + */ + public function get_xml_tag_list() + { + if(!isset($_GET['search']) || !is_string($_GET['search'])) + $_GET['search'] = ''; + + if(!isset($_GET['length']) || !is_numeric($_GET['length'])) + $_GET['length'] = 5; + + + /* retrive tags from database */ + $this->get_tags(); + + $matched_tags = Array(); + + foreach($this->avail_tags as $tag) + { + if(!empty($_GET['search']) && + preg_match("/". $_GET['search'] ."/i", $this->tags[$tag]) && + count($matched_tags) < $_GET['length']) { + + array_push($matched_tags, $this->tags[$tag] .",". $this->tags[$tag]); + } + + /* if we have collected enough items, break out */ + if(count($matched_tags) >= $_GET['length']) + break; + } + + if(empty($matched_tags)) + return; + + return implode('|', $matched_tags); + + } // get_xml_tag_list() + + /** * reset single photo * -- cgit v1.2.3-18-g5258