Fixes int folder name showing as 0

Fixes #2902
Code dusting
This commit is contained in:
Samuel Georges 2017-06-02 20:16:26 +10:00
parent 08f2e05b67
commit 3be6dafa6b
5 changed files with 43 additions and 25 deletions

View File

@ -43,7 +43,7 @@ if(!preg_match('/opera|webtv/i', $ua) && preg_match('/msie\s(\d)/', $ua, $array)
$b[] = $g;
}
// platform
// platform
if(strstr($ua, 'j2me')) {
$b[] = $m . ' j2me';
} else if(strstr($ua, 'iphone')) {

View File

@ -156,10 +156,12 @@ class MediaLibrary
$folderContents = $this->listFolderContents($folder, $sortBy, $filter);
foreach ($folderContents as $item) {
if ($item->type == MediaLibraryItem::TYPE_FOLDER)
if ($item->type == MediaLibraryItem::TYPE_FOLDER) {
$findInFolder($item->path);
elseif ($this->pathMatchesSearch($item->path, $words))
$result[] = $item;
}
elseif ($this->pathMatchesSearch($item->path, $words)) {
$result[] = $item;
}
}
};
@ -224,8 +226,9 @@ class MediaLibrary
$folders = $this->getStorageDisk()->directories($fullPath);
foreach ($folders as $folder) {
if (basename($folder) == $folderName)
if (basename($folder) == $folderName) {
return true;
}
}
return false;
@ -326,21 +329,24 @@ class MediaLibrary
$destPath = self::validatePath($destPath);
$fullDestPath = $this->getMediaPath($destPath);
if (!$disk->makeDirectory($fullDestPath))
if (!$disk->makeDirectory($fullDestPath)) {
return false;
}
$folderContents = $this->scanFolderContents($fullSrcPath);
foreach ($folderContents['folders'] as $dirInfo) {
if (!$copyDirectory($dirInfo->path, $destPath.'/'.basename($dirInfo->path)))
if (!$copyDirectory($dirInfo->path, $destPath.'/'.basename($dirInfo->path))) {
return false;
}
}
foreach ($folderContents['files'] as $fileInfo) {
$fullFileSrcPath = $this->getMediaPath($fileInfo->path);
if (!$disk->copy($fullFileSrcPath, $fullDestPath.'/'.basename($fileInfo->path)))
if (!$disk->copy($fullFileSrcPath, $fullDestPath.'/'.basename($fileInfo->path))) {
return false;
}
}
return true;
@ -368,7 +374,8 @@ class MediaLibrary
}
$this->deleteFolder($originalPath);
} else {
}
else {
// If there's a risk that the directory name was updated
// by changing the letter case - swap source and destination
// using a temporary directory with random name.
@ -496,8 +503,9 @@ class MediaLibrary
{
$path = self::validatePath($path, true);
if (substr($path, 0, $this->storageFolderNameLength) == $this->storageFolder)
if (substr($path, 0, $this->storageFolderNameLength) == $this->storageFolder) {
return substr($path, $this->storageFolderNameLength);
}
throw new SystemException(sprintf('Cannot convert Media Library path "%s" to a path relative to the Library root.', $path));
}
@ -534,8 +542,9 @@ class MediaLibrary
{
$relativePath = $this->getMediaRelativePath($path);
if (!$this->isVisible($relativePath))
if (!$this->isVisible($relativePath)) {
return;
}
/*
* S3 doesn't allow getting the last modified timestamp for folders,
@ -596,14 +605,16 @@ class MediaLibrary
$files = $this->getStorageDisk()->files($fullFolderPath);
foreach ($files as $file) {
if ($libraryItem = $this->initLibraryItem($file, MediaLibraryItem::TYPE_FILE))
if ($libraryItem = $this->initLibraryItem($file, MediaLibraryItem::TYPE_FILE)) {
$result['files'][] = $libraryItem;
}
}
$folders = $this->getStorageDisk()->directories($fullFolderPath);
foreach ($folders as $folder) {
if ($libraryItem = $this->initLibraryItem($folder, MediaLibraryItem::TYPE_FOLDER))
if ($libraryItem = $this->initLibraryItem($folder, MediaLibraryItem::TYPE_FOLDER)) {
$result['folders'][] = $libraryItem;
}
}
return $result;
@ -652,8 +663,9 @@ class MediaLibrary
$result = [];
foreach ($itemList as $item) {
if ($item->getFileType() == $filter)
if ($item->getFileType() == $filter) {
$result[] = $item;
}
}
$itemList = $result;
@ -668,8 +680,9 @@ class MediaLibrary
*/
protected function getStorageDisk()
{
if ($this->storageDisk)
if ($this->storageDisk) {
return $this->storageDisk;
}
return $this->storageDisk = Storage::disk(
Config::get('cms.storage.media.disk', 'local')
@ -688,11 +701,13 @@ class MediaLibrary
foreach ($words as $word) {
$word = trim($word);
if (!strlen($word))
if (!strlen($word)) {
continue;
}
if (!Str::contains($path, $word))
if (!Str::contains($path, $word)) {
return false;
}
}
return true;

View File

@ -50,6 +50,9 @@ class MediaManager extends WidgetBase
*/
public $cropAndInsertButton = false;
/**
* Constructor.
*/
public function __construct($controller, $alias)
{
$this->alias = $alias;
@ -784,7 +787,7 @@ class MediaManager extends WidgetBase
}
}
return array_reverse($result);
return array_reverse($result, true);
}
protected function setViewMode($viewMode)

View File

@ -1,13 +1,13 @@
<ul class="tree-path">
<li class="root"><a href="#" data-type="media-item" data-item-type="folder" data-path="/" data-clear-search="true"><?= e(trans('cms::lang.media.library')) ?></a></li>
<li class="root"><a href="javascript:;" data-type="media-item" data-item-type="folder" data-path="/" data-clear-search="true"><?= e(trans('cms::lang.media.library')) ?></a></li>
<?php if (!$searchMode): ?>
<?php foreach ($pathSegments as $folder=>$path): ?>
<?php foreach ($pathSegments as $folder => $path): ?>
<?php if ($path != '/'): ?>
<li><a href="#" data-type="media-item" data-item-type="folder" data-path="<?= e($path) ?>"><?= basename($folder) ?></a></li>
<li><a href="javascript:;" data-type="media-item" data-item-type="folder" data-path="<?= e($path) ?>"><?= basename($folder) ?></a></li>
<?php endif ?>
<?php endforeach?>
<?php else: ?>
<li><a href="#" data-type="media-item"><?= e(trans('cms::lang.media.search')) ?></a></li>
<li><a href="javascript:;" data-type="media-item"><?= e(trans('cms::lang.media.search')) ?></a></li>
<?php endif ?>
</ul>

View File

@ -136,7 +136,7 @@
startOffset = self.options.vertical ? $el.scrollTop() : $el.scrollLeft()
if (Modernizr.touch) {
$(window).on('touchmove.dragScroll', function(event){
$(window).on('touchmove.dragScroll', function(event) {
var touchEvent = event.originalEvent
moveDrag(touchEvent.touches[0])
if (!isNative) {
@ -149,12 +149,12 @@
})
}
$(window).on('mousemove.dragScroll', function(event){
$(window).on('mousemove.dragScroll', function(event) {
moveDrag(event)
return false
})
$(window).on('mouseup.dragScroll', function(mouseUpEvent){
$(window).on('mouseup.dragScroll', function(mouseUpEvent) {
var isClick = event.pageX == mouseUpEvent.pageX && event.pageY == mouseUpEvent.pageY
stopDrag(isClick)
return false