/// <summary>
    /// Loads custom object type properties control.
    /// </summary>
    /// <param name="objectType">Object type of current cloned object</param>
    private CloneSettingsControl LoadCustomProperties(string objectType)
    {
        Type customCloneControl;

        if (CustomCloneSettings.TryGetControl(objectType, out customCloneControl))
        {
            return(Activator.CreateInstance(customCloneControl) as CloneSettingsControl);
        }

        string fileName           = $"{TranslationHelper.GetSafeClassName(objectType)}Settings.ascx";
        string generalControlFile = "~/CMSModules/Objects/FormControls/Cloning/" + fileName;
        string moduleControlFile  = (string.IsNullOrEmpty(InfoToClone.TypeInfo.ModuleInfo?.ModuleRootPath)
            ? generalControlFile
            : $"{InfoToClone.TypeInfo.ModuleInfo.ModuleRootPath.TrimEnd('/')}/FormControls/Cloning/{fileName}");

        if (customProperties == null)
        {
            try
            {
                customProperties = LoadUserControl(moduleControlFile) as CloneSettingsControl;
            }
            catch { }
        }

        if (customProperties == null)
        {
            try
            {
                customProperties = LoadUserControl(generalControlFile) as CloneSettingsControl;
            }
            catch { }
        }

        return(customProperties);
    }
Exemple #2
0
    /// <summary>
    /// Loads custom object type properties control
    /// </summary>
    /// <param name="objectType">Object type of current cloned object</param>
    private CloneSettingsControl LoadCustomProperties(string objectType)
    {
        string fileName           = TranslationHelper.GetSafeClassName(objectType) + "Settings.ascx";
        string generalControlFile = "~/CMSModules/Objects/FormControls/Cloning/" + fileName;
        string moduleControlFile  = ((typeInfo.ModuleInfo == null) || string.IsNullOrEmpty(typeInfo.ModuleInfo.ModuleRootPath) ? generalControlFile : typeInfo.ModuleInfo.ModuleRootPath.TrimEnd('/') + "/FormControls/Cloning/" + fileName);

        if (customProperties == null)
        {
            try
            {
                customProperties = this.LoadUserControl(moduleControlFile) as CloneSettingsControl;
            }
            catch { }
        }

        if (customProperties == null)
        {
            try
            {
                customProperties = this.LoadUserControl(generalControlFile) as CloneSettingsControl;
            }
            catch { }
        }

        return(customProperties);
    }
    /// <summary>
    /// Tries to load clone settings control of <paramref name="objectType"/> or <paramref name="originalObjectType"/>.
    /// </summary>
    /// <param name="objectType">Object type of current cloned object.</param>
    /// <param name="originalObjectType">Original object type of current cloned object.</param>
    /// <returns>Clone settings control, if any. Returns <c>null</c> otherwise.</returns>
    private CloneSettingsControl LoadCustomProperties(string objectType, string originalObjectType)
    {
        CloneSettingsControl customProperties = LoadCustomProperties(objectType);

        if ((customProperties == null) && (objectType != originalObjectType))
        {
            // Try get original object type settings control
            customProperties = LoadCustomProperties(originalObjectType);
        }

        return(customProperties);
    }
Exemple #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (InfoToClone != null)
        {
            ScriptHelper.RegisterJQuery(this.Page);

            typeInfo = InfoToClone.TypeInfo;

            siteElem.AllowGlobal = typeInfo.SupportsGlobalObjects;

            SetLabel(lblDisplayName, "displaynamelabel", "clonning.newdisplayname");
            SetLabel(lblCodeName, "codenamelabel", "clonning.newcodename");

            lblKeepFieldsTranslated.ToolTip = GetString("clonning.settings.keepfieldstranslated.tooltip");
            lblCloneUnderSite.ToolTip       = GetString("clonning.settings.cloneundersite.tooltip");
            lblMetafiles.ToolTip            = GetString("clonning.settings.metafiles.tooltip");
            lblMaxRelativeLevel.ToolTip     = GetString("clonning.settings.maxrelativelevel.tooltip");


            plcCodeName.Visible    = (typeInfo.CodeNameColumn != ObjectTypeInfo.COLUMN_NAME_UNKNOWN);
            plcDisplayName.Visible = (typeInfo.DisplayNameColumn != ObjectTypeInfo.COLUMN_NAME_UNKNOWN) && !typeInfo.DisplayNameColumn.EqualsCSafe(typeInfo.CodeNameColumn, true);

            // Try to load Custom properties
            customProperties = LoadCustomProperties(typeInfo.ObjectType);
            if ((customProperties == null) && (typeInfo.ObjectType != typeInfo.OriginalObjectType))
            {
                // Try get original object type settings control
                customProperties = LoadCustomProperties(typeInfo.OriginalObjectType);
            }

            if (customProperties != null)
            {
                headCustom.Text              = GetCustomParametersTitle();
                customProperties.ID          = "customProperties";
                customProperties.InfoToClone = InfoToClone;

                plcCustomParameters.Controls.Add(customProperties);
                plcCustomParametersBox.Visible = customProperties.DisplayControl;

                if (customProperties.HideDisplayName)
                {
                    plcDisplayName.Visible = false;
                }
                if (customProperties.HideCodeName)
                {
                    plcCodeName.Visible = false;
                }

                if (!RequestHelper.IsPostBack())
                {
                    TransferExcludedTypes();
                }
            }

            // Show site DDL only for Global Admin and for controls which have SiteID (and are not under group or any other parent) and are not from E-Commerce/Forums module
            int sitesCount = SiteInfoProvider.GetSitesCount();
            plcCloneUnderSite.Visible = typeInfo.SupportsCloneToOtherSite &&
                                        (typeInfo.SiteIDColumn != ObjectTypeInfo.COLUMN_NAME_UNKNOWN) &&
                                        (MembershipContext.AuthenticatedUser != null) &&
                                        (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)) &&
                                        ((typeInfo.SupportsGlobalObjects && (sitesCount > 0)) || (sitesCount > 1)) &&
                                        (InfoToClone.Generalized.ObjectGroupID == 0) &&
                                        (InfoToClone.Generalized.ObjectParentID == 0) &&
                                        !typeInfo.ModuleName.EqualsCSafe(ModuleName.ECOMMERCE, true) &&
                                        !typeInfo.ModuleName.EqualsCSafe(ModuleName.FORUMS, true) &&
                                        (typeInfo.OriginalObjectType != CategoryInfo.OBJECT_TYPE);

            if (((typeInfo.BindingObjectTypes != null) && (typeInfo.BindingObjectTypes.Count > 0)) || ((typeInfo.OtherBindingObjectTypes != null) && (typeInfo.OtherBindingObjectTypes.Count > 0)))
            {
                // Remove site binding from bindings if exists
                List <string> bindings = new List <string>();
                if (typeInfo.BindingObjectTypes != null)
                {
                    bindings.AddRange(typeInfo.BindingObjectTypes);
                }
                if (typeInfo.OtherBindingObjectTypes != null)
                {
                    bindings.AddRange(typeInfo.OtherBindingObjectTypes);
                }
                if (!string.IsNullOrEmpty(typeInfo.SiteBinding))
                {
                    if (bindings.Contains(typeInfo.SiteBinding))
                    {
                        bindings.Remove(typeInfo.SiteBinding);
                    }
                }
                if (bindings.Count > 0)
                {
                    List <string> excludedTypes = new List <string>();
                    excludedTypes.AddRange(excludedBindings);
                    excludedTypes.AddRange(excludedOtherBindings);

                    int itemNumber = 0;
                    lblBindings.ToolTip = GetCloneHelpText(bindings, excludedTypes, out itemNumber);

                    if (itemNumber == 1)
                    {
                        lblBindings.Text    = lblBindings.ToolTip;
                        lblBindings.ToolTip = "";
                    }
                    else
                    {
                        SetLabel(lblBindings, "bindingslabel", "clonning.settings.bindings");
                    }

                    plcBindings.Visible = itemNumber > 0;
                }
            }

            if ((typeInfo.ChildObjectTypes != null) && (typeInfo.ChildObjectTypes.Count > 0))
            {
                int itemNumber = 0;
                lblChildren.ToolTip = GetCloneHelpText(typeInfo.ChildObjectTypes, excludedChildren, out itemNumber);

                if (itemNumber == 1)
                {
                    lblChildren.Text    = lblChildren.ToolTip;
                    lblChildren.ToolTip = "";
                }
                else
                {
                    lblChildren.Text = GetString("clonning.settings.children");
                }

                plcChildren.Visible      = itemNumber > 0;
                plcChildrenLevel.Visible = ShowChildrenLevel(excludedChildren);
            }

            if (!string.IsNullOrEmpty(typeInfo.SiteBinding) && (InfoToClone.Generalized.ObjectGroupID == 0))
            {
                // For objects with SiteID column allow site bindings only for global versions of the object (for example polls)
                if ((typeInfo.SiteIDColumn == ObjectTypeInfo.COLUMN_NAME_UNKNOWN) || (InfoToClone.Generalized.ObjectSiteID == 0))
                {
                    lblAssignToCurrentSite.ToolTip = GetString("clonning.settings.assigntocurrentsite.tooltip");
                    plcAssignToCurrentSite.Visible = true;

                    lblSiteBindings.ToolTip = GetCloneHelpText(new List <string>()
                    {
                        typeInfo.SiteBinding
                    });

                    plcSiteBindings.Visible = true;
                }
            }

            if ((InfoToClone.MetaFiles != null) && (InfoToClone.MetaFiles.Count > 0))
            {
                plcMetafiles.Visible = true;
            }

            // Preselect site of the object as a "clone under site" option
            if (plcCloneUnderSite.Visible && !RequestHelper.IsPostBack())
            {
                siteElem.SiteName = InfoToClone.Generalized.ObjectSiteName;
            }

            if (!RequestHelper.IsPostBack())
            {
                if (plcCodeName.Visible)
                {
                    txtCodeName.Text = InfoToClone.Generalized.GetUniqueCodeName();
                }
                if (plcDisplayName.Visible)
                {
                    txtDisplayName.Text = InfoToClone.Generalized.GetUniqueDisplayName();
                }

                // Exception for cultures for assigning to current site (for cultures the default value should be false)
                if (typeInfo.ObjectType == CultureInfo.OBJECT_TYPE)
                {
                    chkAssignToCurrentSite.Checked = false;
                }
            }

            if (plcChildren.Visible)
            {
                LoadMaxRelativeLevel();
            }
        }
    }
    /// <summary>
    /// Loads custom object type properties control
    /// </summary>
    /// <param name="objectType">Object type of current cloned object</param>
    private CloneSettingsControl LoadCustomProperties(string objectType)
    {
        string fileName = TranslationHelper.GetSafeClassName(objectType) + "Settings.ascx";
        string generalControlFile = "~/CMSModules/Objects/FormControls/Cloning/" + fileName;
        string moduleControlFile = ((typeInfo.ModuleInfo == null) || string.IsNullOrEmpty(typeInfo.ModuleInfo.ModuleRootPath) ? generalControlFile : typeInfo.ModuleInfo.ModuleRootPath.TrimEnd('/') + "/FormControls/Cloning/" + fileName);

        if (File.Exists(HttpContext.Current.Server.MapPath(moduleControlFile)))
        {
            try
            {
                customProperties = this.LoadUserControl(moduleControlFile) as CloneSettingsControl;
            }
            catch { }
        }
        else if (File.Exists(HttpContext.Current.Server.MapPath(generalControlFile)))
        {
            try
            {
                customProperties = this.LoadUserControl(generalControlFile) as CloneSettingsControl;
            }
            catch { }
        }

        return customProperties;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (InfoToClone != null)
        {
            ScriptHelper.RegisterJQuery(this.Page);

            typeInfo = InfoToClone.TypeInfo;

            siteElem.AllowGlobal = typeInfo.SupportsGlobalObjects;

            SetLabel(lblDisplayName, "displaynamelabel", "clonning.newdisplayname");
            SetLabel(lblCodeName, "codenamelabel", "clonning.newcodename");

            lblKeepFieldsTranslated.ToolTip = GetString("clonning.settings.keepfieldstranslated.tooltip");
            lblCloneUnderSite.ToolTip = GetString("clonning.settings.cloneundersite.tooltip");
            lblMetafiles.ToolTip = GetString("clonning.settings.metafiles.tooltip");
            lblMaxRelativeLevel.ToolTip = GetString("clonning.settings.maxrelativelevel.tooltip");

            lblShowAdvanced.Text = "<a href=\"javascript: ShowHideAdvancedSection();\">" + GetString("clonning.settings.showadvanced") + "</a>";
            lblShowSimple.Text = "<a href=\"javascript: ShowHideAdvancedSection();\">" + GetString("clonning.settings.showsimple") + "</a>";

            plcCodeName.Visible = (typeInfo.CodeNameColumn != TypeInfo.COLUMN_NAME_UNKNOWN);
            plcDisplayName.Visible = (typeInfo.DisplayNameColumn != TypeInfo.COLUMN_NAME_UNKNOWN) && !typeInfo.DisplayNameColumn.EqualsCSafe(typeInfo.CodeNameColumn, true);

            // Try to load Custom properties
            customProperties = LoadCustomProperties(typeInfo.ObjectType);
            if ((customProperties == null) && (typeInfo.ObjectType != typeInfo.OriginalObjectType))
            {
                // Try get original object type settings control
                customProperties = LoadCustomProperties(typeInfo.OriginalObjectType);
            }

            if (customProperties != null)
            {
                customProperties.ID = "customProperties";
                customProperties.InfoToClone = InfoToClone;

                plcCustomParameters.Controls.Add(customProperties);
                plcCustomParametersBox.Visible = customProperties.DisplayControl;

                if (customProperties.HideDisplayName)
                {
                    plcDisplayName.Visible = false;
                }
                if (customProperties.HideCodeName)
                {
                    plcCodeName.Visible = false;
                }

                TransferExcludedTypes();
            }

            ltlSpace.Text = (plcDisplayName.Visible || plcCodeName.Visible ? "<br />" : "");
            ltlSpace2.Text = ltlSpace.Text;

            // Show site DDL only for Global Admin and for controls which have SiteID (and are not under group or any other parent) and are not from E-Commerce/Forums module
            plcCloneUnderSite.Visible = typeInfo.SupportsCloneToOtherSite && (typeInfo.SiteIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN) && (CMSContext.CurrentUser != null) && (CMSContext.CurrentUser.IsGlobalAdministrator) &&
                (SiteInfoProvider.GetSitesCount() > 1) && (InfoToClone.Generalized.ObjectGroupID == 0) && (InfoToClone.Generalized.ObjectParentID == 0) &&
                !typeInfo.ModuleName.EqualsCSafe(ModuleEntry.ECOMMERCE, true) && !typeInfo.ModuleName.EqualsCSafe(ModuleEntry.FORUMS, true) && (typeInfo.OriginalObjectType != PredefinedObjectType.CATEGORY);

            if (!string.IsNullOrEmpty(typeInfo.BindingObjectTypes) || !string.IsNullOrEmpty(typeInfo.OtherBindingObjectTypes))
            {
                // Remove site binding from bindings if exists
                string bindings = typeInfo.BindingObjectTypes + ";" + typeInfo.OtherBindingObjectTypes;
                if (!string.IsNullOrEmpty(typeInfo.SiteBinding))
                {
                    bindings = bindings.Replace(typeInfo.SiteBinding, "");
                }
                if (!string.IsNullOrEmpty(bindings.Replace(";", "")))
                {
                    List<string> excludedTypes = new List<string>();
                    excludedTypes.AddRange(excludedBindings);
                    excludedTypes.AddRange(excludedOtherBindings);

                    int itemNumber = 0;
                    lblBindings.ToolTip = GetCloneHelpText(bindings, excludedTypes, out itemNumber);

                    if (itemNumber == 1)
                    {
                        lblBindings.Text = lblBindings.ToolTip;
                        lblBindings.ToolTip = "";
                    }
                    else
                    {
                        SetLabel(lblBindings, "bindingslabel", "clonning.settings.bindings");
                    }

                    plcBindings.Visible = itemNumber > 0;
                }
            }

            if (!string.IsNullOrEmpty(typeInfo.ChildObjectTypes))
            {
                int itemNumber = 0;
                lblChildren.ToolTip = GetCloneHelpText(typeInfo.ChildObjectTypes, excludedChildren, out itemNumber);

                if (itemNumber == 1)
                {
                    lblChildren.Text = lblChildren.ToolTip;
                    lblChildren.ToolTip = "";
                }
                else
                {
                    lblChildren.Text = GetString("clonning.settings.children");
                }

                plcChildren.Visible = itemNumber > 0;
                plcChildrenLevel.Visible = ShowChildrenLevel(excludedChildren);
            }

            if (!string.IsNullOrEmpty(typeInfo.SiteBinding) && (InfoToClone.Generalized.ObjectGroupID == 0))
            {
                // For objects with SiteID column allow site bindings only for global versions of the object (for example polls)
                if ((typeInfo.SiteIDColumn == TypeInfo.COLUMN_NAME_UNKNOWN) || (InfoToClone.Generalized.ObjectSiteID == 0))
                {
                    lblAssignToCurrentSite.ToolTip = GetString("clonning.settings.assigntocurrentsite.tooltip");
                    plcAssignToCurrentSite.Visible = true;

                    lblSiteBindings.ToolTip = GetCloneHelpText(typeInfo.SiteBinding);

                    plcSiteBindings.Visible = true;
                }
            }

            if ((InfoToClone.MetaFiles != null) && (InfoToClone.MetaFiles.Count > 0))
            {
                plcMetafiles.Visible = true;
            }

            // Preselect site of the object as a "clone under site" option
            if (plcCloneUnderSite.Visible && !RequestHelper.IsPostBack())
            {
                siteElem.SiteName = InfoToClone.Generalized.ObjectSiteName;
            }

            if (!RequestHelper.IsPostBack())
            {
                if (plcCodeName.Visible)
                {
                    txtCodeName.Text = InfoToClone.Generalized.GetUniqueCodeName();
                }
                if (plcDisplayName.Visible)
                {
                    txtDisplayName.Text = InfoToClone.Generalized.GetUniqueDisplayName();
                }

                // Exception for cultures for assigning to current site (for cultures the default value should be false)
                if (typeInfo.ObjectType == SiteObjectType.CULTURE)
                {
                    chkAssignToCurrentSite.Checked = false;
                }
            }

            if (plcChildren.Visible)
            {
                LoadMaxRelativeLevel();
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (InfoToClone != null)
        {
            ScriptHelper.RegisterJQuery(this.Page);

            typeInfo = InfoToClone.TypeInfo;

            siteElem.AllowGlobal = typeInfo.SupportsGlobalObjects;

            SetLabel(lblDisplayName, "displaynamelabel", "clonning.newdisplayname");
            SetLabel(lblCodeName, "codenamelabel", "clonning.newcodename");

            lblKeepFieldsTranslated.ToolTip = GetString("clonning.settings.keepfieldstranslated.tooltip");
            lblCloneUnderSite.ToolTip       = GetString("clonning.settings.cloneundersite.tooltip");
            lblMetafiles.ToolTip            = GetString("clonning.settings.metafiles.tooltip");
            lblMaxRelativeLevel.ToolTip     = GetString("clonning.settings.maxrelativelevel.tooltip");

            lblShowAdvanced.Text = "<a href=\"javascript: ShowHideAdvancedSection();\">" + GetString("clonning.settings.showadvanced") + "</a>";
            lblShowSimple.Text   = "<a href=\"javascript: ShowHideAdvancedSection();\">" + GetString("clonning.settings.showsimple") + "</a>";

            plcCodeName.Visible    = (typeInfo.CodeNameColumn != TypeInfo.COLUMN_NAME_UNKNOWN);
            plcDisplayName.Visible = (typeInfo.DisplayNameColumn != TypeInfo.COLUMN_NAME_UNKNOWN) && !typeInfo.DisplayNameColumn.EqualsCSafe(typeInfo.CodeNameColumn, true);

            // Try to load Custom properties
            customProperties = LoadCustomProperties(typeInfo.ObjectType);
            if ((customProperties == null) && (typeInfo.ObjectType != typeInfo.OriginalObjectType))
            {
                // Try get original object type settings control
                customProperties = LoadCustomProperties(typeInfo.OriginalObjectType);
            }

            if (customProperties != null)
            {
                customProperties.ID          = "customProperties";
                customProperties.InfoToClone = InfoToClone;

                plcCustomParameters.Controls.Add(customProperties);
                plcCustomParametersBox.Visible = customProperties.DisplayControl;

                if (customProperties.HideDisplayName)
                {
                    plcDisplayName.Visible = false;
                }
                if (customProperties.HideCodeName)
                {
                    plcCodeName.Visible = false;
                }

                TransferExcludedTypes();
            }

            ltlSpace.Text  = (plcDisplayName.Visible || plcCodeName.Visible ? "<br />" : "");
            ltlSpace2.Text = ltlSpace.Text;

            // Show site DDL only for Global Admin and for controls which have SiteID (and are not under group or any other parent) and are not from E-Commerce/Forums module
            plcCloneUnderSite.Visible = typeInfo.SupportsCloneToOtherSite && (typeInfo.SiteIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN) && (CMSContext.CurrentUser != null) && (CMSContext.CurrentUser.IsGlobalAdministrator) &&
                                        (SiteInfoProvider.GetSitesCount() > 1) && (InfoToClone.Generalized.ObjectGroupID == 0) && (InfoToClone.Generalized.ObjectParentID == 0) &&
                                        !typeInfo.ModuleName.EqualsCSafe(ModuleEntry.ECOMMERCE, true) && !typeInfo.ModuleName.EqualsCSafe(ModuleEntry.FORUMS, true) && (typeInfo.OriginalObjectType != PredefinedObjectType.CATEGORY);

            if (!string.IsNullOrEmpty(typeInfo.BindingObjectTypes) || !string.IsNullOrEmpty(typeInfo.OtherBindingObjectTypes))
            {
                // Remove site binding from bindings if exists
                string bindings = typeInfo.BindingObjectTypes + ";" + typeInfo.OtherBindingObjectTypes;
                if (!string.IsNullOrEmpty(typeInfo.SiteBinding))
                {
                    bindings = bindings.Replace(typeInfo.SiteBinding, "");
                }
                if (!string.IsNullOrEmpty(bindings.Replace(";", "")))
                {
                    List <string> excludedTypes = new List <string>();
                    excludedTypes.AddRange(excludedBindings);
                    excludedTypes.AddRange(excludedOtherBindings);

                    int itemNumber = 0;
                    lblBindings.ToolTip = GetCloneHelpText(bindings, excludedTypes, out itemNumber);

                    if (itemNumber == 1)
                    {
                        lblBindings.Text    = lblBindings.ToolTip;
                        lblBindings.ToolTip = "";
                    }
                    else
                    {
                        SetLabel(lblBindings, "bindingslabel", "clonning.settings.bindings");
                    }

                    plcBindings.Visible = itemNumber > 0;
                }
            }

            if (!string.IsNullOrEmpty(typeInfo.ChildObjectTypes))
            {
                int itemNumber = 0;
                lblChildren.ToolTip = GetCloneHelpText(typeInfo.ChildObjectTypes, excludedChildren, out itemNumber);

                if (itemNumber == 1)
                {
                    lblChildren.Text    = lblChildren.ToolTip;
                    lblChildren.ToolTip = "";
                }
                else
                {
                    lblChildren.Text = GetString("clonning.settings.children");
                }

                plcChildren.Visible      = itemNumber > 0;
                plcChildrenLevel.Visible = ShowChildrenLevel(excludedChildren);
            }

            if (!string.IsNullOrEmpty(typeInfo.SiteBinding) && (InfoToClone.Generalized.ObjectGroupID == 0))
            {
                // For objects with SiteID column allow site bindings only for global versions of the object (for example polls)
                if ((typeInfo.SiteIDColumn == TypeInfo.COLUMN_NAME_UNKNOWN) || (InfoToClone.Generalized.ObjectSiteID == 0))
                {
                    lblAssignToCurrentSite.ToolTip = GetString("clonning.settings.assigntocurrentsite.tooltip");
                    plcAssignToCurrentSite.Visible = true;

                    lblSiteBindings.ToolTip = GetCloneHelpText(typeInfo.SiteBinding);

                    plcSiteBindings.Visible = true;
                }
            }

            if ((InfoToClone.MetaFiles != null) && (InfoToClone.MetaFiles.Count > 0))
            {
                plcMetafiles.Visible = true;
            }

            // Preselect site of the object as a "clone under site" option
            if (plcCloneUnderSite.Visible && !RequestHelper.IsPostBack())
            {
                siteElem.SiteName = InfoToClone.Generalized.ObjectSiteName;
            }

            if (!RequestHelper.IsPostBack())
            {
                if (plcCodeName.Visible)
                {
                    txtCodeName.Text = InfoToClone.Generalized.GetUniqueCodeName();
                }
                if (plcDisplayName.Visible)
                {
                    txtDisplayName.Text = InfoToClone.Generalized.GetUniqueDisplayName();
                }

                // Exception for cultures for assigning to current site (for cultures the default value should be false)
                if (typeInfo.ObjectType == SiteObjectType.CULTURE)
                {
                    chkAssignToCurrentSite.Checked = false;
                }
            }

            if (plcChildren.Visible)
            {
                LoadMaxRelativeLevel();
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (InfoToClone == null)
        {
            return;
        }

        ScriptHelper.RegisterJQuery(Page);

        typeInfo = InfoToClone.TypeInfo;

        SetLabel(lblDisplayName, "displaynamelabel", "clonning.newdisplayname");
        SetLabel(lblCodeName, "codenamelabel", "clonning.newcodename");

        lblKeepFieldsTranslated.ToolTip = GetString("clonning.settings.keepfieldstranslated.tooltip");
        lblCloneUnderSite.ToolTip       = GetString("clonning.settings.cloneundersite.tooltip");
        lblMetafiles.ToolTip            = GetString("clonning.settings.metafiles.tooltip");
        lblMaxRelativeLevel.ToolTip     = GetString("clonning.settings.maxrelativelevel.tooltip");

        FormInfo formInfo = FormHelper.GetFormInfo(typeInfo.ObjectClassName, false);

        SetUpCodeNameControl(formInfo);
        SetUpDisplayNameControl(formInfo);

        customProperties = LoadCustomProperties(typeInfo.ObjectType, typeInfo.OriginalObjectType);
        if (customProperties != null)
        {
            SetUpControlsByCustomProperties();
        }

        siteElem.AllowGlobal      = typeInfo.SupportsGlobalObjects;
        plcCloneUnderSite.Visible = ShowCloneUnderSite();

        RemoveSiteBindingFromBindings();
        SetUpChildrenControl();
        SetUpSiteBindingsControls();

        // Allow meta files control if any
        if (InfoToClone.MetaFiles?.Count > 0)
        {
            plcMetafiles.Visible = true;
        }

        if (!RequestHelper.IsPostBack())
        {
            // Preselect site of the object as a "clone under site" option
            if (plcCloneUnderSite.Visible)
            {
                siteElem.SiteName = InfoToClone.Generalized.ObjectSiteName;
            }

            // Exception for cultures for assigning to current site (for cultures the default value should be false)
            if (typeInfo.ObjectType == CultureInfo.OBJECT_TYPE)
            {
                chkAssignToCurrentSite.Checked = false;
            }
        }

        if (plcChildren.Visible)
        {
            LoadMaxRelativeLevel();
        }
    }