Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

39 rindas
1.1KB

  1. <?php
  2. namespace common\components;
  3. use yii\helpers\Html;
  4. class PageSizer
  5. {
  6. const DEFAULT_PAGE_SIZE = 25;
  7. public static array $pageSizeOptions = [25, 50, 75, 100];
  8. public function getForm(string $entity, string $labelEntity, int $pageSize, array $action = ['producer/pagesize'])
  9. {
  10. return '<form class="form-inline gridview-pagesize" method="post" action="'.\Yii::$app->urlManager->createUrl($action).'"><div class="form-group"><label class="control-label">'.$labelEntity.' par page : </label> '.
  11. Html::hiddenInput('entity', $entity).
  12. Html::dropDownList(
  13. 'pagesize',
  14. $pageSize,
  15. $this->getPageSizeOptions(),
  16. array('class'=>'form-control')).'</div></form></div>';
  17. }
  18. public function getPageSizeOptions(): array
  19. {
  20. $pageSizeOptionsArray = [];
  21. foreach(self::$pageSizeOptions as $pageSize) {
  22. $pageSizeOptionsArray[$pageSize] = $pageSize;
  23. }
  24. return $pageSizeOptionsArray;
  25. }
  26. public function isPageSizeExist(int $pageSize): bool
  27. {
  28. return in_array($pageSize, self::$pageSizeOptions);
  29. }
  30. }