@@ -90,15 +90,15 @@ function get_sql_search_clause($search)
90
90
}
91
91
}
92
92
93
- if (isset ($ search ['fields ' ]['allwords ' ]))
93
+ if (isset ($ search ['fields ' ]['allwords ' ]) and count ( $ search [ ' fields ' ][ ' allwords ' ][ ' fields ' ]) > 0 )
94
94
{
95
95
$ fields = array ('file ' , 'name ' , 'comment ' );
96
96
97
97
if (isset ($ search ['fields ' ]['allwords ' ]['fields ' ]) and count ($ search ['fields ' ]['allwords ' ]['fields ' ]) > 0 )
98
98
{
99
99
$ fields = array_intersect ($ fields , $ search ['fields ' ]['allwords ' ]['fields ' ]);
100
100
}
101
-
101
+
102
102
// in the OR mode, request bust be :
103
103
// ((field1 LIKE '%word1%' OR field2 LIKE '%word1%')
104
104
// OR (field1 LIKE '%word2%' OR field2 LIKE '%word2%'))
@@ -199,6 +199,7 @@ function get_sql_search_clause($search)
199
199
*/
200
200
function get_regular_search_results ($ search , $ images_where ='' )
201
201
{
202
+ // echo '<pre>'; print_r($search); echo '</pre>';
202
203
global $ conf ;
203
204
$ forbidden = get_sql_condition_FandF (
204
205
array
@@ -213,6 +214,37 @@ function get_regular_search_results($search, $images_where='')
213
214
$ items = array ();
214
215
$ tag_items = array ();
215
216
217
+ if (isset ($ search ['fields ' ]['search_in_tags ' ]))
218
+ {
219
+ $ word_clauses = array ();
220
+ foreach ($ search ['fields ' ]['allwords ' ]['words ' ] as $ word )
221
+ {
222
+ $ word_clauses [] = "name LIKE '% " .$ word ."%' " ;
223
+ }
224
+
225
+ $ query = '
226
+ SELECT
227
+ id
228
+ FROM ' .TAGS_TABLE .'
229
+ WHERE ' .implode (' OR ' , $ word_clauses ).'
230
+ ; ' ;
231
+ // echo '<pre>'.$query.'</pre>';
232
+ $ tag_ids = query2array ($ query , null , 'id ' );
233
+
234
+ if (!isset ($ search ['fields ' ]['tags ' ]))
235
+ {
236
+ $ search ['fields ' ]['tags ' ] = array (
237
+ 'words ' => $ tag_ids ,
238
+ 'mode ' => 'OR ' ,
239
+ );
240
+ }
241
+ else
242
+ {
243
+ $ search ['fields ' ]['tags ' ]['words ' ] = array_merge ($ search ['fields ' ]['tags ' ]['words ' ], $ tag_ids );
244
+ }
245
+ // echo '<pre>'; print_r($search); echo '</pre>';
246
+ }
247
+
216
248
if (isset ($ search ['fields ' ]['tags ' ]))
217
249
{
218
250
$ tag_items = get_image_ids_for_tags (
0 commit comments