Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix dropdown on iPad & integrate CKFinder for browsing folder/files

  • Loading branch information...
commit 768b0d2f205237d090ec6fa157894108d210cb4f 1 parent 253f878
@a-fung authored
Showing with 756 additions and 27 deletions.
  1. +3 −0  .gitignore
  2. +12 −1 gather_aspnet.ps1
  3. +10 −0 gather_php.ps1
  4. +82 −0 source/aspnetserver/Handler/AdminFinderRequestHandler.cs
  5. +1 −0  source/aspnetserver/ServerAjax.aspx.cs
  6. +13 −0 source/aspnetserver/SessionWrapper.cs
  7. +1 −0  source/aspnetserver/admin.html
  8. +2 −0  source/aspnetserver/afung.MangaWeb3.Server.csproj
  9. +1 −1  source/aspnetserver/css/mangaweb.css
  10. +4 −4 source/aspnetserver/lang/en-us.html
  11. +27 −6 source/aspnetserver/template/admin.html
  12. +72 −0 source/ckfinder/config.ascx
  13. +5 −0 source/ckfinder/config.js
  14. +71 −0 source/ckfinder/config.php
  15. +13 −0 source/csharpcommon/AdminFinderRequest.cs
  16. +13 −0 source/csharpcommon/AdminFinderResponse.cs
  17. +2 −0  source/csharpcommon/afung.MangaWeb3.Common(script).csproj
  18. +2 −0  source/csharpcommon/afung.MangaWeb3.Common.csproj
  19. +11 −0 source/haxe/afung/mangaWeb3/common/AdminFinderRequest.hx
  20. +11 −0 source/haxe/afung/mangaWeb3/common/AdminFinderResponse.hx
  21. +2 −0  source/haxe/afung/mangaWeb3/server/ServerAjax.hx
  22. +17 −1 source/haxe/afung/mangaWeb3/server/SessionWrapper.hx
  23. +71 −0 source/haxe/afung/mangaWeb3/server/handler/AdminFinderRequestHandler.hx
  24. +14 −0 source/less/mangaweb.less
  25. +95 −0 source/scriptsharp/Import/CKFinder.cs
  26. +1 −1  source/scriptsharp/Modal/LoginModal.cs
  27. +5 −8 source/scriptsharp/Modal/ModalBase.cs
  28. +5 −0 source/scriptsharp/Utility.cs
  29. +1 −0  source/scriptsharp/afung.MangaWeb3.Client.csproj
  30. +1 −0  source/scriptsharpadmin/AdminApp.cs
  31. +8 −1 source/scriptsharpadmin/Modal/AdminCollectionAddModal.cs
  32. +1 −1  source/scriptsharpadmin/Modal/AdminCollectionEditNameModal.cs
  33. +1 −0  source/scriptsharpadmin/Modal/AdminCollectionUsersModal.cs
  34. +155 −0 source/scriptsharpadmin/Modal/AdminFinderModal.cs
  35. +16 −1 source/scriptsharpadmin/Modal/AdminMangaAddModal.cs
  36. +1 −1  source/scriptsharpadmin/Modal/AdminSettingsModal.cs
  37. +1 −1  source/scriptsharpadmin/Modal/AdminUserAddModal.cs
  38. +1 −0  source/scriptsharpadmin/Modal/AdminUserCollectionsModal.cs
  39. +1 −0  source/scriptsharpadmin/Module/AdminCollectionsModule.cs
  40. +1 −0  source/scriptsharpadmin/Module/AdminMangasModule.cs
  41. +1 −0  source/scriptsharpadmin/Module/AdminUsersModule.cs
  42. +1 −0  source/scriptsharpadmin/afung.MangaWeb3.Client.Admin.csproj
View
3  .gitignore
@@ -170,3 +170,6 @@ output/
copy*test.ps1
afung.*.js
mscorlib*js
+
+ckfinder_aspnet/
+ckfinder_php/
View
13 gather_aspnet.ps1
@@ -86,7 +86,7 @@ copy source\aspnetserver\bin\*.dll $path\bin
copy source\aspnetserverinstall\bin\afung.MangaWeb3.Server.Install.dll $path\bin
-# pdf files
+# debug files
if ($true) {
copy source\aspnetserver\bin\*.pdb $path\bin
copy source\aspnetserverinstall\bin\afung.MangaWeb3.Server.Install.pdb $path\bin
@@ -97,3 +97,14 @@ copy source\aspnetserverinstall\bin\afung.MangaWeb3.Server.Install.pdb $path\bin
copy source\aspnetserver\web.config $path
+# ckfinder
+if ($true) {
+mkdir $path\ckfinder
+Copy-Item external_libraries\ckfinder_aspnet\* $path\ckfinder -recurse -force;
+
+copy source\ckfinder\config.js $path\ckfinder -force
+copy source\ckfinder\config.ascx $path\ckfinder -force
+copy external_libraries\ckfinder_aspnet\bin\Release\CKFinder.dll $path\bin -force
+}
+
+
View
10 gather_php.ps1
@@ -84,3 +84,13 @@ del source\haxephp\index.php
robocopy source\haxephp $path /E
+# ckfinder
+if ($true) {
+mkdir $path\ckfinder
+Copy-Item external_libraries\ckfinder_php\* $path\ckfinder -recurse -force;
+
+copy source\ckfinder\config.js $path\ckfinder -force
+copy source\ckfinder\config.php $path\ckfinder -force
+}
+
+
View
82 source/aspnetserver/Handler/AdminFinderRequestHandler.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Web;
+using afung.MangaWeb3.Common;
+
+namespace afung.MangaWeb3.Server.Handler
+{
+ public class AdminFinderRequestHandler : HandlerBase
+ {
+ protected override Type GetHandleRequestType()
+ {
+ return typeof(AdminFinderRequest);
+ }
+
+ public override void HandleRequest(string jsonString, AjaxBase ajax)
+ {
+ if (!User.IsAdminLoggedIn(ajax))
+ {
+ ajax.Unauthorized();
+ return;
+ }
+
+ AdminFinderRequest request = Utility.ParseJson<AdminFinderRequest>(jsonString);
+ AdminFinderResponse response = new AdminFinderResponse();
+ Collection collection = null;
+ string[][] finderData;
+
+ if (request.cid != -1)
+ {
+ collection = Collection.GetById(request.cid);
+ if (collection == null)
+ {
+ ajax.BadRequest();
+ return;
+ }
+
+ finderData = new string[][] { new string[] { collection.Name, collection.Path } };
+ }
+ else
+ {
+ List<string[]> diskData = new List<string[]>();
+ string[] discs = Environment.GetLogicalDrives();
+ for (int i = 0; i < discs.Length; i++)
+ {
+ string driveLetter = discs[i].Replace(":\\", "");
+ using (System.Management.ManagementObject diskObj = new System.Management.ManagementObject("win32_logicaldisk.deviceid=\"" + driveLetter + ":\""))
+ {
+ if (diskObj["DriveType"].ToString() == "3") // Local Disk
+ {
+ diskData.Add(new string[] { driveLetter + ":", driveLetter + ":\\" });
+ }
+ }
+ }
+
+ finderData = diskData.ToArray();
+ }
+
+ Random r = new Random();
+ StringBuilder tokenBuilder = new StringBuilder();
+ for (int i = 0; i < 32; i++)
+ {
+ int n = r.Next(36);
+ if (n < 10)
+ {
+ tokenBuilder.Append(n);
+ }
+ else
+ {
+ tokenBuilder.Append(Convert.ToChar(55 + n));
+ }
+ }
+
+ response.token = tokenBuilder.ToString();
+
+ SessionWrapper.SetFinderData(ajax, response.token, finderData);
+
+ ajax.ReturnJson(response);
+ }
+ }
+}
View
1  source/aspnetserver/ServerAjax.aspx.cs
@@ -40,6 +40,7 @@ protected override void PageLoad()
new AdminCollectionsUsersDeleteRequestHandler(),
new AdminCollectionsUsersAccessRequestHandler(),
new AdminMangaAddRequestHandler(),
+ new AdminFinderRequestHandler(),
};
}
View
13 source/aspnetserver/SessionWrapper.cs
@@ -30,6 +30,19 @@ public static void SetUserName(AjaxBase ajax, string value)
Set(ajax, "username", value);
}
+ public static void SetFinderData(AjaxBase ajax, string token, string[][] finderData)
+ {
+ Dictionary<string, string[][]> dict = (Dictionary<string, string[][]>)Get(ajax, "finder");
+ if (dict == null)
+ {
+ dict = new Dictionary<string, string[][]>();
+ }
+
+ dict[token] = finderData;
+
+ Set(ajax, "finder", dict);
+ }
+
private static object Get(AjaxBase ajax, string name)
{
return ajax.Session["afung.MangaWeb3.Server.Session." + name];
View
1  source/aspnetserver/admin.html
@@ -15,6 +15,7 @@
<script type="text/javascript" src="js/afung.MangaWeb3.Client.debug.js"></script>
<script type="text/javascript" src="js/afung.MangaWeb3.Client.Admin.debug.js"></script>
<script type="text/javascript" src="js/servertype.js"></script>
+ <script type="text/javascript" src="ckfinder/ckfinder.js"></script>
</head>
<body>
<script type="text/javascript">
View
2  source/aspnetserver/afung.MangaWeb3.Server.csproj
@@ -44,6 +44,7 @@
<Reference Include="SevenZipSharp">
<HintPath>..\..\external_libraries\SevenZipSharp.dll</HintPath>
</Reference>
+ <Reference Include="System.Management" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
@@ -115,6 +116,7 @@
<Compile Include="Handler\AdminCollectionsUsersDeleteRequestHandler.cs" />
<Compile Include="Handler\AdminCollectionsUsersGetRequestHandler.cs" />
<Compile Include="Handler\AdminCollectionUserAddRequestHandler.cs" />
+ <Compile Include="Handler\AdminFinderRequestHandler.cs" />
<Compile Include="Handler\AdminMangaAddRequestHandler.cs" />
<Compile Include="Handler\AdminSettingsGetRequestHandler.cs" />
<Compile Include="Handler\AdminSettingsSetRequestHandler.cs" />
View
2  source/aspnetserver/css/mangaweb.css
@@ -1 +1 @@
-body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}code,pre{font-family:Monaco,Menlo,Consolas,"Courier New",monospace,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}.navbar-search .search-query{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}.temp{display:none}.text-left{text-align:left}.text-center{text-align:center}.modal{overflow:hidden}.modal form{margin:0}.nav-admin{margin-top:15px}.select-tall{height:100px}.table tr.vmiddle input[type="checkbox"]{position:relative;bottom:2px}.table tr.vmiddle td{vertical-align:middle}.table th.text-center,.table td.text-center{text-align:center}.table th.td-mini,.table td.td-mini{width:30px}.table th.td-small,.table td.td-small{width:100px}.table td.break-word{word-wrap:break-word}.row-after-table .btn-toolbar{margin-top:0}.row-after-table .pagination{margin-top:0}@media (max-width: 767px){.modal.fade.in{ top:50%}}#error-modal.modal{z-index:1500}#confirm-modal.modal{z-index:1450}#login-modal.modal{z-index:1400}.typeahead{z-index:2000}
+body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}code,pre{font-family:Monaco,Menlo,Consolas,"Courier New",monospace,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}.navbar-search .search-query{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}.temp{display:none}.text-left{text-align:left}.text-center{text-align:center}.modal{overflow:hidden}.modal form{margin:0}.nav-admin{margin-top:15px}.select-tall{height:100px}.table tr.vmiddle input[type="checkbox"]{position:relative;bottom:2px}.table tr.vmiddle td{vertical-align:middle}.table th.text-center,.table td.text-center{text-align:center}.table th.td-mini,.table td.td-mini{width:30px}.table th.td-small,.table td.td-small{width:100px}.table td.break-word{word-wrap:break-word}.row-after-table .btn-toolbar{margin-top:0}.row-after-table .pagination{margin-top:0}@media (max-width: 767px){.modal.fade.in{ top:50%}}#error-modal.modal{z-index:1500}#confirm-modal.modal{z-index:1450}#login-modal.modal{z-index:1400}#admin-finder-modal.modal{z-index:1350}#admin-finder-body.modal-body{height:400px;padding:0}#admin-finder-body.modal-body iframe{display:block;height:400px}.typeahead{z-index:2000}
View
8 source/aspnetserver/lang/en-us.html
@@ -108,10 +108,10 @@
<p id="DeleteItemsConfirm">Are you sure to delete the selected item(s)?</p>
<p id="FileNotFound">File not found.</p>
<p id="PathNotUnderCollection">The specified path is not under the path of the selected collection.</p>
-<p id=""></p>
-<p id=""></p>
-<p id=""></p>
-<p id=""></p>
+<p id="Browse">Browse</p>
+<p id="FileBrowser">File Browser</p>
+<p id="Select">Select</p>
+<p id="CKFinderLanguage">en</p>
<p id=""></p>
<p id=""></p>
<p id=""></p>
View
33 source/aspnetserver/template/admin.html
@@ -68,7 +68,7 @@
<span class="msg msg-ActionOnSelected"></span>
<span class="caret"></span>
</button>
- <ul class="dropdown-menu">
+ <ul class="dropdown-menu" id="admin-collections-action-dropdown">
<li><a href="#" id="admin-collections-delete-btn">
<i class="icon-trash"></i>
<span class="msg msg-Delete"></span>
@@ -154,7 +154,7 @@
<span class="msg msg-ActionOnSelected"></span>
<span class="caret"></span>
</button>
- <ul class="dropdown-menu">
+ <ul class="dropdown-menu" id="admin-mangas-action-dropdown">
<li><a href="#" id="admin-mangas-delete-btn">
<i class="icon-trash"></i>
<span class="msg msg-Delete"></span>
@@ -231,7 +231,7 @@
<span class="msg msg-ActionOnSelected"></span>
<span class="caret"></span>
</button>
- <ul class="dropdown-menu">
+ <ul class="dropdown-menu" id="admin-users-action-dropdown">
<li><a href="#" id="admin-users-delete-btn">
<i class="icon-trash"></i>
<span class="msg msg-Delete"></span>
@@ -311,7 +311,12 @@ <h3 class="msg msg-AddCollection"></h3>
<div class="control-group">
<label class="msg msg-Path control-label" for="admin-collection-add-path"></label>
<div class="controls">
- <input type="text" id="admin-collection-add-path" />
+ <div class="input-append">
+ <input type="text" id="admin-collection-add-path" />
+ <a href="#" class="btn" id="admin-collection-add-browse-btn">
+ <i class="icon-folder-open"></i>
+ </a>
+ </div>
</div>
</div>
<div class="control-group">
@@ -415,7 +420,7 @@ <h3 id="admin-collection-users-name"></h3>
<span class="msg msg-ActionOnSelected"></span>
<span class="caret"></span>
</button>
- <ul class="dropdown-menu">
+ <ul class="dropdown-menu" id="admin-collection-users-action-dropdown">
<li><a href="#" id="admin-collection-users-delete-btn">
<i class="icon-trash"></i>
<span class="msg msg-Delete"></span>
@@ -474,7 +479,7 @@ <h3 id="admin-user-collections-name"></h3>
<span class="msg msg-ActionOnSelected"></span>
<span class="caret"></span>
</button>
- <ul class="dropdown-menu">
+ <ul class="dropdown-menu" id="admin-user-collections-action-dropdown">
<li><a href="#" id="admin-user-collections-delete-btn">
<i class="icon-trash"></i>
<span class="msg msg-Delete"></span>
@@ -512,7 +517,12 @@ <h3 class="msg msg-AddManga"></h3>
<div class="control-group">
<label class="msg msg-Path control-label" for="admin-manga-add-path"></label>
<div class="controls">
+ <div class="input-append">
<input type="text" id="admin-manga-add-path" />
+ <a href="#" class="btn" id="admin-manga-add-browse-btn">
+ <i class="icon-folder-open"></i>
+ </a>
+ </div>
</div>
</div>
<div class="control-group">
@@ -527,3 +537,14 @@ <h3 class="msg msg-AddManga"></h3>
</div>
</form>
</div>
+<div id="admin-finder-modal" class="modal hide fade">
+ <div class="modal-header">
+ <a href="#" class="close" data-dismiss="modal">×</a>
+ <h3 class="msg msg-FileBrowser"></h3>
+ </div>
+ <div class="modal-body" id="admin-finder-body">
+ </div>
+ <div class="modal-footer">
+ <a href="#" class="msg msg-Select btn btn-primary" id="admin-finder-select"></a>
+ </div>
+</div>
View
72 source/ckfinder/config.ascx
@@ -0,0 +1,72 @@
+<%@ Control Language="C#" EnableViewState="false" AutoEventWireup="false" Inherits="CKFinder.Settings.ConfigFile" %>
+<%@ Import Namespace="CKFinder.Settings" %>
+<script runat="server">
+ public override bool CheckAuthentication()
+ {
+ object sessionData = Page.Session["afung.MangaWeb3.Server.Session.finder"];
+ string token = Page.Request.QueryString["token"];
+ if (sessionData == null || String.IsNullOrWhiteSpace(token))
+ {
+ return false;
+ }
+
+ Dictionary<string, string[][]> dict = (Dictionary<string, string[][]>)sessionData;
+ return dict.ContainsKey(token);
+ }
+
+ public override void SetConfig()
+ {
+ object sessionData = Page.Session["afung.MangaWeb3.Server.Session.finder"];
+ string token = Page.Request.QueryString["token"];
+ if (sessionData == null || String.IsNullOrWhiteSpace(token))
+ {
+ return;
+ }
+
+ Dictionary<string, string[][]> dict = (Dictionary<string, string[][]>)sessionData;
+ if (!dict.ContainsKey(token))
+ {
+ return;
+ }
+
+ LicenseName = "";
+ LicenseKey = "";
+ BaseUrl = "/";
+ BaseDir = "\\";
+ DisallowUnsafeCharacters = true;
+ ForceSingleExtension = true;
+ HtmlExtensions = new string[] { "html", "htm", "xml", "js" };
+ HideFolders = new string[] { ".svn", "CVS" };
+ HideFiles = new string[] { ".*" };
+
+ RoleSessionVar = "CKFinder_UserRole";
+
+ AccessControl acl = AccessControl.Add();
+ acl.Role = "*";
+ acl.ResourceType = "*";
+ acl.Folder = "/";
+
+ acl.FolderView = true;
+ acl.FolderCreate = false;
+ acl.FolderRename = false;
+ acl.FolderDelete = false;
+
+ acl.FileView = true;
+ acl.FileUpload = false;
+ acl.FileRename = false;
+ acl.FileDelete = false;
+
+ DefaultResourceTypes = "";
+
+ ResourceType type;
+
+ string[][] finderData = dict[token];
+ foreach (string[] folder in finderData)
+ {
+ type = ResourceType.Add(folder[0]);
+ type.Dir = type.Url = folder[1];
+ type.MaxSize = 0;
+ type.AllowedExtensions = type.DeniedExtensions = new string[] { };
+ }
+ }
+</script>
View
5 source/ckfinder/config.js
@@ -0,0 +1,5 @@
+CKFinder.customConfig = function( config )
+{
+ config.removePlugins = 'help,basket,flashupload';
+ config.selectMultiple = false;
+};
View
71 source/ckfinder/config.php
@@ -0,0 +1,71 @@
+<?php
+
+@session_start();
+
+function CheckAuthentication()
+{
+ if (!isset($_SESSION['afung.MangaWeb3.Server.Session.finder']) || !isset($_GET['token']))
+ {
+ return false;
+ }
+
+ $dict = $_SESSION['afung.MangaWeb3.Server.Session.finder'];
+ $token = $_GET['token'];
+
+ return isset($dict[$token]);
+}
+
+if (!isset($_SESSION['afung.MangaWeb3.Server.Session.finder']) || !isset($_GET['token']))
+{
+ die();
+}
+
+$dict = $_SESSION['afung.MangaWeb3.Server.Session.finder'];
+$token = $_GET['token'];
+
+if(!isset($dict[$token]))
+{
+ die();
+}
+
+$config['LicenseName'] = '';
+$config['LicenseKey'] = '';
+$baseUrl = '/';
+$baseDir = '/';
+$config['CheckDoubleExtension'] = true;
+$config['DisallowUnsafeCharacters'] = true;
+$config['FilesystemEncoding'] = 'UTF-8';
+$config['HtmlExtensions'] = array('html', 'htm', 'xml', 'js');
+$config['HideFolders'] = array(".svn", "CVS");
+$config['HideFiles'] = array(".*");
+
+$config['RoleSessionVar'] = 'CKFinder_UserRole';
+
+$config['AccessControl'][] = array(
+ 'role' => '*',
+ 'resourceType' => '*',
+ 'folder' => '/',
+
+ 'folderView' => true,
+ 'folderCreate' => false,
+ 'folderRename' => false,
+ 'folderDelete' => false,
+
+ 'fileView' => true,
+ 'fileUpload' => false,
+ 'fileRename' => false,
+ 'fileDelete' => false);
+
+$config['DefaultResourceTypes'] = '';
+
+$finderData = $dict[$token];
+for ($i = 0; $i < count($finderData); $i++)
+{
+ $config['ResourceType'][] = array(
+ 'name' => $finderData[$i][0],
+ 'url' => $finderData[$i][1],
+ 'directory' => $finderData[$i][1],
+ 'maxSize' => 0,
+ 'allowedExtensions' => '',
+ 'deniedExtensions' => '');
+}
View
13 source/csharpcommon/AdminFinderRequest.cs
@@ -0,0 +1,13 @@
+// AdminFinderRequest.cs
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace afung.MangaWeb3.Common
+{
+ public class AdminFinderRequest : JsonRequest
+ {
+ public int cid;
+ }
+}
View
13 source/csharpcommon/AdminFinderResponse.cs
@@ -0,0 +1,13 @@
+// AdminFinderResponse.cs
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace afung.MangaWeb3.Common
+{
+ public class AdminFinderResponse : JsonResponse
+ {
+ public string token;
+ }
+}
View
2  source/csharpcommon/afung.MangaWeb3.Common(script).csproj
@@ -57,6 +57,8 @@
<Compile Include="AdminCollectionsUsersGetRequest.cs" />
<Compile Include="AdminCollectionsUsersGetResponse.cs" />
<Compile Include="AdminCollectionUserAddRequest.cs" />
+ <Compile Include="AdminFinderRequest.cs" />
+ <Compile Include="AdminFinderResponse.cs" />
<Compile Include="AdminMangaAddRequest.cs" />
<Compile Include="AdminMangaAddResponse.cs" />
<Compile Include="AdminSettingsGetRequest.cs" />
View
2  source/csharpcommon/afung.MangaWeb3.Common.csproj
@@ -44,6 +44,8 @@
<Compile Include="AdminCollectionsUsersGetRequest.cs" />
<Compile Include="AdminCollectionsUsersGetResponse.cs" />
<Compile Include="AdminCollectionUserAddRequest.cs" />
+ <Compile Include="AdminFinderRequest.cs" />
+ <Compile Include="AdminFinderResponse.cs" />
<Compile Include="AdminMangaAddRequest.cs" />
<Compile Include="AdminMangaAddResponse.cs" />
<Compile Include="AdminSettingsGetRequest.cs" />
View
11 source/haxe/afung/mangaWeb3/common/AdminFinderRequest.hx
@@ -0,0 +1,11 @@
+package afung.mangaWeb3.common;
+
+/**
+ * ...
+ * @author a-fung
+ */
+
+class AdminFinderRequest extends JsonRequest
+{
+ public var cid:Int;
+}
View
11 source/haxe/afung/mangaWeb3/common/AdminFinderResponse.hx
@@ -0,0 +1,11 @@
+package afung.mangaWeb3.common;
+
+/**
+ * ...
+ * @author a-fung
+ */
+
+class AdminFinderResponse extends JsonResponse
+{
+ public var token:String;
+}
View
2  source/haxe/afung/mangaWeb3/server/ServerAjax.hx
@@ -9,6 +9,7 @@ import afung.mangaWeb3.server.handler.AdminCollectionsUsersAccessRequestHandler;
import afung.mangaWeb3.server.handler.AdminCollectionsUsersDeleteRequestHandler;
import afung.mangaWeb3.server.handler.AdminCollectionsUsersGetRequestHandler;
import afung.mangaWeb3.server.handler.AdminCollectionUserAddRequestHandler;
+import afung.mangaWeb3.server.handler.AdminFinderRequestHandler;
import afung.mangaWeb3.server.handler.AdminMangaAddRequestHandler;
import afung.mangaWeb3.server.handler.AdminSettingsGetRequestHandler;
import afung.mangaWeb3.server.handler.AdminSettingsSetRequestHandler;
@@ -67,6 +68,7 @@ class ServerAjax extends AjaxBase
new AdminCollectionsUsersDeleteRequestHandler(),
new AdminCollectionsUsersAccessRequestHandler(),
new AdminMangaAddRequestHandler(),
+ new AdminFinderRequestHandler(),
];
}
View
18 source/haxe/afung/mangaWeb3/server/SessionWrapper.hx
@@ -1,5 +1,7 @@
package afung.mangaWeb3.server;
+import php.Lib;
+import php.NativeArray;
import php.Session;
@@ -24,7 +26,7 @@ class SessionWrapper
}
}
- public static function SetUserName(ajax:AjaxBase, value:String)
+ public static function SetUserName(ajax:AjaxBase, value:String):Void
{
if (value == null)
{
@@ -34,6 +36,20 @@ class SessionWrapper
Set(ajax, "username", value);
}
+ public static function SetFinderData(ajax:AjaxBase, token:String, finderData:NativeArray):Void
+ {
+ var array:NativeArray = Get(ajax, "finder");
+ if (array == null)
+ {
+ array = Lib.toPhpArray([]);
+ }
+
+ var dict:Hash<NativeArray> = Lib.hashOfAssociativeArray(array);
+ dict.set(token, finderData);
+
+ Set(ajax, "finder", Lib.associativeArrayOfHash(dict));
+ }
+
private static function Get(ajax:AjaxBase, name:String):Dynamic
{
return Session.get("afung.MangaWeb3.Server.Session." + name);
View
71 source/haxe/afung/mangaWeb3/server/handler/AdminFinderRequestHandler.hx
@@ -0,0 +1,71 @@
+package afung.mangaWeb3.server.handler;
+
+import afung.mangaWeb3.common.AdminFinderRequest;
+import afung.mangaWeb3.common.AdminFinderResponse;
+import afung.mangaWeb3.server.Collection;
+import afung.mangaWeb3.server.SessionWrapper;
+import php.Lib;
+import php.NativeArray;
+
+/**
+ * ...
+ * @author a-fung
+ */
+
+class AdminFinderRequestHandler extends HandlerBase
+{
+ public override function GetHandleRequestType():Class<Dynamic>
+ {
+ return AdminFinderRequest;
+ }
+
+ public override function HandleRequest(jsonString:String, ajax:AjaxBase):Void
+ {
+ if (!User.IsAdminLoggedIn(ajax))
+ {
+ ajax.Unauthorized();
+ return;
+ }
+
+ var request:AdminFinderRequest = Utility.ParseJson(jsonString);
+ var response:AdminFinderResponse = new AdminFinderResponse();
+ var collection:Collection = null;
+ var finderData:NativeArray;
+
+ if (request.cid != -1)
+ {
+ collection = Collection.GetById(request.cid);
+ if (collection == null)
+ {
+ ajax.BadRequest();
+ return;
+ }
+
+ finderData = Lib.toPhpArray([Lib.toPhpArray([collection.Name, collection.Path])]);
+ }
+ else
+ {
+ finderData = Lib.toPhpArray([Lib.toPhpArray(["/", "/"])]);
+ }
+
+ var tokenBuilder:StringBuf = new StringBuf();
+ for (i in 0...32)
+ {
+ var n:Int = Std.random(36);
+ if (n < 10)
+ {
+ tokenBuilder.add(Std.string(n));
+ }
+ else
+ {
+ tokenBuilder.add(String.fromCharCode(55 + n));
+ }
+ }
+
+ response.token = tokenBuilder.toString();
+
+ SessionWrapper.SetFinderData(ajax, response.token, finderData);
+
+ ajax.ReturnJson(response);
+ }
+}
View
14 source/less/mangaweb.less
@@ -103,6 +103,20 @@ textarea {
z-index:1400;
}
+#admin-finder-modal.modal {
+ z-index:1350;
+}
+
+#admin-finder-body.modal-body {
+ height: 400px;
+ padding: 0;
+
+ iframe {
+ display: block;
+ height: 400px;
+ }
+}
+
.typeahead {
z-index:2000;
}
View
95 source/scriptsharp/Import/CKFinder.cs
@@ -0,0 +1,95 @@
+// CKFinder.cs
+//
+
+using System;
+using System.Collections.Generic;
+using System.Html;
+using System.Runtime.CompilerServices;
+
+namespace Finder
+{
+ [Imported]
+ [IgnoreNamespace]
+ public class CKFinder
+ {
+ [ScriptName("config")]
+ public static CKFinderConfig Config;
+
+ [ScriptName("basePath")]
+ public string BasePath;
+
+ [ScriptName("height")]
+ public int Height;
+
+ [ScriptName("api")]
+ public CKFinderAPI Api;
+
+ [ScriptName("callback")]
+ public Action<CKFinderAPI> Callback;
+
+ [ScriptName("appendTo")]
+ public void AppendTo(string elementId) { }
+
+ [ScriptName("selectActionFunction")]
+ public Action<string> SelectActionFunction;
+ }
+
+ [Imported]
+ [IgnoreNamespace]
+ public class CKFinderConfig
+ {
+ [ScriptName("language")]
+ public string Language;
+
+ [ScriptName("connectorInfo")]
+ public string ConnectorInfo;
+ }
+
+ [Imported]
+ [IgnoreNamespace]
+ public class CKFinderAPI
+ {
+ [ScriptName("disableFileContextMenuOption")]
+ public void DisableFileContextMenuOption(string option, bool addedUsingApi) { }
+
+ [ScriptName("disableFolderContextMenuOption")]
+ public void DisableFolderContextMenuOption(string option, bool addedUsingApi) { }
+
+ [ScriptName("destroy")]
+ public void Destroy() { }
+
+ [ScriptName("destroy")]
+ public void Destroy(Action callback) { }
+
+ [ScriptName("getSelectedFile")]
+ public CKFinderFile GetSelectedFile() { return null; }
+
+ [ScriptName("getSelectedFolder")]
+ public CKFinderFile GetSelectedFolder() { return null; }
+ }
+
+ [Imported]
+ [IgnoreNamespace]
+ public class CKFinderFile
+ {
+ [ScriptName("getUrl")]
+ public string GetUrl() { return null; }
+ }
+
+ [Imported]
+ [IgnoreNamespace]
+ public class CKFinderFolder
+ {
+ [ScriptName("getUrl")]
+ public string GetUrl() { return null; }
+ }
+
+ [Imported]
+ [IgnoreNamespace]
+ [ScriptName("window")]
+ public class CKFinderWindow
+ {
+ [ScriptName("CKFinder")]
+ public static object CKFinder;
+ }
+}
View
2  source/scriptsharp/Modal/LoginModal.cs
@@ -32,7 +32,7 @@ protected override void Initialize()
jQuery.Select("#login-modal-cancel").Click(CancelButtonClicked);
}
- protected override void OnTransitionEnd()
+ protected override void OnShown()
{
jQuery.Select("#login-modal-username").Focus();
}
View
13 source/scriptsharp/Modal/ModalBase.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Runtime.CompilerServices;
using jQueryApi;
namespace afung.MangaWeb3.Client.Modal
@@ -17,18 +18,14 @@ public ModalBase(string template, string templateId)
Initialize();
- attachedObject.Bind("webkitTransitionEnd transitionend msTransitionEnd oTransitionEnd", delegate(jQueryEvent e)
- {
- if (e.Target == attachedObject.GetElement(0))
- {
- OnTransitionEnd();
- }
- });
+ attachedObject.Bind("shown", OnShown);
}
protected abstract void Initialize();
- protected virtual void OnTransitionEnd()
+ [AlternateSignature]
+ protected extern void OnShown(jQueryEvent e);
+ protected virtual void OnShown()
{
}
View
5 source/scriptsharp/Utility.cs
@@ -24,5 +24,10 @@ public static int[] GetSelectedCheckboxIds(string className)
return ids;
}
+
+ public static void FixDropdownTouch(jQueryObject dropdown)
+ {
+ dropdown.Bind("touchstart", delegate(jQueryEvent e) { e.StopPropagation(); });
+ }
}
}
View
1  source/scriptsharp/afung.MangaWeb3.Client.csproj
@@ -49,6 +49,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Import\Bootstrap.cs" />
+ <Compile Include="Import\CKFinder.cs" />
<Compile Include="Modal\ConfirmModal.cs" />
<Compile Include="Modal\ErrorModal.cs" />
<Compile Include="Modal\LoginModal.cs" />
View
1  source/scriptsharpadmin/AdminApp.cs
@@ -13,6 +13,7 @@ protected override void StartStage2()
{
Template.Templates[Template.Templates.Length] = "admin";
Template.TemplateIds["admin"] = new string[] {
+ "admin-finder-modal",
"admin-manga-add-modal",
"admin-user-collections-trow",
"admin-user-collections-modal",
View
9 source/scriptsharpadmin/Modal/AdminCollectionAddModal.cs
@@ -28,9 +28,10 @@ protected override void Initialize()
{
jQuery.Select("#admin-collection-add-submit").Click(SubmitForm);
jQuery.Select("#admin-collection-add-form").Submit(SubmitForm);
+ jQuery.Select("#admin-collection-add-browse-btn").Click(BrowseButtonClicked);
}
- protected override void OnTransitionEnd()
+ protected override void OnShown()
{
jQuery.Select("#admin-collection-add-name").Focus();
}
@@ -109,5 +110,11 @@ private void SubmitFailure(Exception error)
ErrorModal.ShowError(error.ToString());
}
+
+ private void BrowseButtonClicked(jQueryEvent e)
+ {
+ e.PreventDefault();
+ AdminFinderModal.ShowDialog(jQuery.Select("#admin-collection-add-path"), -1);
+ }
}
}
View
2  source/scriptsharpadmin/Modal/AdminCollectionEditNameModal.cs
@@ -31,7 +31,7 @@ protected override void Initialize()
jQuery.Select("#admin-collection-editname-form").Submit(SubmitForm);
}
- protected override void OnTransitionEnd()
+ protected override void OnShown()
{
jQuery.Select("#admin-collection-editname-name").Focus();
}
View
1  source/scriptsharpadmin/Modal/AdminCollectionUsersModal.cs
@@ -44,6 +44,7 @@ protected override void Initialize()
jQuery.Select("#admin-collection-users-delete-btn").Click(DeleteButtonClicked);
jQuery.Select("#admin-collection-users-allow-btn").Click(AllowButtonClicked);
jQuery.Select("#admin-collection-users-deny-btn").Click(DenyButtonClicked);
+ Utility.FixDropdownTouch(jQuery.Select("#admin-collection-users-action-dropdown"));
}
private int GetTotalPage()
View
155 source/scriptsharpadmin/Modal/AdminFinderModal.cs
@@ -0,0 +1,155 @@
+// AdminFinderModal.cs
+//
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+using afung.MangaWeb3.Client.Modal;
+using afung.MangaWeb3.Common;
+using Finder;
+using jQueryApi;
+
+namespace afung.MangaWeb3.Client.Admin.Modal
+{
+ public class AdminFinderModal : ModalBase
+ {
+ private static AdminFinderModal instance = null;
+
+ private jQueryObject targetField = null;
+
+ private int cid = -1;
+
+ private CKFinder finder;
+
+ private AdminFinderModal()
+ : base("admin", "admin-finder-modal")
+ {
+ }
+
+ protected override void Initialize()
+ {
+ jQuery.Select("#admin-finder-select").Click(SelectButtonClicked);
+ }
+
+ public static void ShowDialog(jQueryObject targetField, int cid)
+ {
+ if (!Script.IsNullOrUndefined(CKFinderWindow.CKFinder))
+ {
+ if (instance == null)
+ {
+ instance = new AdminFinderModal();
+ }
+
+ instance.InternalShow(targetField, cid);
+ }
+ }
+
+ public void InternalShow(jQueryObject targetField, int cid)
+ {
+ this.targetField = targetField;
+ this.cid = cid;
+
+ Action getToken = delegate
+ {
+ finder = null;
+ jQuery.Select("#admin-finder-body").Children().Remove();
+
+ AdminFinderRequest request = new AdminFinderRequest();
+ request.cid = cid;
+ Request.Send(request, FinderRequestSuccess);
+
+ Show();
+ };
+
+ if (finder != null)
+ {
+ finder.Api.Destroy(getToken);
+ }
+ else
+ {
+ getToken();
+ }
+ }
+
+ [AlternateSignature]
+ private extern void FinderRequestSuccess(JsonResponse response);
+ private void FinderRequestSuccess(AdminFinderResponse response)
+ {
+ CKFinder.Config.Language = Strings.Get("CKFinderLanguage");
+ CKFinder.Config.ConnectorInfo = "token=" + response.token;
+
+ finder = new CKFinder();
+ finder.BasePath = "ckfinder/";
+ finder.Callback = delegate(CKFinderAPI api)
+ {
+ api.DisableFileContextMenuOption("selectFile", false);
+ api.DisableFileContextMenuOption("viewFile", false);
+ api.DisableFileContextMenuOption("downloadFile", false);
+ api.DisableFileContextMenuOption("renameFile", false);
+ api.DisableFileContextMenuOption("deleteFile", false);
+ api.DisableFolderContextMenuOption("removeFolder", false);
+ api.DisableFolderContextMenuOption("kl", false);
+ api.DisableFolderContextMenuOption("lI", false);
+
+ jQueryObject finderFrame = jQuery.Select("#admin-finder-body iframe").Contents();
+ finderFrame.Find("a.cke_button_upload").Remove();
+ finderFrame.Find("a.cke_button_maximize").Remove();
+
+ Show();
+ };
+
+ finder.SelectActionFunction = delegate(string fileUrl)
+ {
+ if (cid != -1)
+ {
+ ChangeTargetFieldAndHide(fileUrl);
+ }
+ };
+
+ finder.AppendTo("admin-finder-body");
+ }
+
+ private void SelectButtonClicked(jQueryEvent e)
+ {
+ e.PreventDefault();
+
+ if (cid == -1)
+ {
+ ChangeTargetFieldAndHide(finder.Api.GetSelectedFolder().GetUrl());
+ }
+ else
+ {
+ CKFinderFile file = finder.Api.GetSelectedFile();
+ if (file != null)
+ {
+ ChangeTargetFieldAndHide(file.GetUrl());
+ }
+ }
+ }
+
+ private void ChangeTargetFieldAndHide(string url)
+ {
+ url = url.DecodeUriComponent();
+
+ if (Environment.ServerType == ServerType.AspNet)
+ {
+ url = url.Replace("/", @"\");
+ while (url.IndexOf(@"\\") != -1)
+ {
+ url = url.Replace(@"\\", @"\");
+ }
+ }
+ else
+ {
+ url = url.Replace(@"\", "/");
+ while (url.IndexOf("//") != -1)
+ {
+ url = url.Replace("//", "/");
+ }
+ }
+
+ targetField.Value(url);
+ Hide();
+ }
+ }
+}
View
17 source/scriptsharpadmin/Modal/AdminMangaAddModal.cs
@@ -28,9 +28,10 @@ protected override void Initialize()
{
jQuery.Select("#admin-manga-add-submit").Click(SubmitForm);
jQuery.Select("#admin-manga-add-form").Submit(SubmitForm);
+ jQuery.Select("#admin-manga-add-browse-btn").Click(BrowseButtonClicked);
}
- protected override void OnTransitionEnd()
+ protected override void OnShown()
{
jQuery.Select("#admin-manga-add-path").Focus();
}
@@ -116,5 +117,19 @@ private void SubmitFailure(Exception error)
ErrorModal.ShowError(error.ToString());
}
+
+ private void BrowseButtonClicked(jQueryEvent e)
+ {
+ e.PreventDefault();
+
+ string cidString = jQuery.Select("#admin-manga-add-collection").GetValue();
+
+ if (cidString == null || cidString == "" || submittingForm)
+ {
+ return;
+ }
+
+ AdminFinderModal.ShowDialog(jQuery.Select("#admin-manga-add-path"), int.Parse(cidString, 10));
+ }
}
}
View
2  source/scriptsharpadmin/Modal/AdminSettingsModal.cs
@@ -25,7 +25,7 @@ protected override void Initialize()
jQuery.Select("#admin-settings-form").Submit(SubmitForm);
}
- protected override void OnTransitionEnd()
+ protected override void OnShown()
{
jQuery.Select("#admin-settings-guest").Focus();
}
View
2  source/scriptsharpadmin/Modal/AdminUserAddModal.cs
@@ -30,7 +30,7 @@ protected override void Initialize()
jQuery.Select("#admin-user-add-form").Submit(SubmitForm);
}
- protected override void OnTransitionEnd()
+ protected override void OnShown()
{
jQuery.Select("#admin-user-add-name").Focus();
}
View
1  source/scriptsharpadmin/Modal/AdminUserCollectionsModal.cs
@@ -44,6 +44,7 @@ protected override void Initialize()
jQuery.Select("#admin-user-collections-delete-btn").Click(DeleteButtonClicked);
jQuery.Select("#admin-user-collections-allow-btn").Click(AllowButtonClicked);
jQuery.Select("#admin-user-collections-deny-btn").Click(DenyButtonClicked);
+ Utility.FixDropdownTouch(jQuery.Select("#admin-user-collections-action-dropdown"));
}
private int GetTotalPage()
View
1  source/scriptsharpadmin/Module/AdminCollectionsModule.cs
@@ -31,6 +31,7 @@ protected override void InnerInitialize()
jQuery.Select("#admin-collections-public-btn").Click(SetPublicButtonClicked);
jQuery.Select("#admin-collections-private-btn").Click(SetPrivateButtonClicked);
jQuery.Select("#admin-collections-edit-btn").Click(EditButtonClicked);
+ Utility.FixDropdownTouch(jQuery.Select("#admin-collections-action-dropdown"));
pagination = new Pagination(jQuery.Select("#admin-collections-pagination"), ChangePage, GetTotalPage, "right");
Refresh();
}
View
1  source/scriptsharpadmin/Module/AdminMangasModule.cs
@@ -18,6 +18,7 @@ public AdminMangasModule()
protected override void InnerInitialize()
{
jQuery.Select("#admin-mangas-add-btn").Click(AddButtonClicked);
+ Utility.FixDropdownTouch(jQuery.Select("#admin-mangas-action-dropdown"));
}
private void AddButtonClicked(jQueryEvent e)
View
1  source/scriptsharpadmin/Module/AdminUsersModule.cs
@@ -36,6 +36,7 @@ protected override void InnerInitialize()
jQuery.Select("#admin-users-delete-btn").Click(DeleteButtonClicked);
jQuery.Select("#admin-users-setasadmin-btn").Click(SetAsAdminButtonClicked);
jQuery.Select("#admin-users-setasuser-btn").Click(SetAsUserButtonClicked);
+ Utility.FixDropdownTouch(jQuery.Select("#admin-users-action-dropdown"));
pagination = new Pagination(jQuery.Select("#admin-users-pagination"), ChangePage, GetTotalPage, "right");
Refresh();
}
View
1  source/scriptsharpadmin/afung.MangaWeb3.Client.Admin.csproj
@@ -54,6 +54,7 @@
<Compile Include="Modal\AdminCollectionAddModal.cs" />
<Compile Include="Modal\AdminCollectionEditNameModal.cs" />
<Compile Include="Modal\AdminCollectionUsersModal.cs" />
+ <Compile Include="Modal\AdminFinderModal.cs" />
<Compile Include="Modal\AdminMangaAddModal.cs" />
<Compile Include="Modal\AdminSettingsModal.cs" />
<Compile Include="Modal\AdminUserAddModal.cs" />
Please sign in to comment.
Something went wrong with that request. Please try again.