root/devel/mod/search/lib/search_suggest_tags.php

Revision 1539, 1.2 kB (checked in by renato, 1 year ago)

Setting prop svn:eol-style in LOTS of files.

  • Property svn:mime-type set to text/plain
  • Property svn:eol-style set to native
Line 
1 <?php
2 global $CFG,$USER;
3 global $db;
4
5 if (isset($parameter)) {
6    
7     if ($CFG->dbtype == 'mysql') {
8         $dbtag = $db->qstr($parameter);
9         $searchline = "SELECT DISTINCT tag, MATCH(tag) AGAINST (" . $dbtag . ") AS score
10                        FROM ".$CFG->prefix."tags
11                        WHERE (" . run("users:access_level_sql_where",$USER->ident) . ")
12                        AND (MATCH(tag) AGAINST(" . $dbtag . ") > 0) LIMIT 10";
13     } else {
14         $dbtag = $db->qstr("%" . $parameter . "%");
15         $searchline = "SELECT DISTINCT tag,1
16                        FROM ".$CFG->prefix."tags
17                        WHERE (" . run("users:access_level_sql_where",$USER->ident) . ")
18                        AND (tag LIKE " . $dbtag . ") LIMIT 10";           
19     }
20    
21     if (($results = get_records_sql($searchline)) && count($results) > 1) {
22         $run_result .= "<h2>" . __gettext("Automatic tag suggestion:") . "</h2><p>";
23         foreach($results as $returned_tag) {
24             if ($returned_tag->tag != $parameter) {
25                 $run_result .= "<a href=\"".url."tag/".urlencode($returned_tag->tag)."\">" . htmlspecialchars($returned_tag->tag) . "</a> <br />";
26             }
27         }
28         $run_result .= "</p>";
29        
30     }
31    
32 }
33
34 ?>
Note: See TracBrowser for help on using the browser.