Created
May 25, 2011 07:32
-
-
Save fprochazka/990511 to your computer and use it in GitHub Desktop.
Grinder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{block content} | |
<div id="wrapper"> | |
<div id="logo"></div> | |
<h1>Congratulations!</h1> | |
<h2>You have successfully created your Nette Framework project.</h2> | |
<hr> | |
<a href="{plink this, active => 0}">neaktivní</a> | |
<a href="{plink this, active => 1}">aktivní</a> | |
<a href="{plink this, active => NULL}">všechny</a> | |
{control grinder:filters} | |
{control grinder} | |
</div> | |
{/block} | |
{block head} | |
<style> | |
html { | |
font: 16px/1.5 sans-serif; | |
border-top: 8.7em solid #F4EBDB; | |
} | |
body { | |
font: inherit; | |
border-top: 5px solid #E4DED5; | |
margin: 0; | |
background: white; | |
color: #333; | |
} | |
#wrapper { | |
max-width: 670px; | |
margin: -8.7em auto 0; | |
} | |
#logo { | |
position: absolute; | |
width: 150px; | |
height: 8.7em; | |
top: 0; | |
right: 3em; | |
background: url('data:image/gif;base64,R0lGODlhlQA/ALMAAPTr29LKvczEuPzz49rRw+PbzPbt3MK6ruri07u0qPjv3vnw3/Lp2e/m1vXs2/Ho1yH5BAAAAAAALAAAAACVAD8AAAT/EMhJq7046827/2AojmRJLShijOjSrGYszyzKNAURCMLStQ1EjkdQ0I7IpMGVI/CeO9VGqIMGdsqslnSwXr89R6bg/X4H27R6LDC7r2jM4P0uGNf49ZwOtmvafFgweYRZCIB8AhtOgXCFj0qMjXEXA4h8fpCaMguXdJkXDZ5uioObpyKHjaVyOquUqCc+sZWuk3e4Ep2roLk/vjU2QqyyAw0PL7C/BkIFzgUNysW7jQTPOQ9LKaNu1znAFjbe2bO/ODk7T2ETKelQvRkoZOr0ReW6to1g6mg6+atPisRj5o5eGwb3MhjslkvSmzbSTjBIBxAeN31XiszD+FBKOAUO/wMJEBiPjMg4AzaKJBkupL6RlFRxJIVgz0xSCMOpnBlR18WMLXZwXHdC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kMCwz0dvKAEJTFi+jORHSX0XkeokgPXUvpeAPQgkUCIHBUg/OdxFIMCy2A04AIkaJ0AYWOIAw8ofmwJIDuol43oOYsD8JEC++31JegFIQPtOgEAffE9sY9Kf4OAWKAW2gmEYCODNrlcmE+6vgwbogj3sRy4IrgAsIoSZ9EhYQzvMD3g6yWE4YOjCITpDiLrwHxn6AZQgsgkqXOmXMc5nAQaaYoAWMCEPh0i4X//9oIhZ2qINWaTBB2Axi7BKwMr61bWsIBFPsNKB/+4SETBukTawwmFE4OZAELIBehMcYvXG2BJjwTCLPUCgBOXipPdBr41LK18H1QgTJ3KwNWQQn29k+Eb85bEnPPSe1N5Dveh5UQEKvMISdeCkT4pNg2qEm/9wxZgDWOCMOkQDRCrRwf+JAIxGRAEha6mUWTLHNcbogh1eVcdOaslYTujkAsaoR0vWT1Q8rJ8FnQXM98CQmZZcoy+QCTfpLTGcdbNh/iCZxECSb5S5FMMhL0mgADgTA+lzViCveSD+TSefCEKBIwAKR0BSsYo0XMEH4/GA9fWJHfnko4MCqQDu+bEceNky3qhksdHmZah3dGOeNhAXUuYtD6PBw0AEAAA7') right center no-repeat; | |
} | |
h1 { | |
font-size: 47px; | |
color: #3484D2; | |
margin: .4em 0 -.3em; | |
text-shadow: 1px 1px 0 white; | |
} | |
h2, h3 { | |
font-size: 18px; | |
color: #7A7772; | |
margin: .6em 0; | |
text-shadow: 1px 1px 0 white; | |
} | |
h3 { | |
font-size: 16px; | |
color: #3484D2; | |
} | |
ol { | |
margin: 0; | |
padding: 0; | |
} | |
ol li { | |
margin: 1em 0; | |
} | |
ol li p { | |
font-size: 90%; | |
} | |
code { | |
color: #666; | |
} | |
hr { | |
visibility: hidden; | |
height: 2em; | |
} | |
img { | |
border: none; | |
} | |
a { | |
color: #3484D2; | |
padding: 3px 1px; | |
font-weight: bold; | |
} | |
a:hover, a:active, a:focus { | |
background-color: #3484D2; | |
text-decoration: none; | |
color: white; | |
} | |
#environment { | |
font-size: 70%; | |
margin: 3em 0; | |
padding: 1em 0; | |
border-top: 1px solid #EEE; | |
list-style: none; | |
color: gray; | |
} | |
</style> | |
{/block} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Kdyby\Components\Grinder\Actions\ButtonAction; | |
use Kdyby\Components\Grinder\Actions\LinkAction; | |
/** | |
* Homepage presenter. | |
*/ | |
class dibiPresenter extends BasePresenter | |
{ | |
/** @persistent */ | |
public $active; | |
protected function startup() | |
{ | |
parent::startup(); | |
$this->getSession()->start(); | |
} | |
protected function createComponentGrinder($name) | |
{ | |
$query = \dibi::select('*')->from('users'); | |
$model = new Kdyby\Components\Grinder\Models\DibiFluentModel($query); | |
$grid = new Kdyby\Components\Grinder\Grid($model); | |
$grid->setUpProtection($this->getSession()); | |
$grid->setItemsPerPage(5); | |
$grid->addCheckColumn('select'); | |
$grid->addCheckColumn('select2', 'Neco'); | |
$grid->addColumn('username', 'Nick'); | |
$grid->addColumn('name', 'Jméno'); | |
$column = $grid->addActionsColumn('detail', NULL, array( | |
'caption' => 'Detaily', | |
'handler' => callback($this, 'DetailsClicked') | |
)); | |
$column->addAction(new LinkAction, 'other') | |
->setCaption('Jiné') | |
->setHandler(callback($this, 'JineClicked')); | |
$grid->addColumn('mail', 'E-mail'); | |
$grid->addAction('edit', 'Upravit') | |
->setLink($this->lazyLink('edit!'), array('sitemapId' => 'id')); | |
// přidá akci na konec gridu | |
$grid->addAction('delete', 'Smazat', array( | |
'handler' => callback($this, 'DeleteClicked') | |
)); // přidá akci na konec gridu | |
// grid form | |
$grid->addToolbarAction('send', 'Vypsat') | |
->onSubmit[] = callback($this, 'VypsatSubmitted'); | |
// filters | |
$filters = $grid->getFilters(); | |
$filters->addParameter('active', $this, 'active')->setType('integer'); | |
$filters->addTextField('name', 'Jméno', '~'); | |
$filters->addTextField('surname', 'Příjmenní', '~'); | |
$filters->createButtons(); | |
return $grid; | |
} | |
public function DetailsClicked(LinkAction $action, $id) | |
{ | |
$action->getGrid()->flashMessage('detaily ' . $id); | |
} | |
public function JineClicked(LinkAction $action, $id) | |
{ | |
$action->getGrid()->flashMessage('jine ' . $id); | |
} | |
public function handleEdit($sitemapId) | |
{ | |
$this->flashMessage('bar ' . $sitemapId); | |
$this->redirect('this'); | |
} | |
public function DeleteClicked(LinkAction $action, $id) | |
{ | |
$action->getGrid()->flashMessage('foo ' . $id); | |
} | |
/** | |
* @param ButtonAction $grid | |
*/ | |
public function VypsatSubmitted(ButtonAction $action) | |
{ | |
$s = $action->getGrid()->getColumn('select'); | |
dump(count($s->getChecked()), $s->getValues()); | |
$s = $action->getGrid()->getColumn('select2'); | |
dump(count($s->getChecked()), $s->getValues()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Kdyby\Components\Grinder\Actions\ButtonAction; | |
use Kdyby\Components\Grinder\Actions\LinkAction; | |
/** | |
* Homepage presenter. | |
*/ | |
class DoctrinePresenter extends BasePresenter | |
{ | |
/** @persistent */ | |
public $active; | |
protected function startup() | |
{ | |
parent::startup(); | |
$this->getSession()->start(); | |
} | |
protected function createComponentGrinder($name) | |
{ | |
$em = $this->context->doctrine->entityManager; | |
$model = new Kdyby\Components\Grinder\Models\SimpleDoctrineModel($em, 'App\User'); | |
$grid = new Kdyby\Components\Grinder\Grid($model); | |
$grid->setUpProtection($this->getSession()); | |
$grid->setItemsPerPage(5); | |
$grid->addCheckColumn('select'); | |
$grid->addCheckColumn('select2', 'Neco'); | |
$grid->addColumn('username', 'Nick'); | |
$grid->addColumn('name', 'Jméno'); | |
$column = $grid->addActionsColumn('detail', NULL, array( | |
'caption' => 'Detaily', | |
'handler' => callback($this, 'DetailsClicked') | |
)); | |
$column->addAction(new LinkAction, 'other') | |
->setCaption('Jiné') | |
->setHandler(callback($this, 'JineClicked')); | |
$grid->addColumn('mail', 'E-mail'); | |
$grid->addAction('edit', 'Upravit') | |
->setLink($this->lazyLink('edit!'), array('sitemapId' => 'id')); | |
// přidá akci na konec gridu | |
$grid->addAction('delete', 'Smazat', array( | |
'handler' => callback($this, 'DeleteClicked') | |
)); // přidá akci na konec gridu | |
// grid form | |
$grid->addToolbarAction('send', 'Vypsat') | |
->onSubmit[] = callback($this, 'VypsatSubmitted'); | |
// filters | |
$filters = $grid->getFilters(); | |
$filters->addParameter('e.active', $this, 'active')->setType('integer'); | |
$filters->addTextField('e.name', 'Jméno', '~'); | |
$filters->addTextField('e.surname', 'Příjmenní', '~'); | |
$filters->createButtons(); | |
return $grid; | |
} | |
public function DetailsClicked(LinkAction $action, $id) | |
{ | |
$action->getGrid()->flashMessage('detaily ' . $id); | |
} | |
public function JineClicked(LinkAction $action, $id) | |
{ | |
$action->getGrid()->flashMessage('jine ' . $id); | |
} | |
public function handleEdit($sitemapId) | |
{ | |
$this->flashMessage('bar ' . $sitemapId); | |
$this->redirect('this'); | |
} | |
public function DeleteClicked(LinkAction $action, $id) | |
{ | |
$action->getGrid()->flashMessage('foo ' . $id); | |
} | |
/** | |
* @param ButtonAction $grid | |
*/ | |
public function VypsatSubmitted(ButtonAction $action) | |
{ | |
$s = $action->getGrid()->getColumn('select'); | |
dump(count($s->getChecked()), $s->getValues()); | |
$s = $action->getGrid()->getColumn('select2'); | |
dump(count($s->getChecked()), $s->getValues()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This file is part of the Kdyby (http://www.kdyby.org) | |
* | |
* Copyright (c) 2008, 2011 Filip Procházka (filip.prochazka@kdyby.org) | |
* | |
* @license http://www.kdyby.org/license | |
*/ | |
namespace Kdyby\Backend\Article\Categories; | |
use Doctrine\ORM\EntityManager; | |
use Kdyby; | |
use Kdyby\Components\Grinder\Grid; | |
use Kdyby\Components\Grinder\Actions\LinkAction; | |
use Kdyby\Components\Grinder\Models\SimpleDoctrineModel; | |
use Nette; | |
use Nette\Application\UI\Presenter; | |
/** | |
* Complext, real-world component Example | |
* | |
* @author Filip Procházka | |
*/ | |
class OverviewGrid extends Grid | |
{ | |
/** @var CategoriesRepository */ | |
private $categoriesRepository; | |
/** | |
* @param EntityManager $entityManager | |
* @param Nette\Http\Session $session | |
*/ | |
public function __construct(EntityManager $entityManager, Nette\Http\Session $session = NULL) | |
{ | |
parent::__construct(new SimpleDoctrineModel($entityManager, 'Category')); | |
$this->categoriesRepository = $entityManager->getRepository('Category'); | |
$this->setUpProtection($session); | |
$this->getVisualPaginator() | |
->setPlacement(Grid::PLACEMENT_BOTTOM); | |
} | |
/** | |
* @param Nette\ComponentModel\Container $obj | |
*/ | |
protected function attached($obj) | |
{ | |
if ($obj instanceof Nette\Application\UI\Presenter) { | |
$this->createColumns($obj); | |
$this->createActions($obj); | |
$this->createFilters($obj); | |
} | |
parent::attached($obj); | |
} | |
/** | |
* @param Presenter $presenter | |
*/ | |
protected function createColumns(Presenter $presenter) | |
{ | |
$this->addCheckColumn('select'); | |
$this->addColumn('name', 'Category name') | |
->setLink($presenter->lazyLink('this'), array('categoryId' => 'id')); | |
} | |
/** | |
* @param Presenter $presenter | |
*/ | |
protected function createFilters(Presenter $presenter) | |
{ | |
$this->getFilters() | |
->addParameter('e.parent', $presenter, 'categoryId') | |
->setSkipEmpty(FALSE); | |
} | |
/** | |
* @param Presenter $presenter | |
*/ | |
protected function createActions(Presenter $presenter) | |
{ | |
$this->addAction('up', 'Nahoru', array( | |
'handler' => callback($this, 'MoveUpClicked') | |
)) | |
->setImage('%themePath%/img/icons/arrow-up.png') | |
->getImagePrototype()->height('16px'); | |
$this->addAction('down', 'Dolů', array( | |
'handler' => callback($this, 'MoveDownClicked') | |
)) | |
->setImage('%themePath%/img/icons/arrow-down.png') | |
->getImagePrototype()->height('16px'); | |
$this->addAction('add', 'Přidat') | |
->setLink($presenter->lazyLink('Add:'), array('parentId' => 'id')) | |
->setImage('%themePath%/img/icons/button-add.png') | |
->getImagePrototype()->height('16px'); | |
$this->addAction('edit', 'Upravit') | |
->setLink($presenter->lazyLink('Edit:'), array('categoryId' => 'id')) | |
->setImage('%themePath%/img/icons/pencil.png') | |
->getImagePrototype()->height('16px'); | |
$this->addAction('delete', 'Smazat') | |
->setImage('%themePath%/img/icons/button-remove.png') | |
->getImagePrototype()->height('16px'); | |
} | |
/** | |
* @param LinkAction $action | |
* @param int $id | |
*/ | |
public function MoveUpClicked(LinkAction $action, $id) | |
{ | |
$this->categoriesRepository->moveUp($this->categoriesRepository->find($id)); | |
} | |
/** | |
* @param LinkAction $action | |
* @param int $id | |
*/ | |
public function MoveDownClicked(LinkAction $action, $id) | |
{ | |
$this->categoriesRepository->moveDown($this->categoriesRepository->find($id)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Nette; | |
/** | |
* @Entity | |
* @table(name="users") | |
*/ | |
class User extends Nette\Object | |
{ | |
/** | |
* @var int | |
* @Id | |
* @Column(type="integer") | |
* @GeneratedValue | |
*/ | |
private $id; | |
/** | |
* @var string | |
* @Column(unique=true) | |
*/ | |
private $username; | |
/** | |
* @var string | |
* @Column | |
*/ | |
private $password; | |
/** | |
* @var string | |
* @Column | |
*/ | |
private $name; | |
/** | |
* @var string | |
* @Column | |
*/ | |
private $surname; | |
/** | |
* @var string | |
* @Column(unique=true) | |
*/ | |
private $mail; | |
/** | |
* @var bool | |
* @Column(type="boolean") | |
*/ | |
private $active; | |
public function getId() | |
{ | |
return $this->id; | |
} | |
public function getUsername() | |
{ | |
return $this->username; | |
} | |
public function setUsername($username) | |
{ | |
$this->username = $username; | |
} | |
public function getPassword() | |
{ | |
return $this->password; | |
} | |
public function setPassword($password) | |
{ | |
$this->password = $password; | |
} | |
public function getName() | |
{ | |
return $this->name; | |
} | |
public function setName($name) | |
{ | |
$this->name = $name; | |
} | |
public function getSurname() | |
{ | |
return $this->surname; | |
} | |
public function setSurname($surname) | |
{ | |
$this->surname = $surname; | |
} | |
public function getMail() | |
{ | |
return $this->mail; | |
} | |
public function setMail($mail) | |
{ | |
$this->mail = $mail; | |
} | |
public function isActive() | |
{ | |
return $this->active; | |
} | |
public function setActive($active) | |
{ | |
$this->active = $active; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS `users`; | |
CREATE TABLE `users` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`username` varchar(255) COLLATE utf8_czech_ci NOT NULL, | |
`password` varchar(255) COLLATE utf8_czech_ci NOT NULL, | |
`name` varchar(255) COLLATE utf8_czech_ci NOT NULL, | |
`surname` varchar(255) COLLATE utf8_czech_ci NOT NULL, | |
`mail` varchar(255) COLLATE utf8_czech_ci NOT NULL, | |
`active` tinyint(1) NOT NULL, | |
PRIMARY KEY (`id`), | |
UNIQUE KEY `UNIQ_1483A5E9F85E0677` (`username`), | |
UNIQUE KEY `UNIQ_1483A5E95126AC48` (`mail`) | |
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci; | |
INSERT INTO `users` (`id`, `username`, `password`, `name`, `surname`, `mail`, `active`) VALUES | |
(1, 'admin', 'admin', 'admin', 'admin', 'admin@admin.cz', 1), | |
(2, 'johndoe', 'johndoe', 'John', 'Doe', 'john.doe@example.org', 1), | |
(3, 'asd', 'asd', 'asd', 'asd', 'asd@asd.cz', 0), | |
(4, 'dsa', 'dsa', 'dsa', 'dsa', 'dsa@dsa.cz', 1), | |
(5, 'kjh', 'kjh', 'kjh', 'kjh', 'kjh@kjh.cz', 1), | |
(6, 'netd', 'netd', 'netd', 'netd', 'netd@netd.cz', 0), | |
(7, 'uztr', 'uztr', 'uztr', 'uztr', 'uztr@uztr.cz', 1), | |
(8, 'ijkl', 'ijkl', 'ijkl', 'ijkl', 'ijkl@ijkl.cz', 0), | |
(9, 'uuji', 'uuji', 'uuji', 'uuji', 'uuji@uuji.cz', 1), | |
(10, 'rrrt', 'rrrt', 'rrrt', 'rrrt', 'rrrt@rrrt.cz', 0), | |
(11, 'hhhh', 'hhhh', 'hhhh', 'hhhh', 'hhhh@hhhh.cz', 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment