コード例 #1
0
 public function getCkeditor($parentId = null)
 {
     \Debugbar::disable();
     if (is_null($parentId)) {
         $model = Folder::orderBy('sort')->first();
         $parentId = $model->id;
     }
     $folderTree = Filer::folderTree();
     // make a parser instance
     $parser = App::make('Sharenjoy\\Cmsharenjoy\\Utilities\\Parser');
     $folderTreeBuilder = $parser->treeBuilder($folderTree, '<li class="dd-item" data-id="{id}"><a href="' . $this->objectUrl . '/ckeditor/{id}"><div class="dd-handle"><i class="fa fa-folder-o"></i>&nbsp;&nbsp;&nbsp;{name}</div></a> {children} </li>', 'ul class="dd-list"');
     $fileResult = $this->foldercontents($parentId);
     if (!$fileResult['status']) {
         Message::error($fileResult['message']);
     }
     $maxSize = Filer::getMaxSizeAllowed() > Filer::getMaxSizePossible() ? Filer::getMaxSizePossible() : Filer::getMaxSizeAllowed();
     // Convert bytes to mega
     $maxSize = $maxSize / 1048576;
     return $this->layout()->with('parentId', $parentId)->with('fileResult', $fileResult)->with('folderTree', $folderTreeBuilder)->with('uploadMaxFilesize', $maxSize);
 }
コード例 #2
0
 /**
  * Files listing
  *
  * Creates a list of files
  *
  * Used by the Files plugin
  *
  * @return array
  */
 public function getListing($folder_id, $tags, $limit, $offset, $type, $fetch, $order_by, $order_ord)
 {
     if (!empty($folder_id) && (empty($type) || in_array($type, array('a', 'v', 'd', 'i', 'o')))) {
         if (is_numeric($folder_id)) {
             $folder = Folder::find($folder_id);
         } elseif (is_string($folder_id)) {
             $folder = Folder::findByPath($folder_id);
         }
     }
     $subfolders = array();
     if (isset($folder) && $folder && in_array($fetch, array('root', 'subfolder'))) {
         // we're getting the files for an entire tree
         $fetch_id = $fetch === 'root' ? $folder->root_id : $folder->id;
         $subfolders = Files::folderTreeRecursive($fetch_id);
     } elseif (!isset($folder)) {
         // no restrictions by folder so we'll just be getting files by their tags. Set up the join
         return array();
     }
     if (!empty($subfolders)) {
         $ids = array_merge(array((int) $folder->id), array_keys($subfolders));
         File::whereIn('folder_id', $ids);
     } else {
         // just the files for one folder
         File::where('folder_id', $folder->id);
     }
     $type && File::where('type', $type);
     $limit && File::take($limit);
     $offset && File::skip($offset);
     if (!$order_ord) {
         $order_ord = 'asc';
     }
     $order_by && File::orderBy($order_by, $order_ord);
     if ($tags) {
         $files = Files::getTaggedFiles($tags);
     } else {
         $files = File::get();
     }
     return $files;
 }