Get List view data

@param int $start
@param int $rowPerPage
@param string $keyword
@param string $sortField
@param string $sortOrder ASC/DESC
@return array List of beans
@throws \RedBeanPHP\RedException\SQL
436924
protected function getListViewData($start = null, $rowPerPage = null, $keyword = null, $sortField = null, $sortOrder = null) {
        $list = [];

        if ($this->listViewDataClosure != null) {
            $c = $this->listViewDataClosure;
            $list = $c($start, $rowPerPage, $keyword, $sortField, $sortOrder);

        } elseif ($keyword != null && trim($keyword) != "" && $this->searchClosure != null) {         // For Custom Searching
            $c = $this->searchClosure;
            $list = $c($start, $rowPerPage, $keyword, $sortField, $sortOrder);

        } else {
            $this->beforeGetListViewData(function ($tableName, $findClause, $limit, $bindingData) use (&$list) {

                // For RedBean Case
                $list = R::find($tableName, $findClause . $limit, $bindingData);

            }, function ($sql, $limit, $bindingData) use (&$list) {

                // For SQL Case
                $list = R::getAll($sql . $limit, $bindingData);

                try {
                    $list = R::convertToBeans($this->tableName, $list);
                } catch (\Exception $ex) {

                }

            }, $start, $rowPerPage, $keyword, $sortField, $sortOrder);
        }

        return $list;
    }
1361486
public function getPaginated($paged = 15, $orderBy = 'created_at', $sort = 'desc')
    {
        $query = function () use ($paged, $orderBy, $sort) {

            return $this->model
                ->with($this->requiredRelationships)
                ->orderBy($orderBy, $sort)
                ->paginate($paged);
        };

        return $this->doQuery($query);
    }
382569
private function queryOrderBuilder($query, array $sortParameters)
    {
        $model = $this;

        list($column, $direction) = $this->parseParameters($sortParameters);

        if (is_null($column)) {
            return $query;
        }

        $explodeResult = SortableLink::explodeSortParameter($column);
        if ( ! empty($explodeResult)) {
            $relationName = $explodeResult[0];
            $column       = $explodeResult[1];

            try {
                $relation = $query->getRelation($relationName);
                $query    = $this->queryJoinBuilder($query, $relation);
            } catch (BadMethodCallException $e) {
                throw new ColumnSortableException($relationName, 1, $e);
            } catch (\Exception $e) {
                throw new ColumnSortableException($relationName, 2, $e);
            }

            $model = $relation->getRelated();
        }

        if (method_exists($model, camel_case($column).'Sortable')) {
            return call_user_func_array([$model, camel_case($column).'Sortable'], [$query, $direction]);
        }

        if (isset($model->sortableAs) && in_array($column, $model->sortableAs)) {
            $query = $query->orderBy($column, $direction);
        } elseif ($this->columnExists($model, $column)) {
            $column = $model->getTable().'.'.$column;
            $query  = $query->orderBy($column, $direction);
        }

        return $query;
    }
801610
public function getList(int $page, int $limit, Context $context, array $requestFilters, array $sort): array
    {
        --$page;
        $metaData = $this->getSetMetaData($context);

        $isoList = $this->createIsoList($metaData);
        $languageFiles = $this->getSnippetFilesByIso($isoList);

        $fileSnippets = $this->getFileSnippets($languageFiles, $isoList);
        $dbSnippets = $this->databaseSnippetsToArray($this->findSnippetInDatabase(new Criteria(), $context), $fileSnippets);

        $snippets = array_replace_recursive($fileSnippets, $dbSnippets);
        $snippets = $this->fillBlankSnippets($snippets, $isoList);

        foreach ($requestFilters as $requestFilterName => $requestFilterValue) {
            $snippets = $this->snippetFilterFactory->getFilter($requestFilterName)->filter($snippets, $requestFilterValue);
        }

        $snippets = $this->sortSnippets($sort, $snippets);

        $total = 0;
        foreach ($snippets as $setId => &$set) {
            $total = $total > 0 ? $total : count($set['snippets']);
            $set['snippets'] = array_chunk($set['snippets'], $limit, true)[$page] ?? [];
        }

        return [
            'total' => $total,
            'data' => $this->mergeSnippetsComparison($snippets),
        ];
    }
787822
public function getServiceList($start = 0, $end = 5)
    {
        ValidationUtility::ensureInteger('$start', $start);
        ValidationUtility::ensureNotNegative('$start', $start);

        ValidationUtility::ensureInteger('$end', $end);
        ValidationUtility::ensureNotNegative('$end', $end);

        $queryParams = array(
            'start' => $start,
            'end'   => $end
        );

        return $this->callServiceOwnerGetApi(
            '\Authlete\Dto\ServiceListResponse::fromJson',
            self::$SERVICE_GET_LIST_API_PATH,
            $queryParams);
    }
226284
public function getClientList($developer = null, $start = 0, $end = 5)
    {
        ValidationUtility::ensureNullOrString('$developer', $developer);

        ValidationUtility::ensureInteger('$start', $start);
        ValidationUtility::ensureNotNegative('$start', $start);

        ValidationUtility::ensureInteger('$end', $end);
        ValidationUtility::ensureNotNegative('$end', $end);

        $queryParams = array(
            'developer' => $developer,
            'start'     => $start,
            'end'       => $end
        );

        return $this->callServiceGetApi(
            '\Authlete\Dto\ClientListResponse::fromJson',
            self::$CLIENT_GET_LIST_API_PATH,
            $queryParams);
    }
805740
public function getContacts($id, $start = 0, $limit = 0, array $order = array(), array $where = array())
    {
        $parameters = array();
        $args = array('start', 'limit', 'order', 'where');

        foreach ($args as $arg) {
            if (!empty($$arg)) {
                $parameters[$arg] = $$arg;
            }
        }

        return $this->makeRequest($this->endpoint.'/'.$id.'/contacts', $parameters);
    }
383481
public function getPaginatedRoutes($sort = 'name', $perPage = null)
    {
        return $this->paginate(
            $this->getAllRoutes($sort), $perPage
        );
    }
969536
protected function display_start($question, $rowclasses) {
        $tag = 'td';
        $attr = array('class' => $this->get_classes());
        if ($this->isheading) {
            $tag = 'th';
            $attr['scope'] = 'row';
        }
        echo \html_writer::start_tag($tag, $attr);
    }
1081399
public function pagination($start = 1, $length = 10)
	{
		// manually create paginator
		$data = array_map(function ($num) {
			return ['id' => $num, 'value' => "Item $num"];
		}, range(1, 100));
		$page = Paginator::resolveCurrentPage('page');
		$path = Paginator::resolveCurrentPath();
		$items = array_slice($data, abs($start - 1) + (($page - 1) * $length), $length);
		$paginator = new LengthAwarePaginator($items, count($data), $length, $page, [
			'path'     => $path,
			'pageName' => 'page',
		]);

		// append existing parameters
		$paginator->appends(Sketchpad::$params);

		// output
		return view('sketchpad::help/output/pagination', compact('items', 'paginator'));

	}
140985
public function getData( $first = FALSE, $orders = array(), $limit = array(), $verbose = FALSE )
	{
		$data = array();
		if( $this->isFocused() && sizeof( $this->fields ) )
		{
			$conditions	= $this->getConditionQuery( array() );
			$orders		= $this->getOrderQuery( $orders );
			$limit		= $this->getLimitQuery( $limit );

		 	$query = 'SELECT * FROM '.$this->getTableName().' WHERE '.$conditions.$orders.$limit;
			if( $verbose )
				echo '<br/>'.$query;
			$q	= $this->dbc->Execute( $query );
			if( $q->RecordCount() )
			{
				while( $d = $q->FetchNextObject( FALSE ) )
				{
					$line = array();
					foreach( $this->fields as $field )
						$line[$field] = $d->$field;
					$data[] = $line;
				}
			}
		}
		if( count( $data ) && $first )
			$data	= $data[0];
		return $data;
	}
1263129
public function jsonRows()
    {
        $arrWhat = array_values($this->getHeaderColumns());
        $arrWhere = [];
        $arrOrder = ['`id` DESC'];
        $start = 0;
        $pageSize = 15;
        if (isset($_POST['page']) && isset($_POST['pageSize'])) {
            $page = (int) $_POST['page'];
            $pageSize = (int) $_POST['pageSize'];
            $start = $page * $pageSize;
        }
        if (isset($_POST['sort']) && isset($_POST['sortDir'])) {
            $sort = (string) $_POST['sort'];
            $sortDir = (string) $_POST['sortDir'];
            if (!in_array($sortDir, ['ASC', 'DESC'])) {
                throw new Exception('Someone is doing something evil here :(');
            }
            if (!in_array($sort, $this->getAllowedPostColumns())) {
                throw new Exception('Someone is doing something evil here :(');
            }
            $arrOrder = ['`'.$sort.'` '.$sortDir];
        }
        foreach ($arrWhat as $filter) {
            if (in_array($filter, $arrWhat) && isset($_POST['filter_'.$filter])) {
                $arrWhere[$filter] = [
                    "operator" => "like",
                    "value" => '%'.$_POST['filter_'.$filter].'%'
                ];
            }
        }
        
        $arrLimit = [$start, $pageSize];
        $rows = $this->loadByPrepStmt($arrWhat, $arrWhere, $arrOrder, $arrLimit);
        if (count($rows) < 1) {
            return "[]";
        }
        foreach ($rows as $key => $columns) {
            foreach ($columns as $cKey => $column) {
                if ($cKey == "createDate") {
                    $rows[$key][$cKey] = strftime("%d.%m.%Y %H:%M:%S", strtotime($column));
                }
            }
            $rows[$key]['actions'] = $this->renderActionLinks();
        }
        $json = json_encode($rows, JSON_UNESCAPED_UNICODE);
        return $json;
    }
1272932
public function getPaginatedData($tableName, $page = 1, $limit = 10, $orderAttribute = null, $order = 'ASC')
    {
        Paginator::currentPageResolver(function () use ($page) {
            return $page;
        });
        $data = $this->database->table($tableName);
        if (null === $orderAttribute) {
            return $data->paginate($limit)->toArray();
        }
        return $data->orderBy($orderAttribute, $order)->paginate($limit)->toArray();
    }
836042
public function users($keyword, $start_page = 0)
	{
		// Build the request path.
		$path = '/legacy/user/search/' . $keyword . '?';

		$path .= ($start_page) ? '&start_page=' . $start_page : '';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}
1273286
public static function getOrder($sort, $allowField, $mapped = [], $defaultOrder = '')
    {
        $order = $defaultOrder;
        if ($sort) {
            $orders = [];
            $sortData = json_decode($sort, true);
            foreach ($sortData as $item) {
                if (!empty($item) && isset($item['property']) && isset($item['direction'])) {
                    $fieldName = $item['property'];
                    if (isset($mapped[$fieldName])) {
                        $fieldName = $mapped[$fieldName];
                    }
                    if (in_array($fieldName, $allowField)) {
                        $order = $fieldName;
                        if ('DESC' == $item['direction']) {
                            $order .= ' DESC';
                        } else {
                            $order .= ' ASC';
                        }
                        $orders[] = $order;
                    }
                }
            }
            if ($orders) {
                $order = join(',', $orders);
            }
        }

        return $order;
    }
409637
public function getPager(Collection $collection, int $startPage, ?int $maxPages = null, int $flags = 0): Pagerfanta
    {
        $maxTotalCount = null;
        if (is_int($maxPages) && $maxPages > 0) {
            $maxTotalCount = $maxPages * $this->getMaxPerPage($collection);
        }

        $pagerAdapter = new ResultBuilderAdapter(
            $this->resultBuilder,
            $collection,
            $collection->getOffset(),
            $maxTotalCount,
            $flags
        );

        return $this->buildPager($pagerAdapter, $collection, $startPage);
    }
1073202
protected function getNumberLinks($perPage, $startRowNumber, $startIndexNumber = 1)
    {
        $numberLinks = NULL;

        for( $i = $startIndexNumber; $i <= $perPage; $i++ )
        {
            $page = ($i - 1) * $this->limit;

            if( $i - 1 == floor((int) $startRowNumber / $this->limit) )
            {
                $currentLink = $this->getStyleClassAttributes('current');
            }
            else
            {
                $currentLink = $this->getStyleClassLinkAttributes('links');;
            }

            $numberLinks .= $this->getLink($page, $currentLink, $i);
        }

        return $numberLinks;
    }