<commit_before><?php

class Locator extends Page
{
    private static $db = array(
        'AutoGeocode' => 'Boolean',
        'ModalWindow' => 'Boolean',
        'Unit' => 'Enum("m,km","m")',
    );

    private static $many_many = array(
        'Categories' => 'LocationCategory',
    );

    private static $defaults = array(
        'AutoGeocode' => true,
    );

    private static $singular_name = 'Locator';
    private static $plural_name = 'Locators';
    private static $description = 'Find locations on a map';

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        // Settings
        $fields->addFieldsToTab('Root.Settings', array(
            HeaderField::create('DisplayOptions', 'Display Options', 3),
            OptionsetField::create('Unit', 'Unit of measure', array('m' => 'Miles', 'km' => 'Kilometers')),
            CheckboxField::create('AutoGeocode', 'Auto Geocode - Automatically filter map results based on user location')
                ->setDescription('Note: if any locations are set as featured, the auto geocode is automatically disabled.'),
            CheckboxField::create('ModalWindow', 'Modal Window - Show Map results in a modal window'),
        ));

        // Filter categories
        $config = GridFieldConfig_RelationEditor::create();
        if (class_exists('GridFieldAddExistingSearchButton')) {
            $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
            $config->addComponent(new GridFieldAddExistingSearchButton());
        }
        $categories = $this->Categories();
        $categoriesField = GridField::create('Categories', 'Categories', $categories, $config)
            ->setDescription('only show locations from the selected category');

            // Filter
            $fields->addFieldsToTab('Root.Filter', array(
                HeaderField::create('CategoryOptionsHeader', 'Location Filtering', 3),
                $categoriesField,
            ));

        $this->extend('updateCMSFields', $fields);

        return $fields;
    }

    public static function getLocations($filter = array(), $exclude = array(), $filterAny = array())
    {
        $filter['ShowInLocator'] = true;
        $exclude['Lat'] = 0;

        $Locations = Location::get()->exclude($exclude)->filter($filter)->filterAny($filterAny);<commit_msg>Locator - CMS Design<commit_after><?php

class Locator extends Page
{
    private static $db = array(
        'AutoGeocode' => 'Boolean',
        'ModalWindow' => 'Boolean',
        'Unit' => 'Enum("m,km","m")',
    );

    private static $many_many = array(
        'Categories' => 'LocationCategory',
    );

    private static $defaults = array(
        'AutoGeocode' => true,
    );

    private static $singular_name = 'Locator';
    private static $plural_name = 'Locators';
    private static $description = 'Find locations on a map';

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        // Settings
        $fields->addFieldsToTab('Root.Settings', array(
            HeaderField::create('DisplayOptions', 'Display Options', 3),
            OptionsetField::create('Unit', 'Unit of measure', array('m' => 'Miles', 'km' => 'Kilometers')),
            CheckboxField::create('AutoGeocode', 'Auto Geocode - Automatically filter map results based on user location')
                ->setDescription('Note: if any locations are set as featured, the auto geocode is automatically disabled.'),
            CheckboxField::create('ModalWindow', 'Modal Window - Show Map results in a modal window'),
        ));

        // Filter categories
        $config = GridFieldConfig_RelationEditor::create();
        if (class_exists('GridFieldAddExistingSearchButton')) {
            $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
            $config->addComponent(new GridFieldAddExistingSearchButton());
        }
        $categories = $this->Categories();
        $categoriesField = GridField::create('Categories', 'Categories', $categories, $config)
            ->setDescription('only show locations from the selected category');

            // Filter
            $fields->addFieldsToTab('Root.Settings', array(
                HeaderField::create('CategoryOptionsHeader', 'Location Filtering', 3),
                $categoriesField,
            ));

        $this->extend('updateCMSFields', $fields);

        return $fields;
    }

    public static function getLocations($filter = array(), $exclude = array(), $filterAny = array())
    {
        $filter['ShowInLocator'] = true;
        $exclude['Lat'] = 0;

        $Locations = Location::get()->exclude($exclude)->filter($filter)->filterAny($filterAny);
{'fraction_non_alphanumeric': 0.13795295613477432, 'fraction_numerical': 0.0012714558169103624, 'mean_word_length': 2.8911788953009068, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '1824888', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1198, 'n_words': 297}