/** * Reorder pages * * @role sort */ public function reorder() { $inst = StaticPage::getInstanceById($this->request->get('id'), StaticPage::LOAD_DATA); $f = new ARSelectFilter(); $handle = new ARFieldHandle('StaticPage', 'position'); if ('down' == $this->request->get('order')) { $f->setCondition(new MoreThanCond($handle, $inst->position->get())); $f->setOrder($handle, 'ASC'); } else { $f->setCondition(new LessThanCond($handle, $inst->position->get())); $f->setOrder($handle, 'DESC'); } $f->setLimit(1); $s = ActiveRecordModel::getRecordSet('StaticPage', $f); if ($s->size()) { $pos = $inst->position->get(); $replace = $s->get(0); $inst->position->set($replace->position->get()); $replace->position->set($pos); $inst->save(); $replace->save(); return new JSONResponse(array('id' => $inst->getID(), 'order' => $this->request->get('order')), 'success'); } else { return new JSONResponse(false, 'failure', $this->translate('_could_not_reorder_pages')); } }
/** * Main settings page */ public function index() { $f = new ARSelectFilter(); $f->setOrder(new ARFieldHandle('StaticPage', 'position')); $f->setOrder(new ARFieldHandle('StaticPage', 'parentID')); $s = ActiveRecordModel::getRecordSetArray('StaticPage', $f); $pages = array(); foreach ($s as $page) { $pointers[$page['ID']] = array('title' => $page['title_lang'], 'id' => $page['ID'], 'parentID' => $page['parentID']); } foreach ($pointers as $page) { if ($page['parentID'] && !empty($pointers[$page['parentID']])) { $root =& $pointers[$page['parentID']]; } else { $root =& $pages; } $root['children'][] =& $pointers[$page['id']]; } $response = new ActionResponse(); $response->set('pages', json_encode($pages)); $form = $this->getForm(); $page = StaticPage::getNewInstance(); $page->getSpecification()->setFormResponse($response, $form); $response->set('form', $form); $response->set('page', $page->toArray()); return $response; }
public function getSelectFilter($searchTerm) { $c = new ARExpressionHandle($this->getWeighedSearchCondition($this->getOption('BACKEND_QUICK_SEARCH') ? array('title' => 1) : array('title' => 4, 'text' => 2, 'moreText' => 1), $searchTerm)); $f = new ARSelectFilter(new MoreThanCond($c, 0)); $f->setOrder($c, 'DESC'); return $f; }
public function products() { $this->setLayout('empty'); set_time_limit(0); $response = new XMLResponse(); $filter = new ARSelectFilter(); $filter->setOrder(f('Product.dateCreated'), ARSelectFilter::ORDER_DESC); $categoryId = $this->getRequest()->get('id'); if (preg_match('/^\\d+$/', $categoryId)) { $this->shouldBeEnabledFeed('CATEGORY_PRODUCTS'); $category = Category::getInstanceById($categoryId, Category::LOAD_DATA); $filter = new ProductFilter($category, $filter); } else { $this->shouldBeEnabledFeed('ALL_PRODUCTS'); $category = Category::getRootNode(true); $filter = new ProductFilter($category, $filter); $filter->includeSubCategories(); } $feed = new ProductFeed($filter); $feed->setFlush(); $feed->setLimit($this->config->get('NUMBER_OF_PRODUCTS_TO_INCLUDE')); $response->set('feed', $feed); $response->set('category', $category->toArray()); return $response; }
public static function getUserToolbarItems($types = null, $filter = null, $order = 'ASC') { if ($filter == null) { $filter = new ARSelectFilter(); } $filter->mergeCondition(eq(f(__CLASS__ . '.ownerID'), SessionUser::getUser()->getID())); $filter->setOrder(f(__CLASS__ . '.position'), $order); $m = array(BackendToolbarItem::TYPE_MENU => '', BackendToolbarItem::TYPE_PRODUCT => '', BackendToolbarItem::TYPE_USER => '', BackendToolbarItem::TYPE_ORDER => ''); if (is_array($types) == false) { $types = array($types); } $conditions = array(); foreach ($types as $type) { switch ($type) { case BackendToolbarItem::TYPE_MENU: $conditions[] = isnotnull(f(__CLASS__ . '.menuID')); break; case BackendToolbarItem::TYPE_PRODUCT: $conditions[] = new AndChainCondition(array(isnotnull(f(__CLASS__ . '.productID')), isnotnull(f('Product.ID')))); // fake inner join break; case BackendToolbarItem::TYPE_USER: $conditions[] = new AndChainCondition(array(isnotnull(f(__CLASS__ . '.userID')), isnotnull(f('User.ID')))); break; case BackendToolbarItem::TYPE_ORDER: $conditions[] = new AndChainCondition(array(isnotnull(f(__CLASS__ . '.orderID')), isnotnull(f('CustomerOrder.ID')))); break; } } if (count($conditions)) { $filter->mergeCondition(new OrChainCondition($conditions)); } return self::getRecordSetArray(__CLASS__, $filter, true); }
public function filter($emptyListIsException = false) { $request = $this->application->getRequest(); $parser = $this->getParser(); $apiFieldNames = $parser->getApiFieldNames(); $parser->loadDataInRequest($request); $f = new ARSelectFilter(); $id = $request->get('ID'); if (intval($id) > 0) { $f->mergeCondition(new EqualsCond(new ARFieldHandle('NewsPost', 'ID'), $id)); } $f->setOrder(new ARExpressionHandle('NewsPost.ID'), 'DESC'); $newspost = ActiveRecordModel::getRecordSetArray('NewsPost', $f); $response = new LiveCartSimpleXMLElement('<response datetime="' . date('c') . '"></response>'); if ($emptyListIsException && count($newspost) == 0) { throw new Exception('News post not found'); } while ($category = array_shift($newspost)) { $xmlNewsPost = $response->addChild('newspost'); foreach ($category as $k => $v) { if (in_array($k, $apiFieldNames)) { $xmlNewsPost->addChild($k, htmlentities($v)); } } } return new SimpleXMLResponse($response); }
public function getSelectFilter($searchTerm) { // create initial index if (0 && !SearchableItem::getRecordCount()) { $app = ActiveRecordModel::getApplication(); $sc = new SearchableConfigurationIndexing($app->getConfig(), $app); $sc->buildIndex(null); } $c = new ARExpressionHandle($this->getWeighedSearchCondition(array('value' => 1), $searchTerm)); $app = ActiveRecordModel::getApplication(); $f = new ARSelectFilter(new MoreThanCond($c, 0)); $f->mergeCondition(new OrChainCondition(array(eq(f('SearchableItem.locale'), $app->getDefaultLanguageCode()), eq(f('SearchableItem.locale'), $app->getLocaleCode()), isnull(f('SearchableItem.locale'))))); $f->setOrder(f('SearchableItem.sort'), 'DESC'); $f->setOrder($c, 'DESC'); return $f; }
public function index() { // get filter to select manufacturers of active products only $rootCat = Category::getRootNode(); $f = new ARSelectFilter(); $productFilter = new ProductFilter($rootCat, $f); $ids = $counts = array(); foreach (ActiveRecordModel::getDataBySQL('SELECT DISTINCT(manufacturerID), COUNT(*) AS cnt FROM Product ' . $f->createString() . ' GROUP BY manufacturerID') as $row) { $ids[] = $row['manufacturerID']; $counts[$row['manufacturerID']] = $row['cnt']; } $f = new ARSelectFilter(new InCond(new ARFieldHandle('Manufacturer', 'ID'), $ids)); $f->mergeCondition(new NotEqualsCond(new ARFieldHandle('Manufacturer', 'name'), '')); $f->setOrder(new ARFieldHandle('Manufacturer', 'name')); $manufacturers = ActiveRecordModel::getRecordSetArray('Manufacturer', $f); foreach ($manufacturers as &$manufacturer) { $manufacturer['url'] = $this->getManufacturerFilterUrl($manufacturer); } $this->addBreadCrumb($this->translate('_manufacturers'), ''); $response = new ActionResponse(); $response->setReference('manufacturers', $manufacturers); $response->set('counts', $counts); $response->set('rootCat', $rootCat->toArray()); return $response; }
private static function getProductGroupsFilter(Product $product) { $filter = new ARSelectFilter(); $filter->setOrder(new ARFieldHandle(__CLASS__, "position"), 'ASC'); $filter->setCondition(new EqualsCond(new ARFieldHandle(__CLASS__, "productID"), $product->getID())); return $filter; }
public function filter($emptyListIsException = false) { $request = $this->application->getRequest(); $parser = $this->getParser(); $apiFieldNames = $parser->getApiFieldNames(); $parser->loadDataInRequest($request); $id = $request->get('orderID'); $f = new ARSelectFilter(); if (!isset($id)) { throw new Exception('Order id is required'); } $f->mergeCondition(new EqualsCond(new ARFieldHandle('OrderNote', 'orderID'), $id)); $f->setOrder(new ARExpressionHandle('OrderNote.ID'), 'ASC'); $orderNotes = ActiveRecordModel::getRecordSetArray('OrderNote', $f); $response = new LiveCartSimpleXMLElement('<response datetime="' . date('c') . '"></response>'); if ($emptyListIsException && count($orderNotes) == 0) { throw new Exception('Not found notes for this order'); } while ($notes = array_shift($orderNotes)) { $xmlPage = $response->addChild('note'); foreach ($notes as $k => $v) { if (in_array($k, $apiFieldNames)) { $xmlPage->addChild($k, htmlentities($v)); } } } return new SimpleXMLResponse($response); }
public function index() { $this->addIndexBreadCrumb(); $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('NewsPost', 'isEnabled'), true)); $f->setOrder(new ARFieldHandle('NewsPost', 'position'), 'DESC'); return new ActionResponse('news', ActiveRecordModel::getRecordSetArray('NewsPost', $f)); }
public function getSelectFilter($searchTerm) { $c = new ARExpressionHandle($this->getWeighedSearchCondition(array('name' => 1), $searchTerm)); $f = new ARSelectFilter(new MoreThanCond($c, 0)); $f->setOrder($c, 'DESC'); return $f; }
public function index() { $f = new ARSelectFilter(); $f->setOrder(new ARFieldHandle('NewsPost', 'position'), 'DESC'); $response = new ActionResponse('newsList', ActiveRecordModel::getRecordSetArray('NewsPost', $f)); $response->set('form', $this->buildForm()); return $response; }
private static function getProductGroupsFilter(Product $product, $type) { $filter = new ARSelectFilter(); $filter->setOrder(new ARFieldHandle("ProductRelationshipGroup", "position"), 'ASC'); $filter->setCondition(new EqualsCond(new ARFieldHandle("ProductRelationshipGroup", "productID"), $product->getID())); $filter->mergeCondition(new EqualsCond(new ARFieldHandle("ProductRelationshipGroup", "type"), $type)); return $filter; }
/** * Load service rates record set * * @param ARSelectFilter $filter * @param bool $loadReferencedRecords * * @return ARSet */ public static function getRecordSet(ARSelectFilter $filter, $loadReferencedRecords = false) { if (!$loadReferencedRecords) { $loadReferencedRecords = array('Tax'); } $filter->setOrder(new ARFieldHandle('Tax', 'position')); return parent::getRecordSet(__CLASS__, $filter, $loadReferencedRecords); }
public static function getRecordSetByOrder(CustomerOrder $order, ARSelectFilter $filter = null, $loadReferencedRecords = false) { if (!$filter) { $filter = new ARSelectFilter(); } $filter->mergeCondition(new EqualsCond(new ARFieldHandle(__CLASS__, 'orderID'), $order->getID())); $filter->setOrder(new ARFieldHandle(__CLASS__, 'time'), ARSelectFilter::ORDER_DESC); return self::getRecordSet($filter, $loadReferencedRecords); }
/** * Creates a select filter for fields groups * @return ARSelectFilter */ private function getGroupFilter() { $filter = new ARSelectFilter(new EqualsCond(new ARFieldHandle('EavFieldGroup', 'classID'), $this->classID)); if ($this->stringIdentifier) { $filter->mergeCondition(new EqualsCond(new ARFieldHandle('EavFieldGroup', 'stringIdentifier'), $this->stringIdentifier)); } $filter->setOrder(new ARFieldHandle('EavFieldGroup', 'position')); return $filter; }
public function getSpecificationFieldSet($loadReferencedRecords = false) { $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle($this->getFieldClass(), 'classID'), EavField::getClassID($this->owner))); if ($this->owner->getStringIdentifier()) { $f->mergeCondition(new EqualsCond(new ARFieldHandle('EavField', 'stringIdentifier'), $this->owner->getStringIdentifier())); } $f->setOrder(new ARFieldHandle($this->getFieldClass(), 'position')); return ActiveRecordModel::getRecordSet($this->getFieldClass(), $f, $loadReferencedRecords); }
protected function insert() { // get max position $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle(__CLASS__, 'categoryID'), $this->getCategory()->getID())); $f->setOrder(new ARFieldHandle(get_class($this), 'position'), 'DESC'); $f->setLimit(1); $rec = ActiveRecord::getRecordSetArray(get_class($this), $f); $position = is_array($rec) && count($rec) > 0 ? $rec[0]['position'] + 1 : 1; $this->position->set($position); return parent::insert(); }
/** * Get CustomerOrder instance from session * * @return CustomerOrder */ public static function getOrder() { if (self::$instance) { return self::$instance; } $session = new Session(); $id = $session->get('CustomerOrder'); if ($id) { try { $instance = CustomerOrder::getInstanceById($id, true); if (!$instance->getOrderedItems()) { $instance->loadItems(); } $instance->isSyncedToSession = true; } catch (ARNotFoundException $e) { unset($instance); } } if (!isset($instance)) { $userId = SessionUser::getUser()->getID(); // get the last unfinalized order by this user if ($userId > 0) { $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('CustomerOrder', 'userID'), $userId)); $f->mergeCondition(new NotEqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), true)); $f->setOrder(new ARFieldHandle('CustomerOrder', 'ID'), 'DESC'); $f->setLimit(1); $orders = ActiveRecordModel::getRecordSet('CustomerOrder', $f); if ($orders->size()) { $instance = $orders->get(0); } } } if (!isset($instance)) { $instance = CustomerOrder::getNewInstance(User::getNewInstance(0)); $instance->user->set(NULL); } if (!$instance->user->get() && SessionUser::getUser()->getID() > 0) { $instance->setUser(SessionUser::getUser()); $instance->save(); } if ($instance->isFinalized->get()) { $session->unsetValue('CustomerOrder'); return self::getOrder(); } // fixes issue when trying to add OrderedItem to unsaved(without ID) CustomerOrder. // ~ but i don't know if returning unsaved CustomerOrder is expected behaviour. if ($instance->isExistingRecord() == false) { $instance->save(true); } self::setOrder($instance); return $instance; }
public function getSelectFilter($searchTerm) { if (strpos($searchTerm, ',') !== false) { $searchTerm = explode(',', $searchTerm); foreach ($searchTerm as &$term) { $term = trim($term); } $searchTerm = array_filter($searchTerm); } $c = new ARExpressionHandle($this->getWeighedSearchCondition(array('name' => 1, 'sku' => 1), $searchTerm)); $f = new ARSelectFilter(new MoreThanCond($c, 0)); $f->setOrder($c, 'DESC'); return $f; }
public function index() { $owner = ActiveRecordModel::getInstanceByID($this->getOwnerClass(), (int) $this->request->get('id')); $filter = new ARSelectFilter(); $filter->setCondition(new EqualsCond(new ARFieldHandle($this->getModelClass(), $this->getForeignKeyName()), $owner->getID())); $filter->setOrder(new ARFieldHandle($this->getModelClass(), 'position')); $imageArray = ActiveRecordModel::getRecordSetArray($this->getModelClass(), $filter); $response = new ActionResponse(); $response->set('form', $this->buildForm($owner->getID())); $response->set('maxSize', ini_get('upload_max_filesize')); $response->set('ownerId', $owner->getID()); $response->set('images', json_encode($imageArray)); return $response; }
public function index() { ClassLoader::import('application.controller.CategoryController'); $this->request->set('id', Category::ROOT_ID); $this->request->set('cathandle', '-'); $response = parent::index(); // load site news $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('NewsPost', 'isEnabled'), true)); $f->setOrder(new ARFieldHandle('NewsPost', 'position'), 'DESC'); $f->setLimit($this->config->get('NUM_NEWS_INDEX') + 1); $news = ActiveRecordModel::getRecordSetArray('NewsPost', $f); $response->set('news', $news); $response->set('isNewsArchive', count($news) > $this->config->get('NUM_NEWS_INDEX')); return $response; }
public function setNextPosition() { $className = get_class($this); if (!is_integer(self::$nextPosition)) { $filter = new ARSelectFilter(); $filter->setCondition(new EqualsCond(new ARFieldHandle($className, 'productID'), $this->product->get()->getID())); $filter->setOrder(new ARFieldHandle($className, 'position'), ARSelectFilter::ORDER_DESC); $filter->setLimit(1); self::$nextPosition = 0; foreach (ActiveRecord::getRecordSet($className, $filter) as $relatedProductGroup) { self::$nextPosition = $relatedProductGroup->position->get(); } } $this->position->set(++self::$nextPosition); }
public function index() { $categoryID = (int) $this->request->get('id'); $category = Category::getInstanceByID($categoryID, ActiveRecord::LOAD_DATA); // get lists $f = new ARSelectFilter(); $f->setOrder(new ARFieldHandle('ProductList', 'position')); $lists = $category->getRelatedRecordSetArray('ProductList', $f); $ids = array(); foreach ($lists as $list) { $ids[] = $list['ID']; } // get list items $f = new ARSelectFilter(new INCond(new ARFieldHandle('ProductListItem', 'productListID'), $ids)); $f->setOrder(new ARFieldHandle('ProductList', 'position')); $f->setOrder(new ARFieldHandle('ProductListItem', 'productListID')); $f->setOrder(new ARFieldHandle('ProductListItem', 'position')); $items = ActiveRecordModel::getRecordSetArray('ProductListItem', $f, array('ProductList', 'Product', 'ProductImage')); $items = ActiveRecordGroup::mergeGroupsWithFields('ProductList', $lists, $items); $response = new ActionResponse(); $response->set('ownerID', $categoryID); $response->set('items', $items); return $response; }
public static function getStateIDByName($countryCode, $name) { $f = new ARSelectFilter(); $f->setCondition(new EqualsCond(new ARFieldHandle('State', 'countryID'), $countryCode)); $nameCond = new EqualsCond(new ARFieldHandle('State', 'name'), $name); $nameCond->addOr(new EqualsCond(new ARFieldHandle('State', 'code'), $name)); $f->mergeCondition($nameCond); $f->setOrder(new ARFieldHandle('State', 'name')); $f->setLimit(1); $stateArray = ActiveRecordModel::getRecordSetArray('State', $f); if ($stateArray) { return $stateArray[0]['ID']; } else { return null; } }
public static function getUserToolbarItems($types = null, $filter = null, $order = 'ASC') { if ($filter == null) { $filter = new ARSelectFilter(); } $filter->mergeCondition(eq(f(__CLASS__ . '.ownerID'), SessionUser::getUser()->getID())); $filter->setOrder(f(__CLASS__ . '.position'), $order); $m = array(BackendToolbarItem::TYPE_MENU => 'menuID', BackendToolbarItem::TYPE_PRODUCT => 'productID', BackendToolbarItem::TYPE_USER => 'userID', BackendToolbarItem::TYPE_ORDER => 'orderID'); if (is_array($types) == false) { $types = array($types); } $conditions = array(); foreach ($types as $type) { if (array_key_exists($type, $m)) { $conditions[] = isnotnull(f(__CLASS__ . '.' . $m[$type])); } } if (count($conditions)) { $filter->mergeCondition(new OrChainCondition($conditions)); } return self::getRecordSetArray(__CLASS__, $filter, true); }
public function autoComplete() { $f = new ARSelectFilter(); $f->setLimit(20); $resp = array(); $field = $this->request->get('field'); if ('specField_' == substr($field, 0, 10)) { list($foo, $id) = explode('_', $field); $handle = new ARFieldHandle('EavStringValue', 'value'); $locale = $this->locale->getLocaleCode(); $searchHandle = MultilingualObject::getLangSearchHandle($handle, $locale); $f->setCondition(new EqualsCond(new ARFieldHandle('EavStringValue', 'fieldID'), $id)); $f->mergeCondition(new LikeCond($handle, '%:"' . $this->request->get($field) . '%')); $f->mergeCondition(new LikeCond($searchHandle, $this->request->get($field) . '%')); $f->setOrder($searchHandle, 'ASC'); $results = ActiveRecordModel::getRecordSet('EavStringValue', $f); foreach ($results as $value) { $resp[$value->getValueByLang('value', $locale, MultilingualObject::NO_DEFAULT_VALUE)] = true; } $resp = array_keys($resp); } return new AutoCompleteResponse($resp); }
public function __construct(LiveCart $application, ARSelectFilter $filter, $modelClass = false, $columnTypes = array()) { $this->application = $application; $this->modelClass = $modelClass; $this->filter = $filter; $this->columnTypes = $columnTypes; $request = $this->application->getRequest(); // set recordset boundaries (limits) $filter->setLimit($request->get('page_size', 10), $request->get('offset', 0)); // set order if ($request->isValueSet('sort_col')) { $handle = $this->getFieldHandle($request->get('sort_col'), self::SORT_HANDLE); if ($handle) { $filter->setOrder($handle, $request->get('sort_dir')); } } // apply filters $filters = $request->get('filters'); if (!is_array($filters)) { $filters = (array) json_decode($request->get('filters')); } $conds = array(); if ($filter->getCondition()) { $conds[] = $filter->getCondition(); } foreach ($filters as $field => $value) { if (!strlen($value)) { continue; } $value = urldecode($value); $handle = $this->getFieldHandle($field, self::FILTER_HANDLE); if ($handle instanceof EavFieldCommon) { continue; } else { if (!is_array($handle) && !is_null($handle) && !$handle instanceof ARExpressionHandle) { $fieldInst = $this->getFieldInstance($field); if ($fieldInst && ($fieldInst->getDataType() instanceof ARNumeric || $handle->getField()->getDataType() instanceof ARNumeric)) { $value = preg_replace('/[ ]{2,}/', ' ', $value); $constraints = $fieldInst->getDataType() instanceof ARNumeric ? explode(' ', $value) : array($value); foreach ($constraints as $c) { list($operator, $value) = $this->parseOperatorAndValue($c); if (!is_numeric($value) && $fieldInst->getDataType() instanceof ARNumeric) { continue; } $conds[] = new OperatorCond($handle, $value, $operator); } } else { if ($fieldInst && $fieldInst->getDataType() instanceof ARPeriod) { if (substr($value, 0, 10) == 'daterange ') { $value = str_replace('daterange ', '', $value); list($from, $to) = explode('|', $value); $from = trim($from); $to = trim($to); // convert // 2010-9-1 to 2010-09-01 ( +first or last minute of day) // unset dates to 'inf' (meaning ingnore condition) if ($from == '') { $from = 'inf'; } else { list($y, $m, $d) = explode('-', $from); $from = $y . '-' . str_pad($m, 2, '0', STR_PAD_LEFT) . '-' . str_pad($d, 2, '0', STR_PAD_LEFT) . ' 00:00:00'; } if ($to == '') { $to = 'inf'; } else { list($y, $m, $d) = explode('-', $to); $to = $y . '-' . str_pad($m, 2, '0', STR_PAD_LEFT) . '-' . str_pad($d, 2, '0', STR_PAD_LEFT) . ' 23:59:59'; } } else { list($from, $to) = explode(' | ', $value); } $cond = null; // from condition if ('inf' != $from) { $cond = new EqualsOrMoreCond($handle, getDateFromString($from)); } // to condition if ('now' != $to && 'inf' != $to) { $condTo = new EqualsOrLessCond($handle, getDateFromString($to)); if ($cond) { $cond->addAnd($condTo); } else { $cond = $condTo; } } if ($cond) { $conds[] = $cond; } } else { $conds[] = new LikeCond($handle, '%' . $value . '%'); } } } else { if (is_array($handle)) { $cond = null; foreach ($handle as $h) { $c = new LikeCond($h, '%' . $value . '%'); if (!$cond) { $cond = $c; } else { $cond->addOR($c); } } $conds[] = $cond; } else { if (array_key_exists($field, $this->columnTypes)) { $type = $this->columnTypes[$field]['type']; } else { $type = null; } $value = preg_replace('/[ ]{2,}/', ' ', $value); switch ($type) { case 'numeric': $constraints = explode(' ', $value); foreach ($constraints as $c) { list($operator, $value) = $this->parseOperatorAndValue($c); if (!is_numeric($value)) { continue; } $having[] = new OperatorCond($handle, $value, $operator); } break; default: $having[] = eq(new ARExpressionHandle($field), $value); } } } } } // apply IDs to filter if ($request->get('selectedIDs') || $request->get('isInverse')) { $selectedIDs = json_decode($request->get('selectedIDs')); if ($selectedIDs) { if ((bool) $request->get('isInverse')) { $idcond = new NotINCond(new ARFieldHandle($modelClass, 'ID'), $selectedIDs); } else { $idcond = new INCond(new ARFieldHandle($modelClass, 'ID'), $selectedIDs); } $conds[] = $idcond; } else { if (!(bool) $request->get('isInverse')) { $idcond = new EqualsCond(new ARExpressionHandle(1), 2); $conds[] = $idcond; } } } if ($conds) { $filter->setCondition(new AndChainCondition($conds)); } if (!empty($having)) { $filter->setHavingCondition(new AndChainCondition($having)); } }
private function getBillingAddressFilter($defaultFirst = true) { $f = new ARSelectFilter(); $f->setCondition(new EqualsCond(new ARFieldHandle('BillingAddress', 'userID'), $this->getID())); if (!$defaultFirst) { $f->setOrder(new ARExpressionHandle('ID = ' . $this->defaultBillingAddress->get()->getID())); } return $f; }