xref: /plugin/struct/meta/SearchConfig.php (revision 61809d194a3c76106a28f6f325765c699cddf410)
15511bd5bSAndreas Gohr<?php
25511bd5bSAndreas Gohr
35511bd5bSAndreas Gohrnamespace plugin\struct\meta;
45511bd5bSAndreas Gohr
55511bd5bSAndreas Gohr/**
65511bd5bSAndreas Gohr * Class SearchConfig
75511bd5bSAndreas Gohr *
85511bd5bSAndreas Gohr * The same as @see Search but can be initialized by a configuration array
95511bd5bSAndreas Gohr *
105511bd5bSAndreas Gohr * @package plugin\struct\meta
115511bd5bSAndreas Gohr */
125511bd5bSAndreas Gohrclass SearchConfig extends Search {
135511bd5bSAndreas Gohr
145511bd5bSAndreas Gohr    /**
155511bd5bSAndreas Gohr     * SearchConfig constructor.
165511bd5bSAndreas Gohr     * @param $config
175511bd5bSAndreas Gohr     */
185511bd5bSAndreas Gohr    public function __construct($config) {
195511bd5bSAndreas Gohr        parent::__construct();
205511bd5bSAndreas Gohr
215511bd5bSAndreas Gohr        foreach($config['schemas'] as $schema) {
225511bd5bSAndreas Gohr            $this->addSchema($schema[0], $schema[1]);
235511bd5bSAndreas Gohr        }
245511bd5bSAndreas Gohr
255511bd5bSAndreas Gohr        foreach($config['cols'] as $col) {
265511bd5bSAndreas Gohr            $this->addColumn($col);
275511bd5bSAndreas Gohr        }
285511bd5bSAndreas Gohr
29*61809d19SMichael Große        if ($config['sort'][0] != '') {
30*61809d19SMichael Große            $this->addSort($config['sort'][0], $config['sort'][1] === 'ASC');
31*61809d19SMichael Große        }
32*61809d19SMichael Große
335511bd5bSAndreas Gohr        foreach($config['filter'] as $filter) {
345511bd5bSAndreas Gohr            $this->addFilter($filter[0], $filter[2], $filter[1], $filter[3]);
355511bd5bSAndreas Gohr        }
365511bd5bSAndreas Gohr
375511bd5bSAndreas Gohr        // FIXME add additional stuff
385511bd5bSAndreas Gohr
395511bd5bSAndreas Gohr    }
405511bd5bSAndreas Gohr
415511bd5bSAndreas Gohr}
42