Skip to content

Patch 1 #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/nbproject/private/
nbproject/
node_modules/
.idea/

/fackpath/*
851 changes: 442 additions & 409 deletions bridges/php-local/LocalBridge/FileManagerApi.php

Large diffs are not rendered by default.

43 changes: 37 additions & 6 deletions bridges/php-local/index.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,52 @@
<?php
namespace AngularFilemanager\LocalBridge;

date_default_timezone_set('Asia/Shanghai');
define('SYSTEM_coding', 'GBK');

/**
* PHP Local filesystem bridge for angular-filemanager
*
* @author Jakub Ďuraš <jakub@duras.me>
* @version 0.1.0
*
* @author Jakub Ďuraš <jakub@duras.me>
* @version 0.1.0
*/
include 'LocalBridge/Response.php';
include 'LocalBridge/Rest.php';
include 'LocalBridge/Translate.php';
include 'LocalBridge/FileManagerApi.php';

//default path
$base_path = preg_replace(['/\\\\+/', '/\/+/'], ['\\\\', '/'], realpath('../../fackpath'));

//Takes two arguments - base path without last slash (default: '$currentDirectory/../files'); language (default: 'en'); mute_errors (default: true, will call ini_set('display_errors', 0))
$fileManagerApi = new FileManagerApi();
$fileManagerApi = new FileManagerApi($base_path);

$rest = new Rest();
$rest->post([$fileManagerApi, 'postHandler'])
->get([$fileManagerApi, 'getHandler'])
->handle();
->get([$fileManagerApi, 'getHandler'])
->handle();

function sbasename($filename) {
return preg_replace('/^.*[\\\\\\/]/', '', $filename);
}

function getFilesize($file) {
$size = filesize($file);
if ($size < 0) {
if ((strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')) {
exec('for %I in ("' . $file . '") do @echo %~zI', $output);
$size = $output[0];
} else {
$size = trim(`stat -c%s $file`);
}
}
return $size;
}

function debugLog($msg) {
$handle = fopen('debug_log.txt', 'a');
fwrite($handle, sprintf("%s : ", date('Y-m-d H:i:s')));
fwrite($handle, "\r\n");
fwrite($handle, $msg . "\r\n\r\n");
fclose($handle);
}
18 changes: 18 additions & 0 deletions bridges/php-local/lang/zh.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"function_not_implemented": "功能未实现",
"file_not_found": "没有找到文件",
"listing_filed": "获取列表失败",
"moving_failed": "移动失败",
"renaming_failed": "重命名失败",
"copying_failed": "复制失败",
"removing_failed": "删除失败",
"removing_failed_directory_not_empty": "删除失败,您正要删除的文件夹不是空的",
"saving_failed": "保存失败",
"folder_already_exists": "文件夹已存在",
"folder_creation_failed": "新建文件夹失败",
"permissions_change_failed": "修改权限失败",
"compression_failed": "压缩失败",
"archive_opening_failed": "无法打开压缩包,有错误或不支持",
"extraction_failed": "解压缩失败",
"upload_failed": "上传失败"
}
8 changes: 4 additions & 4 deletions dist/angular-filemanager.min.js

Large diffs are not rendered by default.

30 changes: 19 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
@@ -48,6 +48,22 @@
var defaults = config.$get();
config.set({
appName: 'angular-filemanager',
defaultLang: 'zh',

listUrl: 'bridges/php-local/index.php',
uploadUrl: 'bridges/php-local/index.php',
renameUrl: 'bridges/php-local/index.php',
copyUrl: 'bridges/php-local/index.php',
moveUrl: 'bridges/php-local/index.php',
removeUrl: 'bridges/php-local/index.php',
editUrl: 'bridges/php-local/index.php',
getContentUrl: 'bridges/php-local/index.php',
createFolderUrl: 'bridges/php-local/index.php',
downloadFileUrl: 'bridges/php-local/index.php',
downloadMultipleUrl: 'bridges/php-local/index.php',
compressUrl: 'bridges/php-local/index.php',
extractUrl: 'bridges/php-local/index.php',
permissionsUrl: 'bridges/php-local/index.php',
pickCallback: function(item) {
var msg = 'Picked %s "%s" for external use'
.replace('%s', item.type)
@@ -56,8 +72,9 @@
},

allowedActions: angular.extend(defaults.allowedActions, {
pickFiles: false,
pickFolders: false,
extract: false,
compress: false,
downloadMultiple: false,
}),
});
}]);
@@ -66,14 +83,5 @@

<body class="ng-cloak">
<angular-filemanager></angular-filemanager>

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-35182652-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>
10 changes: 10 additions & 0 deletions src/js/controllers/main.js
Original file line number Diff line number Diff line change
@@ -156,6 +156,16 @@
});
};

$scope.openDwonloadLink = function() {
var item = $scope.singleSelection();
$scope.modal('downloadlink', null, true)
.find('#downloadlink-target')
.val(window.location.protocol + '//' + window.location.hostname + '/' + $scope.apiMiddleware.getUrl(item))
.on('focus', function() {
this.select();
});
};

$scope.openEditItem = function() {
var item = $scope.singleSelection();
$scope.apiMiddleware.getContent(item).then(function(data) {
2 changes: 2 additions & 0 deletions src/js/providers/translations.js
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@
wait: 'Wait',
move: 'Move',
download: 'Download',
downloadlink: 'View download link',
view_item: 'View item',
remove: 'Delete',
edit: 'Edit',
@@ -751,6 +752,7 @@
wait: '等待',
move: '移动',
download: '下载',
downloadlink: '显示下载链接',
view_item: '查看子项',
remove: '删除',
edit: '编辑',
6 changes: 6 additions & 0 deletions src/templates/item-context-menu.html
Original file line number Diff line number Diff line change
@@ -25,6 +25,12 @@
</a>
</li>

<li ng-show="config.allowedActions.download && !selectionHas('dir') && singleSelection()">
<a href="" tabindex="-1" ng-click="openDwonloadLink()">
<i class="glyphicon glyphicon-cloud-download"></i> {{'downloadlink' | translate}}
</a>
</li>

<li ng-show="config.allowedActions.preview && singleSelection().isImage() && singleSelection()">
<a href="" tabindex="-1" ng-click="openImagePreview()">
<i class="glyphicon glyphicon-picture"></i> {{'view_item' | translate}}
24 changes: 24 additions & 0 deletions src/templates/modals.html
Original file line number Diff line number Diff line change
@@ -22,6 +22,30 @@ <h4 class="modal-title">{{"preview" | translate}}</h4>
</div>
</div>

<div class="modal animated fadeIn" id="downloadlink">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">{{"close" | translate}}</span>
</button>
<h4 class="modal-title">{{"downloadlink" | translate}}</h4>
</div>
<div class="modal-body">
<div class="text-center">
<input type="text" class="form-control" autofocus="autofocus" id="downloadlink-target">
<span class="label label-warning" ng-show="apiMiddleware.apiHandler.inprocess">{{'loading' | translate}} ...</span>
</div>
<div ng-include data-src="'error-bar'" class="clearfix"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="apiMiddleware.apiHandler.inprocess">{{"close" | translate}}</button>
</div>
</div>
</div>
</div>

<div class="modal animated fadeIn" id="remove">
<div class="modal-dialog">
<div class="modal-content">