Beispiel #1
0
 public function forFile($pageId, $filename, $fieldName, $fieldType, $path)
 {
     $page = $this->page($pageId);
     $file = $page->file(File::decodeFilename($filename));
     if (!$file) {
         throw new Exception(l('files.error.missing.file'));
     }
     $form = $file->form('edit', function () {
     });
     return $this->route($file, $form, $fieldName, $fieldType, $path);
 }
Beispiel #2
0
 public function __construct($page)
 {
     $this->kirby = $page->kirby;
     $this->site = $page->site;
     $this->page = $page;
     // make sure the inventory is always fresh
     $this->page->reset();
     $inventory = $page->inventory();
     foreach ($inventory['files'] as $filename) {
         $file = new File($this, $filename);
         $this->data[strtolower($file->filename())] = $file;
     }
     if ($this->page->canSortFiles()) {
         $sorted = $this->sortBy('sort', 'asc');
         $this->data = $sorted->data;
     }
     if ($this->page->blueprint()->files()->sort() == 'flip') {
         $flipped = $this->flip();
         $this->data = $flipped->data;
     }
 }
Beispiel #3
0
 public function dragText()
 {
     if (kirby()->option('panel.kirbytext') === false) {
         switch ($this->type()) {
             case 'image':
                 return '![' . $this->name() . '](' . parent::url() . ')';
                 break;
             default:
                 return '[' . $this->filename() . '](' . parent::url() . ')';
                 break;
         }
     } else {
         switch ($this->type()) {
             case 'image':
                 return '(image: ' . $this->filename() . ')';
                 break;
             default:
                 return '(file: ' . $this->filename() . ')';
                 break;
         }
     }
 }
Beispiel #4
0
 protected function file($page, $filename)
 {
     $file = $page->file(File::decodeFilename($filename));
     if (!$file) {
         throw new Exception(l('files.error.missing.file'));
     }
     return $file;
 }
Beispiel #5
0
 public function __construct(File $file)
 {
     $this->page = $file->page();
     $this->file = $file;
 }