Merge pull request #3006 from owncloud/===_and_!==_in_files_trashbin-app
Use !== and === in files_trashbin app
This commit is contained in:
commit
895d9ba1b9
|
@ -13,7 +13,7 @@ $success = array();
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($list as $file) {
|
foreach ($list as $file) {
|
||||||
if ( $dirlisting=='0') {
|
if ( $dirlisting === '0') {
|
||||||
$delimiter = strrpos($file, '.d');
|
$delimiter = strrpos($file, '.d');
|
||||||
$filename = substr($file, 0, $delimiter);
|
$filename = substr($file, 0, $delimiter);
|
||||||
$timestamp = substr($file, $delimiter+2);
|
$timestamp = substr($file, $delimiter+2);
|
||||||
|
|
|
@ -12,7 +12,7 @@ $success = array();
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($list as $file) {
|
foreach ($list as $file) {
|
||||||
if ( $dirlisting=='0') {
|
if ( $dirlisting === '0') {
|
||||||
$delimiter = strrpos($file, '.d');
|
$delimiter = strrpos($file, '.d');
|
||||||
$filename = substr($file, 0, $delimiter);
|
$filename = substr($file, 0, $delimiter);
|
||||||
$timestamp = substr($file, $delimiter+2);
|
$timestamp = substr($file, $delimiter+2);
|
||||||
|
|
|
@ -24,7 +24,7 @@ if ($dir) {
|
||||||
$dirContent = $view->opendir($dir);
|
$dirContent = $view->opendir($dir);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while($entryName = readdir($dirContent)) {
|
while($entryName = readdir($dirContent)) {
|
||||||
if ( $entryName != '.' && $entryName != '..' ) {
|
if (!\OC\Files\Filesystem::isIgnoredDir($entryName)) {
|
||||||
$pos = strpos($dir.'/', '/', 1);
|
$pos = strpos($dir.'/', '/', 1);
|
||||||
$tmp = substr($dir, 0, $pos);
|
$tmp = substr($dir, 0, $pos);
|
||||||
$pos = strrpos($tmp, '.d');
|
$pos = strrpos($tmp, '.d');
|
||||||
|
@ -54,13 +54,13 @@ foreach ($result as $r) {
|
||||||
$i['timestamp'] = $r['timestamp'];
|
$i['timestamp'] = $r['timestamp'];
|
||||||
$i['mimetype'] = $r['mime'];
|
$i['mimetype'] = $r['mime'];
|
||||||
$i['type'] = $r['type'];
|
$i['type'] = $r['type'];
|
||||||
if ($i['type'] == 'file') {
|
if ($i['type'] === 'file') {
|
||||||
$fileinfo = pathinfo($r['id']);
|
$fileinfo = pathinfo($r['id']);
|
||||||
$i['basename'] = $fileinfo['filename'];
|
$i['basename'] = $fileinfo['filename'];
|
||||||
$i['extension'] = isset($fileinfo['extension']) ? ('.'.$fileinfo['extension']) : '';
|
$i['extension'] = isset($fileinfo['extension']) ? ('.'.$fileinfo['extension']) : '';
|
||||||
}
|
}
|
||||||
$i['directory'] = $r['location'];
|
$i['directory'] = $r['location'];
|
||||||
if ($i['directory'] == '/') {
|
if ($i['directory'] === '/') {
|
||||||
$i['directory'] = '';
|
$i['directory'] = '';
|
||||||
}
|
}
|
||||||
$i['permissions'] = OCP\PERMISSION_READ;
|
$i['permissions'] = OCP\PERMISSION_READ;
|
||||||
|
@ -68,9 +68,9 @@ foreach ($result as $r) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function fileCmp($a, $b) {
|
function fileCmp($a, $b) {
|
||||||
if ($a['type'] == 'dir' and $b['type'] != 'dir') {
|
if ($a['type'] === 'dir' and $b['type'] !== 'dir') {
|
||||||
return -1;
|
return -1;
|
||||||
} elseif ($a['type'] != 'dir' and $b['type'] == 'dir') {
|
} elseif ($a['type'] !== 'dir' and $b['type'] === 'dir') {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return strnatcasecmp($a['name'], $b['name']);
|
return strnatcasecmp($a['name'], $b['name']);
|
||||||
|
@ -83,7 +83,7 @@ usort($files, "fileCmp");
|
||||||
$pathtohere = '';
|
$pathtohere = '';
|
||||||
$breadcrumb = array();
|
$breadcrumb = array();
|
||||||
foreach (explode('/', $dir) as $i) {
|
foreach (explode('/', $dir) as $i) {
|
||||||
if ($i != '') {
|
if ($i !== '') {
|
||||||
if ( preg_match('/^(.+)\.d[0-9]+$/', $i, $match) ) {
|
if ( preg_match('/^(.+)\.d[0-9]+$/', $i, $match) ) {
|
||||||
$name = $match[1];
|
$name = $match[1];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,7 +16,7 @@ $(document).ready(function() {
|
||||||
var row = document.getElementById(result.data.success[i].filename);
|
var row = document.getElementById(result.data.success[i].filename);
|
||||||
row.parentNode.removeChild(row);
|
row.parentNode.removeChild(row);
|
||||||
}
|
}
|
||||||
if (result.status != 'success') {
|
if (result.status !== 'success') {
|
||||||
OC.dialogs.alert(result.data.message, t('core', 'Error'));
|
OC.dialogs.alert(result.data.message, t('core', 'Error'));
|
||||||
}
|
}
|
||||||
enableActions();
|
enableActions();
|
||||||
|
@ -44,7 +44,7 @@ $(document).ready(function() {
|
||||||
var row = document.getElementById(result.data.success[i].filename);
|
var row = document.getElementById(result.data.success[i].filename);
|
||||||
row.parentNode.removeChild(row);
|
row.parentNode.removeChild(row);
|
||||||
}
|
}
|
||||||
if (result.status != 'success') {
|
if (result.status !== 'success') {
|
||||||
OC.dialogs.alert(result.data.message, t('core', 'Error'));
|
OC.dialogs.alert(result.data.message, t('core', 'Error'));
|
||||||
}
|
}
|
||||||
enableActions();
|
enableActions();
|
||||||
|
@ -75,7 +75,7 @@ $(document).ready(function() {
|
||||||
var rows = $(this).parent().parent().parent().children('tr');
|
var rows = $(this).parent().parent().parent().children('tr');
|
||||||
for (var i = start; i < end; i++) {
|
for (var i = start; i < end; i++) {
|
||||||
$(rows).each(function(index) {
|
$(rows).each(function(index) {
|
||||||
if (index == i) {
|
if (index === i) {
|
||||||
var checkbox = $(this).children().children('input:checkbox');
|
var checkbox = $(this).children().children('input:checkbox');
|
||||||
$(checkbox).attr('checked', 'checked');
|
$(checkbox).attr('checked', 'checked');
|
||||||
$(checkbox).parent().parent().addClass('selected');
|
$(checkbox).parent().parent().addClass('selected');
|
||||||
|
@ -114,7 +114,7 @@ $(document).ready(function() {
|
||||||
var row = document.getElementById(result.data.success[i].filename);
|
var row = document.getElementById(result.data.success[i].filename);
|
||||||
row.parentNode.removeChild(row);
|
row.parentNode.removeChild(row);
|
||||||
}
|
}
|
||||||
if (result.status != 'success') {
|
if (result.status !== 'success') {
|
||||||
OC.dialogs.alert(result.data.message, t('core', 'Error'));
|
OC.dialogs.alert(result.data.message, t('core', 'Error'));
|
||||||
}
|
}
|
||||||
enableActions();
|
enableActions();
|
||||||
|
@ -142,7 +142,7 @@ $(document).ready(function() {
|
||||||
var row = document.getElementById(result.data.success[i].filename);
|
var row = document.getElementById(result.data.success[i].filename);
|
||||||
row.parentNode.removeChild(row);
|
row.parentNode.removeChild(row);
|
||||||
}
|
}
|
||||||
if (result.status != 'success') {
|
if (result.status !== 'success') {
|
||||||
OC.dialogs.alert(result.data.message, t('core', 'Error'));
|
OC.dialogs.alert(result.data.message, t('core', 'Error'));
|
||||||
}
|
}
|
||||||
enableActions();
|
enableActions();
|
||||||
|
@ -176,9 +176,9 @@ $(document).ready(function() {
|
||||||
|
|
||||||
function processSelection(){
|
function processSelection(){
|
||||||
var selected=getSelectedFiles();
|
var selected=getSelectedFiles();
|
||||||
var selectedFiles=selected.filter(function(el){return el.type=='file'});
|
var selectedFiles=selected.filter(function(el){return el.type === 'file'});
|
||||||
var selectedFolders=selected.filter(function(el){return el.type=='dir'});
|
var selectedFolders=selected.filter(function(el){return el.type === 'dir'});
|
||||||
if(selectedFiles.length==0 && selectedFolders.length==0) {
|
if(selectedFiles.length === 0 && selectedFolders.length === 0) {
|
||||||
$('#headerName>span.name').text(t('files','Name'));
|
$('#headerName>span.name').text(t('files','Name'));
|
||||||
$('#modified').text(t('files','Deleted'));
|
$('#modified').text(t('files','Deleted'));
|
||||||
$('table').removeClass('multiselect');
|
$('table').removeClass('multiselect');
|
||||||
|
@ -188,7 +188,7 @@ function processSelection(){
|
||||||
$('.selectedActions').show();
|
$('.selectedActions').show();
|
||||||
var selection='';
|
var selection='';
|
||||||
if(selectedFolders.length>0){
|
if(selectedFolders.length>0){
|
||||||
if(selectedFolders.length==1){
|
if(selectedFolders.length === 1){
|
||||||
selection+=t('files','1 folder');
|
selection+=t('files','1 folder');
|
||||||
}else{
|
}else{
|
||||||
selection+=t('files','{count} folders',{count: selectedFolders.length});
|
selection+=t('files','{count} folders',{count: selectedFolders.length});
|
||||||
|
@ -198,7 +198,7 @@ function processSelection(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(selectedFiles.length>0){
|
if(selectedFiles.length>0){
|
||||||
if(selectedFiles.length==1){
|
if(selectedFiles.length === 1){
|
||||||
selection+=t('files','1 file');
|
selection+=t('files','1 file');
|
||||||
}else{
|
}else{
|
||||||
selection+=t('files','{count} files',{count: selectedFiles.length});
|
selection+=t('files','{count} files',{count: selectedFiles.length});
|
||||||
|
|
|
@ -265,14 +265,14 @@ class Trashbin {
|
||||||
$query = \OC_DB::prepare('SELECT `location`,`type` FROM `*PREFIX*files_trash`'
|
$query = \OC_DB::prepare('SELECT `location`,`type` FROM `*PREFIX*files_trash`'
|
||||||
. ' WHERE `user`=? AND `id`=? AND `timestamp`=?');
|
. ' WHERE `user`=? AND `id`=? AND `timestamp`=?');
|
||||||
$result = $query->execute(array($user, $filename, $timestamp))->fetchAll();
|
$result = $query->execute(array($user, $filename, $timestamp))->fetchAll();
|
||||||
if (count($result) != 1) {
|
if (count($result) !== 1) {
|
||||||
\OC_Log::write('files_trashbin', 'trash bin database inconsistent!', \OC_Log::ERROR);
|
\OC_Log::write('files_trashbin', 'trash bin database inconsistent!', \OC_Log::ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if location no longer exists, restore file in the root directory
|
// if location no longer exists, restore file in the root directory
|
||||||
$location = $result[0]['location'];
|
$location = $result[0]['location'];
|
||||||
if ($result[0]['location'] != '/' &&
|
if ($result[0]['location'] !== '/' &&
|
||||||
(!$view->is_dir('files' . $result[0]['location']) ||
|
(!$view->is_dir('files' . $result[0]['location']) ||
|
||||||
!$view->isUpdatable('files' . $result[0]['location']))) {
|
!$view->isUpdatable('files' . $result[0]['location']))) {
|
||||||
$location = '';
|
$location = '';
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div id='notification'></div>
|
<div id='notification'></div>
|
||||||
|
|
||||||
<?php if (isset($_['files']) && count($_['files'])==0 && $_['dirlisting'] == false):?>
|
<?php if (isset($_['files']) && count($_['files']) === 0 && $_['dirlisting'] === false):?>
|
||||||
<div id="emptyfolder"><?php p($l->t('Nothing in here. Your trash bin is empty!'))?></div>
|
<div id="emptyfolder"><?php p($l->t('Nothing in here. Your trash bin is empty!'))?></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<?php for($i=0; $i<count($_["breadcrumb"]); $i++):
|
<?php for($i=0; $i<count($_["breadcrumb"]); $i++):
|
||||||
$crumb = $_["breadcrumb"][$i];
|
$crumb = $_["breadcrumb"][$i];
|
||||||
$dir = \OCP\Util::encodePath($crumb["dir"]); ?>
|
$dir = \OCP\Util::encodePath($crumb["dir"]); ?>
|
||||||
<div class="crumb <?php if($i == count($_["breadcrumb"])-1) p('last');?> svg"
|
<div class="crumb <?php if($i === count($_["breadcrumb"])-1) p('last');?> svg"
|
||||||
data-dir='<?php p($dir);?>'>
|
data-dir='<?php p($dir);?>'>
|
||||||
<a href="<?php p($_['baseURL'].$dir); ?>"><?php p($crumb["name"]); ?></a>
|
<a href="<?php p($_['baseURL'].$dir); ?>"><?php p($crumb["name"]); ?></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
$name = \OCP\Util::encodePath($file['name']);
|
$name = \OCP\Util::encodePath($file['name']);
|
||||||
$directory = \OCP\Util::encodePath($file['directory']); ?>
|
$directory = \OCP\Util::encodePath($file['directory']); ?>
|
||||||
<tr data-filename="<?php p($file['name']);?>"
|
<tr data-filename="<?php p($file['name']);?>"
|
||||||
data-type="<?php ($file['type'] == 'dir')?p('dir'):p('file')?>"
|
data-type="<?php ($file['type'] === 'dir')?p('dir'):p('file')?>"
|
||||||
data-mime="<?php p($file['mimetype'])?>"
|
data-mime="<?php p($file['mimetype'])?>"
|
||||||
data-permissions='<?php p($file['permissions']); ?>'
|
data-permissions='<?php p($file['permissions']); ?>'
|
||||||
<?php if ( $_['dirlisting'] ): ?>
|
<?php if ( $_['dirlisting'] ): ?>
|
||||||
|
@ -22,14 +22,14 @@
|
||||||
data-dirlisting=0
|
data-dirlisting=0
|
||||||
<?php endif; ?>>
|
<?php endif; ?>>
|
||||||
<td class="filename svg"
|
<td class="filename svg"
|
||||||
<?php if($file['type'] == 'dir'): ?>
|
<?php if($file['type'] === 'dir'): ?>
|
||||||
style="background-image:url(<?php print_unescaped(OCP\mimetype_icon('dir')); ?>)"
|
style="background-image:url(<?php print_unescaped(OCP\mimetype_icon('dir')); ?>)"
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
style="background-image:url(<?php print_unescaped(OCP\mimetype_icon($file['mimetype'])); ?>)"
|
style="background-image:url(<?php print_unescaped(OCP\mimetype_icon($file['mimetype'])); ?>)"
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
>
|
>
|
||||||
<?php if(!isset($_['readonly']) || !$_['readonly']): ?><input type="checkbox" /><?php endif; ?>
|
<?php if(!isset($_['readonly']) || !$_['readonly']): ?><input type="checkbox" /><?php endif; ?>
|
||||||
<?php if($file['type'] == 'dir'): ?>
|
<?php if($file['type'] === 'dir'): ?>
|
||||||
<?php if( $_['dirlisting'] ): ?>
|
<?php if( $_['dirlisting'] ): ?>
|
||||||
<a class="name" href="<?php p($_['baseURL'].'/'.$name); ?>" title="">
|
<a class="name" href="<?php p($_['baseURL'].'/'.$name); ?>" title="">
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
@ -43,14 +43,14 @@
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<span class="nametext">
|
<span class="nametext">
|
||||||
<?php if($file['type'] == 'dir'):?>
|
<?php if($file['type'] === 'dir'):?>
|
||||||
<?php print_unescaped(htmlspecialchars($file['name']));?>
|
<?php print_unescaped(htmlspecialchars($file['name']));?>
|
||||||
<?php else:?>
|
<?php else:?>
|
||||||
<?php print_unescaped(htmlspecialchars($file['basename']));?><span
|
<?php print_unescaped(htmlspecialchars($file['basename']));?><span
|
||||||
class='extension'><?php p($file['extension']);?></span>
|
class='extension'><?php p($file['extension']);?></span>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
</span>
|
</span>
|
||||||
<?php if($file['type'] == 'dir'):?>
|
<?php if($file['type'] === 'dir'):?>
|
||||||
<span class="uploadtext" currentUploads="0">
|
<span class="uploadtext" currentUploads="0">
|
||||||
</span>
|
</span>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
|
|
Loading…
Reference in New Issue