+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Customising DocumentEditorDialog.ascx

Customising DocumentEditorDialog.ascx

7 posts, 0 answered
  1. Karl
    Karl avatar
    45 posts
    Registered:
    18 Jun 2009
    08 Apr 2011
    Link to this post

    Hi,

    I’m currently trying to wrap user roles around certain libraries only allowing them to upload to libraries they have access to.

    This works great i.e., displays the library’s they are allowed to upload to. The problem is when I go to upload a file it seems to put it in to the first library (think this is in alphabetical order). Would it be possible to give me more information on how this works i.e. what values do I need to set to specify to insure that it uploads in to the correct Library?

    Thanks

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Apr 2011
    Link to this post
    Hello Karl,

    You need to create a custom selector that inherits from LibrarySelector

    http://www.sitefinity.com/devnet/forums/sitefinity-3-x/developing-with-sitefinity/imageeditordialog-default-upload-path.aspx

    Then you need to replace the default LibrarySelector inside

    Sitefinity\Admin\ControlTemplates\Libraries\Dialogs\DocumentEditorDialog.ascx with the custom selector and its dialog.


    Best wishes,
    Ivan Dimitrov
    the Telerik team

  3. Karl
    Karl avatar
    45 posts
    Registered:
    18 Jun 2009
    12 Apr 2011
    Link to this post

    Hi,

    Thanks for the reply. I’ve looked at the example provided and it looks to show how to upload to a file path. But how do I specify which Library to upload in to? I'm not using file paths.

    Thanks

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    13 Apr 2011
    Link to this post
    Hello Karl,

    The LibrarySelector inherits from BaseGuidSelector. Inside the LibrarySelector you can subscribe for

    base.Container.RepeaterControl.ItemDataBound += new RepeaterItemEventHandler(RepeaterControl_ItemDataBound);

    and set the selected value of selectedCheckbox or disable( not bind some of the items)

          void RepeaterControl_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    CheckBox selectedCheckbox = (CheckBox) e.Item.FindControl("selectedCheckbox");
                 }
           }


    Kind regards,
    Ivan Dimitrov
    the Telerik team

  5. Karl
    Karl avatar
    45 posts
    Registered:
    18 Jun 2009
    14 Apr 2011
    Link to this post

    Hi,

    This is what I have in the DocumentEditorDialog.ascx:

    <%@ Register Assembly="Telerik.Libraries" Namespace="Telerik.Libraries.WebControls" TagPrefix="sfLib" %>

    <%@ Register TagPrefix="sfMsg" Namespace="Telerik.Cms.Web.UI" Assembly="Telerik.Cms.Web.UI" %>

    <%@ Register Assembly="App_Code" Namespace="Intranet.MainLibrarySelector" TagPrefix="sfLib" %>

     

    <p>

                      <asp:Literal ID="Literal2" runat="server" Text='<%$Resources:UploadIn %>'></asp:Literal>

                      <em id="uploadLibrary"><asp:Literal Visible="false" runat="server" ID="selectedValue"></asp:Literal>

                      <asp:Literal ID="LibName" runat="server" Text="" ></asp:Literal>

                      </em><span id="uploadLocationType"> library</span>

                      <a href="javascript:toggleClass('uploadSelectedInLibrary','changeUploadDirection');" id="changeLink">(<asp:Literal ID="Literal3" runat="server" Text="<%$Resources:Change %>"></asp:Literal>)</a>

                  </p>

     

    And this in CustomBaseGuidSelector.cs in the App_Code folder:

    namespace Intranet.MainLibrarySelector

    {

        public class CustomBaseGuidSelector : LibrarySelector

        {

           

            private ILibrary library;

            private Panel dialog;

            private ImageEditorDialog UploadFolder;

     

            public CustomBaseGuidSelector()

            {

            }

     

            public override string TemplatePath

            {

                get

                {

                    return "~/Sitefinity/Admin/ControlTemplates/Libraries/Dialogs/BaseGuidSelectorTemplate.ascx";

                }

     

            }

     

            protected override void CreateChildControls()

            {

               

                Control parent = this.Parent;

                while (parent != null && !(parent is Panel))

                {

                    parent = parent.Parent;

                }

                dialog = parent as Panel;

     

                // change the default folder for upload

                parent = this.Parent;

                while (parent != null && !(parent is ImageEditorDialog))

                {

                    parent = parent.Parent;

                }

                UploadFolder = parent as ImageEditorDialog;

                UploadFolder.DefaultUploadFolder = "~/SomeFolder/Folder/";

                // call the base class and set the property

                base.SelectAllItemsText = UploadFolder.DefaultUploadFolder;

     

                base.CreateChildControls();

            }

        }

    }

     

    This doesn’t seem to pull in the customer code. I am missing something?

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 Apr 2011
    Link to this post
    Hello Karl,

    I do not see where you have subscribed for the ItemDataBound event where you will get access to the check boxes.

    All the best,
    Ivan Dimitrov
    the Telerik team

  7. Karl
    Karl avatar
    45 posts
    Registered:
    18 Jun 2009
    14 Apr 2011
    Link to this post
    Hi,

    I've not got to that stage yet, just wanted to get it to override. I assume the code below would set the folder to "~/SomeFolder/Folder/". This does seem to be doing this?

    Thanks
Register for webinar
7 posts, 0 answered