aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/js/filelist.js42
-rw-r--r--apps/files/js/files.js10
-rw-r--r--apps/files/lib/helper.php18
-rw-r--r--apps/files/tests/ajax_rename.php8
-rw-r--r--apps/files_sharing/public.php3
-rw-r--r--apps/files_trashbin/js/filelist.js32
-rw-r--r--core/ajax/preview.php31
-rw-r--r--core/js/config.php26
-rw-r--r--core/js/tests/specHelper.js1
-rwxr-xr-xlib/private/request.php2
10 files changed, 135 insertions, 38 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index d6cffde05de..550c10dba3e 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -11,6 +11,7 @@
/* global OC, t, n, FileList, FileActions, Files */
/* global procesSelection, dragOptions, SVGSupport, replaceSVG */
window.FileList={
+ appName: t('files', 'Files'),
useUndo:true,
postProcessList: function() {
$('#fileList tr').each(function() {
@@ -19,6 +20,21 @@ window.FileList={
});
},
/**
+ * Sets a new page title
+ */
+ setPageTitle: function(title){
+ if (title) {
+ title += ' - ';
+ } else {
+ title = '';
+ }
+ title += FileList.appName;
+ // Sets the page title with the " - ownCloud" suffix as in templates
+ window.document.title = title + ' - ' + oc_defaults.title;
+
+ return true;
+ },
+ /**
* Returns the tr element for a given file name
*/
findFileEl: function(fileName){
@@ -129,7 +145,7 @@ window.FileList={
if (loading) {
imgurl = OC.imagePath('core', 'loading.gif');
} else {
- imgurl = OC.imagePath('core', 'filetypes/file.png');
+ imgurl = OC.imagePath('core', 'filetypes/file');
}
var tr = this.createRow(
'file',
@@ -157,7 +173,7 @@ window.FileList={
var tr = this.createRow(
'dir',
name,
- OC.imagePath('core', 'filetypes/folder.png'),
+ OC.imagePath('core', 'filetypes/folder'),
OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/'),
size,
lastModified,
@@ -204,7 +220,16 @@ window.FileList={
return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/');
},
setCurrentDir: function(targetDir, changeUrl) {
- var url;
+ var url,
+ baseDir = OC.basename(targetDir);
+
+ if (baseDir !== '') {
+ FileList.setPageTitle(baseDir);
+ }
+ else {
+ FileList.setPageTitle();
+ }
+
$('#dir').val(targetDir);
if (changeUrl !== false) {
if (window.history.pushState && changeUrl !== false) {
@@ -847,7 +872,8 @@ window.FileList={
};
$(document).ready(function() {
- var isPublic = !!$('#isPublic').val();
+ var baseDir,
+ isPublic = !!$('#isPublic').val();
// handle upload events
var file_upload_start = $('#file_upload_start');
@@ -943,7 +969,7 @@ $(document).ready(function() {
uploadtext.attr('currentUploads', currentUploads);
var translatedText = n('files', 'Uploading %n file', 'Uploading %n files', currentUploads);
if (currentUploads === 0) {
- var img = OC.imagePath('core', 'filetypes/folder.png');
+ var img = OC.imagePath('core', 'filetypes/folder');
data.context.find('td.filename').attr('style','background-image:url('+img+')');
uploadtext.text(translatedText);
uploadtext.hide();
@@ -1003,7 +1029,7 @@ $(document).ready(function() {
if (data.errorThrown === 'abort') {
//cleanup uploading to a dir
var uploadtext = $('tr .uploadtext');
- var img = OC.imagePath('core', 'filetypes/folder.png');
+ var img = OC.imagePath('core', 'filetypes/folder');
uploadtext.parents('td.filename').attr('style','background-image:url('+img+')');
uploadtext.fadeOut();
uploadtext.attr('currentUploads', 0);
@@ -1016,7 +1042,7 @@ $(document).ready(function() {
if (data.errorThrown === 'abort') {
//cleanup uploading to a dir
var uploadtext = $('tr .uploadtext');
- var img = OC.imagePath('core', 'filetypes/folder.png');
+ var img = OC.imagePath('core', 'filetypes/folder');
uploadtext.parents('td.filename').attr('style','background-image:url('+img+')');
uploadtext.fadeOut();
uploadtext.attr('currentUploads', 0);
@@ -1132,5 +1158,7 @@ $(document).ready(function() {
}
}
+ FileList.setCurrentDir(parseCurrentDirFromUrl(), false);
+
FileList.createFileSummary();
});
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index fbac601f67a..f4546120702 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -734,6 +734,9 @@ Files.getMimeIcon = function(mime, ready) {
ready(Files.getMimeIcon.cache[mime]);
} else {
$.get( OC.filePath('files','ajax','mimeicon.php'), {mime: mime}, function(path) {
+ if(SVGSupport()){
+ path = path.substr(0, path.length-4) + '.svg';
+ }
Files.getMimeIcon.cache[mime]=path;
ready(Files.getMimeIcon.cache[mime]);
});
@@ -783,13 +786,16 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) {
}
previewURL = previewURL.replace('(', '%28');
previewURL = previewURL.replace(')', '%29');
+ previewURL += '&forceIcon=0';
// preload image to prevent delay
// this will make the browser cache the image
var img = new Image();
img.onload = function(){
- //set preview thumbnail URL
- ready(previewURL);
+ // if loading the preview image failed (no preview for the mimetype) then img.width will < 5
+ if (img.width > 5) {
+ ready(previewURL);
+ }
}
img.src = previewURL;
});
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php
index ac8a2ad3200..b9e41a352bc 100644
--- a/apps/files/lib/helper.php
+++ b/apps/files/lib/helper.php
@@ -22,6 +22,7 @@ class Helper
public static function determineIcon($file) {
if($file['type'] === 'dir') {
$dir = $file['directory'];
+ $icon = \OC_Helper::mimetypeIcon('dir');
$absPath = \OC\Files\Filesystem::getView()->getAbsolutePath($dir.'/'.$file['name']);
$mount = \OC\Files\Filesystem::getMountManager()->find($absPath);
if (!is_null($mount)) {
@@ -29,21 +30,22 @@ class Helper
if (!is_null($sid)) {
$sid = explode(':', $sid);
if ($sid[0] === 'shared') {
- return \OC_Helper::mimetypeIcon('dir-shared');
+ $icon = \OC_Helper::mimetypeIcon('dir-shared');
}
if ($sid[0] !== 'local' and $sid[0] !== 'home') {
- return \OC_Helper::mimetypeIcon('dir-external');
+ $icon = \OC_Helper::mimetypeIcon('dir-external');
}
}
}
- return \OC_Helper::mimetypeIcon('dir');
+ }else{
+ if($file['isPreviewAvailable']) {
+ $pathForPreview = $file['directory'] . '/' . $file['name'];
+ return \OC_Helper::previewIcon($pathForPreview) . '&c=' . $file['etag'];
+ }
+ $icon = \OC_Helper::mimetypeIcon($file['mimetype']);
}
- if($file['isPreviewAvailable']) {
- $pathForPreview = $file['directory'] . '/' . $file['name'];
- return \OC_Helper::previewIcon($pathForPreview) . '&c=' . $file['etag'];
- }
- return \OC_Helper::mimetypeIcon($file['mimetype']);
+ return substr($icon, 0, -3) . 'svg';
}
/**
diff --git a/apps/files/tests/ajax_rename.php b/apps/files/tests/ajax_rename.php
index a1a5c8983ba..e53c0fb3dd1 100644
--- a/apps/files/tests/ajax_rename.php
+++ b/apps/files/tests/ajax_rename.php
@@ -110,7 +110,9 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
$this->assertEquals('/test', $result['data']['directory']);
$this->assertEquals(18, $result['data']['size']);
$this->assertEquals('httpd/unix-directory', $result['data']['mime']);
- $this->assertEquals(\OC_Helper::mimetypeIcon('dir'), $result['data']['icon']);
+ $icon = \OC_Helper::mimetypeIcon('dir');
+ $icon = substr($icon, 0, -3) . 'svg';
+ $this->assertEquals($icon, $result['data']['icon']);
$this->assertFalse($result['data']['isPreviewAvailable']);
}
@@ -165,7 +167,9 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
$this->assertEquals(18, $result['data']['size']);
$this->assertEquals('httpd/unix-directory', $result['data']['mime']);
$this->assertEquals('abcdef', $result['data']['etag']);
- $this->assertEquals(\OC_Helper::mimetypeIcon('dir'), $result['data']['icon']);
+ $icon = \OC_Helper::mimetypeIcon('dir');
+ $icon = substr($icon, 0, -3) . 'svg';
+ $this->assertEquals($icon, $result['data']['icon']);
$this->assertFalse($result['data']['isPreviewAvailable']);
}
diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php
index e7a5f5024b8..fe61dd4d5a0 100644
--- a/apps/files_sharing/public.php
+++ b/apps/files_sharing/public.php
@@ -32,7 +32,8 @@ function determineIcon($file, $sharingRoot, $sharingToken) {
if($file['isPreviewAvailable']) {
return OCP\publicPreview_icon($relativePath, $sharingToken) . '&c=' . $file['etag'];
}
- return OCP\mimetype_icon($file['mimetype']);
+ $icon = OCP\mimetype_icon($file['mimetype']);
+ return substr($icon, 0, -3) . 'svg';
}
if (isset($_GET['t'])) {
diff --git a/apps/files_trashbin/js/filelist.js b/apps/files_trashbin/js/filelist.js
index f42abb6d029..a88459b0a9a 100644
--- a/apps/files_trashbin/js/filelist.js
+++ b/apps/files_trashbin/js/filelist.js
@@ -1,3 +1,4 @@
+/* globals OC, FileList, t */
// override reload with own ajax call
FileList.reload = function(){
FileList.showMask();
@@ -17,7 +18,36 @@ FileList.reload = function(){
FileList.reloadCallback(result);
}
});
-}
+};
+
+FileList.appName = t('files_trashbin', 'Deleted files');
+
+FileList._deletedRegExp = new RegExp(/^(.+)\.d[0-9]+$/);
+
+/**
+ * Convert a file name in the format filename.d12345 to the real file name.
+ * This will use basename.
+ * The name will not be changed if it has no ".d12345" suffix.
+ * @param name file name
+ * @return converted file name
+ */
+FileList.getDeletedFileName = function(name) {
+ name = OC.basename(name);
+ var match = FileList._deletedRegExp.exec(name);
+ if (match && match.length > 1) {
+ name = match[1];
+ }
+ return name;
+};
+var oldSetCurrentDir = FileList.setCurrentDir;
+FileList.setCurrentDir = function(targetDir) {
+ oldSetCurrentDir.apply(this, arguments);
+
+ var baseDir = OC.basename(targetDir);
+ if (baseDir !== '') {
+ FileList.setPageTitle(FileList.getDeletedFileName(baseDir));
+ }
+};
FileList.linkTo = function(dir){
return OC.linkTo('files_trashbin', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/');
diff --git a/core/ajax/preview.php b/core/ajax/preview.php
index a1267d6f5cf..526719e8a1b 100644
--- a/core/ajax/preview.php
+++ b/core/ajax/preview.php
@@ -7,34 +7,39 @@
*/
\OC_Util::checkLoggedIn();
-$file = array_key_exists('file', $_GET) ? (string) $_GET['file'] : '';
-$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36';
-$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36';
-$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
+$file = array_key_exists('file', $_GET) ? (string)$_GET['file'] : '';
+$maxX = array_key_exists('x', $_GET) ? (int)$_GET['x'] : '36';
+$maxY = array_key_exists('y', $_GET) ? (int)$_GET['y'] : '36';
+$scalingUp = array_key_exists('scalingup', $_GET) ? (bool)$_GET['scalingup'] : true;
+$always = array_key_exists('forceIcon', $_GET) ? (bool)$_GET['forceIcon'] : true;
-if($file === '') {
+if ($file === '') {
//400 Bad Request
\OC_Response::setStatus(400);
\OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG);
exit;
}
-if($maxX === 0 || $maxY === 0) {
+if ($maxX === 0 || $maxY === 0) {
//400 Bad Request
\OC_Response::setStatus(400);
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
exit;
}
-try{
+try {
$preview = new \OC\Preview(\OC_User::getUser(), 'files');
- $preview->setFile($file);
- $preview->setMaxX($maxX);
- $preview->setMaxY($maxY);
- $preview->setScalingUp($scalingUp);
+ if (!$always and !$preview->isMimeSupported(\OC\Files\Filesystem::getMimeType($file))) {
+ \OC_Response::setStatus(404);
+ } else {
+ $preview->setFile($file);
+ $preview->setMaxX($maxX);
+ $preview->setMaxY($maxY);
+ $preview->setScalingUp($scalingUp);
+ }
$preview->show();
-}catch(\Exception $e) {
+} catch (\Exception $e) {
\OC_Response::setStatus(500);
\OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG);
-} \ No newline at end of file
+}
diff --git a/core/js/config.php b/core/js/config.php
index 139c3b6d485..c606ef35056 100644
--- a/core/js/config.php
+++ b/core/js/config.php
@@ -10,12 +10,15 @@
header("Content-type: text/javascript");
// Disallow caching
-header("Cache-Control: no-cache, must-revalidate");
-header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Enable l10n support
$l = OC_L10N::get('core');
+// Enable OC_Defaults support
+$defaults = new OC_Defaults();
+
// Get the config
$apps_paths = array();
foreach(OC_App::getEnabledApps() as $app) {
@@ -61,8 +64,25 @@ $array = array(
'session_lifetime' => \OCP\Config::getSystemValue('session_lifetime', ini_get('session.gc_maxlifetime')),
'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true)
)
+ ),
+ "oc_defaults" => json_encode(
+ array(
+ 'entity' => $defaults->getEntity(),
+ 'name' => $defaults->getName(),
+ 'title' => $defaults->getTitle(),
+ 'baseUrl' => $defaults->getBaseUrl(),
+ 'syncClientUrl' => $defaults->getSyncClientUrl(),
+ 'docBaseUrl' => $defaults->getDocBaseUrl(),
+ 'slogan' => $defaults->getSlogan(),
+ 'logoClaim' => $defaults->getLogoClaim(),
+ 'shortFooter' => $defaults->getShortFooter(),
+ 'longFooter' => $defaults->getLongFooter()
+ )
)
- );
+);
+
+// Allow hooks to modify the output values
+OC_Hook::emit('\OCP\Config', 'js', array('array' => &$array));
// Echo it
foreach ($array as $setting => $value) {
diff --git a/core/js/tests/specHelper.js b/core/js/tests/specHelper.js
index 1848d08354e..b1193240580 100644
--- a/core/js/tests/specHelper.js
+++ b/core/js/tests/specHelper.js
@@ -63,6 +63,7 @@ window.oc_config = {
session_lifetime: 600 * 1000,
session_keepalive: false
};
+window.oc_defaults = {};
// global setup for all tests
(function setupTests() {
diff --git a/lib/private/request.php b/lib/private/request.php
index 14f3bf2cbb7..afd3fda4f2d 100755
--- a/lib/private/request.php
+++ b/lib/private/request.php
@@ -59,7 +59,7 @@ class OC_Request {
if (isset($_SERVER['HTTP_HOST'])) {
$host = $_SERVER['HTTP_HOST'];
}
- if (isset($_SERVER['SERVER_NAME'])) {
+ else if (isset($_SERVER['SERVER_NAME'])) {
$host = $_SERVER['SERVER_NAME'];
}
}