Skip to content

Commit be08f78

Browse files
committed
Making file manager work with child blogs
1 parent 11888c3 commit be08f78

9 files changed

Lines changed: 67 additions & 38 deletions

File tree

BlogEngine/BlogEngine.Core/Data/FileManagerRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public IEnumerable<FileInstance> Find(int take = 10, int skip = 0, string path =
2121
var responsePath = "root";
2222

2323
if(string.IsNullOrEmpty(path))
24-
path = "/" + Security.CurrentUser.Identity.Name;
24+
path = Blog.CurrentInstance.StorageLocation + Utils.FilesFolder;
2525

2626
var directory = BlogService.GetDirectory(path);
2727

BlogEngine/BlogEngine.Core/Data/StatsRepository.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,16 @@ void Subscribers(Stats stats)
4747
if (!Security.IsAuthorizedTo(BlogEngine.Core.Rights.AccessAdminPages))
4848
throw new System.UnauthorizedAccessException();
4949

50-
string filename = System.IO.Path.Combine(Blog.CurrentInstance.StorageLocation, "newsletter.xml");
51-
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
52-
doc.Load(System.Web.Hosting.HostingEnvironment.MapPath(filename));
53-
System.Xml.XmlNodeList list = doc.GetElementsByTagName("email");
54-
stats.SubscribersCount += (list.Count).ToString();
50+
var filename = System.IO.Path.Combine(Blog.CurrentInstance.StorageLocation, "newsletter.xml");
51+
filename = System.Web.Hosting.HostingEnvironment.MapPath(filename);
52+
53+
if (System.IO.File.Exists(filename))
54+
{
55+
var doc = new System.Xml.XmlDocument();
56+
doc.Load(filename);
57+
System.Xml.XmlNodeList list = doc.GetElementsByTagName("email");
58+
stats.SubscribersCount += (list.Count).ToString();
59+
}
5560
}
5661

5762
void CountComments(Stats stats)

BlogEngine/BlogEngine.Core/Web/HttpHandlers/ResourceHandler.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,15 @@ public void ProcessRequest(HttpContext context)
9191

9292
sbSiteVars.Append("ApplicationRelativeWebRoot: '" + Utils.ApplicationRelativeWebRoot + "',");
9393
sbSiteVars.Append("RelativeWebRoot: '" + Utils.RelativeWebRoot + "',");
94-
sbSiteVars.Append("BlogInstanceId: '" + Blog.CurrentInstance.Id + "',");
9594
sbSiteVars.Append("AbsoluteWebRoot: '" + Utils.AbsoluteWebRoot + "',");
96-
sbSiteVars.Append("GenericPageSize: '" + BlogConfig.GenericPageSize.ToString() + "',");
97-
sbSiteVars.Append("GalleryFeedUrl: '" + BlogConfig.GalleryFeedUrl + "',");
95+
9896
sbSiteVars.Append("IsPrimary: '" + Blog.CurrentInstance.IsPrimary + "',");
97+
sbSiteVars.Append("BlogInstanceId: '" + Blog.CurrentInstance.Id + "',");
98+
sbSiteVars.Append("BlogStorageLocation: '" + Blog.CurrentInstance.StorageLocation + "',");
99+
sbSiteVars.Append("BlogFilesFolder: '" + Utils.FilesFolder + "',");
100+
101+
sbSiteVars.Append("GenericPageSize: '" + BlogConfig.GenericPageSize.ToString() + "',");
102+
sbSiteVars.Append("GalleryFeedUrl: '" + BlogConfig.GalleryFeedUrl + "',");
99103
sbSiteVars.Append("Version: 'BlogEngine.NET " + BlogSettings.Instance.Version() + "'");
100104

101105
sb.Append("SiteVars = {" + sbSiteVars.ToString() + "}; BlogAdmin = { i18n: " + jc.ToJsonString() + "};");

BlogEngine/BlogEngine.NET/AppCode/App_Start/BlogEngineConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static void RegisterBundles(BundleCollection bundles)
129129
.Include("~/admin/app/controllers/pages.js")
130130
.Include("~/admin/app/controllers/tags.js")
131131
.Include("~/admin/app/controllers/categories.js")
132-
.Include("~/admin/app/controllers/files.js")
132+
.Include("~/admin/app/controllers/fileManager.js")
133133
.Include("~/admin/app/controllers/commentList.js")
134134
.Include("~/admin/app/controllers/users.js")
135135
.Include("~/admin/app/controllers/roles.js")
@@ -165,7 +165,7 @@ static void RegisterBundles(BundleCollection bundles)
165165
.Include("~/admin/app/editor-helpers.js")
166166
.Include("~/admin/app/controllers/postEditor.js")
167167
.Include("~/admin/app/controllers/pageEditor.js")
168-
.Include("~/admin/app/controllers/files.js")
168+
.Include("~/admin/app/controllers/fileManager.js")
169169
.Include("~/admin/app/controllers/common.js")
170170
.Include("~/admin/app/data-service.js")
171171
);

BlogEngine/BlogEngine.NET/BlogEngine.NET.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
<Content Include="admin\app\controllers\pageEditor.js" />
134134
<Content Include="admin\app\controllers\pings.js" />
135135
<Content Include="admin\app\controllers\blogRoll.js" />
136-
<Content Include="admin\app\controllers\files.js" />
136+
<Content Include="admin\app\controllers\fileManager.js" />
137137
<Content Include="admin\app\controllers\postEditor.js" />
138138
<Content Include="admin\app\data-service.js" />
139139
<Content Include="admin\app\controllers\tools.js" />

BlogEngine/BlogEngine.NET/admin/Web.Config

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,5 @@
22
<configuration>
33
<system.web>
44
<pages enableSessionState="true" />
5-
<authorization>
6-
<deny users="?"/>
7-
<allow users="*"/>
8-
</authorization>
95
</system.web>
106
</configuration>

BlogEngine/BlogEngine.NET/admin/app/controllers/files.js renamed to BlogEngine/BlogEngine.NET/admin/app/controllers/fileManager.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
angular.module('blogAdmin').controller('FilesController', ["$rootScope", "$scope", "$location", "$filter", "$log", "dataService", function ($rootScope, $scope, $location, $filter, $log, dataService) {
1+
angular.module('blogAdmin').controller('FileManagerController', ["$rootScope", "$scope", "$location", "$filter", "$log", "dataService", function ($rootScope, $scope, $location, $filter, $log, dataService) {
22
$scope.data = dataService;
33
$scope.items = [];
44
$scope.itemsPerPage = 45; // page size - pass into grid on init
55
$scope.id = {};
66
$scope.file = {};
7-
$scope.dirName = '';
8-
$scope.currentPath = '/' + UserVars.Name;
9-
$scope.rootStorage = editVars.storageLocation + "files";
7+
$scope.dirName = '';
108
$scope.root = $rootScope.SiteVars.ApplicationRelativeWebRoot;
9+
$scope.rootStorage = SiteVars.BlogStorageLocation + SiteVars.BlogFilesFolder;
10+
$scope.currentPath = '/';
1111
$scope.focusInput = false;
1212

1313
$scope.load = function (path) {
@@ -16,16 +16,14 @@
1616
.success(function (data) {
1717
angular.copy(data, $scope.items);
1818
gridInit($scope, $filter);
19-
$scope.currentPath = path ? path : $scope.rootStorage + "/" + UserVars.Name;
19+
$scope.currentPath = path ? path : $scope.rootStorage;
2020
rowSpinOff($scope.items);
2121
})
2222
.error(function (data) {
2323
toastr.error($rootScope.lbl.Error);
2424
});
2525
}
2626

27-
$scope.load('');
28-
2927
$scope.processChecked = function (action) {
3028
var i = $scope.items.length;
3129
var checked = [];
@@ -144,6 +142,8 @@
144142
wm.getWindows()[0].close();
145143
}
146144

145+
$scope.load('');
146+
147147
function rowSpinOff(items) {
148148
if (items.length > 0) {
149149
$('#tr-spinner').hide();
@@ -152,5 +152,4 @@
152152
$('#div-spinner').html(BlogAdmin.i18n.empty);
153153
}
154154
}
155-
156155
}]);

BlogEngine/BlogEngine.NET/admin/editors/tinymce/plugins/filemanager/plugin.min.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tinymce.PluginManager.add("filemanager", function (editor, url) {
55
onclick: function () {
66
editor.windowManager.open({
77
title: "File manager",
8-
url: url + "../../../../../filemanager.cshtml",
8+
url: SiteVars.RelativeWebRoot + "admin/filemanager.cshtml",
99
width: window.innerWidth * 0.9,
1010
height: window.innerHeight * 0.8
1111
}, {

BlogEngine/BlogEngine.NET/admin/filemanager.cshtml

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,41 @@
2121
</script>
2222
<script type="text/javascript" src="admin.res.axd"></script>
2323
<style>
24-
.file-card { border: 1px solid #e5e5e5; width: 138px; height: 160px; display: inline-block; float: left; margin: 5px }
25-
.file-card img { width: 138px; }
26-
.file-form { margin: 0 20px; padding: 8px 8px 8px 0 }
27-
.file-card-box { width: 138px; height: 140px; overflow: hidden; background-color: #e5e5e5 }
28-
.file-card-lbl { display: inline-block; padding: 2px 10px; width: 138px; height: 24px; background-color: #ccc; }
24+
.file-card {
25+
border: 1px solid #e5e5e5;
26+
width: 138px;
27+
height: 160px;
28+
display: inline-block;
29+
float: left;
30+
margin: 5px;
31+
}
32+
33+
.file-card img {
34+
width: 138px;
35+
}
36+
37+
.file-form {
38+
margin: 0 20px;
39+
padding: 8px 8px 8px 0;
40+
}
41+
42+
.file-card-box {
43+
width: 138px;
44+
height: 140px;
45+
overflow: hidden;
46+
background-color: #e5e5e5;
47+
}
48+
49+
.file-card-lbl {
50+
display: inline-block;
51+
padding: 2px 10px;
52+
width: 138px;
53+
height: 24px;
54+
background-color: #ccc;
55+
}
2956
</style>
3057
</head>
31-
<body ng-controller="FilesController">
58+
<body ng-controller="FileManagerController">
3259
@Scripts.Render("~/scripts/wysiwyg")
3360

3461
<div class="wrapper @Resources.labels.LangDirection">
@@ -63,7 +90,7 @@
6390
<button type="button" tabindex="-1" class="btn btn-sm btn-success" id="fileBtn"><i class="fa fa-plus"></i> NEW</button>
6491
<input type="file" id="file" name="file" data-role="magic-overlay" tabindex="-1" data-target="#fileBtn" title="{{lbl.uploadFile}}" onchange="angular.element(this).scope().uploadFile(this.files)" />
6592
</div>
66-
</div>
93+
</div>
6794
<div class="btn-group befdv pull-left">
6895
<button ng-click="addFolder()" class="btn btn-sm btn-warning" type="submit" title="Add folder"><i class="fa fa-folder"></i></button>
6996
<button ng-disabled="itemsChecked() === false" ng-click="processChecked('delete')" title="Delete" class="btn btn-sm btn-danger"><i class="fa fa-trash"></i></button>
@@ -73,10 +100,10 @@
73100
</div>
74101
<div class="pull-left" style="margin-left: 20px; line-height: 32px; color: #666">{{currentPath}}</div>
75102
</div>
76-
</div>
103+
</div>
77104

78105
<div class="row">
79-
<div class="file-card" ng-if="item.FullPath != rootStorage" ng-repeat="item in pagedItems[currentPage] | orderBy:sortingOrder:reverse">
106+
<div class="file-card" ng-repeat="item in pagedItems[currentPage] | orderBy:sortingOrder:reverse">
80107
<div class="file-card-box">
81108
<a ng-if="item.FileType === 0 && item.Name != '...'" title="{{item.Name}}" href="" ng-click="load(item.FullPath)" class="pull-left">
82109
<img ng-src="{{root}}Content/images/blog/placeholders/folder.png" />
@@ -88,7 +115,7 @@
88115
<img ng-src="{{root}}Content/images/blog/placeholders/zip.png" />
89116
</a>
90117
<a ng-if="item.FileType === 2" title="{{item.Name}}" href="" ng-click="insertFile(item)">
91-
<img ng-src="{{root}}image.axd?picture={{item.FullPath}}" />
118+
<img ng-src="{{root}}@Blog.CurrentInstance.StorageContainerName/image.axd?picture={{item.FullPath}}" />
92119
</a>
93120
</div>
94121
<div class="file-card-lbl">
@@ -97,7 +124,7 @@
97124
</div>
98125
</div>
99126

100-
<div ng-if="items.length > itemsPerPage" class="text-right pagination-wrapper" style="margin-top: 10px">
127+
<div ng-if="items.length > itemsPerPage" class="text-right pagination-wrapper" style="margin-top: 10px">
101128
<ul class="pagination pagination-sm">
102129
<li data-ng-class="{disabled: currentPage == 0}">
103130
<a data-ng-click="prevPage()"{{lbl.prev}}</a>
@@ -116,5 +143,3 @@
116143
</div>
117144
</body>
118145
</html>
119-
120-

0 commit comments

Comments
 (0)