当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::isSuccess方法代码示例

本文整理汇总了PHP中Nette\Application\UI\Form::isSuccess方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::isSuccess方法的具体用法?PHP Form::isSuccess怎么用?PHP Form::isSuccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Application\UI\Form的用法示例。


在下文中一共展示了Form::isSuccess方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fileUploadSuccess

 public function fileUploadSuccess(AppForm $form)
 {
     try {
         foreach ($form->values->image as $image) {
             $file = new \File();
             $d = $image->getImageSize();
             if ($d[0] < 300 && $d[1] < 300) {
                 throw new InvalidArgumentException('Obrázek je příliš malý. Musí mít minimálně jeden rozměr vyšší než 300px. Nahrajte prosím větší obrázek.');
             }
             if ($d[0] > 3000 || $d[1] > 3000) {
                 throw new InvalidArgumentException('Obrázek je až zbytečně veliký. Žádný rozměr by neměl být vyšší než 3000px. Nahrajte prosím menší obrázek.');
             }
             $file->file_prefix = "";
             $file->file_sufix = "_u" . $this->context->user->id . "_" . substr(sha1(time()), 0, 4);
             $file->user_id = $this->context->user->id;
             $file->insertUploaded($image, FILESTORAGE_DIR);
             $file->visible = 1;
             // automaticka publikace
             $file->save();
             if ($form->values->type == "event") {
                 dibi::query('INSERT INTO event_x_file', array('event_id' => $form->values->id, 'file_id' => $file->id));
                 $res = dibi::select('*')->from('event_x_file')->where('first', '=', 1)->where('event_id', '=', $form->values->id);
                 if (count($res) == 0) {
                     $res = dibi::select('*')->from('event_x_file')->where('event_id', '=', $form->values->id)->fetch();
                     dibi::query('UPDATE event_x_file SET ', array('first' => 1), 'WHERE event_id = ', $res->event_id, 'AND file_id =', $res->file_id);
                 }
             } elseif ($form->values->type == "place") {
                 dibi::query('INSERT INTO subject_x_file', array('subject_id' => $form->values->id, 'file_id' => $file->id));
                 $res = dibi::select('*')->from('subject_x_file')->where('first', '=', 1)->where('subject_id', '=', $form->values->id);
                 if (count($res) == 0) {
                     $res = dibi::select('*')->from('subject_x_file')->where('subject_id', '=', $form->values->id)->fetch();
                     dibi::query('UPDATE subject_x_file SET ', array('first' => 1), 'WHERE subject_id = ', $res->subject_id, 'AND file_id =', $res->file_id);
                 }
             }
         }
     } catch (Exception $e) {
         $form->addError($e->getMessage());
     }
     if ($form->isSuccess()) {
         $cache = new \Nette\Caching\Cache($this->context->cacheStorage);
         $cache->clean(array('files', 'images', 'file', 'image', $form->values->type, $form->values->type . 's'));
         $this->presenter->flashMessage('Dobrá zpráva, fotografie se podařilo vložit!', 'success');
         $this->redirect('this');
     }
 }
开发者ID:soundake,项目名称:pd,代码行数:45,代码来源:ManagePhotosControl.php

示例2: saveEmail

 public function saveEmail(Form $form)
 {
     $values = $form->getValues();
     try {
         $this->context->createService('newsletters')->insert($values);
     } catch (\Exception $e) {
         if ($e->getCode() == 23000) {
             $form->addError('E-mailová adresa "' . $values->email . '" je již v databázi uložena');
         }
     }
     if ($form->isSuccess()) {
         $this->flashMessage('E-mailová adresa byla úspěšně přidána do databáze.', 'success');
         if (!$this->presenter->isAjax()) {
             $this->presenter->redirect('this');
         }
     }
     if ($this->presenter->isAjax()) {
         $this->redrawControl('subscribeForm');
     }
 }
开发者ID:soundake,项目名称:pd,代码行数:20,代码来源:NewsletterControl.php

示例3: fileUploadSuccess

 public function fileUploadSuccess(AppForm $form)
 {
     try {
         foreach ($form->values->image as $key => $image) {
             $file = new \File();
             $file->file_prefix = "user" . $this->user->id . "_";
             $file->insertUploaded($image, FILESTORAGE_DIR);
             $file->user_id = $this->user->id;
             $file->save();
         }
     } catch (Exception $e) {
         $form->addError($e->getMessage());
     } catch (DibiException $e) {
         $form->addError($e->getMessage());
     }
     if ($form->isSuccess()) {
         $this->cleanCache('subjects', 'subject', 'files', 'images', 'file', 'image');
         $this->flashMessage('Successfully saved.', 'ok');
         $this->redirect('default');
     }
 }
开发者ID:soundake,项目名称:pd,代码行数:21,代码来源:OldFilesPresenter.php

示例4: regeneratePassword

 public function regeneratePassword(UI\Form $form)
 {
     $values = $form->getValues();
     $user = $this->context->createServiceUsers()->where('hash', $values->hash)->fetch();
     if ($user) {
         try {
             $unhash_password = $values->password;
             $values->password = $this->users->calculateHash($values->password);
             $values->hash = sha1($values->username . $values->password);
             $user->update(array('password' => $values->password));
         } catch (Exception $e) {
             $this->flashMessage('Neco se nezdarilo. Zkuste to prosim za chvili znovu', 'error');
         }
     } else {
         $form->addError('Neexistuje žádný uživatel s touto e-maiovou adresou. Zkuste to znovu.', 'error');
     }
     if ($form->isSuccess()) {
         $this->cleanCache('users', 'user');
         $this->flashMessage('Vaše nové heslo bylo uloženo a přihlášení proběhlo úspěšně. Vítejte!', 'success');
         $this->logUser($values->username, $unhash_password);
     }
 }
开发者ID:soundake,项目名称:pd,代码行数:22,代码来源:SignPresenter.php

示例5: fileUploadSuccess

 public function fileUploadSuccess(AppForm $form)
 {
     try {
         foreach ($form->values->image as $key => $image) {
             $file = new \File();
             $d = $image->getImageSize();
             if ($d[0] < 300 && $d[1] < 300) {
                 throw new Exception('Obrázek je příliš malý. Musí mít minimálně jeden rozměr vyšší než 300px. Nahrajte prosím větší obrázek.');
             }
             if ($d[0] > 3000 || $d[1] > 3000) {
                 throw new Exception('Obrázek je až zbytečně veliký. Žádný rozměr by neměl být vyšší než 3000px. Nahrajte prosím menší obrázek.');
             }
             $file->file_prefix = "";
             $file->file_sufix = "_u" . $this->user->id . "_" . substr(sha1(time()), 0, 4);
             $file->user_id = $this->user->id;
             $file->insertUploaded($image, FILESTORAGE_DIR);
             $file->save();
             dibi::query('INSERT INTO event_x_file', array('event_id' => $form->values->event_id, 'file_id' => $file->id));
         }
     } catch (Exception $e) {
         $form->addError($e->getMessage());
     } catch (DibiException $e) {
         $form->addError($e->getMessage());
     }
     if ($form->isSuccess()) {
         $this->cleanCache('subjects', 'subject', 'files', 'images', 'file', 'image');
         $this->flashMessage('Successfully saved.', 'ok');
         $this->redirect('thx', array('event_id' => $form->values->event_id));
     }
 }
开发者ID:soundake,项目名称:pd,代码行数:30,代码来源:AddPresenter.php

示例6: createComponentCreateEdgeForm

 /**
  * Create edge between two nodes.
  * @param string $name
  * @return Form
  */
 public function createComponentCreateEdgeForm($name)
 {
     $form = new Form($this, $name);
     $form->addText('source');
     $form->addText('label');
     $form->addText('target');
     $form->addSubmit('create');
     if ($form->isSuccess()) {
         $this->graph->createEdge($form['source']->isFilled() ? $form['source']->value : $this->node->getLabel(), $form['target']->isFilled() ? $form['target']->value : $this->node->getLabel(), $form['label']->value);
         $this->redirect('this');
     }
     return $form;
 }
开发者ID:echo511,项目名称:graphadmin,代码行数:18,代码来源:GraphPresenter.php

示例7: fileUploadSuccess

 public function fileUploadSuccess(AppForm $form)
 {
     try {
         foreach ($form->values->image as $key => $image) {
             $file = new \File();
             $file->file_prefix = "user" . $this->user->id . "_";
             $file->insertUploaded($image, FILESTORAGE_DIR);
             //$file->simulation = true;
             $file->visible = 1;
             $file->user_id = $this->user->id;
             $file->save();
             switch ($this->getParameter('module')) {
                 case "subject":
                     \dibi::query('INSERT INTO subject_x_file', array('subject_id' => $this->getParameter('item_id'), 'file_id' => $file->id));
                     break;
                 case "event":
                     \dibi::query('INSERT INTO event_x_file', array('event_id' => $this->getParameter('item_id'), 'file_id' => $file->id));
                     break;
             }
         }
     } catch (Exception $e) {
         $form->addError($e->getMessage());
     } catch (DibiException $e) {
         $form->addError($e->getMessage());
     }
     if ($form->isSuccess()) {
         $this->cleanCache('subjects', 'subject', 'files', 'images', 'file', 'image');
         $this->flashMessage('Successfully saved.', 'ok');
         $this->redirect('default', array('item_id' => $form->values->item_id, 'module' => $form->values->module));
     }
 }
开发者ID:soundake,项目名称:pd,代码行数:31,代码来源:GalleryJoinPresenter.php


注:本文中的Nette\Application\UI\Form::isSuccess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。