コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check if any relationship exists
        DataSet dsRel = RelationshipNameInfoProvider.GetRelationshipNames("RelationshipAllowedObjects LIKE '%" + ObjectHelper.GROUP_DOCUMENTS + "%' AND RelationshipNameID IN (SELECT RelationshipNameID FROM CMS_RelationshipNameSite WHERE SiteID = " + SiteContext.CurrentSiteID + ")", null, 1, "RelationshipNameID");

        if (DataHelper.DataSourceIsEmpty(dsRel))
        {
            relatedDocuments.Visible = false;
            ShowInformation(ResHelper.GetString("relationship.norelationship"));
        }
        else
        {
            if (Node != null)
            {
                bool enabled = true;

                // Check modify permissions
                if (!DocumentUIHelper.CheckDocumentPermissions(Node, PermissionsEnum.Modify))
                {
                    relatedDocuments.Enabled = enabled = false;
                }
            }
        }

        pnlContent.Enabled = !DocumentManager.ProcessingAction;
    }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SetPropertyTab(TAB_LINKEDDOCS);

        if (Node != null)
        {
            // Check modify permissions
            if (!DocumentUIHelper.CheckDocumentPermissions(Node, PermissionsEnum.Modify))
            {
                pnlContainer.Enabled = false;
            }
        }

        currentSiteName = SiteContext.CurrentSiteName.ToLowerCSafe();

        gridDocs.OnExternalDataBound += gridDocuments_OnExternalDataBound;
        gridDocs.OnAction            += gridDocs_OnAction;
        gridDocs.OnDataReload        += gridDocs_OnDataReload;
        gridDocs.ShowActionsMenu      = true;
        gridDocs.Columns              = "NodeAliasPath, SiteName, NodeParentID, DocumentName, DocumentNamePath, ClassDisplayName";

        // Get all possible columns to retrieve
        gridDocs.AllColumns = SqlHelper.JoinColumnList(ObjectTypeManager.GetColumnNames(PredefinedObjectType.NODE, PredefinedObjectType.DOCUMENTLOCALIZATION));

        pnlContainer.Enabled = !DocumentManager.ProcessingAction;
    }
コード例 #3
0
    /// <summary>
    /// Fires when the page loads
    /// </summary>
    private void OnLoad(object sender, EventArgs eventArgs)
    {
        var page = (CMSPage)Control.Page;

        var manager = page.DocumentManager;

        manager.RedirectForNonExistingDocument = false;
        manager.Tree.CombineWithDefaultCulture = false;

        var node = manager.Node;

        if (node != null)
        {
            Node = node;

            ScriptHelper.RegisterScriptFile(Control.Page, "~/CMSModules/Content/CMSDesk/EditTabs.js");

            // Document from different site
            if (node.NodeSiteID != SiteContext.CurrentSiteID)
            {
                URLHelper.Redirect(DocumentUIHelper.GetPageNotAvailable(string.Empty, false, node.DocumentName));
            }

            showProductTab = node.HasSKU;

            DocumentUIHelper.EnsureDocumentBreadcrumbs(page.PageBreadcrumbs, node, null, null);
        }
        else
        {
            // Document does not exist -> redirect to new culture version creation dialog
            RedirectToNewCultureVersionPage();
        }
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SetPropertyTab(TAB_RELATEDDOCS);

        // Check if any relationship exists
        DataSet dsRel = RelationshipNameInfoProvider.GetRelationshipNames("RelationshipAllowedObjects LIKE '%" + ObjectHelper.GROUP_DOCUMENTS + "%' AND RelationshipNameID IN (SELECT RelationshipNameID FROM CMS_RelationshipNameSite WHERE SiteID = " + SiteContext.CurrentSiteID + ")", null, 1, "RelationshipNameID");

        if (DataHelper.DataSourceIsEmpty(dsRel))
        {
            relatedDocuments.Visible = false;
            ShowInformation(ResHelper.GetString("relationship.norelationship"));
        }
        else
        {
            if (Node != null)
            {
                bool enabled = true;

                // Check modify permissions
                if (!DocumentUIHelper.CheckDocumentPermissions(Node, PermissionsEnum.Modify))
                {
                    relatedDocuments.Enabled = enabled = false;
                }

                menuElem.AddExtraAction(new HeaderAction()
                {
                    Enabled     = enabled,
                    Text        = GetString("relationship.addrelateddocs"),
                    RedirectUrl = "~/CMSModules/Content/CMSDesk/Properties/Relateddocs_Add.aspx?nodeid=" + NodeID
                });
            }
        }

        pnlContent.Enabled = !DocumentManager.ProcessingAction;
    }
コード例 #5
0
    private bool TryGetUrl(out string url)
    {
        try
        {
            var queryStringParameters = GetQueryStringParameters();
            url = PageBuilderHelper.GetPreviewModeUrl(Node, MembershipContext.AuthenticatedUser.UserGUID, queryStringParameters);
        }
        catch (InvalidOperationException ex)
        {
            LogAndShowError("PageEdit", "PreviewLinkGeneration", ex);
            url = null;
            return(false);
        }

        if (url == null)
        {
            url = DocumentUIHelper.GetPageNotAvailableUrl();
            return(false);
        }

        if (DocumentManager.AllowSave)
        {
            url = PageBuilderHelper.AddEditModeParameter(url);
        }

        if (dataPropagated)
        {
            url = PageBuilderHelper.AddClearPageCacheParameter(url);
        }

        return(true);
    }
コード例 #6
0
    /// <summary>
    /// Fires when the page loads
    /// </summary>
    private void OnLoad(object sender, EventArgs eventArgs)
    {
        var page = (CMSPage)Control.Page;

        var manager = page.DocumentManager;

        manager.RedirectForNonExistingDocument = false;
        manager.Tree.CombineWithDefaultCulture = false;

        var node = manager.Node;

        if (node != null)
        {
            Node = node;

            ScriptHelper.RegisterScriptFile(Control.Page, "~/CMSModules/Content/CMSDesk/EditTabs.js");

            // Document from different site
            if (node.NodeSiteID != SiteContext.CurrentSiteID)
            {
                URLHelper.Redirect(DocumentUIHelper.GetPageNotAvailable(string.Empty, false, node.DocumentName));
            }

            showProductTab = node.HasSKU;

            // Initialize required variables
            isWireframe  = node.IsWireframe();
            hasWireframe = isWireframe || (node.NodeWireframeTemplateID > 0);

            try
            {
                var pi = PageInfoProvider.GetPageInfo(node.NodeSiteName, node.NodeAliasPath, node.DocumentCulture, node.DocumentUrlPath, false);
                if ((pi != null) && (pi.DesignPageTemplateInfo != null))
                {
                    var pti = pi.DesignPageTemplateInfo;

                    showMasterPage = pti.IsPortal && ((node.NodeAliasPath == "/") || pti.ShowAsMasterTemplate);

                    showDesign = ((pti.PageTemplateType == PageTemplateTypeEnum.Portal) || (pti.PageTemplateType == PageTemplateTypeEnum.AspxPortal));
                }
            }
            catch
            {
                // Page info not found - probably tried to display document from different site
            }

            if (node.NodeClassName.EqualsCSafe("CMS.File", true))
            {
                showDesign     = false;
                showMasterPage = false;
            }

            DocumentUIHelper.EnsureDocumentBreadcrumbs(page.PageBreadcrumbs, node, null, null);
        }
        else if (!PortalContext.ViewMode.IsDesign(true))
        {
            // Document does not exist -> redirect to new culture version creation dialog
            RedirectToNewCultureVersionPage();
        }
    }
コード例 #7
0
ファイル: Default.aspx.cs プロジェクト: itymofieiev/Kentico9
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check UI Analytics.Settings
        var ui = MembershipContext.AuthenticatedUser;

        if (!ui.IsAuthorizedPerUIElement("CMS.Content", "Analytics.Settings"))
        {
            RedirectToUIElementAccessDenied("CMS.Content", "Analytics.Settings");
        }
        EditedObject = Node;

        // Set disabled module info
        ucDisabledModule.SettingsKeys = "CMSAnalyticsEnabled;";
        ucDisabledModule.ParentPanel  = pnlDisabled;

        ucConversionSelector.SelectionMode = SelectionModeEnum.SingleTextBox;
        ucConversionSelector.IsLiveSite    = false;

        // Check modify permissions
        if (!DocumentUIHelper.CheckDocumentPermissions(Node, PermissionsEnum.Modify))
        {
            DocumentManager.DocumentInfo = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), Node.NodeAliasPath);

            // Disable save button
            CurrentMaster.HeaderActions.Enabled = false;
        }

        if ((Node != null) && !URLHelper.IsPostback())
        {
            ReloadData();
        }
    }
コード例 #8
0
    /// <summary>
    /// Raises the callback event.
    /// </summary>
    public void RaiseCallbackEvent(string eventArgument)
    {
        string[] argumentParts = eventArgument.Split(';');

        if (argumentParts.Length > 0)
        {
            string action = argumentParts[0];

            switch (action)
            {
            // Get edit page url (also consider custom document type urls)
            case "editurl":
            {
                int nodeId = ValidationHelper.GetInteger(argumentParts[1], 0);

                // Prepare url retriever settings
                UIPageURLSettings settings = new UIPageURLSettings();
                settings.AllowSplitview  = false;
                settings.NodeID          = nodeId;
                settings.AdditionalQuery = "dialog=1";
                settings.Mode            = "editform";
                settings.Action          = null;
                settings.Culture         = preferredCultureCode;

                // Get edit page url
                callbackResult = DocumentUIHelper.GetDocumentPageUrl(settings);
            }
            break;
            }
        }
    }
コード例 #9
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterJQuery(Page);
        ScriptHelper.RegisterModule(Page, "CMS/HeaderShadow");

        // Setup Edit menu
        bool preview = PortalContext.ViewMode.IsPreview();

        editMenu.ShowProperties    = false;
        editMenu.ShowSpellCheck    = true;
        editMenu.ShowSave          = !preview;
        editMenu.ShowCheckOut      = !preview;
        editMenu.ShowCheckIn       = !preview;
        editMenu.ShowUndoCheckOut  = !preview;
        editMenu.ShowApplyWorkflow = !preview;
        editMenu.NodeID            = NodeID;
        editMenu.CultureCode       = CultureCode;
        editMenu.UseSmallIcons     = true;
        editMenu.IsLiveSite        = false;

        viewPage = DocumentUIHelper.GetViewPageUrl();

        // Bind external buttons (i.e. Persona selector)
        var extensionTarget = editMenu as IExtensibleEditMenu;

        extensionTarget.InitializeExtenders("Content");

        // Preview link is not valid after going through workflow because DocumentWorkflowCycleGUID has changed
        if (Node != null)
        {
            DocumentManager.OnAfterAction += (obj, args) => viewPage = new PreviewLinkGenerator(Node).GeneratePreviewModeUrl(MembershipContext.AuthenticatedUser.UserGUID, embededInAdministration: true);
        }
    }
コード例 #10
0
    /// <summary>
    /// Fires when the page loads
    /// </summary>
    private void OnLoad(object sender, EventArgs eventArgs)
    {
        var page = (CMSPage)Control.Page;

        var manager = page.DocumentManager;

        manager.RedirectForNonExistingDocument = false;
        manager.Tree.CombineWithDefaultCulture = false;

        var node = manager.Node;

        if (node != null)
        {
            Node = node;

            ScriptHelper.RegisterScriptFile(Control.Page, "~/CMSModules/Content/CMSDesk/EditTabs.js");

            // Document from different site
            if (node.NodeSiteID != SiteContext.CurrentSiteID)
            {
                URLHelper.Redirect(DocumentUIHelper.GetPageNotAvailable(string.Empty, false, node.DocumentName));
            }

            showProductTab = node.HasSKU;

            try
            {
                var pageInfo = new PageInfo();
                pageInfo.LoadVersion(node);
                var template = pageInfo.DesignPageTemplateInfo;
                if (template != null)
                {
                    showMasterPage = template.IsPortal && ((node.NodeAliasPath == "/") || template.ShowAsMasterTemplate);

                    ConfigureShowDesignIfAuthorized(node, template);
                }
            }
            catch
            {
                // Page info not found - probably tried to display document from different site
            }

            if (node.IsFile())
            {
                showDesign     = false;
                showMasterPage = false;
            }

            DocumentUIHelper.EnsureDocumentBreadcrumbs(page.PageBreadcrumbs, node, null, null);
        }
        else if (!PortalContext.ViewMode.IsDesign(true))
        {
            // Document does not exist -> redirect to new culture version creation dialog
            RedirectToNewCultureVersionPage();
        }
    }
コード例 #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = QueryHelper.GetString("splitUrl", null);

        if (!string.IsNullOrEmpty(url) && UIContext.DisplaySplitMode)
        {
            // Register script files
            ltlScript.Text += ScriptHelper.GetScriptTag("~/CMSModules/Content/CMSDesk/SplitView.js");

            // Decode URL
            url = HttpUtility.UrlDecode(url);
            docSplitView.NodeID  = ValidationHelper.GetInteger(URLHelper.GetQueryValue(url, "nodeid"), 0);
            docSplitView.Culture = ValidationHelper.GetString(URLHelper.GetQueryValue(url, "culture"), null);

            // Update view mode (e.g. to remember edit tabs)
            PortalContext.UpdateViewMode(PortalContext.ViewMode);

            // Set frame1 URL
            docSplitView.Frame1Url = url;

            // Get the URL of the compare frame
            UIPageURLSettings settings = new UIPageURLSettings
            {
                Mode                  = Mode,
                NodeID                = NodeID,
                Culture               = UIContext.SplitModeCultureCode,
                SplitViewSourceURL    = url,
                TransformToCompareUrl = true
            };
            // Get URL
            docSplitView.Frame2Url = DocumentUIHelper.GetDocumentPageUrl(settings);

            StringBuilder script = new StringBuilder();
            script.Append(
                @"
function InitSplitViewSyncScroll(frameElement, body, refreshSameCulture, unbind) {
  if (InitSyncScroll) {
    InitSyncScroll(frameElement, body, refreshSameCulture, unbind);
  }
}
function SplitModeRefreshFrame() {
  if (FSP_SplitModeRefreshFrame) {
    FSP_SplitModeRefreshFrame();
  }
}

var FSP_appPref = '", URLHelper.GetFullApplicationUrl(), @"';
var FSP_cntPref = '", ScriptPrefix, @"';
");

            ScriptHelper.RegisterStartupScript(Page, typeof(string), "splitViewSync_" + Page.ClientID, script.ToString(), true);
        }
    }
コード例 #12
0
    /// <summary>
    /// Fires when a tab is created and hides ui elements which should not be visible for content only classes.
    /// </summary>
    private void OnTabCreated(object sender, TabCreatedEventArgs e)
    {
        if (e.Tab == null)
        {
            return;
        }

        if (DocumentUIHelper.IsElementHiddenForNode(e.UIElement, node))
        {
            e.Tab = null;
        }
    }
コード例 #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SetPropertyTab(TAB_TEMPLATE);

        // Setup child controls
        inheritElem.Node = Node;

        // Keep information whether current user has modify permission
        if (node != null)
        {
            PageTemplateCategoryInfo category = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo("/");
            int id = (category != null) ? category.CategoryId : 0;

            hasModifyPermission     = DocumentUIHelper.CheckDocumentPermissions(node, PermissionsEnum.Modify);
            btnSelect.OnClientClick = "modalDialog('" + ResolveUrl("~/CMSModules/PortalEngine/UI/Layout/PageTemplateSelector.aspx") + "?rootcategoryid=" + id + "&documentid=" + node.DocumentID + "&nodeguid=" + node.NodeGUID + "', 'PageTemplateSelection', '90%', '85%'); return false;";
        }

        btnSelect.Text         = GetString("PageProperties.Select");
        btnClone.OnClientClick = "return confirm(" + ScriptHelper.GetLocalizedString("Template.ConfirmClone") + ");";


        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SelectTemplate", ScriptHelper.GetScript(
                                                   @"
function RefreshPage() {
    document.location.replace(document.location);
}

function SetTemplateToHdnField(templateId) {
    document.getElementById('" + hdnSelected.ClientID + @"').value = templateId;
}

function OnSaveAsNewPageTemplate(templateId, selectorId) {
    SetTemplateToHdnField(templateId);
    RefreshPage();
}

function OnSelectPageTemplate(templateId, selectorId) {
    SetTemplateToHdnField(templateId);
    " + ClientScript.GetPostBackEventReference(btnSelect, String.Empty) + @"
}"));

        // Reflect processing action
        pnlInherits.Enabled = DocumentManager.AllowSave;

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

        ReloadControls();

        HandleCultureSettings();
    }
コード例 #14
0
    /// <summary>
    /// External data binding handler.
    /// </summary>
    protected object gridDocuments_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        DataRowView data;

        switch (sourceName.ToLowerCSafe())
        {
        case "documentname":
        {
            data = (DataRowView)parameter;

            string name                = ValidationHelper.GetString(data["NodeAliasPath"], "");
            string siteName            = SiteInfoProvider.GetSiteName(ValidationHelper.GetInteger(data["NodeSiteID"], 0));
            int    currentNodeId       = ValidationHelper.GetInteger(data["NodeID"], 0);
            int    currentNodeParentId = ValidationHelper.GetInteger(data["NodeParentID"], 0);

            string result;
            if (currentSiteName == siteName.ToLowerCSafe())
            {
                result = "<a href=\"javascript: SelectItem(" + currentNodeId + ", " + currentNodeParentId + ");\">" + HTMLHelper.HTMLEncode(TextHelper.LimitLength(name, 50)) + "</a>";
            }
            else
            {
                result = "<span>" + HTMLHelper.HTMLEncode(TextHelper.LimitLength(name, 50)) + "</span>";
            }

            // Show document mark only if method is not called from grid export
            bool isLink = (data["NodeLinkedNodeID"] != DBNull.Value);
            if ((sender != null) && isLink)
            {
                result += DocumentUIHelper.GetDocumentMarkImage(this, DocumentMarkEnum.Link);
            }

            return(result);
        }

        case "documentnametooltip":
            data = (DataRowView)parameter;
            return(UniGridFunctions.DocumentNameTooltip(data));

        case "deleteaction":
        {
            GridViewRow container     = (GridViewRow)parameter;
            int         currentNodeId = ValidationHelper.GetInteger(((DataRowView)container.DataItem)["NodeID"], 0);

            bool current = (Node.NodeID == currentNodeId);
            ((Control)sender).Visible = ((((DataRowView)container.DataItem)["NodeLinkedNodeID"] != DBNull.Value) && !current);
            ((CMSGridActionButton)sender).CommandArgument = currentNodeId.ToString();
            break;
        }
        }
        return(parameter);
    }
コード例 #15
0
    protected void btnCheckin_Click(object sender, EventArgs e)
    {
        try
        {
            // Check permissions
            if (!WorkflowManager.CheckStepPermissions(Node, WorkflowActionEnum.Approve) || ((versionsElem.CheckedOutByUserID != MembershipContext.AuthenticatedUser.UserID) && !versionsElem.CanCheckIn))
            {
                DisableForm();
                return;
            }

            // Check in the document
            string version = null;
            if (txtVersion.Text.Trim() != string.Empty)
            {
                version = txtVersion.Text.Trim();
            }
            string comment = null;
            if (txtComment.Text.Trim() != string.Empty)
            {
                comment = txtComment.Text.Trim();
            }

            VersionManager.CheckIn(Node, version, comment);

            txtComment.Text = "";
            txtVersion.Text = "";

            DocumentManager.ClearContentChanged();

            // Refresh tree if icon checked out was displayed
            if (DocumentUIHelper.IsIconUsed(IconType.CheckedOut, SiteContext.CurrentSiteName))
            {
                AddAfterActionScript();
            }

            ReloadData();
            versionsElem.ReloadData();
        }
        catch (WorkflowException)
        {
            ShowError(GetString("EditContent.DocumentCannotCheckIn"));
        }
        catch (Exception ex)
        {
            // Log exception
            EventLogProvider.LogException("Content", "CHECKIN", ex);
            ShowError(ex.Message);
        }
    }
コード例 #16
0
ファイル: View.aspx.cs プロジェクト: itymofieiev/Kentico9
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterJQuery(Page);
        ScriptHelper.RegisterModule(Page, "CMS/HeaderShadow");

        // Setup Edit menu
        bool preview = PortalContext.ViewMode.IsPreview();

        editMenu.ShowProperties    = false;
        editMenu.ShowSpellCheck    = true;
        editMenu.ShowSave          = !preview;
        editMenu.ShowCheckOut      = !preview;
        editMenu.ShowCheckIn       = !preview;
        editMenu.ShowUndoCheckOut  = !preview;
        editMenu.ShowApplyWorkflow = !preview;
        editMenu.NodeID            = NodeID;
        editMenu.CultureCode       = CultureCode;
        editMenu.UseSmallIcons     = true;
        editMenu.IsLiveSite        = false;

        var pageUrl = string.Empty;

        pageUrl             = DocumentUIHelper.GetViewPageUrl();
        ucView.ViewPage     = pageUrl;
        ucView.RotateDevice = ValidationHelper.GetBoolean(CookieHelper.GetValue(CookieName.CurrentDeviceProfileRotate), false);

        const string deviceRotateScript = @"
$cmsj(document).ready(function () {
    if (window.CMSDeviceProfile) {
        CMSDeviceProfile.OnRotationFunction = (function() {
            CMSView.InitializeFrame(CMSView.PreviewWidth, CMSView.PreviewHeight, !CMSView.Rotated);
            CMSView.DeviceWindowResize();
        });
    }
});";

        ScriptHelper.RegisterStartupScript(this, typeof(string), "deviceRotateScript", deviceRotateScript, true);

        // Bind external buttons (i.e. Persona selector)
        var extensionTarget = editMenu as IExtensibleEditMenu;

        extensionTarget.InitializeExtenders("Content");

        if (Node.NodeIsContentOnly)
        {
            // Preview link is not valid after going through worflow because DocumentWorkflowCycleGUID has changed
            DocumentManager.OnAfterAction += (obj, args) => { ucView.ViewPage = Node.GetPreviewLink(MembershipContext.AuthenticatedUser.UserName); };
        }
    }
コード例 #17
0
    private void OnLoad(object sender, EventArgs eventArgs)
    {
        var page = (CMSPage)Control.Page;

        // Setup the document manager
        var manager = page.DocumentManager;

        manager.RedirectForNonExistingDocument = false;

        ScriptHelper.RegisterScriptFile(Control.Page, "~/CMSModules/Content/CMSDesk/View/ViewTabs.js");

        var node = manager.Node;

        if (node != null)
        {
            DocumentUIHelper.EnsureDocumentBreadcrumbs(page.PageBreadcrumbs, node, null, null);
        }
    }
    /// <summary>
    /// Adds document to list.
    /// </summary>
    /// <param name="dr">Data row with document</param>
    private void AddToList(DataRow dr)
    {
        int    nodeId       = ValidationHelper.GetInteger(dr["NodeID"], 0);
        int    linkedNodeId = ValidationHelper.GetInteger(dr["NodeLinkedNodeID"], 0);
        int    documentCheckedOutByUserID = ValidationHelper.GetInteger(dr["DocumentCheckedOutByUserID"], 0);
        string name = HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr["DocumentName"], string.Empty));

        if (documentCheckedOutByUserID != 0)
        {
            name += " " + DocumentUIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.CheckedOut);
        }
        if (linkedNodeId != 0)
        {
            name += " " + DocumentUIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link);
        }
        name        += "<br />";
        list[nodeId] = name;
    }
コード例 #19
0
    protected void OnTabCreated(object sender, TabCreatedEventArgs e)
    {
        if (e.Tab == null)
        {
            return;
        }

        var tab     = e.Tab;
        var element = e.UIElement;

        var manager = DocumentManager;
        var node    = manager.Node;

        bool splitViewSupported = PortalContext.ViewMode != ViewModeEnum.EditLive;

        string elementName = element.ElementName.ToLowerCSafe();

        if (DocumentUIHelper.IsElementHiddenForNode(element, node))
        {
            e.Tab = null;
            return;
        }

        switch (elementName)
        {
        case "properties.languages":
            splitViewSupported = false;
            break;

        case "properties.security":
        case "properties.relateddocs":
        case "properties.linkeddocs":
            splitViewSupported = false;
            break;
        }

        // Ensure split view mode
        if (splitViewSupported && PortalUIHelper.DisplaySplitMode)
        {
            tab.RedirectUrl = DocumentUIHelper.GetSplitViewUrl(tab.RedirectUrl);
        }
    }
コード例 #20
0
ファイル: View.aspx.cs プロジェクト: SMEWebmaster/Kentico16
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterJQuery(Page);
        ScriptHelper.RegisterModule(Page, "CMS/HeaderShadow");

        ucView.ViewPage     = DocumentUIHelper.GetViewPageUrl();
        ucView.RotateDevice = ValidationHelper.GetBoolean(CookieHelper.GetValue(CookieName.CurrentDeviceProfileRotate), false);

        // Setup Edit menu
        bool preview = PortalContext.ViewMode.IsPreview();

        editMenu.ShowProperties    = false;
        editMenu.ShowSpellCheck    = true;
        editMenu.ShowSave          = !preview;
        editMenu.ShowCheckOut      = !preview;
        editMenu.ShowCheckIn       = !preview;
        editMenu.ShowUndoCheckOut  = !preview;
        editMenu.ShowApplyWorkflow = !preview;
        editMenu.NodeID            = NodeID;
        editMenu.CultureCode       = CultureCode;
        editMenu.UseSmallIcons     = true;
        editMenu.IsLiveSite        = false;

        // Bind external buttons (i.e. Persona selector)
        var extensionTarget = editMenu as IExtensibleEditMenu;

        extensionTarget.InitializeExtenders("Content");

        const string deviceRotateScript = @"
$cmsj(document).ready(function () {
    if (window.CMSDeviceProfile) {
        CMSDeviceProfile.OnRotationFunction = (function() {
            CMSView.InitializeFrame(CMSView.PreviewWidth, CMSView.PreviewHeight, !CMSView.Rotated);
            CMSView.DeviceWindowResize();
        });
    }
});";

        ScriptHelper.RegisterStartupScript(this, typeof(String), "deviceRotateScript", deviceRotateScript, true);
    }
コード例 #21
0
    protected void btnUndoCheckout_Click(object sender, EventArgs e)
    {
        try
        {
            // Check permissions
            if (!WorkflowManager.CheckStepPermissions(Node, WorkflowActionEnum.Approve))
            {
                DisableForm();
                return;
            }

            // Undo check out
            VersionManager.UndoCheckOut(Node);

            txtComment.Text = "";
            txtVersion.Text = "";

            DocumentManager.ClearContentChanged();

            // Refresh tree if icon checked out was displayed
            if (DocumentUIHelper.IsIconUsed(IconType.CheckedOut, SiteContext.CurrentSiteName))
            {
                AddAfterActionScript();
            }

            ReloadData();
            versionsElem.ReloadData();
        }
        catch (WorkflowException)
        {
            ShowError(GetString("EditContent.DocumentCannotUndoCheckOut"));
        }
        catch (Exception ex)
        {
            // Log exception
            EventLogProvider.LogException("Content", "UNDOCHECKOUT", ex);
            ShowError(ex.Message);
        }
    }
コード例 #22
0
ファイル: Default.aspx.cs プロジェクト: websedev/kentico-amp
    /// <summary>
    /// Handling page reload
    /// </summary>
    /// <param name="sender">Sender object</param>
    /// <param name="e">Event arguments</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        EditedObject = Node;

        // Check modify permissions
        if (!DocumentUIHelper.CheckDocumentPermissions(Node, PermissionsEnum.Modify))
        {
            DocumentManager.DocumentInfo = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), Node.NodeAliasPath);

            // Disable save button
            CurrentMaster.HeaderActions.Enabled = false;
        }

        if (Node != null && !RequestHelper.IsPostBack())
        {
            ReloadData();
        }
        else
        {
            ShowControls(chkEnableAmpFilter.Checked);
        }
    }
コード例 #23
0
    /// <summary>
    /// Callback event handler.
    /// </summary>
    /// <param name="argument">Callback argument</param>
    public void RaiseCallbackEvent(string eventArgument)
    {
        if (String.IsNullOrEmpty(eventArgument))
        {
            return;
        }

        var parts = eventArgument.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

        if (parts.Length == 2)
        {
            mNodePreviewUrl = DocumentUIHelper.GetDocumentPageUrl(new UIPageURLSettings
            {
                NodeID            = ValidationHelper.GetInteger(parts[0], 0),
                Culture           = parts[1],
                Mode              = ViewModeEnum.Preview.ToString(),
                AllowViewValidate = false,
            });
        }

        mNodePreviewUrl = mNodePreviewUrl ?? DocumentUIHelper.GetPageNotAvailableUrl();
    }
コード例 #24
0
    /// <summary>
    /// Returns URL of modal dialog for creating new page.
    /// </summary>
    private string GetCreateNewPageDialogUrl()
    {
        var path = SettingsKeyInfoProvider.GetValue("CMSCampaignNewPageLocation", SiteContext.CurrentSiteName);
        var tree = new TreeProvider(MembershipContext.AuthenticatedUser);
        var node = tree.SelectSingleNode(SiteContext.CurrentSiteName, path, SiteContext.CurrentSite.DefaultVisitorCulture, true);

        if (node == null)
        {
            node = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/", SiteContext.CurrentSite.DefaultVisitorCulture, true);
        }

        // General url settings
        var settings = new UIPageURLSettings
        {
            AllowSplitview  = false,
            NodeID          = node.NodeID,
            Culture         = node.DocumentCulture,
            Action          = "new",
            AdditionalQuery = "dialog=1&action=new&hidecontentonly=true"
        };

        return(DocumentUIHelper.GetDocumentPageUrl(settings));
    }
コード例 #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string nodeIdsString = QueryHelper.GetString("sourcenodeids", string.Empty);

        // Load node IDs to session for the first time
        if (!URLHelper.IsPostback() && !String.IsNullOrEmpty(nodeIdsString))
        {
            StringBuilder aliasPaths = new StringBuilder();
            TreeProvider  tree       = new TreeProvider(MembershipContext.AuthenticatedUser);
            DataSet       ds         = tree.SelectNodes(SiteContext.CurrentSiteName, TreeProvider.ALL_DOCUMENTS, TreeProvider.ALL_CULTURES, true, null, String.Format("NodeID IN ({0})", nodeIdsString.Trim('|').Replace("|", ",")), null, TreeProvider.ALL_LEVELS, false, 0, DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS + ",NodeParentID, DocumentName, NodeAliasPath, NodeLinkedNodeID");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                const string lineBreak = "<br />";

                // Create list of paths
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    aliasPaths.Append(ValidationHelper.GetString(dr["NodeAliasPath"], string.Empty));
                    if (ValidationHelper.GetInteger(dr["NodeLinkedNodeID"], 0) != 0)
                    {
                        aliasPaths.Append(DocumentUIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link));
                    }
                    aliasPaths.Append(lineBreak);
                }

                // Trim last line break
                if (aliasPaths.Length > lineBreak.Length)
                {
                    aliasPaths = aliasPaths.Remove(aliasPaths.Length - lineBreak.Length, lineBreak.Length);
                }
            }

            SessionHelper.SetValue("CopyMoveDocAliasPaths", aliasPaths.ToString());
            SessionHelper.Remove("CopyMoveDocCopyPermissions");
        }
    }
コード例 #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        EditedObject = Node;

        // Set disabled module info
        ucDisabledModule.ParentPanel = pnlDisabled;

        ucConversionSelector.SelectionMode = SelectionModeEnum.SingleTextBox;
        ucConversionSelector.IsLiveSite    = false;

        // Check modify permissions
        if (!DocumentUIHelper.CheckDocumentPermissions(Node, PermissionsEnum.Modify))
        {
            DocumentManager.DocumentInfo = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), Node.NodeAliasPath);

            // Disable save button
            CurrentMaster.HeaderActions.Enabled = false;
        }

        if ((Node != null) && !RequestHelper.IsPostBack())
        {
            ReloadData();
        }
    }
コード例 #27
0
    protected void btnCheckout_Click(object sender, EventArgs e)
    {
        try
        {
            // Check permissions
            if (!WorkflowManager.CheckStepPermissions(Node, WorkflowActionEnum.Approve))
            {
                DisableForm();
                return;
            }

            VersionManager.EnsureVersion(Node, Node.IsPublished);

            // Check out the document
            VersionManager.CheckOut(Node);

            // Refresh tree if icon checked out should be displayed
            if (DocumentUIHelper.IsIconUsed(IconType.CheckedOut, SiteContext.CurrentSiteName))
            {
                AddAfterActionScript();
            }

            ReloadData();
            versionsElem.ReloadData();
        }
        catch (WorkflowException)
        {
            ShowError(GetString("EditContent.DocumentCannotCheckOut"));
        }
        catch (Exception ex)
        {
            // Log exception
            EventLogProvider.LogException("Content", "CHECKOUT", ex);
            ShowError(ex.Message);
        }
    }
コード例 #28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script files
        ScriptHelper.RegisterCMS(this);
        ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Operation.js");

        if (!QueryHelper.ValidateHash("hash"))
        {
            pnlContent.Visible = false;
            ShowError(GetString("dialogs.badhashtext"));
            return;
        }

        // Setup page title text and image
        PageTitle.TitleText = GetString("Content.TranslateTitle");
        EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: PageTitle.TitleText);

        if (IsDialog)
        {
            RegisterModalPageScripts();
            RegisterEscScript();

            plcInfo.Visible = false;

            pnlButtons.Visible = false;
        }

        if (!TranslationServiceHelper.IsTranslationAllowed(CurrentSiteName))
        {
            pnlContent.Visible = false;
            ShowError(GetString("translations.translationnotallowed"));
            return;
        }

        // Initialize current user
        currentUser = MembershipContext.AuthenticatedUser;

        // Initialize events
        ctlAsyncLog.OnFinished += ctlAsyncLog_OnFinished;
        ctlAsyncLog.OnError    += ctlAsyncLog_OnError;
        ctlAsyncLog.OnCancel   += ctlAsyncLog_OnCancel;

        isSelect = QueryHelper.GetBoolean("select", false);
        if (isSelect)
        {
            pnlDocList.Visible     = false;
            pnlDocSelector.Visible = true;
            translationElem.DisplayMachineServices = false;
        }

        var currentCulture        = LocalizationContext.CurrentCulture.CultureCode;
        var displayTargetLanguage = !IsDialog || isSelect;

        translationElem.DisplayTargetlanguage = displayTargetLanguage;

        // Get target culture(s)
        targetCultures = displayTargetLanguage ? translationElem.TargetLanguages : new HashSet <string>(new[] { QueryHelper.GetString("targetculture", currentCulture) });

        // Set the target settings
        var settings = new TranslationSettings();

        settings.TargetLanguages.AddRange(targetCultures);

        var useCurrentAsDefault = QueryHelper.GetBoolean("currentastargetdefault", false);

        if (!currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) && currentUser.UserHasAllowedCultures && !currentUser.IsCultureAllowed(currentCulture, CurrentSiteName))
        {
            // Do not use current culture as default if user has no permissions to edit it
            useCurrentAsDefault = false;
        }

        translationElem.UseCurrentCultureAsDefaultTarget = useCurrentAsDefault;

        // Do not include default culture if it is current one
        string defaultCulture = CultureHelper.GetDefaultCultureCode(CurrentSiteName);

        if (useCurrentAsDefault && !string.Equals(currentCulture, defaultCulture, StringComparison.InvariantCultureIgnoreCase) && !RequestHelper.IsPostBack())
        {
            settings.TargetLanguages.Add(currentCulture);
        }

        translationElem.TranslationSettings = settings;
        allowTranslate = true;

        if (RequestHelper.IsCallback())
        {
            return;
        }

        // If not in select mode, load all the document IDs and check permissions
        // In select mode, documents are checked when the button is clicked
        if (!isSelect)
        {
            DataSet      allDocs = null;
            TreeProvider tree    = new TreeProvider();

            // Current Node ID to translate
            string parentAliasPath = string.Empty;
            if (Parameters != null)
            {
                parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty);
                nodeIdsArr      = ValidationHelper.GetString(Parameters["nodeids"], string.Empty).Trim('|').Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            }

            if (string.IsNullOrEmpty(parentAliasPath))
            {
                if (nodeIdsArr == null)
                {
                    // One document translation is requested
                    string nodeIdQuery = QueryHelper.GetString("nodeid", "");
                    if (nodeIdQuery != "")
                    {
                        // Mode of single node translation
                        pnlList.Visible           = false;
                        chkSkipTranslated.Checked = false;

                        translationElem.NodeID = ValidationHelper.GetInteger(nodeIdQuery, 0);

                        nodeIdsArr = new[] { nodeIdQuery };
                    }
                    else
                    {
                        nodeIdsArr = new string[] { };
                    }
                }

                foreach (string nodeId in nodeIdsArr)
                {
                    int id = ValidationHelper.GetInteger(nodeId, 0);
                    if (id != 0)
                    {
                        nodeIds.Add(id);
                    }
                }
            }
            else
            {
                // Exclude root of the website from multiple translation requested by document listing bulk action
                var where = new WhereCondition(WhereCondition)
                            .WhereNotEquals("ClassName", SystemDocumentTypes.Root);

                allDocs = tree.SelectNodes(CurrentSiteName, parentAliasPath.TrimEnd(new[] { '/' }) + "/%",
                                           TreeProvider.ALL_CULTURES, true, ClassID > 0 ? DataClassInfoProvider.GetClassName(ClassID) : TreeProvider.ALL_CLASSNAMES, where.ToString(true),
                                           "DocumentName", AllLevels ? TreeProvider.ALL_LEVELS : 1, false, 0,
                                           DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID,NodeAliasPath");

                if (!DataHelper.DataSourceIsEmpty(allDocs))
                {
                    foreach (DataTable table in allDocs.Tables)
                    {
                        foreach (DataRow row in table.Rows)
                        {
                            nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0));
                        }
                    }
                }
            }

            if (nodeIds.Count > 0)
            {
                var where = new WhereCondition().WhereIn("NodeID", nodeIds).ToString(true);
                DataSet ds = allDocs ?? tree.SelectNodes(CurrentSiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", TreeProvider.ALL_LEVELS, false);

                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    string docList = null;

                    cancelNodeId = string.IsNullOrEmpty(parentAliasPath)
                        ? DataHelper.GetIntValue(ds.Tables[0].Rows[0], "NodeParentID")
                        : TreePathUtils.GetNodeIdByAliasPath(CurrentSiteName, parentAliasPath);

                    foreach (DataTable table in ds.Tables)
                    {
                        foreach (DataRow dr in table.Rows)
                        {
                            bool   isLink = (dr["NodeLinkedNodeID"] != DBNull.Value);
                            string name   = (string)dr["DocumentName"];
                            docList += HTMLHelper.HTMLEncode(name);
                            if (isLink)
                            {
                                docList += DocumentUIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link);
                            }
                            docList          += "<br />";
                            lblDocuments.Text = docList;

                            // Set visibility of checkboxes
                            TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr);

                            if (!TranslationServiceHelper.IsAuthorizedToTranslateDocument(node, currentUser, targetCultures))
                            {
                                allowTranslate = false;

                                plcMessages.AddError(String.Format(GetString("cmsdesk.notauthorizedtotranslatedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath)));
                            }
                        }
                    }

                    if (!allowTranslate && !RequestHelper.IsPostBack())
                    {
                        // Hide UI only when security check is performed within first load, if postback used user may loose some setting
                        HideUI();
                    }
                }

                // Display check box for separate submissions for each document if there is more than one document
                translationElem.DisplaySeparateSubmissionOption = (nodeIds.Count > 1);
            }
            else
            {
                // Hide everything
                pnlContent.Visible = false;
            }
        }

        // Register the dialog script
        ScriptHelper.RegisterDialogScript(this);

        ctlAsyncLog.TitleText = GetString("contentrequest.starttranslate");
        // Set visibility of panels
        pnlContent.Visible = true;
        pnlLog.Visible     = false;
    }
コード例 #29
0
    /// <summary>
    /// Creates the tree node.
    /// </summary>
    /// <param name="sourceNode">Source node</param>
    /// <param name="index">Node index</param>
    /// <param name="childNode">True if the node is child node</param>
    protected System.Web.UI.WebControls.TreeNode CreateNode(TreeSiteMapNode sourceNode, int index, bool childNode)
    {
        System.Web.UI.WebControls.TreeNode newNode = new System.Web.UI.WebControls.TreeNode();
        ISimpleDataContainer container             = sourceNode;

        int nodeId    = (int)container.GetValue("NodeID");
        int nodeLevel = (int)container.GetValue("NodeLevel");

        if (nodeId < 0)
        {
            newNode.SelectAction = TreeNodeSelectAction.None;
            newNode.Text         = GetString("ContentTree.ReadDocumentDenied");
            newNode.NavigateUrl  = (DeniedNodePostback ? mBasePath + "#" : string.Empty);
            return(newNode);
        }

        // Show complete node if index is lower than MaxTreeNodes or level is lower than RootNodeLevel
        if ((MaxTreeNodes <= 0) || (index < MaxTreeNodes) || (nodeLevel <= MapProvider.RootNodeLevel + 1))
        {
            allNodes[nodeId] = newNode;

            // Set the base data
            newNode.Value       = nodeId.ToString();
            newNode.NavigateUrl = "javascript:void(0);";

            int           classId = ValidationHelper.GetInteger(container.GetValue("NodeClassID"), 0);
            DataClassInfo ci      = DataClassInfoProvider.GetDataClassInfo(classId);
            if (ci == null)
            {
                throw new Exception("[ContentTree.CreateNode]: Node class not found.");
            }

            string className = ci.ClassName;

            // Use file type icons for file
            var sb = new StringBuilder();
            if (UseCMSFileIcons && string.Equals(className, SystemDocumentTypes.File, StringComparison.InvariantCultureIgnoreCase))
            {
                string extension = ValidationHelper.GetString(container.GetValue("DocumentType"), string.Empty);
                string image     = UIHelper.GetFileIcon(Page, extension, FontIconSizeEnum.Standard, CMSFileIconSet);
                sb.Append(image);
            }
            // Use class icons
            else
            {
                var iconClass = ValidationHelper.GetString(ci.GetValue("ClassIconClass"), String.Empty);
                var icon      = UIHelper.GetDocumentTypeIcon(Page, className, iconClass);
                sb.Append(icon);
            }
            string imageTag = sb.ToString();

            string nodeName     = HttpUtility.HtmlEncode(ValidationHelper.GetString(container.GetValue("DocumentName"), string.Empty));
            string nodeNameJava = ScriptHelper.GetString(nodeName);
            string marks        = "";

            // Render special marks only if allowed
            if (AllowMarks)
            {
                int workflowStepId            = ValidationHelper.GetInteger(container.GetValue("DocumentWorkflowStepID"), 0);
                WorkflowStepTypeEnum stepType = WorkflowStepTypeEnum.Undefined;

                if (workflowStepId > 0)
                {
                    WorkflowStepInfo stepInfo = WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowStepId);
                    if (stepInfo != null)
                    {
                        stepType = stepInfo.StepType;
                    }
                }

                // Add icons
                marks = DocumentUIHelper.GetDocumentMarks(Page, SiteName, Culture, stepType, sourceNode, true);
                if (!string.IsNullOrEmpty(marks))
                {
                    marks = string.Format("<span class=\"tn-group\">{0}</span>", marks);
                }
            }

            string template;

            if ((SelectedNode != null) && (nodeId == SelectedNode.NodeID))
            {
                template         = SelectedNodeTextTemplate;
                selectedRendered = true;
            }
            else
            {
                template = NodeTextTemplate;
            }

            // Prepare the node text
            newNode.Text = ResolveNode(template, nodeName, imageTag, nodeNameJava, nodeId, marks);

            // Drag and drop envelope
            if (AllowDragAndDrop)
            {
                sb.Length = 0;

                if (childNode)
                {
                    sb.Append("<span id=\"target_", nodeId, "\"><span class=\"DDItem\" id=\"node_", nodeId, "\"><span class=\"DDHandle\" id=\"handle_", nodeId, "\" onmousedown=\"return false;\" onclick=\"return false;\">", newNode.Text, "</span></span></span>");
                }
                else
                {
                    sb.Append("<span id=\"target_", nodeId, "\" class=\"RootNode\"><span class=\"DDItem\" id=\"node_", nodeId, "\">", newNode.Text, "</span></span>");
                }

                newNode.Text = sb.ToString();
            }

            bool nodeHasChildren = ValidationHelper.GetBoolean(container.GetValue("NodeHasChildren"), false);
            // Check if can expand
            if (!nodeHasChildren)
            {
                newNode.PopulateOnDemand = false;
                newNode.Expanded         = true;
            }
            else
            {
                if ((sourceNode.ChildNodes.Count > 0) || !sourceNode.ChildNodesLoaded)
                {
                    newNode.PopulateOnDemand = true;
                }
            }

            // Set expanded status
            string aliasPath = ValidationHelper.GetString(container.GetValue("NodeAliasPath"), string.Empty);
            newNode.Expanded = aliasPath.Equals(MapProvider.Path, StringComparison.InvariantCultureIgnoreCase) || expandNodes.Contains(nodeId);
        }
        else
        {
            string parentNodeId = ValidationHelper.GetString(container.GetValue("NodeParentID"), string.Empty);
            newNode.Value       = nodeId.ToString();
            newNode.Text        = MaxTreeNodeText.Replace("##PARENTNODEID##", parentNodeId);
            newNode.NavigateUrl = "#";
        }

        return(newNode);
    }
コード例 #30
0
 /// <summary>
 /// Redirects to new document language version page.
 /// </summary>
 protected virtual void RedirectToNewCultureVersionPage()
 {
     URLHelper.Redirect(DocumentUIHelper.GetNewCultureVersionPageUrl());
 }