public function nexcloud::search in filedepot 6
Same name and namespace in other branches
- 7 nexcloud.class.php \nexcloud::search()
File
- ./
nexcloud.class.php, line 461 - nexcloud.class.php Tag Cloud class for the fildepot module
Class
- nexcloud
- @file nexcloud.class.php Tag Cloud class for the fildepot module
Code
public function search($query) {
$query = addslashes($query);
$itemids = array();
// Get a list of Tag ID's for the tag words in the query
$sql = "SELECT id,tagword FROM {nextag_words} ";
$asearchtags = explode(',', stripslashes($query));
if (count($asearchtags) > 1) {
$sql .= "WHERE ";
$i = 1;
foreach ($asearchtags as $tag) {
$tag = addslashes($tag);
if ($i > 1) {
$sql .= "OR tagword = '{$tag}' ";
}
else {
$sql .= "tagword = '{$tag}' ";
}
$i++;
}
}
else {
$sql .= "WHERE tagword = '{$query}' ";
}
$query = db_query($sql);
$tagids = array();
$sql = "SELECT itemid FROM {nextag_items} WHERE type='{$this->_type}' AND ";
$i = 1;
while ($A = db_fetch_array($query)) {
$tagids[] = $A['id'];
// REGEX - search for id that is the first id or has a leading comma
// must then have a trailing , or be the end of the field
if ($i > 1) {
$sql .= "AND tags REGEXP '(^|,){$A['id']}(,|\$)' ";
}
else {
$sql .= "tags REGEXP '(^|,){$A['id']}(,|\$)' ";
}
$i++;
}
if (count($tagids) > 0) {
$this->_activetags = implode(',', $tagids);
$query = db_query($sql);
while ($A = db_fetch_array($query)) {
$itemids[] = $A['itemid'];
}
if (count($itemids) > 0) {
return $itemids;
}
else {
return FALSE;
}
}
else {
return FALSE;
}
}