nattreid / gallery
Gallery for Nette Framework
Installs: 429
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Language:JavaScript
Requires
- php: >= 7.1
- nattreid/image-storage: ~1.0
- nette/application: ~2.4
- nette/di: ~2.4
- nette/utils: ~2.4
- nextras/secured-links: ~1.3
Requires (Dev)
- nattreid/cms: ~1.0
- nattreid/orm: ~1.0
- nette/database: ~2.4
- nette/tester: ~1.7
- tracy/tracy: ~2.4
This package is auto-updated.
Last update: 2024-11-22 12:02:38 UTC
README
Nastavení v config.neon
extensions: gallery: NAttreid\Gallery\DI\GalleryExtension gallery: maxFileSize: 5 #MB maxFiles: 50
Načtení továrny
/** @var \NAttreid\Gallery\Control\IGalleryFactory @inject */ public $galleryFactory;
Použítí s databází
function createComponentGalleryDB() { $model = $this->db->table('example'); $gallery = $this->galleryFactory->create(); $gallery->setStorage($model); $gallery->setNamespace('example/class'); $gallery->setForeignKey('foreignKey', 5); return $gallery; }
Použití se session
function createComponentGallerySession() { $session = $this->getSession('example/class'); $gallery = $this->galleryFactory->create(); $gallery->setStorage($session, 'nameOfVariableInSession'); $gallery->setNamespace('example/class'); return $gallery; }
Použití s cms konfigurátorem
/** @var \NAttreid\Cms\Configurator\Configurator @inject */ public $configurator; function createComponentGalleryConfigurator() { $gallery = $this->galleryFactory->create(); $gallery->setStorage($this->configurator, 'nameOfVariableInSession'); $gallery->setNamespace('example/class'); return $gallery; }
Použití ve formuláři
protected function createComponentGallery() { $session = $this->getSession('example/class'); $session->setExpiration('1 hour'); $gallery = $this->galleryFactory->create(); $gallery->setStorage($session, 'example'); return $gallery; } function onSuccessForm(Form $form, $values) { $createGallery = empty($values->id); $id = $this->model->save($values->id, $values)->getPrimary(); if ($createGallery) { /* @var $gallery \NAttreid\Gallery\Gallery */ $gallery=$this['gallery']; $gallery->changeNamespace('item/' . $values->url); $this->imageModel->add($id, $gallery->getImages()); $gallery->clearTemp(); } }