📄 ftb.imagegallery.aspx.cs
字号:
using System;
using System.Collections;
using System.IO;
using System.Web;
using System.Web.UI;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Security;
using FreeTextBoxControls;
//
// DotNetNuke - http://www.dotnetnuke.com
// Copyright (c) 2002-2005
// by Shaun Walker ( sales@perpetualmotion.ca ) of Perpetual Motion Interactive Systems Inc. ( http://www.perpetualmotion.ca )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
namespace DotNetNuke.HtmlEditor
{
/// -----------------------------------------------------------------------------
/// <summary>
/// The FTBImageGallery Class provides the Image Gallery for the FTB Provider
/// </summary>
/// <returns></returns>
/// <remarks>
/// </remarks>
/// <history>
/// [cnurse] 12/14/2004 documented and updated to work with FTB3.0
/// </history>
/// -----------------------------------------------------------------------------
public class FTBImageGallery : DotNetNuke.Framework.PageBase
{
[CLSCompliant(false)]
protected FreeTextBoxControls.ImageGallery imgGallery;
private string title;
public FTBImageGallery()
{
this.title = string.Empty;
}
private void Page_Load (System.Object sender, System.EventArgs e)
{
// set page title
title = PortalSettings.PortalName + " > Image Gallery";
// show copyright credits?
if (Common.Globals.GetHashValue(Common.Globals.HostSettings["Copyright"], "Y") == "Y")
{
title += " ( SNN " + PortalSettings.Version + " )";
}
bool allowAccess;
try
{
string currentFolder = Server.MapPath(imgGallery.CurrentImagesFolder);
if (!currentFolder.EndsWith("\\"))
{
currentFolder += "\\";
}
if (PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId)
{
currentFolder = currentFolder.Substring(Common.Globals.HostMapPath.Length);
}
else
{
currentFolder = currentFolder.Substring(PortalSettings.HomeDirectoryMapPath.Length);
}
if (currentFolder.EndsWith("\\"))
{
currentFolder = currentFolder.Substring(0, currentFolder.Length - 1);
}
// Check permissions for current directory
string roles = FileSystemUtils.GetRoles(currentFolder.Replace("\\", "/"), PortalSettings.PortalId, "WRITE");
allowAccess = (PortalSecurity.IsInRoles(roles));
}
catch (Exception) //wrong directory
{
allowAccess = false;
}
imgGallery.AllowDirectoryCreate = allowAccess;
imgGallery.AllowDirectoryDelete = allowAccess;
imgGallery.AllowImageDelete = allowAccess;
imgGallery.AllowImageUpload = allowAccess;
imgGallery.JavaScriptLocation = ResourceLocation.ExternalFile;
imgGallery.UtilityImagesLocation = ResourceLocation.ExternalFile;
imgGallery.SupportFolder = DotNetNuke.Common.Globals.ResolveUrl("~/Providers/HtmlEditorProviders/Ftb3HtmlEditorProvider/ftb3/");
}
private void Page_PreRender (object sender, System.EventArgs e)
{
//Get the list of sub-directories
string[] directories = Directory.GetDirectories(Server.MapPath(imgGallery.CurrentImagesFolder), "*");
ArrayList alDirectories = new ArrayList();
string directoryName;
string roles;
//Parse directories (only adding those we have permission for
foreach (string directory in directories)
{
if (PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId)
{
directoryName = directory.Substring(Common.Globals.HostMapPath.Length);
}
else
{
directoryName = directory.Substring(PortalSettings.HomeDirectoryMapPath.Length);
}
roles = FileSystemUtils.GetRoles(directoryName.Replace("\\", "/"), PortalSettings.PortalId, "READ");
if (PortalSecurity.IsInRoles(roles))
{
alDirectories.Add(directoryName);
}
}
imgGallery.CurrentDirectories = ((string[]) alDirectories.ToArray(typeof(string)));
//Verify access to current folder
string currentfolder = Server.MapPath(imgGallery.CurrentImagesFolder);
if (!currentfolder.EndsWith("\\"))
{
currentfolder += "\\";
}
if (PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId)
{
directoryName = currentfolder.Substring(Common.Globals.HostMapPath.Length);
}
else
{
directoryName = currentfolder.Substring(PortalSettings.HomeDirectoryMapPath.Length);
}
if (directoryName.EndsWith("\\"))
{
directoryName = directoryName.Substring(0, directoryName.Length - 1);
}
roles = FileSystemUtils.GetRoles(directoryName.Replace("\\", "/"), PortalSettings.PortalId, "READ");
if (!PortalSecurity.IsInRoles(roles))
{
System.IO.FileInfo[] noimage = new System.IO.FileInfo[0];
imgGallery.CurrentImages = noimage;
}
}
public string Title
{
get { return this.title; }
set { this.title = value; }
}
#region " Web Form Designer Generated Code "
//This call is required by the Web Form Designer.
[System.Diagnostics.DebuggerStepThrough()]
private void InitializeComponent ()
{
this.Load += new EventHandler(this.Page_Load);
this.PreRender += new EventHandler(this.Page_PreRender);
}
protected override void OnInit(EventArgs e)
{
this.InitializeComponent();
base.OnInit (e);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -