Example #1
0
File: Art.php Project: 4otaku/art
 public function __construct($url, $get = [], $clean = true)
 {
     parent::__construct($url, $get, $clean);
     $pool_count = 0;
     foreach ($this->get() as $key => $items) {
         $negated = false;
         if (strpos($key, '-') === 0) {
             $key = substr($key, 1);
             $negated = true;
         }
         $is_comparable = in_array($key, $this->comparable_keys);
         $is_equal = in_array($key, $this->equal_keys);
         $is_other = in_array($key, $this->other_keys);
         $is_pool = in_array($key, $this->pool_keys);
         if (!$is_comparable && !$is_equal) {
             if ($is_other) {
                 $item = is_array($items) ? reset($items) : $items;
                 if ($key == 'mode' && !in_array($item, $this->possible_modes)) {
                     continue;
                 }
                 $this->other[$key] = $item;
             }
             continue;
         }
         list($is, $not, $more, $less) = $this->parse((array) $items, $is_comparable, $negated);
         if (!isset($this->parsed[$key])) {
             $this->parsed[$key] = ['is' => [], 'not' => [], 'more' => [], 'less' => []];
         }
         $this->parsed[$key]['is'] = array_merge($this->parsed[$key]['is'], $is);
         $this->parsed[$key]['not'] = array_merge($this->parsed[$key]['not'], $not);
         $this->parsed[$key]['more'] = array_merge($this->parsed[$key]['more'], $more);
         $this->parsed[$key]['less'] = array_merge($this->parsed[$key]['less'], $less);
         if ($is_pool && $pool_count !== false) {
             if (!empty($not) || !empty($more) || !empty($less)) {
                 $pool_count = false;
             } else {
                 $pool_count += count($is);
                 $this->pool_mode = $key;
             }
         }
     }
     if ($pool_count !== 1 || $this->is_pool_list()) {
         $this->pool_mode = false;
     }
     if (!empty($this->other['sort']) && !in_array($this->other['sort'], $this->legal_sort)) {
         unset($this->other['sort']);
     }
     ksort($this->other);
     if (isset($this->other['per_page']) && $this->other['per_page'] == 'all') {
         if ($this->get_pool_mode() || !empty($this->parsed['parent']['is'])) {
             $this->other['per_page'] = 999999;
             $this->per_page_all = true;
         } else {
             unset($this->other['per_page']);
         }
     }
     if (isset($this->other['per_page'])) {
         $this->other['per_page'] = (int) $this->other['per_page'];
     }
     if (empty($this->other['per_page'])) {
         if (isset($this->other['mode']) && $this->other['mode'] == 'comment') {
             $this->other['per_page'] = Config::getInstance()->get('art', 'per_page_comment');
         } else {
             $this->other['per_page'] = Config::getInstance()->get('art', 'per_page');
         }
         $this->forced_per_page = false;
     }
 }