configureI18nProcessing($search, array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION')); if (null !== $code = $this->getCode()) { $search->filterByCode($code, Criteria::IN); } if (null !== $excludeCode = $this->getExcludeCode()) { $search->filterByCode($excludeCode, Criteria::NOT_IN); } if (null !== $exclude = $this->getExclude()) { $search->filterById($exclude, Criteria::NOT_IN); } if (null !== $id = $this->getId()) { $search->filterById($id, Criteria::IN); } if (null !== $position = $this->getPosition()) { $search->filterByPosition($position, Criteria::IN); } if (null !== $title = $this->getTitle()) { //find all selections that match exactly this title and find with all locales. $search2 = SelectionI18nQuery::create() ->filterByTitle($title, Criteria::LIKE) ->select('id') ->find(); if ($search2) { $search->filterById( $search2, Criteria::IN ); } } $visible = $this->getVisible(); if (BooleanOrBothType::ANY !== $visible) { $search->filterByVisible($visible ? 1 : 0); } $search->leftJoinSelectionContainerAssociatedSelection(SelectionContainerAssociatedSelectionTableMap::TABLE_NAME); /** @noinspection PhpUndefinedMethodInspection */ $wantedContainerId = $this->getContainerId(); /** @noinspection PhpUndefinedMethodInspection */ $withoutContainer = $this->getWithoutContainer(); if (null !== $wantedContainerId) { $search->leftJoinSelectionContainerAssociatedSelection(SelectionContainerAssociatedSelectionTableMap::TABLE_NAME); $search->where(SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID . Criteria::EQUAL . $wantedContainerId); } else if (null !== $withoutContainer && $withoutContainer) { $search->leftJoinSelectionContainerAssociatedSelection(SelectionContainerAssociatedSelectionTableMap::TABLE_NAME); $search->where(SelectionContainerAssociatedSelectionTableMap::SELECTION_ID . Criteria::ISNULL); } /** @noinspection PhpUndefinedMethodInspection */ $orders = $this->getOrder(); foreach ($orders as $order) { switch ($order) { case "id": $search->orderById(Criteria::ASC); break; case "id_reverse": $search->orderById(Criteria::DESC); break; case "code": $search->orderByCode(Criteria::ASC); break; case "code_reverse": $search->orderByCode(Criteria::DESC); break; case "alpha": $search->addAscendingOrderByColumn('i18n_TITLE'); break; case "alpha_reverse": $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "manual": $search->orderByPosition(Criteria::ASC); break; case "manual_reverse": $search->orderByPosition(Criteria::DESC); break; case "visible": $search->orderByVisible(Criteria::ASC); break; case "visible_reverse": $search->orderByVisible(Criteria::DESC); break; case "created": $search->addAscendingOrderByColumn('created_at'); break; case "created_reverse": $search->addDescendingOrderByColumn('created_at'); break; case "updated": $search->addAscendingOrderByColumn('updated_at'); break; case "updated_reverse": $search->addDescendingOrderByColumn('updated_at'); break; case "random": $search->clearOrderByColumns(); $search->addAscendingOrderByColumn('RAND()'); break; default: $search->orderByPosition(Criteria::ASC); } } return $search; } /** * @param LoopResult $loopResult * * @return LoopResult * @throws PropelException */ public function parseResults(LoopResult $loopResult) { foreach ($loopResult->getResultDataCollection() as $selection) { /** @var Selection $selection */ $loopResultRow = new LoopResultRow($selection); /** @noinspection PhpUndefinedMethodInspection */ $loopResultRow ->set("SELECTION_ID", $selection->getId()) ->set("SELECTION_URL", $this->getReturnUrl() ? $selection->getUrl($this->locale) : null) ->set("SELECTION_TITLE", $selection->geti18n_TITLE()) ->set("SELECTION_CODE", $selection->getCode()) ->set("SELECTION_META_TITLE", $selection->geti18n_META_TITLE()) ->set("SELECTION_POSITION", $selection->getPosition()) ->set("SELECTION_VISIBLE", $selection->getVisible()) ->set("SELECTION_DESCRIPTION", $selection->geti18n_DESCRIPTION()) ->set("SELECTION_META_DESCRIPTION", $selection->geti18n_META_DESCRIPTION()) ->set("SELECTION_POSTSCRIPTUM", $selection->geti18n_POSTSCRIPTUM()) ->set("SELECTION_CHAPO", $selection->geti18n_CHAPO()) ->set("SELECTION_CONTAINER_ID", $selection->getSelectionContainerAssociatedSelections()) ; $loopResult->addRow($loopResultRow); } return $loopResult; } }