Retrieve filter URL template with placeholders for range.

@return string
513553
private function getUrlTemplate()
    {
        $filter = $this->getFilter();
        $item   = current($this->getFilter()->getItems());

        $regexp      = "/({$filter->getRequestVar()})=(-?[0-9]+)/";
        $replacement = '${1}=<%- from %>-<%- to %>';

        return preg_replace($regexp, $replacement, $item->getUrl());
    }
1170855
public function getDateFilterForm() {

		// Display a form that allows filtering from a specified date.

		$children = MediaPage::get()->filter('ParentID', $this->data()->ID);
		$form = Form::create(
			$this,
			'getDateFilterForm',
			FieldList::create(
				$date = DateField::create(
					'from',
					'From'
				)->setMinDate($children->min('Date'))->setMaxDate($children->max('Date')),
				HiddenField::create(
					'category'
				),
				HiddenField::create(
					'tag'
				)
			),
			FieldList::create(
				FormAction::create(
					'dateFilter',
					'Filter'
				),
				FormAction::create(
					'clearFilters',
					'Clear'
				)
			)
		);
		$form->setFormMethod('get');

		// Remove validation if clear has been triggered.

		$request = $this->getRequest();
		if($request->getVar('action_clearFilters')) {
			$form->unsetValidator();
		}

		// Allow extension customisation.

		$this->extend('updateFilterForm', $form);

		// Display existing request filters.

		$form->loadDataFrom($request->getVars());
		return $form;
	}
224474
protected function _GetFilter() {
      $Filter = $this->Request->Get('Filter');
      if ($Filter) {
         $Parts = explode(' ', $Filter, 3);
         if (count($Parts) < 2)
            return FALSE;
         
         $Field = $Parts[0];
         if (count($Parts) == 2) {
            $Op = '=';
            $FilterValue = $Parts[1];
         } else {
            $Op = $Parts[1];
            if (!in_array($Op, array('=', 'like'))) {
               $Op = '=';
            }
            $FilterValue = $Parts[2];
         }
         
         if (strpos($Field, '.') !== FALSE)
            $Field = array_pop(explode('.', $Field));
         
         if (!in_array($Field, array('Name', 'Email', 'LastIPAddress', 'InsertIPAddress', 'RankID', 'DateFirstVisit', 'DateLastVisit')))
            return FALSE;

         return array("$Field $Op" => $FilterValue);
      }
      return FALSE;
   }
123526
public function renderFilters()
    {
        $headers = $this->getTable()->getHeaders();
        $render = '';

        foreach ($headers as $name => $params) {

            if (isset($params['filters'])) {
                $value = $this->getTable()->getParamAdapter()->getValueOfFilter($name);
                $id = 'zff_'.$name;

                if (is_string($params['filters'])) {
                    $element = new \Zend\Form\Element\Text($id);
                } else {
                    $element = new \Zend\Form\Element\Select($id);
                    $element->setValueOptions($params['filters']);
                }
                $element->setAttribute('class', 'filter form-control');
                $element->setValue($value);

                $render .= sprintf('<td>%s</td>', $this->getRenderer()->formRow($element));
            } else {
                $render .= '<td></td>';
            }
        }
        return sprintf('<tr>%s</tr>', $render);
    }
555800
public function getQueryText(): string
    {
        return (
            isset($this->filters['_query']) &&
            $this->filters['_query'] instanceof Filter
        )
            ? $this->filters['_query']->getValues()[0]
            : '';
    }
525632
protected function _get_args_for_template_part() {
		$view  = [
			'slug' => '',
			'name' => '',
		];

		$template_name = Helper\locate_template( (array) Helper\config( 'view' ), $this->view, $this->view_suffix );
		if ( empty( $template_name ) ) {
			return $view;
		}

		if ( ! $this->view_suffix ) {
			$view  = [
				'slug' => $template_name,
				'name' => '',
			];
		} else {
			$view  = [
				'slug' => preg_replace( '|\-' . preg_quote( $this->view_suffix ) . '$|', '', $template_name ),
				'name' => $this->view_suffix,
			];
		}

		if ( is_404() || is_search() ) {
			return $view;
		}

		$static_template_name = $this->get_static_view_template_name();
		if ( locate_template( $static_template_name . '.php', false ) ) {
			return [
				'slug' => $static_template_name,
				'name' => '',
			];
		}

		return $view;
	}
163182
public function getFilters()
    {
        $parser = \Parsedown::instance();
        $translator = $this->translator;
        $routeRenderer = $this->routeRenderer;

        return array(
            'markdown' => new \Twig_SimpleFilter(
                'markdown',
                function ($value) use ($parser) {
                    return $parser->text($value);
                }
            ),
            'trans' => new \Twig_SimpleFilter(
                'trans',
                function ($value, $context) use ($translator) {
                    if (!$context) {
                        $context = array();
                    }

                    return vsprintf($translator->translate($value), $context);
                }
            ),
            'route' => new \Twig_SimpleFilter(
                'route',
                function ($value, $presentation = 'normal') use ($routeRenderer) {
                    return $routeRenderer->render($value, $presentation);
                }
            ),
            'sort' => new \Twig_SimpleFilter(
                'sort_*',
                function ($direction, $collection) {
                    if (!$collection instanceof Collection) {
                        return $collection;
                    }

                    $iterator = $collection->getIterator();
                    $iterator->uasort(
                        function ($a, $b) use ($direction) {
                            $aElem = strtolower($a->getName());
                            $bElem = strtolower($b->getName());
                            if ($aElem === $bElem) {
                                return 0;
                            }
                            if ($direction === 'asc' && $aElem > $bElem || $direction === 'desc' && $aElem < $bElem) {
                                return 1;
                            }

                            return -1;
                        }
                    );

                    return $iterator;
                }
            ),
        );
    }
139614
protected function getTemplate()
    {
        //if no template
        if(!$this->template) {
            //Action folder and template folder
            //are in the same directoryby default

            // Sample\Namespace\Action\Can\Be\Anywhere
            $index = 'Action\\';
            $root = strpos(get_class($this), $index);
            $root += strlen($index);

            $this->template = eve('string')
                // \Can\Be\Anywhere
                ->set('\\'.substr(get_class($this), $root))
                // /Can/Be/Anywhere
                ->str_replace('\\', DIRECTORY_SEPARATOR)
                // /can/be/anywhere
                ->strtolower()
                // jic
                ->str_replace('//', '/')
                //done
                ->get();
        }

        return $this->template;
    }
86302
public function generateAddedFilter()
    {
        $mapping = self::$url_handlers;
        $params = $this->getURLParams();
        /** @var array $filter Generic/default filter */
        $filter = array(
            'Live' => 1,
        );
        if (array_key_exists('Action', $params) && $params['Action'] !== null) {
            switch ($mapping[$params['Action']]) {
                /** Archive */
                case 'archive':
                    if (!array_key_exists('ID', $params) || $params['ID'] === null) {
                        $month = SS_DateTime::now()->Format('m');
                        $year = SS_DateTime::now()->Format('Y');
                    } elseif ((!array_key_exists('OtherID', $params) || $params['OtherID'] === null)
                        && (array_key_exists('ID', $params) && $params['ID'] !== null)
                    ) {
                        $year = $params['ID'];
                        $month = '';
                    } else {
                        $year = $params['ID'];
                        $month = date_parse('01-' . $params['OtherID'] . '-1970');
                        $month = str_pad((int)$month['month'], 2, "0", STR_PAD_LEFT);
                    }
                    $filter['PublishFrom:PartialMatch'] = $year . '-' . $month;
                    break;
                /** Author */
                case 'author' :
                    $filter['AuthorHelper.URLSegment:ExactMatch'] = $params['ID'];
                    break;
            }
        }

        return $filter;
    }
1134082
protected function getUriTemplate()
    {
        if (!$this->uriTemplate) {
            $this->uriTemplate = ParserRegistry::getInstance()->getParser('uri_template');
        }

        return $this->uriTemplate;
    }
845573
public function getFilters()
    {
        return array(
            'timeAgo' => new \Twig_Filter_Method($this, 'timeAgo'),
            'homeLink' => new \Twig_Filter_Method($this, 'homeLink'),
            'activeLink' => new \Twig_Filter_Method($this, 'activeLink'),
            'activeRoute' => new \Twig_Filter_Method($this, 'activeRoute'),
            'compareRoute' => new \Twig_Filter_Method($this, 'compareRoute'),
            'autoLink' => new \Twig_Filter_Method($this, 'autoLink')
        );
    }
815266
public function getFilters()
    {
        return [
            new Twig_SimpleFilter('add_filter_value', [$this->urlBuilder, 'addFilterValue']),
            new Twig_SimpleFilter('remove_filter_value', [$this->urlBuilder, 'removeFilterValue']),
            new Twig_SimpleFilter('remove_price_range_filter', [$this->urlBuilder, 'removePriceRangeFilter']),
            new Twig_SimpleFilter('add_prev_page', [$this->urlBuilder, 'addPrevPage']),
            new Twig_SimpleFilter('add_page', [$this->urlBuilder, 'addPage']),
            new Twig_SimpleFilter('add_next_page', [$this->urlBuilder, 'addNextPage']),
            new Twig_SimpleFilter('add_sort_by', [$this->urlBuilder, 'addSortBy']),
        ];
    }
339811
public function raw($var, $default = '', $filter = null)
    {
        $data = $this->get($var);
        if (is_null($data['data'])) {
            $data['data'] = $this->returnDefault($default);
        }
        if (is_string($filter)) {
            $filter = explode('|', $filter);
        }
        $filters = array_merge($data['filters'], (array) $filter);
        if (empty($filters)) {
            return $data['data'];
        }

        return $this->template()->filter($filters, $data['data']);
    }
225956
public function getAsString(): string
    {
        $text = $this->source->getAsString();

        $stripAll = new StripAllFilter();
        $htmlFilter = new HtmlFilter();

        /* Removing CDATA tags */
        $text = preg_replace_callback(
            '#<!\[CDATA\[(.*?)\]\]>#ums',
            function ($match) use ($htmlFilter) {
                $string = $htmlFilter->filter($match[1]);

                //      <![CDATA[               ]]
                return '         ' . $string . '  ';
            },
            $text
        );

        /* Processing bottom level tags */
        $text = preg_replace_callback(
            '#(<(\w+)(\s[^>]*?)?>)([^<>]*)(</\w+\s*>)#um',
            function ($match) use ($stripAll) {
                if (strtolower($match[2]) === 'target') {
                    $replace = $stripAll->filter($match[1]) . $match[4]
                        . $stripAll->filter($match[5]);
                } else {
                    $replace = $stripAll->filter($match[0]);
                }

                return $replace;
            },
            $text
        );

        /* Other replacements */
        foreach ($this->filters as $pattern => $filter) {
            if (null === $filter) {
                $filter = $stripAll;
            }
            $text = preg_replace_callback(
                $pattern,
                function ($match) use ($filter) {
                    return $filter->filter($match[0]);
                },
                $text
            );
        }

        return $text;
    }
572728
public function getUrlTemplateDir()
    {
        if (($sValue = $this->getViewConfigParam('urltemplatedir')) === null) {
            $sValue = $this->getConfig()->getTemplateUrl($this->isAdmin());
            $this->setViewConfigParam('urltemplatedir', $sValue);
        }

        return $sValue;
    }
648191
public function getData()
    {
        $defaultLimit = $this->container->getParameter('pedro_teixeira_grid.pagination.limit');

        $page       = $this->request->query->get('page', 1);
        $limit      = $this->request->query->get('limit', $defaultLimit);
        $sortIndex  = $this->request->query->get('sort');
        $sortOrder  = $this->request->query->get('sort_order');
        $filters    = $this->request->query->get('filters', array());

        $page = intval(abs($page));
        $page = ($page <= 0 ? 1 : $page);

        $limit = intval(abs($limit));
        $limit = ($limit <= 0 ? $defaultLimit : $limit);

        /** @todo Remove the unnecessary iterations */

        // Check and change cascade array in get
        foreach ($filters as $key => $filter) {
            if (strpos($filter['name'], '[]') !== false) {

                unset($filters[$key]);
                $name = str_replace('[]', '', $filter['name']);

                if (!isset($filters[$name])) {
                    $filters[$name] = array(
                        'name' => $name,
                        'value' => array($filter['value'])
                    );
                } else {
                    $filters[$name]['value'][] = $filter['value'];
                }
            }
        }

        foreach ($filters as $filter) {
            /** @var \PedroTeixeira\Bundle\GridBundle\Grid\Column $column */
            foreach ($this->columns as $column) {
                if ($filter['name'] == $column->getIndex() && $filter['value'] != '') {
                    $column->getFilter()->execute($this->getQueryBuilder(), $filter['value']);
                }
            }
        }

        if ($sortIndex) {
            $this->getQueryBuilder()->orderBy($sortIndex, $sortOrder);
        }

        // Don't process grid for export
        if (!$this->isExport()) {
            $totalCount = count(new Paginator($this->getQueryBuilder()->getQuery()));

            $totalPages = ceil($totalCount / $limit);
            $totalPages = ($totalPages <= 0 ? 1 : $totalPages);

            $page = ($page > $totalPages ? $totalPages : $page);

            $queryOffset = (($page * $limit) - $limit);

            $this->getQueryBuilder()
                ->setFirstResult($queryOffset)
                ->setMaxResults($limit);

            $response = array(
                'page'       => $page,
                'page_count' => $totalPages,
                'page_limit' => $limit,
                'row_count'  => $totalCount,
                'rows'       => array()
            );
        } else {
            $response = array(
                'rows'       => array()
            );
        }

        foreach ($this->getQueryBuilder()->getQuery()->getResult() as $key => $row) {

            $rowValue = array();

            /** @var Column $column */
            foreach ($this->columns as $column) {

                if ($column->getExportOnly() && !$this->isExport()) {
                    continue;
                }

                $rowColumn = ' ';

                // Array
                if (array_key_exists($column->getField(), $row)) {

                    $rowColumn = $row[$column->getField()];

                // Array scalar
                } elseif (array_key_exists(0, $row) && array_key_exists($column->getField(), $row[0])) {

                    $rowColumn = $row[0][$column->getField()];

                // Object
                } elseif (method_exists($row, 'get' . ucfirst($column->getField()))) {

                    $method = 'get' . ucfirst($column->getField());
                    $rowColumn = $row->$method();

                // Object scalar
                } elseif (array_key_exists(0, $row) && method_exists($row[0], 'get' . ucfirst($column->getField()))) {

                    $method = 'get' . ucfirst($column->getField());
                    $rowColumn = $row[0]->$method();

                // Array
                } elseif ($column->getTwig()) {

                    $rowColumn = $this->templating->render(
                        $column->getTwig(),
                        array(
                            'row' => $row
                        )
                    );
                }

                $rowValue[$column->getField()] = $column->getRender()
                    ->setValue($rowColumn)
                    ->setStringOnly($this->isExport())
                    ->render();
            }

            $response['rows'][$key] = $rowValue;
        }

        return $response;
    }
370198
def get_templates(self, id_or_uri, start=0, count=-1, filter='', query='', sort=''):
        
        uri = self._client.build_uri(id_or_uri) + "/templates"
        return self._client.get(self._client.build_query_uri(start=start, count=count, filter=filter,
                                                             query=query, sort=sort, uri=uri))