Beispiel #1
0
 public function edit($id, $filename)
 {
     $self = $this;
     $page = $this->page($id);
     try {
         $file = $this->file($page, $filename);
     } catch (Exception $e) {
         $this->alert(l('files.error.missing.file'));
         $this->redirect($page);
     }
     // setup the form and form action
     $form = $file->form('edit', function ($form) use($file, $page, $self) {
         $form->validate();
         if (!$form->isValid()) {
             return $self->alert(l('files.show.error.form'));
         }
         try {
             $file->update($form->serialize());
             $self->notify(':)');
             $self->redirect($file);
         } catch (Exception $e) {
             $self->alert($e->getMessage());
         }
     });
     return $this->screen('files/edit', $file, array('form' => $form, 'page' => $page, 'file' => $file, 'returnTo' => url::last() == $page->url('files') ? $page->uri('files') : $page->uri('edit'), 'uploader' => $this->snippet('uploader', array('url' => $file->url('replace'), 'accept' => $file->mime(), 'multiple' => false))));
 }
Beispiel #2
0
 /**
  * Redirects to the last location of the user
  * 
  * @param string $fallback
  */
 public static function back($fallback = null)
 {
     // get the last url
     $last = url::last();
     // make sure there's a proper fallback
     if (empty($last)) {
         $last = $fallback ? $fallback : url::home();
     }
     static::send($last);
 }
Beispiel #3
0
 public function index($text = null, $exception = null)
 {
     $this->auth();
     if (is_null($text)) {
         $text = l('pages.error.missing');
     }
     if (server::get('HTTP_MODAL')) {
         return $this->modal('error', array('text' => $text, 'back' => url::last()));
     } else {
         return $this->screen('error/index', 'error', array('text' => $text, 'exception' => $exception));
     }
 }