Esempio n. 1
0
    /// <summary>
    /// Returns rendered panel with translation services
    /// </summary>
    public void RegisterTranslationServicesActions()
    {
        string currentSiteName = SiteContext.CurrentSiteName;

        if (TranslationServiceHelper.IsTranslationAllowed(currentSiteName))
        {
            string where = "TranslationServiceEnabled = 1 AND TranslationServiceIsMachine = 1";

            foreach (TranslationServiceInfo tsi in TranslationServiceInfoProvider.GetTranslationServices(where, "TranslationServiceDisplayName", 0, "TranslationServiceDisplayName, TranslationServiceName"))
            {
                AddTranslationControl(tsi, currentSiteName);
            }
        }
    }
    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;
    }
    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"))
        {
            // This is only to make sure that WebApplicationPhysicalPath is loaded when Async translation is started
            string appPath = URLHelper.WebApplicationPhysicalPath;

            // Set current UI culture
            currentCulture = CultureHelper.PreferredUICulture;
            // Initialize current user
            currentUser = CMSContext.CurrentUser;
            // Initialize current site
            currentSite = CMSContext.CurrentSite;

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

            // Initialize events
            ctlAsync.OnFinished   += ctlAsync_OnFinished;
            ctlAsync.OnError      += ctlAsync_OnError;
            ctlAsync.OnRequestLog += ctlAsync_OnRequestLog;
            ctlAsync.OnCancel     += ctlAsync_OnCancel;

            targetCulture = QueryHelper.GetString("targetculture", CMSContext.PreferredCultureCode);
            isSelect      = QueryHelper.GetBoolean("select", false);

            if (isModal)
            {
                RegisterModalPageScripts();
                RegisterEscScript();

                plcInfo.Visible = false;

                pnlAsyncBody.CssClass       = "DialogPageBody";
                pnlTitleAsync.CssClass      = "DialogsPageHeader";
                pnlContent.CssClass         = "PageContent";
                pnlServiceSelector.CssClass = "TranslationSelectorBox";
                pnlButtons.CssClass         = "FloatRight PageFooterLine";
            }

            if (isSelect)
            {
                pnlDocList.Visible     = false;
                pnlDocSelector.Visible = true;
                translationElem.DisplayMachineServices = false;
                translationElem.DisplayTargetlanguage  = true;
            }

            if (!RequestHelper.IsCallback())
            {
                // 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(currentUser);

                    // 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 char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    }
                    if (string.IsNullOrEmpty(parentAliasPath))
                    {
                        if (nodeIdsArr == null)
                        {
                            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 string[] { nodeIdQuery };
                            }
                            else
                            {
                                nodeIdsArr = new string[] { };
                            }
                        }

                        foreach (string nodeId in nodeIdsArr)
                        {
                            int id = ValidationHelper.GetInteger(nodeId, 0);
                            if (id != 0)
                            {
                                nodeIds.Add(id);
                            }
                        }
                    }
                    else
                    {
                        string where = WhereCondition;
                        allDocs      = tree.SelectNodes(currentSite.SiteName, parentAliasPath.TrimEnd(new char[] { '/' }) + "/%",
                                                        TreeProvider.ALL_CULTURES, true, TreeProvider.ALL_CLASSNAMES, where,
                                                        "DocumentName", TreeProvider.ALL_LEVELS, false, 0,
                                                        TreeProvider.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)
                    {
                        // Set the target settings
                        translationElem.TranslationSettings = new TranslationSettings()
                        {
                            TargetLanguage = targetCulture
                        };

                        string where = "NodeID IN (";
                        foreach (int nodeID in nodeIds)
                        {
                            where += nodeID + ",";
                        }

                        where = where.TrimEnd(',') + ")";
                        DataSet ds = allDocs ?? tree.SelectNodes(currentSite.SiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", -1, false);

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

                            if (string.IsNullOrEmpty(parentAliasPath))
                            {
                                cancelNodeId = ValidationHelper.GetInteger(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NodeParentID"), 0);
                            }
                            else
                            {
                                cancelNodeId = TreePathUtils.GetNodeIdByAliasPath(currentSite.SiteName, 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 += UIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link);
                                    }
                                    docList          += "<br />";
                                    lblDocuments.Text = docList;

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

                                    if (!IsUserAuthorizedToTranslateDocument(node, currentSite.SiteName))
                                    {
                                        HideUI();
                                        plcMessages.AddError(String.Format(GetString("cmsdesk.notauthorizedtotranslatedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath)), null);
                                    }
                                }
                            }
                        }

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

                // Setup page title text and image
                CurrentMaster.Title.TitleText  = GetString("Content.TranslateTitle");
                CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/translate.png");

                if (isSelect)
                {
                    CurrentMaster.Title.HelpTopicName = "translationservices_translatedocuments";
                }
                else
                {
                    CurrentMaster.Title.HelpTopicName = "translationservices_createsubmission";
                }

                btnCancel.Text = GetString("general.cancel");
                btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;");

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

                titleElemAsync.TitleText  = GetString("ContentTranslate.TranslatingDocuments");
                titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/translate.png");

                // Set visibility of panels
                pnlContent.Visible = true;
                pnlLog.Visible     = false;
            }
        }
        else
        {
            pnlContent.Visible = false;
            ShowError(GetString("dialogs.badhashtext"));
        }
    }
Esempio n. 4
0
    /// <summary>
    /// Creates default mass actions. Has to be called on Page_Init before MassActions extenders are initialized, so default actions will be at the beginning.
    /// </summary>
    private void CreateMassActionItems()
    {
        var urlBuilder = new DocumentListMassActionsUrlGenerator();

        // Converts functions with signature as in DocumentListMassActionsUrlGenerator to CreateUrlDelegate as MassActionItem expects
        Func <Func <List <int>, DocumentListMassActionsParameters, string>, CreateUrlDelegate> functionConverter = generateActionFunction =>
        {
            return((scope, selectedNodeIDs, parameters) =>
            {
                return generateActionFunction(scope == MassActionScopeEnum.AllItems ? null : selectedNodeIDs, (DocumentListMassActionsParameters)parameters);
            });
        };

        ctrlMassActions.AddMassActions(
            new MassActionItem
        {
            CodeName = "action|move",
            DisplayNameResourceString = "general.move",
            CreateUrl  = functionConverter(urlBuilder.GetMoveActionUrl),
            ActionType = MassActionTypeEnum.OpenModal,
        },
            new MassActionItem
        {
            CodeName = "action|copy",
            DisplayNameResourceString = "general.copy",
            CreateUrl  = functionConverter(urlBuilder.GetCopyActionUrl),
            ActionType = MassActionTypeEnum.OpenModal,
        });

        ctrlMassActions.AddMassActions(new MassActionItem
        {
            CodeName = "action|link",
            DisplayNameResourceString = "general.link",
            CreateUrl  = functionConverter(urlBuilder.GetLinkActionUrl),
            ActionType = MassActionTypeEnum.OpenModal,
        });

        ctrlMassActions.AddMassActions(new MassActionItem
        {
            CodeName = "action|delete",
            DisplayNameResourceString = "general.delete",
            CreateUrl  = functionConverter(urlBuilder.GetDeleteActionUrl),
            ActionType = MassActionTypeEnum.Redirect,
        });

        if (CultureSiteInfoProvider.IsSiteMultilingual(currentSiteName) &&
            LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.TranslationServices) &&
            TranslationServiceHelper.IsTranslationAllowed(currentSiteName) &&
            TranslationServiceHelper.AnyServiceAvailable(currentSiteName))
        {
            ctrlMassActions.AddMassActions(new MassActionItem
            {
                CodeName = "action|translate",
                DisplayNameResourceString = "general.translate",
                CreateUrl  = functionConverter(urlBuilder.GetTranslateActionUrl),
                ActionType = MassActionTypeEnum.Redirect,
            });
        }

        if (currentUserInfo.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) || currentUserInfo.IsAuthorizedPerResource("CMS.Content", "ManageWorkflow"))
        {
            ctrlMassActions.AddMassActions(
                new MassActionItem
            {
                CodeName = "action|publish",
                DisplayNameResourceString = "general.publish",
                CreateUrl  = functionConverter(urlBuilder.GetPublishActionUrl),
                ActionType = MassActionTypeEnum.Redirect,
            },
                new MassActionItem
            {
                CodeName = "action|archive",
                DisplayNameResourceString = "general.archive",
                CreateUrl  = functionConverter(urlBuilder.GetArchiveActionUrl),
                ActionType = MassActionTypeEnum.Redirect,
            });
        }
    }
Esempio n. 5
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"))
        {
            // Setup page title text and image
            PageTitle.TitleText = GetString("Content.TranslateTitle");
            EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: PageTitle.TitleText);

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

                plcInfo.Visible = false;

                pnlAsyncBody.CssClass  = "DialogPageBody";
                pnlTitleAsync.CssClass = "DialogsPageHeader";
                pnlContent.CssClass    = "PageContent";
                pnlButtons.CssClass    = "FloatRight PageFooterLine";
            }

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

            // Set current UI culture
            currentCulture = CultureHelper.PreferredUICultureCode;
            // Initialize current user
            currentUser = MembershipContext.AuthenticatedUser;
            // Initialize current site
            currentSite = SiteContext.CurrentSite;

            // Initialize events
            ctlAsync.OnFinished   += ctlAsync_OnFinished;
            ctlAsync.OnError      += ctlAsync_OnError;
            ctlAsync.OnRequestLog += ctlAsync_OnRequestLog;
            ctlAsync.OnCancel     += ctlAsync_OnCancel;

            targetCulture = QueryHelper.GetString("targetculture", LocalizationContext.PreferredCultureCode);
            isSelect      = QueryHelper.GetBoolean("select", false);

            if (isSelect)
            {
                pnlDocList.Visible     = false;
                pnlDocSelector.Visible = true;
                translationElem.DisplayMachineServices = false;
                translationElem.DisplayTargetlanguage  = true;
            }

            if (!RequestHelper.IsCallback())
            {
                // 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(currentUser);

                    // 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
                        string where = "ClassName <> 'CMS.Root'";
                        if (!string.IsNullOrEmpty(WhereCondition))
                        {
                            where = SqlHelper.AddWhereCondition(where, WhereCondition);
                        }

                        allDocs = tree.SelectNodes(currentSite.SiteName, parentAliasPath.TrimEnd(new[] { '/' }) + "/%",
                                                   TreeProvider.ALL_CULTURES, true, ClassID > 0 ? DataClassInfoProvider.GetClassName(ClassID) : TreeProvider.ALL_CLASSNAMES, where,
                                                   "DocumentName", AllLevels ? TreeProvider.ALL_LEVELS : 1, false, 0,
                                                   TreeProvider.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)
                    {
                        // Set the target settings
                        translationElem.TranslationSettings = new TranslationSettings
                        {
                            TargetLanguage = targetCulture
                        };

                        var where = new WhereCondition().WhereIn("NodeID", nodeIds).ToString(true);
                        DataSet ds = allDocs ?? tree.SelectNodes(currentSite.SiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", TreeProvider.ALL_LEVELS, false);

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

                            if (string.IsNullOrEmpty(parentAliasPath))
                            {
                                cancelNodeId = ValidationHelper.GetInteger(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NodeParentID"), 0);
                            }
                            else
                            {
                                cancelNodeId = TreePathUtils.GetNodeIdByAliasPath(currentSite.SiteName, 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 += DocumentHelper.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 (!IsUserAuthorizedToTranslateDocument(node, currentSite.SiteName, targetCulture))
                                    {
                                        HideUI();
                                        plcMessages.AddError(String.Format(GetString("cmsdesk.notauthorizedtotranslatedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath)));
                                    }
                                }
                            }
                        }

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

                btnCancel.Text = GetString("general.cancel");
                btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;");

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

                titleElemAsync.TitleText = GetString("contentrequest.starttranslate");
                // Set visibility of panels
                pnlContent.Visible = true;
                pnlLog.Visible     = false;
            }
        }
        else
        {
            pnlContent.Visible = false;
            ShowError(GetString("dialogs.badhashtext"));
        }
    }