Example #1
0
 protected function generateContent()
 {
     $conditions = [];
     if (!User::isInGroup(U_GROUP_EMPLOYEE)) {
         $conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
     }
     // include child categories if current category is empty
     if ($this->category) {
         $conditions[] = ['category', (int) end($this->category)];
     }
     // recreate form selection
     $this->filter = $this->filterObj->getForm('form');
     $this->filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : null;
     $this->filter['fi'] = $this->filterObj->getForm();
     if ($fiCnd = $this->filterObj->getConditions()) {
         $conditions[] = $fiCnd;
     }
     $acvList = new AchievementList($conditions);
     if (!$acvList->getMatches()) {
         $curCats = $catList = [!empty($this->category) ? (int) end($this->category) : 0];
         while ($curCats) {
             $curCats = DB::Aowow()->SelectCol('SELECT Id FROM ?_achievementcategory WHERE parentCategory IN (?a)', $curCats);
             $catList = array_merge($catList, $curCats);
         }
         $conditions = [];
         if ($fiCnd) {
             $conditions[] = $fiCnd;
         }
         if ($catList) {
             $conditions[] = ['category', $catList];
         }
         $acvList = new AchievementList($conditions);
     }
     $params = $data = [];
     if (!$acvList->error) {
         $data = $acvList->getListviewData();
         // fill g_items, g_titles, g_achievements
         $this->extendGlobalData($acvList->getJSGlobals());
         // if we are have different cats display field
         if ($acvList->hasDiffFields(['category'])) {
             $params['visibleCols'] = "\$['category']";
         }
         if (!empty($this->filter['fi']['extraCols'])) {
             $params['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)';
         }
         // create note if search limit was exceeded
         if ($acvList->getMatches() > CFG_SQL_LIMIT_DEFAULT) {
             $params['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_achievementsfound', $acvList->getMatches(), CFG_SQL_LIMIT_DEFAULT);
             $params['_truncated'] = 1;
         }
         if ($this->filterObj->error) {
             $params['_errors'] = '$1';
         }
     }
     $this->lvTabs[] = array('file' => 'achievement', 'data' => $data, 'params' => $params);
     // sort for dropdown-menus in filter
     Lang::sort('game', 'si');
 }