Skip to content

Commit

Permalink
Added base component
Browse files Browse the repository at this point in the history
  • Loading branch information
Salamek committed Jan 4, 2018
1 parent 589012b commit fc12df2
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/Dravencms/Components/BasePaginator/BasePaginator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Dravencms\Components\BasePaginator;

use Dravencms\Components\BaseControl\BaseControl;
use IPub\VisualPaginator\Components\Control;
use Nette\ComponentModel\IContainer;
use Nette\Localization\ITranslator;

/**
* Copyright (C) 2016 Adam Schubert <[email protected]>.
*/
class BasePaginator extends BaseControl implements BasePaginatorFactory
{
/** @var ITranslator */
private $translator;

public function __construct(ITranslator $translator = null)
{
$this->translator = $translator;

parent::__construct();
}

/**
* @param IContainer $container
* @param $name
* @return Grid
*/
public function create(IContainer $container = null, $name = null)
{
$control = new Control();
$control->setTemplateFile(__DIR__.'/bootstrap-localized.latte');

return $control;
}

}
18 changes: 18 additions & 0 deletions src/Dravencms/Components/BasePaginator/BasePaginatorFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Copyright (C) 2016 Adam Schubert <[email protected]>.
*/

namespace Dravencms\Components\BasePaginator;

use Nette\ComponentModel\IContainer;

interface BasePaginatorFactory
{
/**
* @param IContainer $container
* @param $name
* @return BasePaginator
*/
public function create(IContainer $container = null, $name = null);
}
24 changes: 24 additions & 0 deletions src/Dravencms/Components/BasePaginator/bootstrap-localized.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{if $paginator->pageCount > 1}
<ul class="pagination">
{if $paginator->isFirst()}
<li class="disabled"><a{_"visualPaginator.Previous"}</a></li>
{else}
<li><a href="{link $handle, 'page' => $paginator->page - 1}" rel="prev" n:class="$useAjax ? ajax"{_"visualPaginator.Previous"}</a></li>
{/if}

{foreach $steps as $step}
{if $step == $paginator->page}
<li class="active"><a href="#">{$step}</a></li>
{else}
<li><a href="{link $handle, 'page' => $step}" n:class="$useAjax ? ajax">{$step}</a></li>
{/if}
{if $iterator->nextValue > $step + 1}<li class="disabled"><a>…</a></li>{/if}
{/foreach}

{if $paginator->isLast()}
<li class="disabled"><a>{_"visualPaginator.Next"} »</a></li>
{else}
<li><a href="{link $handle, 'page' => $paginator->page + 1}" rel="next" n:class="$useAjax ? ajax">{_"visualPaginator.Next"} »</a></li>
{/if}
</ul>
{/if}

0 comments on commit fc12df2

Please sign in to comment.