Beispiel #1
0
 public function search(\Base $f3, $params)
 {
     $get = [];
     if (isset($params[1])) {
         $get = $this->parametric($params[1]);
     }
     $searchData = $f3->get('POST');
     $searchData = array_filter(array_merge($get, $searchData));
     $ratings = $this->model->ratings();
     $f3->set('searchRatings', $ratings);
     $ratingMaxID = end($ratings)['rid'];
     // Add personal search preferences at some point
     $searchData['rating'][0] = min(@$searchData['rating'][0] ?: 0, $ratingMaxID);
     // Add personal search preferences at some point
     $searchData['rating'][1] = min(max(@$searchData['rating'][1] ?: end($ratings)['rid'], $searchData['rating'][0]), $ratingMaxID);
     $this->view->addTitle($f3->get('LN__Search'));
     // Author
     if (empty($searchData['author'])) {
         $f3->set('prepopulateData.author', "[]");
     } else {
         $f3->set('prepopulateData.author', $this->model->searchPrepopulate("author", implode(",", $this->searchCleanInput($searchData['author']))));
     }
     // Category
     if (empty($searchData['category'])) {
         $f3->set('prepopulateData.category', "[]");
     } else {
         $f3->set('prepopulateData.category', $this->model->searchPrepopulate("category", implode(",", $this->searchCleanInput($searchData['category']))));
     }
     // Tag
     if (empty($searchData['tagIn'])) {
         $f3->set('prepopulateData.tagIn', "[]");
     } else {
         $f3->set('prepopulateData.tagIn', $this->model->searchPrepopulate("tag", implode(",", $this->searchCleanInput($searchData['tagIn']))));
     }
     // excluded Tag
     if (empty($searchData['tagOut'])) {
         $f3->set('prepopulateData.tagOut', "[]");
     } else {
         $f3->set('prepopulateData.tagOut', $this->model->searchPrepopulate("tag", implode(",", $this->searchCleanInput($searchData['tagOut']))));
     }
     // return string
     if (sizeof($searchData) > 0) {
         foreach ($searchData as $k => $v) {
             if (is_array($v)) {
                 $return[] = "{$k}=" . implode(",", $v);
             } elseif ($v > "") {
                 $return[] = "{$k}={$v}";
             }
         }
         $return = implode(";", $return);
         $data = $this->model->search($searchData, $return);
         $this->buffer(\View\Story::searchPage($searchData));
         $this->buffer(\View\Story::viewList($data));
     } else {
         $this->buffer(\View\Story::searchPage());
     }
 }