Source of file ShopSearchFilter.php
Size: 2,457 Bytes - Last Modified: 2021-12-23T10:47:54+00:00
/var/www/docs.ssmods.com/process/src/code/admin/ShopSearchFilter.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 | <?php /** * Search filter for option sets, used for searching {@link Order} statuses in the CMS. * * @author Frank Mullenger <frankmullenger@gmail.com> * @copyright Copyright (c) 2011, Frank Mullenger * @package swipestripe * @subpackage admin */ class ShopSearchFilter_OptionSet extends SearchFilter { /** * Apply filter query SQL to a search query * * @see SearchFilter::apply() * @return SQLQuery */ public function apply(DataQuery $query) { $this->model = $query->applyRelation($this->relation); $values = $this->getValue(); if (count($values)) { foreach ($values as $value) { $matches[] = sprintf("%s LIKE '%s%%'", $this->getDbName(), Convert::raw2sql(str_replace("'", '', $value)) ); } return $query->where(implode(" OR ", $matches)); } return $query; } /** * Determine whether the filter should be applied, depending on the * value of the field being passed * * @see SearchFilter::isEmpty() * @return Boolean */ public function isEmpty() { if(is_array($this->getValue())) { return count($this->getValue()) == 0; } else { return $this->getValue() == null || $this->getValue() == ''; } } protected function applyOne(DataQuery $query) { return; } protected function excludeOne(DataQuery $query) { return; } } /** * Search filter for {@link Product} status, whether a {@link Product} is published * or unpublished. * * @author Frank Mullenger <frankmullenger@gmail.com> * @copyright Copyright (c) 2011, Frank Mullenger * @package swipestripe * @subpackage admin */ class ShopSearchFilter_PublishedStatus extends SearchFilter { /** * Apply filter query SQL to a search query * * @see SearchFilter::apply() */ public function apply(DataQuery $query) { return $query; $query = $this->applyRelation($query); $value = $this->getValue(); if ($value) { if ($value == 1) return $query->where("Status = 'Published'"); if ($value == 2) return $query->where("Status != 'Published'"); } } /** * Determine whether the filter should be applied, depending on the * value of the field being passed * * @see SearchFilter::isEmpty() * @return Boolean */ public function isEmpty() { return $this->getValue() == null || $this->getValue() == '' || $this->getValue() == 0; } protected function applyOne(DataQuery $query) { return; } protected function excludeOne(DataQuery $query) { return; } } |