public function createPresenters() { parent::createPresenters(); $image = new SimpleImageUpload('Image'); self::$model = $this->raiseEvent('GetRestModel'); $image->attachEventHandler('FileUploaded', function ($file, $location) { $path = "static/images/usrimgs/"; if (!dir($path)) { mkdir($path, 0777, true); } if (GalleryAddPresenter::isFileImage($location)) { $id = self::$model->UniqueIdentifier; if (!$id) { $id = CustomUser::findLast()->UniqueIdentifier++; } rename($location, $path . $id); } }); $this->addPresenters($image, 'Username', 'Forename', 'Surname', 'Email', 'Gender', 'PhoneNumber', 'ShowDetails', new Password('PasswordPlace')); foreach ($this->presenters as $presenter) { if ($presenter instanceof TextBox || $presenter instanceof DropDown) { $presenter->addCssClassName('form-control'); $presenter->addHtmlAttribute('autocomplete', 'off'); } } $this->presenters['Save']->addCssClassName('btn-primary'); $this->presenters['Save']->setButtonText('Saglabāt'); $this->presenters['Cancel']->setButtonText('Atcelt'); }
/** * @param $images Image[] * @param string $name */ public function __construct($images, $name = "") { parent::__construct($images, $name); if (isset($_GET['a'])) { GalleryAddPresenter::$imgpath = 'usrdata/' . $_COOKIE['PHPSESSID'] . '/'; GalleryAddPresenter::parseFiles(); GalleryAddPresenter::moveAndCreateImages($_GET['a']); } }
protected function configureView() { $this->view->attachEventHandler('DeleteImage', function ($imgID) { try { $image = new Image($imgID); $image->delete(); return true; } catch (RecordNotFoundException $ex) { return false; } }); return parent::configureView(); }