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');
 }
Beispiel #2
0
 public function createPresenters()
 {
     parent::createPresenters();
     $this->addPresenters($name = new TextBox('Name'), $email = new TextBox('Email'), $website = new TextBox('Website'), $company = new TextBox('CompanyName'), $send = new Button('Send', 'Register', function () {
         if ($this->presenters['Name'] && $this->presenters['Email'] && $this->presenters['CompanyName'] && $this->presenters['Website']) {
             if (IndexPresenter::checkIfIPIsTaken($_SERVER['REMOTE_ADDR']) && IndexPresenter::checkIfCompanyIsTaken($this->presenters['CompanyName']) && IndexPresenter::checkIfEmailIsTaken($this->presenters['Email']) && IndexPresenter::checkIfNameIsTaken($this->presenters['CompanyName']) && IndexPresenter::checkIfWebsiteIsTaken($this->presenters['Website'])) {
                 $contact = new Contact();
                 $contact->Name = $this->presenters['Name']->Text;
                 $contact->ContactEmail = $this->presenters['Email']->Text;
                 $contact->CompanyName = $this->presenters['CompanyName']->Text;
                 $contact->Website = $this->presenters['Website']->Text;
                 $contact->IP = $_SERVER['REMOTE_ADDR'];
                 $contact->save();
                 throw new ForceResponseException(new RedirectResponse('/h'));
             }
         }
     }));
     foreach ($this->presenters as $presenter) {
         if ($presenter instanceof TextBox) {
             $presenter->addCssClassName('alert');
         }
     }
     $name->setPlaceholderText('Name');
     $email->setPlaceholderText('Contact Email Address');
     $website->setPlaceholderText('Website (If any)');
     $company->setPlaceholderText('Company Name');
     $send->addCssClassName('c-button c-button--secondary');
 }
 public function createPresenters()
 {
     parent::createPresenters();
     $model = $this->raiseEvent('GetRestModel');
     $slideView = new ImageCommentsPanorama(Image::find(new Equals('GalleryID', $model->GalleryID))->addSort('Order'), 'SlideView');
     $this->addPresenters($slideView);
 }
 public function createPresenters()
 {
     parent::createPresenters();
     $this->addPresenters("Title");
     $this->presenters['Save']->addCssClassNames(['btn', 'btn-primary']);
     $this->presenters['Save']->setButtonText('Saglābat');
     $this->presenters['Cancel']->setButtonText('Atcelt');
 }
 public function createPresenters()
 {
     parent::createPresenters();
     $this->addPresenters($table = new Table(CustomUser::find(new Equals('Enabled', true)), 25, 'UserTable'), $delete = new Button('Dzēst', 'Dzēst', function ($a) {
         try {
             $user = new CustomUser($a);
             $user->Enabled = false;
             $user->save();
         } catch (RecordNotFoundException $ex) {
         }
     }), $edit = new Button('Mainīt', 'Mainīt', function ($a) {
         throw new ForceResponseException(new RedirectResponse('/users/' . $a . '/edit/'));
     }));
     $delete->addCssClassName('btn-danger');
     $delete->setConfirmMessage('Vai jūs tiešam gribat dzēst šo lietotāju?');
     $table->addTableCssClass(['table table-striped table-bordered']);
     $this->presenters['UserTable']->Columns = ['Lietotaja vārds' => 'Username', 'Vārds' => 'Forename', 'Uzvārds' => 'Surname', 'E - pasts' => 'Email', '' => new FixedWidthColumn($edit), ' ' => new FixedWidthColumn($delete)];
 }