Esempio n. 1
0
 public function replace()
 {
     $file = $this->file;
     $upload = new Upload($file->root(), array('overwrite' => true, 'accept' => function ($upload) use($file) {
         if ($upload->mime() != $file->mime()) {
             throw new Error(l('files.replace.error.type'));
         }
     }));
     $file = $this->move($upload);
     kirby()->trigger('panel.file.replace', $file);
 }
Esempio n. 2
0
 public function replace()
 {
     $file = $this->file;
     $upload = new Upload($file->root(), array('overwrite' => true, 'accept' => function ($upload) use($file) {
         if ($upload->mime() != $file->mime()) {
             throw new Error(l('files.replace.error.type'));
         }
     }));
     $file = $this->move($upload);
     // make sure that the file is being marked as updated
     touch($file->root());
     // clean the thumbs folder
     $this->page->removeThumbs();
     kirby()->trigger('panel.file.replace', $file);
 }
Esempio n. 3
0
 public function upload()
 {
     if (!panel()->user()->isAdmin() and !$this->user->isCurrent()) {
         throw new Exception(l('users.avatar.error.permission'));
     }
     $root = $this->exists() ? $this->root() : $this->user->avatarRoot('{safeExtension}');
     $upload = new Upload($root, array('accept' => function ($upload) {
         if ($upload->type() != 'image') {
             throw new Error(l('users.avatar.error.type'));
         }
     }));
     if (!$upload->file()) {
         throw $upload->error();
     }
     // flush the cache in case if the user data is
     // used somewhere on the site (i.e. for profiles)
     kirby()->cache()->flush();
     kirby()->trigger('panel.avatar.upload', $this);
 }
 public function upload()
 {
     if (!panel()->user()->isAdmin() and !$this->user->isCurrent()) {
         throw new Exception(l('users.avatar.error.permission'));
     }
     $root = $this->exists() ? $this->root() : $this->user->avatarRoot('{safeExtension}');
     $upload = new Upload($root, array('accept' => function ($upload) {
         if ($upload->type() != 'image') {
             throw new Error(l('users.avatar.error.type'));
         }
     }));
     if (!$upload->file()) {
         throw $upload->error();
     }
     thumb::$defaults['root'] = dirname($upload->file()->root());
     $thumb = new Thumb($upload->file(), array('filename' => $upload->file()->filename(), 'overwrite' => true, 'width' => 256, 'height' => 256, 'crop' => true));
     kirby()->trigger('panel.avatar.upload', $this);
 }