summaryrefslogtreecommitdiffstats
path: root/phpfspot.class.php
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2008-03-27 22:59:06 +0100
committerAndreas Unterkircher <unki@netshadow.at>2008-03-27 22:59:06 +0100
commitaf0be8f9546fb5dec947be33e465bb6d9e85d0a7 (patch)
tree46fa7f026d861e54753e78ac8265563b0ddfca36 /phpfspot.class.php
parent2b589908f4624b0ee41217f21d5b0b7cb383d38c (diff)
issue111, first try of auto completion for tag search box
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r--phpfspot.class.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index 7e7d4dd..9c1126d 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -690,6 +690,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
*
* if a specific photo was requested (external link)