Search file system.

@param string $config
@param array $options
@param string $name
@return array
333650
protected static function _search($config, $options, $name = null) {
		$defaults = [
			'path' => null,
			'suffix' => null,
			'namespaces' => false,
			'recursive' => false,
			'preFilter' => '/[A-Z][A-Za-z0-9]+\./',
			'filter' => false,
			'exclude' => false,
			'format' => function ($file, $config) {
				$trim = [strlen($config['path']) + 1, strlen($config['suffix'])];
				$file = substr($file, $trim[0], -$trim[1]);
				return $config['prefix'] . str_replace('/', '\\', $file);
			}
		];
		$options += $defaults;
		$path = $options['path'];
		$suffix = $options['namespaces'] ? '' : $config['suffix'];
		$suffix = ($options['suffix'] === null) ? $suffix : $options['suffix'];


		$dFlags = GLOB_ONLYDIR;
		$zFlags = 0;
		if (strpos($path, '{') !== false) {
			$message  = "Search path `{$path}` relies on brace globbing. ";
			$message .= 'Support for brace globbing in search paths has been deprecated.';
			trigger_error($message, E_USER_DEPRECATED);

			$dFlags |= GLOB_BRACE;
			$zFlags |= GLOB_BRACE;
		}
		$libs = (array) glob($path . $suffix, $options['namespaces'] ? $dFlags : $zFlags);

		if ($options['recursive']) {
			list($current, $match) = explode('/*', $path, 2);
			$queue = array_diff((array) glob($current . '/*', $dFlags), $libs);
			$match = str_replace('##', '.+', preg_quote(str_replace('*', '##', $match), '/'));
			$match = '/' . $match . preg_quote($suffix, '/') . '$/';

			while ($queue) {
				if (!is_dir($dir = array_pop($queue))) {
					continue;
				}
				$libs = array_merge($libs, (array) glob("{$dir}/*{$suffix}"));
				$queue = array_merge($queue, array_diff((array) glob("{$dir}/*", $dFlags), $libs));
			}
			$libs = preg_grep($match, $libs);
		}
		if ($suffix) {
			$libs = $options['preFilter'] ? preg_grep($options['preFilter'], $libs) : $libs;
		}
		return static::_filter($libs, (array) $config, $options + compact('name'));
	}
818983
public function search($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'search'          => null,
            'submit_on_clear' => true,
            'placeholder'     => $this->getObject('translator')->translate('Find by title or description&hellip;')
        ));

        $html = '';

        if ($config->submit_on_clear)
        {
            $html .= $this->getTemplate()->helper('behavior.jquery');
            $html .= '
            <script>
            (function() {
            var value = '.json_encode($config->search).',
                submitForm = function(form) {
                    if (form.length) {
                        var controller = form.data("controller");
                        if (typeof controller === "object" && controller !== null
                                && controller.grid && typeof controller.grid.uncheckAll !== "undefined") {
                            controller.grid.uncheckAll();
                        }
    
                        form[0].submit();
                    }
                },
                send = function(event) {
                    var v = kQuery(this).val();

                    if (v) {
                        kQuery(".k-search__empty").addClass("k-is-visible");
                    } else {
                        kQuery(".k-search__empty").removeClass("k-is-visible");
                    }

                    if (event.which === 13 || (event.type === "blur" && (v || value) && v != value)) {
                        event.preventDefault();
                        submitForm(kQuery(this).parents("form"));
                    }
                };

            kQuery(function($) {
                $(".k-search__field").keypress(send).blur(send);
                var empty_button = $(".k-search__empty");
                
                if (value) {
                    empty_button.addClass("k-is-visible");
                }
                
                empty_button.click(function(event) {
                    event.preventDefault();

                    var input = $(this).siblings("input");
                    input.val("");

                    if (value) {
                        submitForm(input.parents("form"));
                    }
                });
            });
            })();
            </script>';
        }

        $html .= '<div class="k-search k-search--has-both-buttons">';
        $html .= '<label for="k-search-input">' . $this->getObject('translator')->translate('Search') . '</label>';
        $html .= '<input id="k-search-input" type="search" name="search" class="k-search__field" placeholder="'.$config->placeholder.'" value="'.$this->getTemplate()->escape($config->search).'" />';
        $html .= '<button type="submit" class="k-search__submit">';
        $html .= '<span class="k-icon-magnifying-glass" aria-hidden="true"></span>';
        $html .= '<span class="k-visually-hidden">' . $this->getObject('translator')->translate('Search') . '</span>';
        $html .= '</button>';
        $html .= '<button type="button" class="k-search__empty">';
        $html .= '<span class="k-search__empty-area">';
        $html .= '<span class="k-icon-x" aria-hidden="true"></span>';
        $html .= '<span class="k-visually-hidden">' . $this->getObject('translator')->translate('Clear search') . '</span>';
        $html .= '</span>';
        $html .= '</button>';
        $html .= '</div>';



        return $html;
    }
1267070
protected function getOptionsList($name, $options)
    {
        if (empty($options)) {
            $options = $this->getOptionsFromModel($name);
        }

        return $options;
    }
900119
public function validateOptions($name, $options)
	{
		if (is_string($options))
		{
			$name = $options;
			$options = array();
		}

		//if the name is not a string or the options is not an array at this point, throw an error because we can't do anything with it
		if (!is_string($name) || !is_array($options))
		{
			throw new \InvalidArgumentException("One of the fields in your " . $this->config->getOption('name') . " configuration file is invalid");
		}

		//in any case, make sure the 'column_name' option is set
		$options['field_name'] = $name;

		return $options;
	}
1334112
public function loadArray(array $options, Config $config = null)
    {
        Assertion::notEmpty($options);

        if (is_null($config)) {
            $config = new Config();
        }

        $options = $this->doReplacements($options);

        $config->merge(
            new Config($options)
        );

        return $config;
    }
370445
public function selectCollection($name, array $options = [])
    {
        if (!isset($this->collections[$name])) {
            $this->createCollection($name);
        }
        return $this->collections[$name]['collection'];
    }
122529
public function password($name, array $options = [])
    {
        return $this->form->password($name,
                                     $this->addFormControlClass($this->getFieldOptions($name, $options)));
    }
723472
protected function doCreateCollection($name, array $options)
    {
        if (version_compare(phpversion('mongo'), '1.4.0', '>=')) {
            $this->riak->createCollection($name, $options);
        } else {
            $this->riak->createCollection($name, $options['capped'], $options['size'], $options['max']);
        }

        return $this->doSelectCollection($name);
    }
564356
public function search(string $search, $properties = null, array $options = null)
    {
        return $this->__call('search', [$search, $properties, $options]);
    }
40379
public function searchMenu($name, $menu = false)
    {
        //parse the type based on the config name if this is the top-level item
        if ($menu === false) {
            $this->parseType($name);
        }

        $config = false;
        $menu   = $menu ? $menu : $this->options['menu'];

        //iterate over all the items in the menu array
        foreach ($menu as $key => $item) {
            //if the item is a string, try to find the config file
            if (is_string($item) && $item === $name) {
                $config = $this->fetchConfigFile($name);
            }
            //if the item is an array, recursively run this method on it
            elseif (is_array($item)) {
                $config = $this->searchMenu($name, $item);
            }

            //if the config var was set, break the loop
            if (is_array($config)) {
                break;
            }
        }

        return $config;
    }
565897
protected function getRecursive(&$config, $names)
    {
        if (empty($names)) {
            return $config;
        }

        $name = array_shift($names);

        if (!isset($config[$name])) {
            return null;
        }

        return $this->getRecursive($config[$name], $names);
    }
255269
public static function connect($config = [], $name = 'default')
    {
        if (is_string($config) || (isset($config['dsn']) && !empty($config['dsn']))) {
            $config = self::parseDsn($config);
        }
        $options = array_merge(self::$defaultConfig, $config);
        if (empty($options['type'])) {
            throw new \InvalidArgumentException('Undefined db type');
        }
        $class                 = false !== strpos($options['type'], '\\') ? $options['type'] : '\\tpr\\db\\connector\\' . ucwords(strtolower($options['type'])) . "Connector";
        self::$instance[$name] = new $class($options);
        return self::$instance[$name];
    }
191653
protected function getClass($config, $name)
    {
        if (array_key_exists($name, $config) 
                && is_array($config[$name])
                && array_key_exists('class', $config[$name]) 
                && is_scalar($config[$name]['class'])) {
            return $config[$name]['class'];
        }
        
        return false;
    }
529455
private static function isFileNamePatternMatch($name, $pattern, $options) {
    if (in_array($name, static::$excluded_file_names)) {
      return false;
    }

    $fnmatch_flags = 0;
    if ($options & GLOB_NOESCAPE) {
      $fnmatch_flags |= FNM_NOESCAPE;
    }

    return fnmatch($pattern, $name, $fnmatch_flags);
  }
345746
public function file($name, $label = null, array $options = [])
    {
        $label = $this->getLabelTitle($label, $name);

        $options = array_merge(['class' => 'filestyle', 'data-buttonBefore' => 'true'], $options);

        $options = $this->getFieldOptions($options, $name);
        $inputElement = $this->form->input('file', $name, null, $options);

        $wrapperOptions = $this->isHorizontal() ? ['class' => $this->getRightColumnClass()] : [];
        $wrapperElement = '<div' . $this->html->attributes($wrapperOptions) . '>' . $inputElement . $this->getFieldError($name) . $this->getHelpText($name, $options) . '</div>';

        return $this->getFormGroup($name, $label, $wrapperElement);
    }
182618
protected function buildFilter($name, $config)
    {
        $className = App::className($name, 'Filter');
        if (!class_exists($className)) {
            $className = App::className('AssetCompress.' . $name, 'Filter');
        }
        $className = $className ?: $name;

        return parent::buildFilter($className, $config);
    }
641640
public function filter($name, array $options = [])
    {
        $result = static::INT_FILTER;

        if ($this->isMultipartImage()) {
            $this->resource = $this->resource->coalesceImages();
        }

        foreach ($this->resource as $frame) {
            $result = $this->callParentFilter($name, $options);
        }


        if (static::EXT_FILTER === $result and isset($this->filters[$name])) {

            $filter = new $this->filters[$name]($this, $options);

            foreach ($this->resource as $frame) {
                $filter->run();
            }
        }

    }