<?php
namespace ModulesAbstract\PluginReports\ConfigUDEFListing; abstract class Model extends \App\Mvc\Model_ListingAbstract { abstract public function getUDEFConfigs(); abstract public function saveUDEFConfigs(array $UDEFConfigs); abstract public function getUDEFPossibleFields(); protected function sliceResultsList(array $UDEFResults, \App\Mvc\View\Listing\Members\Params $listingParams) { $currentPage = $listingParams->getCurrentPage(); $resultsPerPage = $listingParams->getResultsPerPage(); if (!$resultsPerPage) { throw new \Exception(sprintf("[%s] resultsPerPage not set", __METHOD__)); } $UDEFResults = array_slice($UDEFResults, $currentPage*$resultsPerPage, $resultsPerPage, true); return $UDEFResults; } protected function UDEFShouldBeDisplayed(array $UDEF, array $filters) { if ($filters['corporateFilter']) { if ($UDEF['corporateFilter'] != $filters['corporateFilter']) { return false; } } return true; } function list_execute(\App\Mvc\View\Listing\Members\Params $listingParams) { $UDEFConfigs = $this->getUDEFConfigs(); $filters = $listingParams->getFilters(); $listedUDEFs = []; foreach ($UDEFConfigs as $k=>$UDEFConfig) { if ($this->UDEFShouldBeDisplayed($UDEFConfig, ($filters?$filters:[]))) { $UDEFConfig['id'] = $k; $listedUDEFs[$k] = $UDEFConfig; } } $totalRecordsCount = count($listedUDEFs); $listedUDEFs = $this->sliceResultsList($listedUDEFs, $listingParams); $this->recordsList = $listedUDEFs; $this->totalRecordsCount = $totalRecordsCount; } } 