summaryrefslogtreecommitdiffstats
path: root/phpfspot.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r--phpfspot.class.php49
1 files changed, 40 insertions, 9 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index 9c1126d..d6ecaed 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -697,33 +697,45 @@ class PHPFSPOT {
if(!isset($_GET['search']) || !is_string($_GET['search']))
$_GET['search'] = '';
- if(!isset($_GET['length']) || !is_numeric($_GET['length']))
- $_GET['length'] = 5;
-
+ $length = 15;
+ $i = 1;
/* retrive tags from database */
$this->get_tags();
$matched_tags = Array();
+ header("Content-Type: text/xml");
+
+ $string = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
+ $string.= "<results>\n";
+
foreach($this->avail_tags as $tag)
{
if(!empty($_GET['search']) &&
preg_match("/". $_GET['search'] ."/i", $this->tags[$tag]) &&
- count($matched_tags) < $_GET['length']) {
+ count($matched_tags) < $length) {
- array_push($matched_tags, $this->tags[$tag] .",". $this->tags[$tag]);
+ $count = $this->get_num_photos($tag);
+
+ if($count == 1) {
+ $string.= " <rs id=\"". $i ."\" info=\"". $count ." photo\">". $this->tags[$tag] ."</rs>\n";
+ }
+ else {
+ $string.= " <rs id=\"". $i ."\" info=\"". $count ." photos\">". $this->tags[$tag] ."</rs>\n";
+
+ }
+ $i++;
}
/* if we have collected enough items, break out */
- if(count($matched_tags) >= $_GET['length'])
+ if(count($matched_tags) >= $length)
break;
}
- if(empty($matched_tags))
- return;
+ $string.= "</results>\n";
- return implode('|', $matched_tags);
+ return $string;
} // get_xml_tag_list()
@@ -2310,6 +2322,25 @@ class PHPFSPOT {
{
return $this->get_web_protocol() ."://". $this->get_server_name() . $this->cfg->web_path;
} // get_phpfspot_url()
+
+ /**
+ * returns the number of photos which are tagged with $tag_id
+ */
+ public function get_num_photos($tag_id)
+ {
+ if($result = $this->db->db_fetchSingleRow("
+ SELECT count(*) as number
+ FROM photo_tags
+ WHERE
+ tag_id LIKE '". $tag_id ."'")) {
+
+ return $result['number'];
+
+ }
+
+ return 0;
+
+ } // get_num_photos()
/**
* check file exists and is readable