Function to allow the creation of search defaults in code

@see getSearchFilter()

@return array
979893
public function getSearchDefaults()
    {
        if (! isset($this->defaultSearchData['gr2t_id_organization'])) {
            $orgs = $this->currentUser->getRespondentOrganizations();
            $this->defaultSearchData['gr2t_id_organization'] = array_keys($orgs);
        }
        
        if (!isset($this->defaultSearchData['gtf_id_track'])) {
            $orgs = $this->currentUser->getRespondentOrganizations();
            $tracks = $this->util->getTrackData()->getTracksForOrgs($orgs);
            if (count($tracks) == 1) {
                $this->defaultSearchData['gtf_id_track'] = key($tracks);
            }
        }

        return parent::getSearchDefaults();
    }
828668
private function getFieldAnalyzers()
    {
        $analyzers = [];

        if ($this->isSearchable() || $this->isUsedForSortBy()) {
            // Default search analyzer.
            $analyzers = [$this->getDefaultSearchAnalyzer()];

            if ($this->isSearchable() && $this->getSearchWeight() > 1) {
                $analyzers[] = self::ANALYZER_WHITESPACE;
                $analyzers[] = self::ANALYZER_SHINGLE;
            }
        }

        if ($this->isFilterable() || empty($analyzers)) {
            // For filterable fields or fields without analyzer : append the untouched analyzer.
            $analyzers[] = self::ANALYZER_UNTOUCHED;
        }

        if ($this->isUsedForSortBy()) {
            $analyzers[] = self::ANALYZER_SORTABLE;
        }

        return $analyzers;
    }
338722
public function findDefaultFilter()
	{
		if (!empty($this->filter)) {
			return;
		}

		if ($this->getSessionData('_grid_has_filtered')) {
			return;
		}

		if (!empty($this->default_filter)) {
			$this->filter = $this->default_filter;
		}

		foreach ($this->filter as $key => $value) {
			$this->saveSessionData($key, $value);
		}
	}
52825
public function getCurrentFilters()
    {
        $sessionValues = $this->session->get(Configuration::SESSION_PREFIX.'filters', null);

        return $sessionValues !== null ? $sessionValues : $this->getDefaultFilters();
    }
1294755
public function defaults() {
        $this->addFilter(new \Decoda\Filter\DefaultFilter());
        $this->addFilter(new \Decoda\Filter\EmailFilter());
        $this->addFilter(new \Decoda\Filter\ImageFilter());
        $this->addFilter(new \Decoda\Filter\UrlFilter());
        $this->addFilter(new \Decoda\Filter\TextFilter());
        $this->addFilter(new \Decoda\Filter\BlockFilter());
        $this->addFilter(new \Decoda\Filter\VideoFilter());
        $this->addFilter(new \Decoda\Filter\CodeFilter());
        $this->addFilter(new \Decoda\Filter\QuoteFilter());
        $this->addFilter(new \Decoda\Filter\ListFilter());
        $this->addFilter(new \Decoda\Filter\TableFilter());

        $this->addHook(new \Decoda\Hook\CensorHook());
        $this->addHook(new \Decoda\Hook\ClickableHook());

        return $this;
    }
804888
public function GetSearchRestrictionLink()
    {
        // get current search... then add filter
        $oShop = $this->getShopService()->getActiveShop();
        $oSearchCache = &$oShop->GetActiveSearchObject();
        //$oSearchCache->aFilter[TdbShopCategory::FILTER_KEY_NAME] = $this->id;
        return $oSearchCache->GetSearchLink(array(TdbShopCategory::FILTER_KEY_NAME => $this->id));
    }
1249674
protected function initializeDefaultValues()
    {
        $defaults = [];

        $filters = $this->getFilterInformation();

        foreach (array_keys($filters) as $key) {
            $defaults[ $key ] = null;
        }

        $this->defaults = $defaults;

        return $this;
    }
595253
protected function filters()
    {
        $where = $this->initFilters();

        $gf = $this->globalFilter();
        $where .= (empty($where) ? $gf : (empty($gf) ? '' : ' AND '.$gf));

        $gf = $this->individualColumnFilters();
        $where .= (empty($where) ? $gf : (empty($gf) ? '' : ' AND '.$gf));

        return $where;
    }
1325417
protected function _getListOptionsForElem() {
		$cachePath = 'DefaultOptions_Filter_' . $this->_currUIlang;
		$cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_HELPERS);
		if (!empty($cached)) {
			return $cached;
		}

		$inputSize = '';
		$btnSize = '';
		$formInputSize = $this->_getFormInputSize();
		if (!empty($formInputSize)) {
			$inputSize = ' input-' . $formInputSize;
			$btnSize = ' btn-' . $formInputSize;
		}
		$emptyText = $this->ViewExtension->showEmpty('');

		$result = [];
		$result['openFilterForm'] = [
			'role' => 'form',
			'class' => 'filter-form clone-wrapper',
			'autocomplete' => 'off',
			'data-max-clone' => CAKE_THEME_FILTER_ROW_LIMIT
		];
		$result['paginTableRowHeaderActTitle'] = __d('view_extension', 'Actions');
		$result['createFilterTableRow'] = [
			'commonOptions' => [
				'label' => false,
				'required' => false,
				'secure' => false,
				'class' => 'form-control' . $inputSize
			],
			'filterText' => __d(
				'view_extension',
				'Data filter for the table: %s',
				$this->Html->tag(
					'code',
					$emptyText,
					[
						'data-toggle' => 'filter-conditions',
						'data-empty-text' => $emptyText
					]
				)
			),
			'showFilterBtn' => $this->ViewExtension->button(
				'far fa-caret-square-down',
				'btn-default',
				['class' => 'show-filter-btn',
					'title' => __d('view_extension', 'Show or hide filter'),
					'data-toggle' => 'collapse', 'data-target' => '.filter-collapse',
					'aria-expanded' => 'false',
					'data-toggle-icons' => 'fa-caret-square-down,fa-caret-square-up'
				]
			),
			'applyFilterBtn' => $this->ViewExtension->button(
				'fas fa-filter',
				'btn-info',
				[
					'type' => 'submit',
					'class' => 'exclude-clone filter-apply',
					'title' => __d('view_extension', 'Apply filter'),
					'data-toggle' => 'tooltip',
					'value' => 'filter-apply',
					'name' => 'data[FilterAction]'
				]
			),
			'clearFilterBtn' => $this->ViewExtension->button(
				'fas fa-eraser',
				'btn-warning',
				[
					'type' => 'reset',
					'class' => 'exclude-clone filter-clear',
					'title' => __d(
						'view_extension',
						'Clear filter'
					),
					'data-toggle' => 'tooltip'
				]
			),
			'addRowBtn' => $this->ViewExtension->button(
				'fas fa-plus',
				'btn-success',
				[
					'title' => __d('view_extension', 'Add row of filter'),
					'data-toggle' => 'btn-action-clone'
				]
			),
			'deleteRowBtn' => $this->ViewExtension->button(
				'fas fa-trash-alt',
				'btn-danger',
				[
					'title' => __d('view_extension', 'Delete row of filter'),
					'data-toggle' => 'btn-action-delete'
				]
			),
			'printBtnOptions' => [
				'title' => __d('view_extension', 'Print informations'),
				'data-toggle' => 'tooltip',
				'target' => '_blank'
			],
			'exportBtnOptions' => [
				'title' => __d('view_extension', 'Export informations'),
				'data-toggle' => 'tooltip'
			],
			'tableHeaderOptions' => [
				'data-toggle' => 'clone-source',
				'class' => 'filter-collapse collapse filter-controls-row'
			]
		];
		$result['createGroupActionControls'] = [
			'selectAllBtn' => $this->ViewExtension->button(
				'far fa-check-square',
				'btn-info',
				['escape' => false, 'class' => 'hidden-print',
					'title' => __d('view_extension', 'Select / deselect all'),
					'data-toggle' => 'btn-action-select-all',
					'data-toggle-icons' => 'fa-check-square,fa-square']
			),
			'groupDataProcTitle' => $this->Html->tag('strong', __d('view_extension', 'Group data processing')),
			'performActionBtn' => [
				'type' => 'submit',
				'escape' => false,
				'title' => __d('view_extension', 'Perform action'),
				'data-toggle' => 'tooltip', 'value' => 'group-action',
				'name' => 'data[FilterAction]', 'data-dialog-title' => __d('view_extension', 'Action to perform'),
				'data-dialog-sel-placeholder' => __d('view_extension', 'Select a action'),
				'data-dialog-btn-ok' => __d('view_extension', 'Perform'),
				'data-dialog-btn-cancel' => __d('view_extension', 'Cancel')
			],
		];
		$result['getBtnConditionField'] = [
			'options' => [
				'' => ['name' => '=', 'title' => '=',
					'data-subtext' => __d('view_extension', 'Equal'), 'value' => ''],
				'gt' => ['name' => '&gt;', 'title' => '&gt;',
					'data-subtext' => __d('view_extension', 'Greater than'), 'value' => 'gt'],
				'ge' => ['name' => '&ge;', 'title' => '&ge;',
					'data-subtext' => __d('view_extension', 'Greater than or equal to'), 'value' => 'ge'],
				'lt' => ['name' => '&lt;', 'title' => '&lt;',
					'data-subtext' => __d('view_extension', 'Less than'), 'value' => 'lt'],
				'le' => ['name' => '&le;', 'title' => '&le;',
					'data-subtext' => __d('view_extension', 'Less than or equal to'), 'value' => 'le'],
				'ne' => ['name' => '&ne;', 'title' => '&ne;',
					'data-subtext' => __d('view_extension', 'Not equal'), 'value' => 'ne'],
			],
			'title' => __d('view_extension', 'Change the logical condition of the field')
		];
		$result['getBtnConditionGroup'] = [
			'options' => [
				'' => ['name' => '&nbsp;&&', 'title' => '&nbsp;&&', 'data-subtext' => __d('view_extension', 'And'), 'value' => ''],
				'or' => ['name' => '&nbsp;||', 'title' => '&nbsp;||', 'data-subtext' => __d('view_extension', 'Or'), 'value' => 'or'],
				'not' => ['name' => '&nbsp;!', 'title' => '&nbsp;!', 'data-subtext' => __d('view_extension', 'Not'), 'value' => 'not'],
			],
			'title' => __d('view_extension', 'Change the logical condition of the group')
		];
		$result['getBtnCondition'] = [
			'type' => 'select',
			'title' => __d('view_extension', 'Changing the filter condition'),
			'style' => 'btn-default btn-filter-condition' . $btnSize,
			'width' => 'fit',
			'live-search' => false,
			'class' => 'form-control show-tick filter-condition' . $inputSize,
			'autocomplete' => 'off',
			'div' => false,
			'label' => false,
			'escape' => false,
			'required' => false,
			'secure' => false,
		];
		$result['prepareOptions'] = [
			'select' => [
				'empty' => '--' . __d('view_extension', 'Sel.') . '--',
				'style' => 'btn-default' . $btnSize
			],
			'string' => [
				'div' => false,
				'type' => 'autocomplete',
				'url' => $this->url(
					$this->ViewExtension->addUserPrefixUrl([
						'controller' => 'filter',
						'action' => 'autocomplete',
						'plugin' => 'cake_theme',
						'ext' => 'json',
						'prefix' => false
					])
				)
			],
			'integer' => [
				'div' => 'input-group'
			],
			'boolean' => [
				'options' => $this->ViewExtension->yesNoList(),
				'type' => 'select',
				'style' => 'btn-default' . $btnSize,
				'empty' => '--' . __d('view_extension', 'Sel.') . '--'
			],
			'date' => [
				'div' => 'input-group',
				'widget-position-vertical' => 'bottom',
				'icon-type' => 'false',
			],
			'binary' => [
				'disabled' => true
			]
		];
		Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_HELPERS);

		return $result;
	}
732682
public function getDefaults()
    {
        global $user;
        return array(
            'post_type'     => $this->getPostType(),
            'post_author'   => (is_object($user)) ? $user->ID : null,
            'post_date'     => current_time('mysql'),
            'post_category' => array(0),
            'post_status'   => 'publish'
        );
    }
1028633
public function defaults()
	{
		// Reset filters.
        foreach ($this->getProfileConfig('filters') as $filter) {
        	$this->addFilter(new $filter);
        }

        // Reset hooks.
        foreach ($this->getProfileConfig('hooks') as $hook => $config) {
        	$this->addHook(new $hook($config));
        }

        // Reset black & white list.
        $this->whitelist($this->getProfileConfig('whitelist'));
        $this->blacklist($this->getProfileConfig('blacklist'));

        // Add configs dir as path.
        $this->addPath($this->_configs->get('bbcoder::cpath'));

        return $this;
	}
1025891
public function getSearchAttributes()
	{
		$attributes = array();

		foreach( $this->_searchConfig as $values ) {
			$attributes[] = new MW_Common_Criteria_Attribute_Default( $values );
		}

		return $attributes;
	}
146205
public function addAllFilters()
    {
        $fields = array_keys($this->getDataObjectInstance()->searchableFields());
        foreach ($fields as $fieldName) {
            $this->addDefaultFilters($fieldName);
        }

        return $this;
    }
91149
public function getDefaultValues()
    {
        $result = [];

        foreach ($this->getFormFields() as $attribute => $field) {
            if (($value = array_get($field, 'default')) === null) {
                continue;
            }

            $result[$attribute] = $value;
        }

        return $result;
    }
1207700
private static function getDefaults()
    {
        return [
            self::OPTION_ENDPOINT           => null,
            self::OPTION_HOST               => null,
            self::OPTION_PORT               => DefaultValues::DEFAULT_PORT,
            self::OPTION_TIMEOUT            => DefaultValues::DEFAULT_TIMEOUT,
            self::OPTION_CREATE             => DefaultValues::DEFAULT_CREATE,
            self::OPTION_UPDATE_POLICY      => DefaultValues::DEFAULT_UPDATE_POLICY,
            self::OPTION_REPLACE_POLICY     => DefaultValues::DEFAULT_REPLACE_POLICY,
            self::OPTION_DELETE_POLICY      => DefaultValues::DEFAULT_DELETE_POLICY,
            self::OPTION_REVISION           => null,
            self::OPTION_WAIT_SYNC          => DefaultValues::DEFAULT_WAIT_SYNC,
            self::OPTION_BATCHSIZE          => null,
            self::OPTION_JOURNAL_SIZE       => DefaultValues::DEFAULT_JOURNAL_SIZE,
            self::OPTION_IS_SYSTEM          => false,
            self::OPTION_IS_VOLATILE        => DefaultValues::DEFAULT_IS_VOLATILE,
            self::OPTION_CLIENT             => DefaultValues::DEFAULT_CLIENT,
            self::OPTION_TRACE              => null,
            self::OPTION_ENHANCED_TRACE     => false,
            self::OPTION_AUTH_USER          => null,
            self::OPTION_AUTH_PASSWD        => null,
            self::OPTION_AUTH_TYPE          => null,
            self::OPTION_RECONNECT          => false,
            self::OPTION_BATCH              => false,
            self::OPTION_BATCHPART          => false,
            self::OPTION_CHECK_UTF8_CONFORM => DefaultValues::DEFAULT_CHECK_UTF8_CONFORM,
        ];
    }
396091
public function getAvailableFilters()
    {
        if (!$this->defaultFilter) {
            $this->defaultFilter = $this->app->make(StandardFilter::class, [
                $this,
                self::IDENTIFIER,
                t('User Deactivated'),
                'userdeactivatednotification'
            ]);
        }

        return [$this->defaultFilter];
    }
195527
public function getDefaultSearchContext()
    {
        $context = parent::getDefaultSearchContext();
        $fields = $context->getSearchFields();

        $fields->removeByName('Gateway');
        $fields->removeByName('Created');

        $fields->insertAfter('Money', DropdownField::create(
            'Gateway',
            $this->fieldLabel('Gateway'),
            GatewayInfo::getSupportedGateways()
        )->setHasEmptyDefault(true));

        // create a localized status dropdown for the search-context
        $fields->insertAfter('Gateway', DropdownField::create(
            'Status',
            $this->fieldLabel('Status'),
            $this->getStatusValues()
        )->setHasEmptyDefault(true));

        $context->addFilter(new PartialMatchFilter('Gateway'));

        return $context;
    }