示例#1
0
 /**
  * Trigger the submit action via URL
  *
  * The url must be exactly {$pagepath}/submit where $pagepath is the location
  * of this form in the loops page structure.
  *
  * If not accessed by a POST request, the user will be redirected back to the form.
  * In this case, the confirmed state will also be reset and the form has to be confirmed
  * again.
  *
  * This url can be accessed directly with the input as POST data. However for this, the
  * no_confirm property has to be set to true. Otherwise the user will be redirected to the
  * form page.
  *
  * The session will also be cleared after successfully submitting the form leaving no user
  * input on next access.
  */
 public function submitAction($parameter)
 {
     if ($parameter) {
         return;
     }
     $this->initFromSession();
     if (!$this->request->isPost()) {
         if ($this->confirmed) {
             $this->back();
             $this->saveToSession();
         }
         return Misc::redirect($this);
     }
     if ($this->no_confirm) {
         if (!$this->confirm($this->request->post())) {
             return TRUE;
         }
     } elseif (!$this->confirmed) {
         return Misc::redirect($this);
     }
     $this->submitted = $this->submit();
     if ($this->no_confirm) {
         $this->confirmed = $this->submitted;
     }
     if ($this->submitted) {
         $this->clearSession();
     }
     return TRUE;
 }
示例#2
0
 public function deleteAction($parameter)
 {
     if (!$this->delete) {
         return FALSE;
     }
     $loops = $this->getLoops();
     $request = $loops->getService("request");
     if (!$request->isPost()) {
         return FALSE;
     }
     $entity = $this->offsetGet("list")->queryEntity($parameter, $unused);
     if ($unused) {
         return FALSE;
     }
     $doctrine = $loops->getService("doctrine");
     $doctrine->remove($entity);
     $doctrine->flush();
     return Misc::redirect($this, 302, $loops);
 }
示例#3
0
 public function testRedirect()
 {
     $app2 = new WebApplication(__DIR__ . DIRECTORY_SEPARATOR . "app", "/");
     $app = new WebApplication(__DIR__ . DIRECTORY_SEPARATOR . "app", "/");
     $res = Misc::redirect("http://www.example.com");
     $this->assertEquals(302, $res);
     $this->assertContains("Location: http://www.example.com", $app->response->extra_header);
     $res = Misc::redirect("http://www.example.com", 301);
     $this->assertEquals(301, $res);
     $element = new Testpage();
     Misc::redirect($element->test);
     $this->assertContains("Location: /testpage/test", $app->response->extra_header);
     Misc::redirect("http://www.example.com/test", 302, $app2->loops);
     $this->assertNotContains("Location: http://www.example.com/test", $app->response->extra_header);
     $this->assertContains("Location: http://www.example.com/test", $app2->response->extra_header);
 }