MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Separate File Galleries?  (Mono Support )

Viewed 57495 time(s), 21 post(s) 4/16/2012 1:11:08 PMby erin0201

Related topics

erin0201

erin0201

4/23/2012 7:00:59 PM
Ok, I created my own FileAdminIT aspx and aspx.cs file.
Were you meaning that I could set the RootPath in the code behind for that file?  I can do this even without having the source code recompiled?

  EDIT:  I got it to work with a script at the top of the aspx file!  Now I can create a couple more of these files for the different user groups/roles.

Thanks so much for your help!!

Here is what worked for me for anyone that wants to use the FileAdmin page/control for their own FileManagement instead of the basic FileGallery and FileView controls:
ASPX Page Code:
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="/MonoX/MasterPages/Default.Master" CodeBehind="FileAdminIT.aspx.cs" EnableTheming="true" Theme="Default" Inherits="MonoSoftware.MonoX.Admin.FileAdmin" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="MonoXControls" Namespace="MonoSoftware.MonoX.Controls" Assembly="MonoX" %>
<%@ MasterType TypeName="MonoSoftware.MonoX.BaseMasterPage" %>   
 
<asp:Content ID="Content1" ContentPlaceHolderID="cp" Runat="Server">
    <script runat="server" language="C#">
        protected override void OnInit(EventArgs e)
        {
        base.OnInit(e);
          //Change the rootpath to the starting folder for your File Administration needs.
        RootPath = "/Intranet";
        }
        </script>
     <telerik:RadCodeBlock ID="cb1" runat="server">
        <script language="javascript">
        var selectedTemplateFile = "";
 
        function GridMenuItemClicked(sender, args)
        {
            var oExplorer = $find("<%= ctlFileExplorer.ClientID %>");
            var itemValue = args.get_item().get_value();
            var itemText = args.get_item().get_text();
            if (itemValue != null) {
                if (itemValue.indexOf("newpage|") >= 0) {
                    selectedTemplateFile = itemValue.replace(/newpage\|/g, "");
                    radprompt(ResourceManager.GetString("NewPagePrompt"), NewPageCallback, 330, 100, "", ResourceManager.GetString("New"), " ");
                    return false;
                }
                if (itemValue == "PageProperties")
                {
                    var itemPath = oExplorer.get_selectedItem().get_path();
                    //.aspx extension interferes with URL rewriting so it is replaced to _aspx_ and decoded at the server side
                    var oWindow = window.radopen("FileManagerPropertiesDialog.aspx?pageUrl=" + encodeURIComponent(itemPath).replace(/\.aspx/gi, "_aspx_"), "PageProperties");
                    oWindow.setSize(700, 650);
                    oWindow.set_modal(true);
                    oWindow.center();
                    oWindow.OnClientPageLoad = function() {
                        oWindow.SetTitle(itemText);
                    }
                     
                }
            }
        }
         
        function NewPageCallback(arg)
        {
            if (arg)
            {
                window.top.setTimeout(function() {
                    var ajaxManager = $find("<%= ajaxManager.ClientID %>");
                    ajaxManager.ajaxRequest("NewPage|" + arg + "|" + selectedTemplateFile);
                }, 0);
                return true;
                 
            }
        }
 
        function OnResponseEnd(sender, arguments) {
            var oExplorer = $find("<%= ctlFileExplorer.ClientID %>");
            oExplorer.refresh();
 
        }
 
        function OnFileOpen(sender, args) {
            var manager = sender.get_windowManager();
            var item = args.get_item();
            window.setTimeout(
            function() {
                var activeWindow = manager.getActiveWindow();
                if (!activeWindow)
                    return;
                activeWindow.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Maximize);
                if (item != null && item.get_path().substr(0, 2) == '//')
                    activeWindow.setUrl(item.get_path().substr(1, item.get_path().length));
                activeWindow.setSize(700, 700);
                activeWindow.center();
            }, 20);
        }
         
 
        </script>
    </telerik:RadCodeBlock>
    <MonoXControls:MonoXWindowManager ID="windowDialog" runat="server" Modal="true"></MonoXControls:MonoXWindowManager>
    <div style="width:100%;height:100%;margin-left:auto;margin-right:auto;" class="fileExplorerContainer">
    <center>
    <telerik:RadFileExplorer OnClientFileOpen="OnFileOpen" runat="server" ID="ctlFileExplorer" Width="99%" Height="600px" CssClass="fileExplorer" DisplayUpFolderItem="true" ExplorerMode="Default">
  <Configuration SearchPatterns="*.*" DeletePaths="/Intranet" UploadPaths="/Intranet/" ViewPaths="/Intranet/">
        </Configuration>
    </telerik:RadFileExplorer>
    </center>
    </div>
    <telerik:RadAjaxManager runat="server" ID="ajaxManager" OnAjaxRequest="ajaxManager_AjaxRequest" ClientEvents-OnResponseEnd="OnResponseEnd">
       <AjaxSettings>
       <telerik:AjaxSetting AjaxControlID="ajaxManager">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="ctlFileExplorer.Grid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
</asp:Content>

</code>
This content has not been rated yet. 
453 Reputation 61 Total posts
erin0201

erin0201

4/16/2012 1:11:09 PM
Hello!

Is there a setting on the file gallery that will allow me to have more than one file gallery? Is there a path I can set on the web part?
I would like to have different file galleries available for different use roles/groups, but when I add a file gallery module to the page it just shows all of the files I've uploaded to the file gallery in general.

Thanks!
Erin
This content has not been rated yet. 
453 Reputation 61 Total posts
denis

denis

4/17/2012 11:38:44 AM
Hi Erin,
You can either use the FileList property of the FileGallery part, or use the ParentEntityType and ParentEntityId properties to bind the gallery to the "parent" part. The first approach will probably be easier and more suitable for your scenario. You can create the list of SnFileDTO objects in the codebehind, or alternatively use the following markup in your aspx/ascx code:

<MonoX:FileGallery runat="server" ID="fgScreenshots" UsePrettyPhoto="true" Title="Screen gallery">
                <FileList>
                    <MonoRepositories:SnFileDTO Name="MonoX" Description="Default screen" Url="/App_Themes/Mono/img/Screens/default-b.png" ThumbnailUrl="/App_Themes/Mono/img/Screens/default-s.png"></MonoRepositories:SnFileDTO>
                    <MonoRepositories:SnFileDTO Name="MonoX" Description="File admin screen" Url="/App_Themes/Mono/img/Screens/file-admin-b.png" ThumbnailUrl="/App_Themes/Mono/img/Screens/file-admin-s.png"></MonoRepositories:SnFileDTO>
... add more files...
</FileList>
  <CurrentTemplateHtml>
       <div class="image-effect">
         <# FileIcon #>
       </div>
  </CurrentTemplateHtml>
</MonoX:FileGallery>

Note that this sample includes a technique for defining the part's template inline via the CurrentTemplateHtml property; you can remove it if you want to use standard templates from the App_Templates folder.

This content has not been rated yet. 
7207 Reputation 956 Total posts
denis

denis

4/17/2012 2:34:46 PM
Your ascx should have the following in the header:

<%@ Register TagPrefix="MonoX" TagName="FileGallery" Src="/MonoX/ModuleGallery/SocialNetworking/FileGallery.ascx" %>
<%@ Register Assembly="MonoX" Namespace="MonoSoftware.MonoX.Repositories" TagPrefix="MonoRepositories" %>


This content has not been rated yet. 
7207 Reputation 956 Total posts
erin0201

erin0201

4/20/2012 3:29:11 PM
Hi Denis!

Thanks for your help!  Where in the code above do I specify the folder or path for the different files?  So say I want to have files for IT, files for HR, and files for Sales all separate.  How do I point the filelist to a specific folder or group of files? 
Do I just change the name of the repository?

So by your above example for IT for example:
<FileList>
                    <MonoRepositories:SnFileDTO Name="IT" Description="Default screen" Url="/App_Themes/Mono/img/Screens/default-b.png" ThumbnailUrl="/App_Themes/Mono/img/Screens/default-s.png"></MonoRepositories:SnFileDTO>
                    <MonoRepositories:SnFileDTO Name="IT" Description="File admin screen" Url="/App_Themes/Mono/img/Screens/file-admin-b.png" ThumbnailUrl="/App_Themes/Mono/img/Screens/file-admin-s.png"></MonoRepositories:SnFileDTO>
... add more files...
</FileList>


and for example HR:
<FileList>
                    <MonoRepositories:SnFileDTO Name="HR" Description="Default screen" Url="/App_Themes/Mono/img/Screens/default-b.png" ThumbnailUrl="/App_Themes/Mono/img/Screens/default-s.png"></MonoRepositories:SnFileDTO>
                    <MonoRepositories:SnFileDTO Name="HR" Description="File admin screen" Url="/App_Themes/Mono/img/Screens/file-admin-b.png" ThumbnailUrl="/App_Themes/Mono/img/Screens/file-admin-s.png"></MonoRepositories:SnFileDTO>
... add more files...
</FileList>


?

I just want to make sure the files are kept completely separate and secured to only certain users.

Thanks!!
Erin
This content has not been rated yet. 
453 Reputation 61 Total posts
erin0201

erin0201

4/20/2012 4:03:37 PM
Also, can I code the File Upload module kind of the same way so that users can upload files specifically to their secured areas?

Do you have an example of how to code that one as well that I could follow?

Thanks!
Erin
This content has not been rated yet. 
453 Reputation 61 Total posts
denis

denis

4/20/2012 9:16:24 PM
This was a "static" sample where you put your files (identified by their URLs) into the FileList property. If you have to perform some business logic during this process, you should do it from the codebehind and fill this property dynamically in the Page_Load or similar event. As for the File upload part, both "simple" and SIlverlight-based upload parts have a TargetFolder property which you can also set based on your custom rules.
This content has not been rated yet. 
7207 Reputation 956 Total posts
erin0201

erin0201

4/23/2012 12:15:05 PM
Hi Denis,

Thanks for the tip on the File upload and silverlight-based upload parts!

Do you have an example of dynamically filling the FileList property from the codebehind on pageload? Maybe something similar to what is used in the Administrative area where all of the files are listed for a certain folder only and can be viewed, uploaded, or deleted as needed?

I found a small FileManager C# ASP.NET program that has all of these properties, but I'm not sure how to bind the login variables from MonoX to it so that the users don't have to login separately to both so I haven't pursued it. I would rather use Monox's built in features. I just need to customize the file view so it works something like the Pages or Files area in the administrative panel.

Thanks in advance!
Erin
This content has not been rated yet. 
453 Reputation 61 Total posts
erin0201

erin0201

4/23/2012 12:20:48 PM
Actually if there is anyway I could copy the FileAdmin page or functionality and customize it so that the "root" for it is the specific folder I need it to be, that would work perfect!

Is there any way to take the FileAdmin feature and copy it out and point it to another location? Do you have a list of the files and controls involved so I don't have to go searching and trying to make sure I find all of them myself?

Thanks!!
Erin
This content has not been rated yet. 
453 Reputation 61 Total posts
denis

denis

4/23/2012 1:26:52 PM
Hi Erin,
Back-end FileAdmin does not use the same Web part. This is more advanced control that resembles the functionality of the Windows Explorer. I will check if we could publish the code sample that would allow you do build something similar.
This content has not been rated yet. 
7207 Reputation 956 Total posts
erin0201

erin0201

4/23/2012 3:59:49 PM
Hi Denis,

I've been looking at the code for the FileAdmin.aspx page:

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="/MonoX/MasterPages/AdminDefault.master" CodeBehind="FileAdmin.aspx.cs" EnableTheming="true" Theme="DefaultAdmin" Inherits="MonoSoftware.MonoX.Admin.FileAdmin" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="MonoXControls" Namespace="MonoSoftware.MonoX.Controls" Assembly="MonoX" %>
<%@ MasterType TypeName="MonoSoftware.MonoX.BaseMasterPage" %>   
 
<asp:Content ID="Content1" ContentPlaceHolderID="cp" Runat="Server">
     <telerik:RadCodeBlock ID="cb1" runat="server">
        <script language="javascript">
        var selectedTemplateFile = "";
 
        function GridMenuItemClicked(sender, args)
        {
            var oExplorer = $find("<%= ctlFileExplorer.ClientID %>");
            var itemValue = args.get_item().get_value();
            var itemText = args.get_item().get_text();
            if (itemValue != null) {
                if (itemValue.indexOf("newpage|") >= 0) {
                    selectedTemplateFile = itemValue.replace(/newpage\|/g, "");
                    radprompt(ResourceManager.GetString("NewPagePrompt"), NewPageCallback, 330, 100, "", ResourceManager.GetString("New"), " ");
                    return false;
                }
                if (itemValue == "PageProperties")
                {
                    var itemPath = oExplorer.get_selectedItem().get_path();
                    //.aspx extension interferes with URL rewriting so it is replaced to _aspx_ and decoded at the server side
                    var oWindow = window.radopen("FileManagerPropertiesDialog.aspx?pageUrl=" + encodeURIComponent(itemPath).replace(/\.aspx/gi, "_aspx_"), "PageProperties");
                    oWindow.setSize(700, 650);
                    oWindow.set_modal(true);
                    oWindow.center();
                    oWindow.OnClientPageLoad = function() {
                        oWindow.SetTitle(itemText);
                    }
                     
                }
            }
        }
         
        function NewPageCallback(arg)
        {
            if (arg)
            {
                window.top.setTimeout(function() {
                    var ajaxManager = $find("<%= ajaxManager.ClientID %>");
                    ajaxManager.ajaxRequest("NewPage|" + arg + "|" + selectedTemplateFile);
                }, 0);
                return true;
                 
            }
        }
 
        function OnResponseEnd(sender, arguments) {
            var oExplorer = $find("<%= ctlFileExplorer.ClientID %>");
            oExplorer.refresh();
 
        }
 
        function OnFileOpen(sender, args) {
            var manager = sender.get_windowManager();
            var item = args.get_item();
            window.setTimeout(
            function() {
                var activeWindow = manager.getActiveWindow();
                if (!activeWindow)
                    return;
                activeWindow.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Maximize);
                if (item != null && item.get_path().substr(0, 2) == '//')
                    activeWindow.setUrl(item.get_path().substr(1, item.get_path().length));
                activeWindow.setSize(700, 700);
                activeWindow.center();
            }, 20);
        }
         
 
        </script>
    </telerik:RadCodeBlock>
    <MonoXControls:MonoXWindowManager ID="windowDialog" runat="server" Modal="true"></MonoXControls:MonoXWindowManager>
    <div style="width:100%;height:100%;margin-left:auto;margin-right:auto;" class="fileExplorerContainer">
    <center>
    <telerik:RadFileExplorer OnClientFileOpen="OnFileOpen" runat="server" ID="ctlFileExplorer" Width="99%" Height="600px" CssClass="fileExplorer" DisplayUpFolderItem="true" ExplorerMode="Default" >
              <Configuration SearchPatterns="*.*" DeletePaths="/Intranet" UploadPaths="/Intranet/" ViewPaths="/Intranet/"> </Configuration>
    </telerik:RadFileExplorer>
    </center>
    </div>
    <telerik:RadAjaxManager runat="server" ID="ajaxManager" OnAjaxRequest="ajaxManager_AjaxRequest" ClientEvents-OnResponseEnd="OnResponseEnd">
       <AjaxSettings>
       <telerik:AjaxSetting AjaxControlID="ajaxManager">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="ctlFileExplorer.Grid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
</asp:Content>

I tried to create the FileAdmin.aspx.cs code behind file like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik;
using Telerik.Web.UI;
 
/// <summary>
/// Summary description for techspec
/// </summary>
//public class techspec
//{
//    public techspec()
//    {
//        //
//        // TODO: Add constructor logic here
//        //
//    }
//}
namespace MonoSoftware.Monox.Admin
{
public partial class FileAdmin : MonoSoftware.MonoX.BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
        String basePath = "/Intranet/";
                 
        ctlFileExplorer.Configuration.ViewPaths = new string[] { basePath };
        ctlFileExplorer.Configuration.DeletePaths = new string[] { basePath };
        ctlFileExplorer.Configuration.UploadPaths = new string[] { basePath };
        ctlFileExplorer.InitialPath = Page.ResolveUrl("/Intranet");
         
 
        ctlFileExplorer.EnableOpenFile = true;
        ctlFileExplorer.DisplayUpFolderItem = true;
        ctlFileExplorer.AllowPaging = true;
        ctlFileExplorer.EnableCreateNewFolder = true;
 
 
    }
}
}

However, it doesn't appear that the FileAdmin.aspx file is really looking at the codebehind information. Because I had set it's InitialPath to go to /Intranet instead of to / as it is going right now and it doesn't change like it should.

I followed the Telerik RadFileExplorer reference here that tells you how to set the initialpath in the code behind, but it looks like it is ignoring my code behind file. Is there something in the reference code at the top that is overriding the FileAdmin.aspx page from allowing it to look to the FileAdmin.aspx.cs page for its settings?

Thanks for your help!
Erin
This content has not been rated yet. 
453 Reputation 61 Total posts
1 2 3