Changeset 3003a0c0d5bbc65f6c4134bf7f96d20eaaa65339
- Timestamp:
- 10/08/11 11:56:05 (8 months ago)
- Author:
- Xemle <xemle@phtagr.org>
- Children:
- 3ee918f972a91be207cf67e3793a87a5cce5e711
- Parents:
- 5511ea68dc1694dc8f00a8a4e8fb8b2973bdf048
- git-author:
- Xemle <xemle@phtagr.org> / 2011-10-08T11:48:14Z+0200
- git-committer:
- Xemle <xemle@phtagr.org> / 2011-10-08T11:56:05Z+0200
- Message:
-
Improve negated autocomplete of explorer
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r5511ea6
|
r3003a0c
|
|
| 220 | 220 | function _getAssociation($type, $value) { |
| 221 | 221 | $result = array(); |
| | 222 | $isNegated = false; |
| | 223 | $normalized = $value; |
| | 224 | if ($value && $value[0] = '-') { |
| | 225 | $normalized = trim(substr($value, 1)); |
| | 226 | $isNegated = true; |
| | 227 | } |
| | 228 | if (!$normalized) { |
| | 229 | return $result; |
| | 230 | } |
| 222 | 231 | switch ($type) { |
| 223 | 232 | case 'tag': |
| 224 | 233 | $data = $this->Media->Tag->find('all', array( |
| 225 | | 'conditions' => array('name LIKE' => $value.'%'), |
| | 234 | 'conditions' => array('name LIKE' => $normalized.'%'), |
| 226 | 235 | 'limit' => 10 |
| 227 | 236 | )); |
| … |
… |
|
| 230 | 239 | case 'category': |
| 231 | 240 | $data = $this->Media->Category->find('all', array( |
| 232 | | 'conditions' => array('name LIKE' => $value.'%'), |
| | 241 | 'conditions' => array('name LIKE' => $normalized.'%'), |
| 233 | 242 | 'limit' => 10 |
| 234 | 243 | )); |
| … |
… |
|
| 237 | 246 | case 'location': |
| 238 | 247 | $data = $this->Media->Location->find('all', array( |
| 239 | | 'conditions' => array('name LIKE' => $value.'%'), |
| | 248 | 'conditions' => array('name LIKE' => $normalized.'%'), |
| 240 | 249 | 'limit' => 10 |
| 241 | 250 | )); |
| … |
… |
|
| 244 | 253 | case 'city': |
| 245 | 254 | $data = $this->Media->Location->find('all', array( |
| 246 | | 'conditions' => array('name LIKE' => $value.'%', 'type' => LOCATION_CITY), |
| | 255 | 'conditions' => array('name LIKE' => $normalized.'%', 'type' => LOCATION_CITY), |
| 247 | 256 | 'limit' => 10 |
| 248 | 257 | )); |
| … |
… |
|
| 251 | 260 | case 'sublocation': |
| 252 | 261 | $data = $this->Media->Location->find('all', array( |
| 253 | | 'conditions' => array('name LIKE' => $value.'%', 'type' => LOCATION_SUBLOCATION), |
| | 262 | 'conditions' => array('name LIKE' => $normalized.'%', 'type' => LOCATION_SUBLOCATION), |
| 254 | 263 | 'limit' => 10 |
| 255 | 264 | )); |
| … |
… |
|
| 258 | 267 | case 'state': |
| 259 | 268 | $data = $this->Media->Location->find('all', array( |
| 260 | | 'conditions' => array('name LIKE' => $value.'%', 'type' => LOCATION_STATE), |
| | 269 | 'conditions' => array('name LIKE' => $normalized.'%', 'type' => LOCATION_STATE), |
| 261 | 270 | 'limit' => 10 |
| 262 | 271 | )); |
| … |
… |
|
| 265 | 274 | case 'country': |
| 266 | 275 | $data = $this->Media->Location->find('all', array( |
| 267 | | 'conditions' => array('name LIKE' => $value.'%', 'type' => LOCATION_COUNTRY), |
| | 276 | 'conditions' => array('name LIKE' => $normalized.'%', 'type' => LOCATION_COUNTRY), |
| 268 | 277 | 'limit' => 10 |
| 269 | 278 | )); |
| … |
… |
|
| 288 | 297 | $this->redirect(404); |
| 289 | 298 | break; |
| | 299 | } |
| | 300 | if ($isNegated && count($result)) { |
| | 301 | $tmp = array(); |
| | 302 | foreach ($result as $name) { |
| | 303 | $tmp[] = '-' . $name; |
| | 304 | } |
| | 305 | $result = $tmp; |
| 290 | 306 | } |
| 291 | 307 | return $result; |