<commit_before><?php

namespace Craft;

use Twig_Extension;
use Twig_Filter_Method;

class QueryStringsTwigExtension extends Twig_Extension
{

  public function getName()
  {
    return 'Query Strings';
  }

  public function getFilters()
  {
    return array(
        'preserveQueryStrings' => new Twig_Filter_Method($this, 'preserveQueryStrings'),
    );
  }

  public function getFunctions()
  {
    return array(
      // 'getQueryStrings' => new Twig_Function('getQueryStrings', 'getQueryStrings'),
        'getQueryStrings' => new \Twig_SimpleFunction('getQueryStrings', array($this, 'getQueryStrings'), array('is_safe' => array('html'))),
    );
  }


  public function getQueryFormFields()
  {
    $queryStrings = $this->getQueryStrings();
    $return       = '';

    foreach ($queryStrings as $string)
    {
      $return .= "<input type=\"hidden\" name=\"{$string['key']}\" value=\"{$string['value']}\">\n" ;
    }

    return TemplateHelper::getRaw($return);
  }

  public function preserveQueryStrings($url)
  {
    if (substr(craft()->request->queryString, 0, 2) == "p=")
    {
      $queries = explode("&", craft()->request->queryString, 2);

      if (sizeof($queries) > 1)
      {
        $queryStrings = $queries[1];
      } else
      {
        return TemplateHelper::getRaw($url);
      }
    }

    if (substr($url, -1) != "?")
    {
      $return = $url . "?";
    } else
    {
      $return = $url;
    }
<commit_msg>actually register the function in the extension<commit_after><?php

namespace Craft;

use Twig_Extension;
use Twig_Filter_Method;

class QueryStringsTwigExtension extends Twig_Extension
{

  public function getName()
  {
    return 'Query Strings';
  }

  public function getFilters()
  {
    return array(
        'preserveQueryStrings' => new Twig_Filter_Method($this, 'preserveQueryStrings'),
    );
  }

  public function getFunctions()
  {
    return array(
      // 'getQueryStrings' => new Twig_Function('getQueryStrings', 'getQueryStrings'),
        'getQueryStrings'    => new \Twig_SimpleFunction('getQueryStrings', array($this, 'getQueryStrings'), array('is_safe' => array('html'))),
        'getQueryFormFields' => new \Twig_SimpleFunction('getQueryFormFields', array($this, 'getQueryFormFields'), array('is_safe' => array('html'))),
    );
  }


  public function getQueryFormFields()
  {
    $queryStrings = $this->getQueryStrings();
    $return       = '';

    foreach ($queryStrings as $string)
    {
      $return .= "<input type=\"hidden\" name=\"{$string['key']}\" value=\"{$string['value']}\">\n";
    }

    return TemplateHelper::getRaw($return);
  }

  public function preserveQueryStrings($url)
  {
    if (substr(craft()->request->queryString, 0, 2) == "p=")
    {
      $queries = explode("&", craft()->request->queryString, 2);

      if (sizeof($queries) > 1)
      {
        $queryStrings = $queries[1];
      } else
      {
        return TemplateHelper::getRaw($url);
      }
    }

    if (substr($url, -1) != "?")
    {
      $return = $url . "?";
    } else
    {
      $return = $url;
    }

{'fraction_non_alphanumeric': 0.16498206716661232, 'fraction_numerical': 0.0039126181936746, 'mean_word_length': 3.063576158940397, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '528600', 'n_tokens_mistral': 980, 'n_tokens_neox': 950, 'n_words': 187}