getOptions(); $shown = $options['currentItemsPerPage'] * $options['currentPage']; if ($shown > $options['itemsTotal']) { $shown = $options['itemsTotal']; } $moreItemsLinkAction = false; if ($shown < $options['itemsTotal']) { $moreItemsLinkAction = new LinkAction( 'moreItems', new NullAction(), __('grid.action.moreItems'), 'more_items' ); } $templateMgr = TemplateManager::getManager($request); $templateMgr->assign([ 'iterator' => $this->getItemIterator(), 'shown' => $shown, 'grid' => $grid, 'moreItemsLinkAction' => $moreItemsLinkAction, ]); return [ 'pagingMarkup' => $templateMgr->fetch('controllers/grid/feature/infiniteScrolling.tpl'), ]; } // // Hooks implementation. // /** * @copydoc GridFeature::fetchRows() */ public function fetchRows($args) { $request = $args['request']; $grid = $args['grid']; $jsonMessage = $args['jsonMessage']; // Render the paging options, including updated markup. $this->setOptions($request, $grid); $pagingAttributes = ['pagingInfo' => $this->getOptions()]; // Add paging attributes to json so grid can update UI. $additionalAttributes = (array) $jsonMessage->getAdditionalAttributes(); $jsonMessage->setAdditionalAttributes( array_merge( $pagingAttributes, $additionalAttributes ) ); } /** * @copydoc GridFeature::fetchRow() * Check if user really deleted a row and fetch the last one from * the current page. */ public function fetchRow($args) { $request = $args['request']; $grid = $args['grid']; $row = $args['row']; $jsonMessage = $args['jsonMessage']; $pagingAttributes = []; // Render the paging options, including updated markup. $this->setOptions($request, $grid); $pagingAttributes['pagingInfo'] = $this->getOptions(); if (is_null($row)) { $gridData = $grid->getGridDataElements($request); // Get the last data element id of the current page. end($gridData); $lastRowId = key($gridData); // Get the row and render it. $args = ['rowId' => $lastRowId]; $row = $grid->getRequestedRow($request, $args); $pagingAttributes['deletedRowReplacement'] = $grid->renderRow($request, $row); } else { // No need for paging markup. unset($pagingAttributes['pagingInfo']['pagingMarkup']); } // Add paging attributes to json so grid can update UI. $additionalAttributes = $jsonMessage->getAdditionalAttributes(); // Unset sequence map until we support that. unset($additionalAttributes['sequenceMap']); $jsonMessage->setAdditionalAttributes( array_merge( $pagingAttributes, $additionalAttributes ) ); } } if (!PKP_STRICT_MODE) { class_alias('\PKP\controllers\grid\feature\InfiniteScrollingFeature', '\InfiniteScrollingFeature'); }