Set the regular list criteria.

@param NewsCriteria $criteria
@param Module       $module

@throws CategoryNotFoundException
@throws NoNewsException
429080
private function setRegularListCriteria(NewsCriteria $criteria, Module $module)
    {
        // Filter by default categories
        if (\count($default = StringUtil::deserialize($module->news_filterDefault, true)) > 0) {
            $criteria->setDefaultCategories($default);
        }

        // Filter by multiple active categories
        if ($module->news_filterCategoriesCumulative) {
            /** @var Input $input */
            $input = $this->framework->getAdapter(Input::class);
            $param = $this->manager->getParameterName();

            if ($aliases = $input->get($param)) {
                $aliases = StringUtil::trimsplit(CumulativeFilterModule::getCategorySeparator(), $aliases);
                $aliases = array_unique(array_filter($aliases));

                if (count($aliases) > 0) {
                    /** @var NewsCategoryModel $model */
                    $model = $this->framework->getAdapter(NewsCategoryModel::class);

                    foreach ($aliases as $alias) {
                        // Return null if the category does not exist
                        if (null === ($category = $model->findPublishedByIdOrAlias($alias))) {
                            throw new CategoryNotFoundException(sprintf('News category "%s" was not found', $alias));
                        }

                        $criteria->setCategory($category->id, (bool) $module->news_filterPreserve, (bool) $module->news_includeSubcategories);
                    }
                }
            }

            return;
        }

        // Filter by active category
        if ($module->news_filterCategories) {
            /** @var Input $input */
            $input = $this->framework->getAdapter(Input::class);
            $param = $this->manager->getParameterName();

            if ($alias = $input->get($param)) {
                /** @var NewsCategoryModel $model */
                $model = $this->framework->getAdapter(NewsCategoryModel::class);

                // Return null if the category does not exist
                if (null === ($category = $model->findPublishedByIdOrAlias($alias))) {
                    throw new CategoryNotFoundException(sprintf('News category "%s" was not found', $alias));
                }

                $criteria->setCategory($category->id, (bool) $module->news_filterPreserve, (bool) $module->news_includeSubcategories);
            }
        }
    }
227749
public function setBasicCriteria(array $archives, $sorting = null)
    {
        $archives = $this->parseIds($archives);

        if (0 === \count($archives)) {
            throw new NoNewsException();
        }

        $t = $this->getNewsModelAdapter()->getTable();

        $this->columns[] = "$t.pid IN(".\implode(',', \array_map('intval', $archives)).')';

        // Set the sorting
        switch ($sorting) {
            case 'order_headline_asc':
                $this->options['order'] = "$t.headline";
                break;
            case 'order_headline_desc':
                $this->options['order'] = "$t.headline DESC";
                break;
            case 'order_random':
                $this->options['order'] = 'RAND()';
                break;
            case 'order_date_asc':
                $this->options['order'] = "$t.date";
                break;
            default:
                $this->options['order'] = "$t.date DESC";
                break;
        }

        // Never return unpublished elements in the back end, so they don't end up in the RSS feed
        if (!BE_USER_LOGGED_IN || TL_MODE === 'BE') {
            /** @var Date $dateAdapter */
            $dateAdapter = $this->framework->getAdapter(Date::class);

            $time = $dateAdapter->floorToMinute();
            $this->columns[] = "($t.start=? OR $t.start<=?) AND ($t.stop=? OR $t.stop>?) AND $t.published=?";
            $this->values = \array_merge($this->values, ['', $time, '', ($time + 60), 1]);
        }
    }
166249
public function addNamedCriteria(string $name, CriteriaInterface $criteria): NamedCriteriaCollectionInterface
    {
        return $this->addNamedItem($name, $criteria);
    }
667648
public function setModule($module)
        {
            if (null !== $module && !is_string($module)) {
                throw new Exception(
                    'Invalid argument: $module must be a string or null'
                );
            }

            $this->_module    = $module;
            $this->_hrefCache = null;

            return $this;
        }
1050663
public function setCriteriaRequired($query_name, $criteria_required)
    {
        //$this->check_column_name("set_criteria_lrequired", $query_name);
        if (($cl = ReporticoUtility::getQueryColumn($query_name, $this->lookup_queries))) {
            $cl->setCriteriaRequired($criteria_required);
        } else {
            echo "fail<BR>";
        }

    }
42835
private function _initCriteriaSortations( MW_Common_Criteria_Interface $criteria, stdClass $params )
	{
		if( isset( $params->sort ) && isset( $params->dir ) )
		{
			$sortation = array();

			switch( $params->dir )
			{
				case 'ASC':
					$sortation[] = $criteria->sort( '+', $params->sort ); break;
				case 'DESC':
					$sortation[] = $criteria->sort( '-', $params->sort ); break;
				default:
					throw new Controller_ExtJS_Exception( sprintf( 'Invalid sort direction "%1$s"', $params->sort ) );
			}

			$criteria->setSortations( $sortation );
		}


		if( $this->_sort !== null )
		{
			$sort = $criteria->getSortations();
			$sort[] = $criteria->sort( '+', $this->_sort );
			$criteria->setSortations( $sort );
		}
	}
893977
public function init(Criteria $criteria)
    {
        // init $this->db
        try {
            $db = Propel::getDB($criteria->getDbName());
            $this->setDB($db);
        } catch (Exception $e) {
            // we are only doing this to allow easier debugging, so
            // no need to throw up the exception, just make note of it.
            Propel::log("Could not get a DBAdapter, sql may be wrong", Propel::LOG_ERR);
        }

        // init $this->realtable
        $realtable = $criteria->getTableForAlias($this->table);
        $this->realtable = $realtable ? $realtable : $this->table;
    }
919490
public function setModule($module) {
        if (!is_string($module) || empty($module)) {
            $errMessage = "The module value must be a string and not be empty";
            throw new \InvalidArgumentException($errMessage, GeneralErrors::VALUE_IS_NOT_OF_EXPECTED_TYPE);
        }

        $this->module = $module;
    }
118717
public static function setAlreadyAddSubmodulesFor($module, $app = null)
    {
        if (empty($app)) {
            $app = Yii::$app;
        }
        $appKey = UniApplication::appKey($app);
        if($module instanceof YiiBaseModule) {
            static::$_modulesWithInstalledSubmodules[$appKey][$module::className()] = $module->uniqueId; // uniqueId for Yii::$app = ''
        }
    }
998311
public function append($operator, Criteria $criteria)
    {
        $this->children[] = new Node(self::TYPE_LEAF, $operator, $criteria);
        $this->mostRecentCriteria = $criteria;

        return $this;
    }
1119345
protected function applyCriteria(QueryBuilder $queryBuilder, array $criteria = [])
    {
        foreach ($criteria as $property => $value) {
            $name = $this->getPropertyName($property);
            if (null === $value) {
                $queryBuilder->andWhere($queryBuilder->expr()->isNull($name));
            } elseif (is_array($value)) {
                $queryBuilder->andWhere($queryBuilder->expr()->in($name, $value));
            } elseif ('' !== $value) {
                $parameter = str_replace('.', '_', $property);
                $queryBuilder
                    ->andWhere($queryBuilder->expr()->eq($name, ':'.$parameter))
                    ->setParameter($parameter, $value)
                ;
            }
        }
    }
28457
public function setDefaultCategories(array $defaultCategories, $includeSubcategories = true, $order = null)
    {
        $defaultCategories = $this->parseIds($defaultCategories);

        if (0 === \count($defaultCategories)) {
            throw new NoNewsException();
        }

        // Include the subcategories
        if ($includeSubcategories) {
            /** @var NewsCategoryModel $newsCategoryModel */
            $newsCategoryModel = $this->framework->getAdapter(NewsCategoryModel::class);
            $defaultCategories = $newsCategoryModel->getAllSubcategoriesIds($defaultCategories);
        }

        /** @var Model $model */
        $model = $this->framework->getAdapter(Model::class);

        $newsIds = $model->getReferenceValues('tl_news', 'categories', $defaultCategories);
        $newsIds = $this->parseIds($newsIds);

        if (0 === \count($newsIds)) {
            throw new NoNewsException();
        }

        $t = $this->getNewsModelAdapter()->getTable();

        $this->columns['defaultCategories'] = "$t.id IN(".\implode(',', $newsIds).')';

        // Order news items by best match
        if ($order === 'best_match') {
            $mapper = [];

            // Build the mapper
            foreach (array_unique($newsIds) as $newsId) {
                $mapper[$newsId] = count(array_intersect($defaultCategories, array_unique($model->getRelatedValues($t, 'categories', $newsId))));
            }

            arsort($mapper);

            $this->options['order'] = Database::getInstance()->findInSet("$t.id", array_keys($mapper));
        }
    }
762854
private function addFilterCriteria()
    {
        $filters = $this->dm->getFilterCollection()->getFilterCriteria($this->class);

        foreach ($filters as $filter) {
            $this->addCriteria($filter);
        }
    }
1113544
public function addCriteria($criteria, $value = null, $before = 'and')
    {
        if ($value && is_array($value)) {
            $criteriaX = $this->buildCriteria($value, $this->qmMode);
            array_shift($criteriaX);
            $this->criteria = array_merge($this->criteria, $criteriaX);
        }

        $this->criteria[0] .= ($this->criteria[0] ? " $before " : '') . $criteria;

        return $this;
    }
986948
public function setCriteriaLink($link_from, $link_to, $clause, $link_number = -1)
    {

        if (!$this->checkCriteriaNameR("set_criteria_link", $link_from)) {
            ReporticoApp::handleError("Failure in Criteria Link: Unknown Lookup Name $link_from");
            return;
        }
        if (!$this->checkCriteriaNameR("set_criteria_link", $link_to)) {
            ReporticoApp::handleError("Failure in Criteria Link: Unknown Lookup Name $link_to");
            return;
        }

        //$lf =& $this->columns[$link_from];
        //$lt =& $this->columns[$link_to];

        //$lfq =& $lf->lookup_query;
        //$ltq =& $lt->lookup_query;

        $lfq = &$this->lookup_queries[$link_from]->lookup_query;
        $ltq = &$this->lookup_queries[$link_to]->lookup_query;

        if (!$lfq) {
            ReporticoApp::handleError("set_criteria_link: No Lookup For $link_from");
        }

        $this->lookup_queries[$link_from]->lookup_query->addCriteriaLink($clause, $link_from, $link_to, $ltq, $link_number);
    }
1357841
protected function applyCriteria(Builder $builder, array $criteria)
    {
        foreach ($criteria as $criterion) {
            $criterion->apply($builder);
        }
    }
156754
public function addCriterion(CriterionInterface $criterion, $name = null, $link = Link::LINK_AND)
    {
        if (null === $name) {
            $this->collection[] = [$criterion, $link];
        } else {
            $this->collection[$this->resolveString($name, __METHOD__)] = [$criterion, $link];
        }

        $this->collectionCount++;

        return $this;
    }