public function createPresenters()
 {
     parent::createPresenters();
     $table = new Table(Gallery::find()->addSort('Order'), 50, 'Table');
     $this->addPresenters($table, $up = new Button('Up', 'Up', function ($id) {
         $gallery = new Gallery($id);
         if ($gallery->Order == null) {
             $gallery->Order = 0;
         }
         $gallery->Order--;
         $gallery->save();
     }), $down = new Button('down', 'down', function ($id) {
         $gallery = new Gallery($id);
         if ($gallery->Order == null) {
             $gallery->Order = 0;
         }
         $gallery->Order++;
         $gallery->save();
     }), $delete = new Button('delete', 'delete', function ($id) {
         $g = new Gallery($id);
         $g->delete();
     }));
     $table->addTableCssClass(['table']);
     $table->NoDataHtml = '<h3 class="center-align">Oops! Nav galerijas</h3>';
     $delete->addCssClassName('btn-danger');
     $delete->setConfirmMessage('Vai jūs tiešam gribat dzēst šo galeriju?');
     $table->Columns = ['Nosaukums' => 'Title', 'Indekss' => 'Order', '' => new FixedWidthColumn($up), ' ' => new FixedWidthColumn($down), '  ' => new FixedWidthColumn($delete)];
 }
Esempio n. 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();
     $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)];
 }
 public function createPresenters()
 {
     parent::createPresenters();
     $images = Image::find(new Equals('GalleryID', $this->getData('GalleryID')))->addSort('Order');
     $this->addPresenters($table = new Table($images, 25, 'Images'), $delete = new Button('Dzēst', 'Dzēst', function ($id) {
         $image = new Image($id);
         $image->delete();
     }), $down = new Button('down', 'Uz leju', function ($id) {
         $image = new Image($id);
         $image->Order++;
         $image->save();
     }), $up = new Button('up', 'Uz augšu', function ($id) {
         $image = new Image($id);
         $image->Order--;
         $image->save();
     }));
     $delete->setConfirmMessage('Vai jūs tiešam gribat dzēst šo lietotāju?');
     $table->addTableCssClass(['table']);
     $table->Columns = ['Bilde' => '<img style="max-width: 250px;" src="{Thumbnail}">', 'Indekss' => 'Order', '&nbsp' => new FixedWidthColumn($delete), '&nbsp&nbsp' => new FixedWidthColumn($up), '&nbsp&nbsp&nbsp' => new FixedWidthColumn($down)];
 }
 public function __construct($name = "", $buttonText = "", $onButtonPressed = null)
 {
     parent::__construct($name, $buttonText, $onButtonPressed);
     $this->addCssClassName("button-warning");
 }