MetaModels\Filter\Setting\Simple::prepareFrontendFilterOptions PHP Method

prepareFrontendFilterOptions() protected method

The returning array will be made of option arrays containing the following fields: * key The option value as raw key from the options array in the given widget information. * value The value to show as option label. * href The URL to use to activate this value in the filter. * active Boolean determining if this value is the current active option in the widget. * class The CSS class to use. Contains active if the option is active or is empty otherwise.
protected prepareFrontendFilterOptions ( array $arrWidget, array $arrFilterUrl, array $arrJumpTo, boolean $blnAutoSubmit ) : array
$arrWidget array The widget information to use for value generating.
$arrFilterUrl array The filter url parameters to use.
$arrJumpTo array The jumpTo page to use for URL generating - if empty, the current frontend page will get used.
$blnAutoSubmit boolean Determines if the generated options/widgets shall perform auto submitting or not.
return array The filter option values to use in the mm_filteritem_* templates.
    protected function prepareFrontendFilterOptions($arrWidget, $arrFilterUrl, $arrJumpTo, $blnAutoSubmit)
    {
        $arrOptions = array();
        if (!isset($arrWidget['options'])) {
            return $arrOptions;
        }
        $dispatcher = $this->getEventDispatcher();
        $strFilterAction = $this->buildFilterUrl($arrFilterUrl, $arrWidget['eval']['urlparam']);
        // If no jumpTo-page has been provided, we use the current page.
        if (!$arrJumpTo) {
            $arrJumpTo = $GLOBALS['objPage']->row();
        }
        if ($arrWidget['eval']['includeBlankOption']) {
            $blnActive = $this->isActiveFrontendFilterValue($arrWidget, $arrFilterUrl, '');
            $event = new GenerateFrontendUrlEvent($arrJumpTo, sprintf($strFilterAction, ''));
            $dispatcher->dispatch(ContaoEvents::CONTROLLER_GENERATE_FRONTEND_URL, $event);
            $arrOptions[] = array('key' => '', 'value' => $arrWidget['eval']['blankOptionLabel'] ? $arrWidget['eval']['blankOptionLabel'] : $GLOBALS['TL_LANG']['metamodels_frontendfilter']['do_not_filter'], 'href' => $event->getUrl(), 'active' => $blnActive, 'class' => 'doNotFilter' . ($blnActive ? ' active' : ''));
        }
        foreach ($arrWidget['options'] as $strKeyOption => $strOption) {
            $strValue = rawurlencode($this->getFrontendFilterValue($arrWidget, $arrFilterUrl, $strKeyOption));
            $blnActive = $this->isActiveFrontendFilterValue($arrWidget, $arrFilterUrl, $strKeyOption);
            if (!empty($strValue)) {
                if ($arrWidget['eval']['urlparam'] !== 'auto_item') {
                    $strValue = '/' . $arrWidget['eval']['urlparam'] . '/' . $strValue;
                } else {
                    $strValue = '/' . $strValue;
                }
            }
            $event = new GenerateFrontendUrlEvent($arrJumpTo, sprintf($strFilterAction, $strValue), null, true);
            $dispatcher->dispatch(ContaoEvents::CONTROLLER_GENERATE_FRONTEND_URL, $event);
            $arrOptions[] = array('key' => $strKeyOption, 'value' => $strOption, 'href' => $event->getUrl(), 'active' => $blnActive, 'class' => standardize($strKeyOption) . ($blnActive ? ' active' : ''));
        }
        return $arrOptions;
    }