Change the handling in widgetToValue.

Now the function check if the value is a string or not.
Improve the buildFilterRulesForUsedOnly.

Change the SQL from select to tags. Now it should return the right ids.