Ejemplo n.º 1
0
 /// <summary>
 /// Custom extension method that localizes text based on a given key
 /// </summary>
 /// <param name="helper">Html helper</param>
 /// <param name="key">Full key stored in Localization app within Kentico</param>
 /// <returns></returns>
 public static string Localize(this HtmlHelper helper, string key)
 {
     return(ResHelper.GetString(key));
 }
    /// <summary>
    /// Initialize wizard header.
    /// </summary>
    /// <param name="index">Step index</param>
    private void InitializeHeader(int index)
    {
        Help.Visible        = true;
        StartHelp.Visible   = true;
        StartHelp.TopicName = Help.TopicName = HELP_TOPIC_LINK;

        lblHeader.Text = ResHelper.GetFileString("Install.Step") + " - ";

        string[] stepIcons  = { " icon-cogwheel", " icon-database", " icon-separate", " icon-check-circle icon-style-allow" };
        string[] stepTitles = { GetString("install.sqlsetting"), GetString("install.lbldatabase"), GetString("install.separation"), GetString("install.finishstep") };

        // Set common properties to each step icon
        for (var i = 0; i < stepIcons.Length; i++)
        {
            // Step panel
            var pnlStepIcon = new Panel();
            pnlStepIcon.ID       = "stepPanel" + i;
            pnlStepIcon.CssClass = "install-step-panel";
            pnlHeaderImages.Controls.Add(pnlStepIcon);

            // Step icon
            var icon = new CMSIcon();
            icon.ID       = "stepIcon" + i;
            icon.CssClass = "install-step-icon cms-icon-200" + stepIcons[i];
            icon.Attributes.Add("aria-hidden", "true");
            pnlStepIcon.Controls.Add(icon);

            // Step icon title
            var title = new HtmlGenericControl("title");
            title.ID        = "stepTitle" + i;
            title.InnerText = stepTitles[i];
            title.Attributes.Add("class", "install-step-title");
            pnlStepIcon.Controls.Add(title);

            // Render separator only between step icons
            if (i < stepIcons.Length - 1)
            {
                // Separator panel
                var pnlSeparator = new Panel();
                pnlSeparator.ID       = "separatorPanel" + i;
                pnlSeparator.CssClass = "install-step-icon-separator";
                pnlHeaderImages.Controls.Add(pnlSeparator);

                // Separator icon
                var separatorIcon = new CMSIcon();
                separatorIcon.CssClass = "icon-arrow-right cms-icon-150";
                separatorIcon.Attributes.Add("aria-hidden", "true");
                pnlSeparator.Controls.Add(separatorIcon);
            }
        }

        var currentStepIndex = wzdInstaller.ActiveStepIndex;

        switch (index)
        {
        // SQL server and authentication mode
        case 0:
            lblHeader.Text += GetString("separationDB.Step0");
            SetSelectedCSSClass("stepPanel0");
            break;

        // Database
        case 1:
        case COLLATION_DIALOG_INDEX:
            lblHeader.Text += ResHelper.GetFileString("separationDB.Step1");
            SetSelectedCSSClass("stepPanel1");
            currentStepIndex = 1;
            break;

        // Separation
        case 2:
            StartHelp.Visible = Help.Visible = false;
            lblHeader.Text   += ResHelper.GetFileString("separationDB.Step2");
            SetSelectedCSSClass("stepPanel2");
            break;

        // Finish step
        case 3:
            lblHeader.Text += ResHelper.GetFileString("Install.Step7");
            SetSelectedCSSClass("stepPanel3");
            break;
        }

        lblHeader.Text = string.Format(lblHeader.Text, currentStepIndex + 1);
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // For up to 10 Gateways edit all on one page, hide UniGrid
        if (GatewayCount <= 10)
        {
            gridGateways.StopProcessing = true;
            pnlGrid.Visible             = false;
            string heading;
            string gatewayLbl = GetString("notification.template.gateway");
            bool   isRTL      = CultureHelper.IsCultureRTL(MembershipContext.AuthenticatedUser.PreferredUICultureCode);

            // Generate controls
            foreach (NotificationGatewayInfo info in mDsGateways)
            {
                if (isRTL)
                {
                    heading = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(info.GatewayDisplayName)) + gatewayLbl;
                }
                else
                {
                    heading = String.Format("{0}: {1}", gatewayLbl, HTMLHelper.HTMLEncode(ResHelper.LocalizeString(info.GatewayDisplayName)));
                }
                var headingControl = new LocalizedHeading()
                {
                    Level = 4,
                    Text  = heading
                };

                Panel pnlGrouping = new Panel();
                pnlGrouping.Controls.Add(headingControl);

                TemplateTextEdit ctrl = Page.LoadUserControl("~/CMSModules/Notifications/Controls/TemplateTextEdit.ascx") as TemplateTextEdit;
                if (ctrl != null)
                {
                    ctrl.ID         = "templateEdit" + info.GatewayID;
                    ctrl.TemplateID = TemplateID;
                    ctrl.GatewayID  = info.GatewayID;

                    // Add gateway edit control to the container panel
                    pnlGrouping.Controls.Add(ctrl);
                    plcTexts.Controls.Add(pnlGrouping);
                }
            }
        }
        else
        {
            // Hook event handlers
            gridGateways.OnExternalDataBound += gridGateways_OnExternalDataBound;
            gridGateways.OnAction            += gridGateways_OnAction;
        }
    }
    /// <summary>
    /// Restores set of given version histories.
    /// </summary>
    /// <param name="recycleBin">DataSet with nodes to restore</param>
    /// <param name="action">Action to be performed</param>
    private void RestoreDataSet(DataSet recycleBin, Action action)
    {
        // Result flags
        bool resultOK = true;

        if (!DataHelper.DataSourceIsEmpty(recycleBin))
        {
            // Restore all objects
            foreach (DataRow dataRow in recycleBin.Tables[0].Rows)
            {
                int versionId = ValidationHelper.GetInteger(dataRow["VersionID"], 0);

                // Log current event
                string taskTitle = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ValidationHelper.GetString(dataRow["VersionObjectDisplayName"], string.Empty)));

                // Restore object
                if (versionId > 0)
                {
                    GeneralizedInfo restoredObj = null;
                    try
                    {
                        switch (action)
                        {
                        case Action.Restore:
                            restoredObj = ObjectVersionManager.RestoreObject(versionId, true);
                            break;

                        case Action.RestoreToCurrentSite:
                            restoredObj = ObjectVersionManager.RestoreObject(versionId, SiteContext.CurrentSiteID);
                            break;

                        case Action.RestoreWithoutSiteBindings:
                            restoredObj = ObjectVersionManager.RestoreObject(versionId, 0);
                            break;
                        }
                    }
                    catch (CodeNameNotUniqueException ex)
                    {
                        CurrentError = String.Format(GetString("objectversioning.restorenotuniquecodename"), (ex.Object != null) ? "('" + ex.Object.ObjectCodeName + "')" : null);
                        AddLog(CurrentError);
                    }

                    if (restoredObj != null)
                    {
                        AddLog(ResHelper.GetString("general.object", mCurrentCulture) + " '" + taskTitle + "'");
                    }
                    else
                    {
                        // Set result flag
                        if (resultOK)
                        {
                            resultOK = false;
                        }
                    }
                }
            }
        }

        if (resultOK)
        {
            CurrentInfo = ResHelper.GetString("ObjectVersioning.Recyclebin.RestorationOK", mCurrentCulture);
            AddLog(CurrentInfo);
        }
        else
        {
            CurrentError = ResHelper.GetString("objectversioning.recyclebin.restorationfailed", mCurrentCulture);
            AddLog(CurrentError);
        }
    }
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void ugRecycleBin_OnAction(string actionName, object actionArgument)
    {
        int versionHistoryId = ValidationHelper.GetInteger(actionArgument, 0);

        actionName = actionName.ToLowerCSafe();

        switch (actionName)
        {
        case "restorechilds":
        case "restorewithoutbindings":
        case "restorecurrentsite":
            try
            {
                if (MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.globalpermissions", "RestoreObjects"))
                {
                    switch (actionName)
                    {
                    case "restorechilds":
                        ObjectVersionManager.RestoreObject(versionHistoryId, true);
                        break;

                    case "restorewithoutbindings":
                        ObjectVersionManager.RestoreObject(versionHistoryId, 0);
                        break;

                    case "restorecurrentsite":
                        ObjectVersionManager.RestoreObject(versionHistoryId, SiteContext.CurrentSiteID);
                        break;
                    }

                    ShowConfirmation(GetString("ObjectVersioning.Recyclebin.RestorationOK"));
                }
                else
                {
                    ShowError(ResHelper.GetString("objectversioning.recyclebin.restorationfailedpermissions"));
                }
            }
            catch (CodeNameNotUniqueException ex)
            {
                ShowError(String.Format(GetString("objectversioning.restorenotuniquecodename"), (ex.Object != null) ? "('" + ex.Object.ObjectCodeName + "')" : null));
            }
            catch (Exception ex)
            {
                ShowError(GetString("objectversioning.recyclebin.restorationfailed") + GetString("general.seeeventlog"));

                // Log to event log
                LogException("OBJECTRESTORE", ex);
            }
            break;

        case "destroy":
            ObjectVersionHistoryInfo verInfo = ObjectVersionHistoryInfo.Provider.Get(versionHistoryId);
            if (verInfo != null)
            {
                // Get object site name
                string siteName = (CurrentSite != null) ? CurrentSite.SiteName : SiteInfoProvider.GetSiteName(verInfo.VersionObjectSiteID);

                if (CurrentUser.IsAuthorizedPerObject(PermissionsEnum.Destroy, verInfo.VersionObjectType, siteName))
                {
                    ObjectVersionManager.DestroyObjectHistory(verInfo.VersionObjectType, verInfo.VersionObjectID);
                    ShowConfirmation(GetString("ObjectVersioning.Recyclebin.DestroyOK"));
                }
                else
                {
                    ShowError(String.Format(ResHelper.GetString("objectversioning.recyclebin.destructionfailedpermissions"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(verInfo.VersionObjectDisplayName))));
                }
            }
            break;
        }

        ugRecycleBin.ResetSelection();
    }
Ejemplo n.º 6
0
 /// <summary>
 /// Displays info label about the winner of the test.
 /// </summary>
 /// <param name="winner">AB test winner</param>
 private void DisplayWinnerInformation(ABVariantInfo winner)
 {
     ShowInformation(String.Format(GetString("abtesting.winningvariantselected"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(winner.ABVariantDisplayName))));
 }
Ejemplo n.º 7
0
    protected TreeNode Tree_OnNodeCreated(DataRow itemData, TreeNode defaultNode)
    {
        if (itemData != null)
        {
            if (MembershipContext.AuthenticatedUser != null)
            {
                SettingsCategoryInfo category = new SettingsCategoryInfo(itemData);

                string currentIdPath = category.CategoryIDPath;

                defaultNode.Expanded = category.CategoryParentID == 0 ? true : defaultNode.Expanded;

                if (!String.IsNullOrEmpty(mExpandedPaths) || (ModuleID > 0))
                {
                    bool selected = false;

                    foreach (string idPath in mExpandedPaths.Split(';'))
                    {
                        if (idPath == currentIdPath)
                        {
                            // End node
                            defaultNode.Expanded = true;

                            defaultNode.Text = defaultNode.Text.Replace("##NAMECSSCLASS##", "highlighted ");
                            selected         = true;
                            break;
                        }

                        if (currentIdPath.StartsWith(idPath, StringComparison.Ordinal) && (ModuleID == category.CategoryResourceID))
                        {
                            // Child node
                            defaultNode.Expanded = true;
                            defaultNode.Text     = defaultNode.Text.Replace("##NAMECSSCLASS##", "");
                            selected             = true;
                            break;
                        }

                        if (idPath.StartsWith(currentIdPath, StringComparison.Ordinal))
                        {
                            // Parent node
                            defaultNode.Expanded = true;
                            defaultNode.Text     = defaultNode.Text.Replace("##NAMECSSCLASS##", "highlighted" + (SystemContext.DevelopmentMode ? "" : " disabled"));
                            selected             = true;
                            break;
                        }
                    }

                    if (!defaultNode.Expanded.Value || String.IsNullOrEmpty(mExpandedPaths) || !selected)
                    {
                        // Nodes which doesn't belong to selected module have no current module's group
                        defaultNode.Text = defaultNode.Text.Replace("##NAMECSSCLASS##", SystemContext.DevelopmentMode ? "" : "disabled");
                    }
                }
                else
                {
                    // Keep everything same as before and remove css class macro
                    defaultNode.Text = defaultNode.Text.Replace("##NAMECSSCLASS##", "");

                    if (RootCategory.CategoryIDPath == currentIdPath)
                    {
                        // Expand root node
                        defaultNode.Expanded = true;
                    }
                }

                defaultNode.Text = defaultNode.Text.Replace("##NODECUSTOMNAME##", HTMLHelper.HTMLEncode(ResHelper.LocalizeString(category.CategoryDisplayName)));
                defaultNode.Text = defaultNode.Text.Replace("##NODECODENAME##", HTMLHelper.HTMLEncode(category.CategoryName));
                defaultNode.Text = defaultNode.Text.Replace("##SITEID##", SiteID.ToString());
                defaultNode.Text = defaultNode.Text.Replace("##PARENTID##", category.CategoryParentID.ToString());
                defaultNode.Text = defaultNode.Text.Replace("##RESOURCEID##", category.CategoryResourceID.ToString());

                if (OnNodeCreated != null)
                {
                    return(OnNodeCreated(category, defaultNode));
                }

                return(defaultNode);
            }
        }

        return(null);
    }
    /// <summary>
    /// External data binding handler.
    /// </summary>
    private object Control_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        bool running;

        switch (sourceName.ToLowerCSafe())
        {
        case "openlivesite":
        {
            // Open live site action
            DataRowView row = (DataRowView)((GridViewRow)parameter).DataItem;
            running = SiteIsRunning(row["SiteStatus"]);
            if (!running)
            {
                var button = ((CMSGridActionButton)sender);
                button.Enabled = false;
            }
        }
        break;

        case "sitestatus":
            // Colorize site status
        {
            DataRowView row = (DataRowView)parameter;
            running = SiteIsRunning(row["SiteStatus"]);
            bool offline = ValidationHelper.GetBoolean(row["SiteIsOffline"], false);

            if (running)
            {
                if (offline)
                {
                    return(UniGridFunctions.SpanMsg(ResHelper.GetString("Site_List.Offline"), "SiteStatusOffline"));
                }
                else
                {
                    return(UniGridFunctions.SpanMsg(ResHelper.GetString("Site_List.Running"), "SiteStatusRunning"));
                }
            }
            else
            {
                return(UniGridFunctions.SpanMsg(ResHelper.GetString("Site_List.Stopped"), "SiteStatusStopped"));
            }
        }

        case "culture":
            // Culture with flag
        {
            DataRowView row         = (DataRowView)parameter;
            string      siteName    = ValidationHelper.GetString(row["SiteName"], "");
            string      cultureCode = CultureHelper.GetDefaultCultureCode(siteName);
            return(UniGridFunctions.DocumentCultureFlag(cultureCode, null, Control.Page));
        }

        case "start":
        {
            // Start action
            DataRowView row = (DataRowView)((GridViewRow)parameter).DataItem;
            running = SiteIsRunning(row["SiteStatus"]);
            ((CMSGridActionButton)sender).Visible = !running;
        }
        break;

        case "stop":
        {
            // Stop action
            DataRowView row = (DataRowView)((GridViewRow)parameter).DataItem;
            running = SiteIsRunning(row["SiteStatus"]);
            ((CMSGridActionButton)sender).Visible = running;
        }
        break;
        }

        return(parameter);
    }
Ejemplo n.º 9
0
    /// <summary>
    /// OnNodeCreated event handler.
    /// </summary>
    TreeNode uniTree_OnNodeCreated(DataRow itemData, TreeNode defaultNode)
    {
        bool isChild = false;
        bool disable = false;

        UIElementInfo ui = new UIElementInfo(itemData);

        string[] paths    = ContentTree.ExpandPath.ToLowerCSafe().Split(';');
        string   nodePath = ui.ElementIDPath;

        if (!nodePath.EndsWith("/", StringComparison.Ordinal))
        {
            nodePath += "/";
        }

        string cssClass = null;

        // Check expanded paths
        foreach (string t in paths)
        {
            var path = t;
            if (path != String.Empty)
            {
                // Add slash - select only children
                if (!path.EndsWith("/", StringComparison.Ordinal))
                {
                    path += "/";
                }

                if (!isChild)
                {
                    isChild = nodePath.StartsWith(path, StringComparison.InvariantCulture);
                }

                cssClass = " highlighted";

                if ((path.StartsWithCSafe(nodePath)))
                {
                    defaultNode.Expanded = true;
                    break;
                }
            }
        }

        // ResourceID
        if ((ModuleId != 0) && (ModuleId != ui.ElementResourceID))
        {
            disable = true;
        }

        string displayName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ui.ElementDisplayName));

        // Get tree icon
        string icon = UIHelper.GetAccessibleImageMarkup(this, ui.ElementIconClass, ui.ElementIconPath, size: FontIconSizeEnum.Standard);

        if (disable)
        {
            cssClass = " disabled";

            // Expanded node = different module, but parent from module nodes
            if (!isChild && ((defaultNode.Expanded != null) && defaultNode.Expanded.Value))
            {
                cssClass += " highlighted";
            }
        }

        // Ensure default template
        defaultNode.Text = String.Format("<span class=\"ContentTreeItem{5}\" id=\"node_{0}\" onclick=\"SelectNode({0},{1},{2}, true); return false;\" name=\"treeNode\">{4}<span class=\"Name\">{3}</span></span>",
                                         ui.ElementID, ui.ElementParentID, ui.ElementResourceID, displayName, icon, cssClass);

        return(defaultNode);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // If StopProcessing flag is set, do nothing
        if (StopProcessing)
        {
            Visible = false;
            return;
        }

        string   subscriptionHash = QueryHelper.GetString("subscriptionhash", string.Empty);
        string   requestTime      = QueryHelper.GetString("datetime", string.Empty);
        DateTime datetime         = DateTimeHelper.ZERO_TIME;

        // Get date and time
        if (!string.IsNullOrEmpty(requestTime))
        {
            try
            {
                datetime = DateTime.ParseExact(requestTime, SecurityHelper.EMAIL_CONFIRMATION_DATETIME_FORMAT, null);
            }
            catch
            {
                lblInfo.Text = ResHelper.GetString("newsletter.approval_failed");
                return;
            }
        }

        if (string.IsNullOrEmpty(subscriptionHash))
        {
            Visible = false;
            return;
        }

        var approvalService = Service <ISubscriptionApprovalService> .Entry();

        var result = approvalService.ApproveSubscription(subscriptionHash, false, SiteContext.CurrentSiteName, datetime);

        switch (result)
        {
        case ApprovalResult.Success:
            lblInfo.Text = !String.IsNullOrEmpty(SuccessfulApprovalText) ? SuccessfulApprovalText : ResHelper.GetString("newsletter.successful_approval");

            var subscription = SubscriberNewsletterInfoProvider.GetSubscriberNewsletterInfo(subscriptionHash);
            if (subscription == null)
            {
                return;
            }

            var newsletter = NewsletterInfoProvider.GetNewsletterInfo(subscription.NewsletterID);
            var subscriber = SubscriberInfoProvider.GetSubscriberInfo(subscription.SubscriberID);

            if ((newsletter == null) || (subscriber == null))
            {
                return;
            }

            LogNewsletterSubscriptionActivity(subscriber, newsletter);
            break;

        case ApprovalResult.Failed:
            lblInfo.Text = !String.IsNullOrEmpty(UnsuccessfulApprovalText) ? UnsuccessfulApprovalText : ResHelper.GetString("newsletter.approval_failed");
            break;

        case ApprovalResult.TimeExceeded:
            lblInfo.Text = !String.IsNullOrEmpty(UnsuccessfulApprovalText) ? UnsuccessfulApprovalText : ResHelper.GetString("newsletter.approval_timeexceeded");
            break;

        case ApprovalResult.AlreadyApproved:
            lblInfo.Text = !String.IsNullOrEmpty(SuccessfulApprovalText) ? SuccessfulApprovalText : ResHelper.GetString("newsletter.successful_approval");
            break;

        // Subscription not found
        default:
            lblInfo.Text = !String.IsNullOrEmpty(UnsuccessfulApprovalText) ? UnsuccessfulApprovalText : ResHelper.GetString("newsletter.approval_invalid");
            break;
        }
    }
Ejemplo n.º 11
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void Control_OnAction(string actionName, object actionArgument)
    {
        SiteInfo si = SiteInfoProvider.GetSiteInfo(ValidationHelper.GetInteger(actionArgument, 0));

        if (si != null)
        {
            string siteName = si.SiteName;

            switch (actionName)
            {
            case "delete":
                URLHelper.Redirect("~/CMSModules/Sites/Pages/site_delete.aspx?siteid=" + actionArgument);
                break;

            case "editContent":
            {
                // Build URL for site in format 'http(s)://sitedomain/application/admin'
                string sitedomain  = si.DomainName.TrimEnd('/');
                string application = null;

                // Support of multiple web sites on single domain
                if (!sitedomain.Contains("/"))
                {
                    application = URLHelper.ResolveUrl("~/.").TrimEnd('/');
                }

                // Application includes string '/admin'.
                application += "/admin/";
                string url = RequestContext.CurrentScheme + "://" + sitedomain + application;
                ScriptHelper.RegisterStartupScript(Control.Page, typeof(string), "EditContentScript", ScriptHelper.GetScript("window.open('" + url + "');"));
            }
            break;

            case "openLiveSite":
            {
                // Make url for site in form 'http(s)://sitedomain/application'.
                string sitedomain = si.DomainName.TrimEnd('/');

                string application = null;
                // Support of multiple web sites on single domain
                if (!sitedomain.Contains("/"))
                {
                    application = URLHelper.ResolveUrl("~/.").TrimEnd('/');
                }
                string url = RequestContext.CurrentScheme + "://" + sitedomain + application + "/";
                ScriptHelper.RegisterStartupScript(Control.Page, typeof(string), "OpenLiveSiteScript", ScriptHelper.GetScript("window.open('" + url + "');"));
            }
            break;

            case "start":
                try
                {
                    SiteInfoProvider.RunSite(siteName);
                }
                catch (Exception ex)
                {
                    Control.ShowError(ResHelper.GetString("Site_List.ErrorMsg"), ex.Message, null);
                }
                break;

            case "stop":
                SiteInfoProvider.StopSite(siteName);
                SessionManager.Clear(siteName);
                break;

            case "export":
                URLHelper.Redirect(URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ModuleName.CMS, "Export", false), "siteID=" + actionArgument));
                break;
            }
        }
    }
Ejemplo n.º 12
0
    protected object listElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        CMSGridActionButton btn;

        switch (sourceName.ToLowerCSafe())
        {
        // Delete action
        case "delete":
            btn = (CMSGridActionButton)sender;
            btn.OnClientClick = "if(!confirm(" + ScriptHelper.GetString(String.Format(ResHelper.GetString("autoMenu.RemoveStateConfirmation"), HTMLHelper.HTMLEncode(TypeHelper.GetNiceObjectTypeName(ContactInfo.OBJECT_TYPE).ToLowerCSafe()))) + ")) { return false; }" + btn.OnClientClick;
            if (!WorkflowStepInfoProvider.CanUserRemoveAutomationProcess(CurrentUser, SiteContext.CurrentSiteName))
            {
                if (btn != null)
                {
                    btn.Enabled = false;
                }
            }
            break;

        case "view":
            btn = (CMSGridActionButton)sender;
            // Ensure accountID parameter value;
            var objectID = ValidationHelper.GetInteger(btn.CommandArgument, 0);
            // Contact detail URL
            string contactURL = ApplicationUrlHelper.GetElementDialogUrl(ModuleName.CONTACTMANAGEMENT, "EditContact", objectID);
            // Add modal dialog script to onClick action
            btn.OnClientClick = ScriptHelper.GetModalDialogScript(contactURL, "ContactDetail");
            break;

        // Process status column
        case "statestatus":
            return(AutomationHelper.GetProcessStatus((ProcessStatusEnum)ValidationHelper.GetInteger(parameter, 0)));
        }

        return(null);
    }
Ejemplo n.º 13
0
    /// <summary>
    /// Loads data of specific activity.
    /// </summary>
    protected void LoadData()
    {
        if (activityId <= 0)
        {
            return;
        }

        // Load and check if object exists
        ActivityInfo ai = ActivityInfoProvider.GetActivityInfo(activityId);

        EditedObject = ai;

        ActivityTypeInfo ati = ActivityTypeInfoProvider.GetActivityTypeInfo(ai.ActivityType);

        plcActivityValue.Visible = (ati == null) || ati.ActivityTypeIsCustom || (ati.ActivityTypeName == PredefinedActivityType.PAGE_VISIT) && !String.IsNullOrEmpty(ai.ActivityValue);

        string dispName = (ati != null ? ati.ActivityTypeDisplayName : GetString("general.na"));

        lblTypeVal.Text    = String.Format("{0}", HTMLHelper.HTMLEncode(dispName));
        lblContactVal.Text = HTMLHelper.HTMLEncode(ContactInfoProvider.GetContactFullName(ai.ActivityActiveContactID));

        // Init contact detail link
        string contactURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", ai.ActivityActiveContactID, "isSiteManager=" + ContactHelper.IsSiteManager);

        btnContact.Attributes.Add("onClick", ScriptHelper.GetModalDialogScript(contactURL, "ContactDetail"));
        btnContact.ToolTip = GetString("om.contact.viewdetail");

        lblDateVal.Text = (ai.ActivityCreated == DateTimeHelper.ZERO_TIME ? GetString("general.na") : HTMLHelper.HTMLEncode(ai.ActivityCreated.ToString()));

        // Get site display name
        string siteName = SiteInfoProvider.GetSiteName(ai.ActivitySiteID);

        if (String.IsNullOrEmpty(siteName))
        {
            siteName = GetString("general.na");
        }
        else
        {
            // Retrieve site info and its display name
            SiteInfo si = SiteInfoProvider.GetSiteInfo(siteName);
            if (si != null)
            {
                siteName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(si.DisplayName));
            }
            else
            {
                siteName = GetString("general.na");
            }
        }
        lblSiteVal.Text = siteName;

        string url = ai.ActivityURL;

        plcCampaign.Visible = !String.IsNullOrEmpty(ai.ActivityCampaign);
        lblCampaignVal.Text = HTMLHelper.HTMLEncode(ai.ActivityCampaign);
        lblValue.Text       = HTMLHelper.HTMLEncode(String.IsNullOrEmpty(ai.ActivityValue) ? GetString("general.na") : ai.ActivityValue);

        // Init textboxes only for the first time
        if (!RequestHelper.IsPostBack())
        {
            txtComment.Value = ai.ActivityComment;
            txtTitle.Text    = ai.ActivityTitle;
            txtURLRef.Text   = ai.ActivityURLReferrer;
            if (ai.ActivityType != PredefinedActivityType.NEWSLETTER_CLICKTHROUGH)
            {
                txtURL.Text = url;
            }
        }

        cDetails.ActivityID = activityId;

        // Init link button URL
        if (ai.ActivitySiteID > 0)
        {
            SiteInfo si = SiteInfoProvider.GetSiteInfo(ai.ActivitySiteID);
            if (si != null)
            {
                // Hide view button if URL is blank
                string activityUrl = ai.ActivityURL;
                if ((activityUrl != null) && !String.IsNullOrEmpty(activityUrl.Trim()))
                {
                    string appUrl = URLHelper.GetApplicationUrl(si.DomainName);
                    url                 = URLHelper.GetAbsoluteUrl(activityUrl, appUrl, appUrl, "");
                    url                 = URLHelper.AddParameterToUrl(url, URLHelper.SYSTEM_QUERY_PARAMETER, "1");
                    btnView.ToolTip     = GetString("general.view");
                    btnView.NavigateUrl = url;
                    btnView.Visible     = true;
                }
                else
                {
                    btnView.Visible = false;
                }
            }
        }
    }
    /// <summary>
    /// Prepares the layout of the web part.
    /// </summary>
    protected override void PrepareLayout()
    {
        StartLayout();

        if (IsDesign)
        {
            Append("<table class=\"LayoutTable\" cellspacing=\"0\" style=\"width: 100%;\">");

            if (ViewModeIsDesign())
            {
                Append("<tr><td class=\"LayoutHeader\">");

                // Add header container
                AddHeaderContainer();

                Append("</td></tr>");
            }

            Append("<tr><td>");
        }

        // Content before zones
        Append(BeforeZones);

        string separator = Separator;
        string before    = BeforeZone;
        string after     = AfterZone;

        string zoneclass = ZoneCSSClass;
        string zonewidth = ZoneWidth;

        // Render the zones
        for (int i = 1; i <= Zones; i++)
        {
            if (i > 1)
            {
                Append(separator);
            }
            Append("<div");

            // Zone class
            if (!String.IsNullOrEmpty(zoneclass))
            {
                Append(" class=\"", zoneclass, "\"");
            }

            // Zone width
            if (!String.IsNullOrEmpty(zonewidth))
            {
                Append(" style=\"width: ", zonewidth, "\";");
            }

            Append(">", before);

            // Add the zone
            CMSWebPartZone zone = AddZone(ID + "_" + i, "[" + i + "]");

            Append(after, "</div>");
        }

        // Content after zones
        Append(AfterZones);

        if (IsDesign)
        {
            Append("</td></tr>");

            // Footer
            if (AllowDesignMode)
            {
                Append("<tr><td class=\"LayoutFooter cms-bootstrap\" colspan=\"2\"><div class=\"LayoutFooterContent\">");

                // Zone actions
                AppendRemoveAction(ResHelper.GetString("Layout.RemoveZone"), "Zones");
                Append("&nbsp;&nbsp;");
                AppendAddAction(ResHelper.GetString("Layout.AddZone"), "Zones");

                Append("</div></td></tr>");
            }

            Append("</table>");
        }

        // Register jQuery
        if (IncludeJQuery)
        {
            ScriptHelper.RegisterJQuery(Page);
        }

        // Register scripts
        string[] scripts = ScriptFiles.Split('\r', '\n');
        foreach (string script in scripts)
        {
            // Register the script file
            string sfile = script.Trim();
            if (!String.IsNullOrEmpty(sfile))
            {
                ScriptHelper.RegisterScriptFile(Page, sfile);
            }
        }

        // Add init script
        string resolvedInitScript = MacroResolver.Resolve(InitScript);

        if (!string.IsNullOrEmpty(resolvedInitScript))
        {
            ScriptHelper.RegisterStartupScript(this, typeof(string), ShortClientID + "_Init", ScriptHelper.GetScript(resolvedInitScript));
        }

        // Register CSS files
        string[] cssFiles = CSSFiles.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
        Array.ForEach(cssFiles, cssFile => CSSHelper.RegisterCSSLink(Page, cssFile.Trim()));

        // Add inline CSS
        string inlinecss = MacroResolver.Resolve(InlineCSS);

        if (!string.IsNullOrEmpty(inlinecss))
        {
            // Add css to page header
            CSSHelper.RegisterCSSBlock(Page, "zonesWithEffectInlineCss_" + ClientID, inlinecss);
        }

        FinishLayout();
    }
Ejemplo n.º 15
0
    private void wzdExport_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
        switch (e.CurrentStepIndex)
        {
        case 0:
            // Apply settings
            if (!configExport.ApplySettings())
            {
                e.Cancel = true;
                return;
            }

            // Update settings
            ExportSettings = configExport.Settings;

            if (!configExport.ExportHistory)
            {
                ltlScriptAfter.Text = ScriptHelper.GetScript(
                    @"var actDiv = document.getElementById('actDiv');
if (actDiv != null) { actDiv.style.display='block'; }
var buttonsDiv = document.getElementById('buttonsDiv');
if (buttonsDiv != null) { buttonsDiv.disabled=true; }
BTN_Disable('" + NextButton.ClientID + @"');
StartSelectionTimer();");

                // Select objects asynchronously
                ctrlAsyncSelection.RunAsync(SelectObjects, WindowsIdentity.GetCurrent());
                e.Cancel = true;
            }
            else
            {
                pnlExport.Settings = ExportSettings;
                pnlExport.ReloadData();

                wzdExport.ActiveStepIndex = e.NextStepIndex;
            }
            break;

        case 1:
            // Apply settings
            if (!pnlExport.ApplySettings())
            {
                e.Cancel = true;
                return;
            }
            ExportSettings = pnlExport.Settings;

            // Delete temporary files
            try
            {
                ExportProvider.DeleteTemporaryFiles(ExportSettings, true);
            }
            catch (Exception ex)
            {
                SetErrorLabel(ex.Message);
                e.Cancel = true;
                return;
            }

            try
            {
                // Save export history
                ExportHistoryInfo history = new ExportHistoryInfo
                {
                    ExportDateTime = DateTime.Now,
                    ExportFileName = ExportSettings.TargetFileName,
                    ExportSettings = ExportSettings.GetXML(),
                    ExportSiteID   = ExportSettings.SiteId,
                    ExportUserID   = MembershipContext.AuthenticatedUser.UserID
                };

                ExportHistoryInfo.Provider.Set(history);
            }
            catch (Exception ex)
            {
                SetErrorLabel(ex.Message);
                pnlError.ToolTip = EventLogProvider.GetExceptionLogMessage(ex);
                e.Cancel         = true;
                return;
            }

            if (ExportSettings.SiteId > 0)
            {
                ExportSettings.EventLogSource = String.Format(ExportSettings.GetAPIString("ExportSite.EventLogSiteSource", "Export '{0}' site"), ResHelper.LocalizeString(ExportSettings.SiteInfo.DisplayName));
            }

            // Start asynchronous export
            var manager = ExportManager;

            ExportSettings.LogContext = ctlAsyncExport.CurrentLog;
            manager.Settings          = ExportSettings;

            ctlAsyncExport.RunAsync(manager.Export, WindowsIdentity.GetCurrent());

            wzdExport.ActiveStepIndex = e.NextStepIndex;

            break;
        }
    }
Ejemplo n.º 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script for pendingCallbacks repair
        ScriptHelper.FixPendingCallbacks(Page);

        if (!RequestHelper.IsCallback())
        {
            if (!RequestHelper.IsPostBack())
            {
                // Initialize deletion info
                DeletionInfo = new DeletionInfo();
                DeletionInfo.PersistentSettingsKey = PersistentSettingsKey;
            }

            DeletionManager.DeletionInfo = DeletionInfo;

            // Register the script to perform get flags for showing buttons retrieval callback
            ScriptHelper.RegisterClientScriptBlock(this, GetType(), "GetState", ScriptHelper.GetScript("function GetState(cancel){ return " + Page.ClientScript.GetCallbackEventReference(this, "cancel", "SetStateMssg", null) + " } \n"));

            // Setup page title text and image
            PageTitle.TitleText = GetString("Site_Edit.DeleteSite");
            backToSiteListUrl   = UIContextHelper.GetElementUrl(ModuleName.CMS, "Sites", false);

            PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem
            {
                Text        = GetString("general.sites"),
                RedirectUrl = backToSiteListUrl,
                Target      = "cmsdesktop",
            });

            PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem
            {
                Text = GetString("Site_Edit.DeleteSite"),
            });

            // Get site ID
            siteId = QueryHelper.GetInteger("siteId", 0);

            si = SiteInfoProvider.GetSiteInfo(siteId);
            if (si != null)
            {
                siteName        = si.SiteName;
                siteDisplayName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(si.DisplayName));

                ucHeader.Header        = string.Format(GetString("Site_Delete.Header"), siteDisplayName);
                ucHeaderConfirm.Header = GetString("Site_Delete.HeaderConfirm");

                // Initialize web root path
                DeletionInfo.WebRootFullPath = HttpContext.Current.Server.MapPath("~/");

                DeletionInfo.DeletionLog = string.Format("I" + SiteDeletionManager.SEPARATOR + DeletionManager.DeletionInfo.GetAPIString("Site_Delete.DeletingSite", "Initializing deletion of the site") + SiteDeletionManager.SEPARATOR + SiteDeletionManager.SEPARATOR, siteName);

                headConfirmation.Text = string.Format(GetString("Site_Edit.Confirmation"), siteDisplayName);
                btnYes.Text           = GetString("General.Yes");
                btnNo.Text            = GetString("General.No");
                btnOk.Text            = GetString("General.OK");
                lblLog.Text           = string.Format(GetString("Site_Delete.DeletingSite"), siteDisplayName);
            }

            btnYes.Click += btnYes_Click;
            btnNo.Click  += btnNo_Click;
            btnOk.Click  += btnOK_Click;

            // Javascript functions
            string script =
                "function SetStateMssg(rValue, context) \n" +
                "{\n" +
                "   var values = rValue.split('<#>');\n" +
                "   if((values[0]=='E') || (values[0]=='F') || values=='')\n" +
                "   {\n" +
                "       StopStateTimer();\n" +
                "       var actDiv = document.getElementById('actDiv');\n" +
                "       if (actDiv != null) { actDiv.style.display = 'none'; }\n" +
                "       BTN_Enable('" + btnOk.ClientID + "');\n" +
                "   }\n" +
                "   if((values[0]=='E') && values[2] && (values[2].length > 0))\n" +
                "   {\n" +
                "       document.getElementById('" + lblError.ClientID + "').innerHTML = values[2];\n" +
                "       document.getElementById('" + pnlError.ClientID + "').style.removeProperty('display');\n" +
                "   }\n" +
                "   else if(values[0]=='I')\n" +
                "   {\n" +
                "       document.getElementById('" + lblLog.ClientID + "').innerHTML = values[1];\n" +
                "   }\n" +
                "   else if((values=='') || (values[0]=='F'))\n" +
                "   {\n" +
                "       document.getElementById('" + lblLog.ClientID + "').innerHTML = values[1];\n" +
                "   }\n" +
                "   if (values[3] && (values[3].length > 0))\n" +
                "   {\n" +
                "       document.getElementById('" + lblWarning.ClientID + "').innerHTML = values[3];\n" +
                "       document.getElementById('" + pnlWarning.ClientID + "').style.removeProperty('display');\n" +
                "   }\n" +
                "}\n";

            // Register the script to perform get flags for showing buttons retrieval callback
            ScriptHelper.RegisterClientScriptBlock(this, GetType(), "GetDeletionState", ScriptHelper.GetScript(script));
        }
    }
Ejemplo n.º 17
0
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        if (!RequestHelper.IsPostBack())
        {
            return(string.Empty);
        }

        // Handle the grid action first because it doesn't require access to VariantsStatisticsData
        if (sourceName == "selectwinner")
        {
            var gridViewRow = parameter as GridViewRow;
            if (gridViewRow != null)
            {
                var dataRowView = gridViewRow.DataItem as DataRowView;
                if (dataRowView != null)
                {
                    var img = sender as CMSGridActionButton;
                    if (img != null)
                    {
                        // Check permissions to select winner
                        if (!IsUserAuthorizedToManageTest)
                        {
                            img.Enabled = false;
                            img.ToolTip = GetString("abtesting.selectwinner.permission.tooltip");
                        }
                        else
                        {
                            var winner = GetTestWinner();
                            if (winner != null)
                            {
                                string variantName = (ValidationHelper.GetString(dataRowView["ABVariantName"], ""));
                                if (variantName == winner.ABVariantName)
                                {
                                    // Disable action image for the winning variant
                                    img.Enabled = false;
                                }
                                else
                                {
                                    // Hide action image for other variants
                                    img.Visible = false;
                                }
                            }
                        }
                    }
                }
            }
            return(string.Empty);
        }

        string currentVariantName = parameter.ToString();

        if (String.IsNullOrEmpty(currentVariantName) || (OriginalVariant == null) || !VariantsStatisticsData.ContainsKey(currentVariantName))
        {
            return(string.Empty);
        }

        var variantData = VariantsStatisticsData[currentVariantName];

        switch (sourceName)
        {
        case "name":
            var variant = ABVariants.FirstOrDefault(v => v.ABVariantName == currentVariantName);
            if (variant != null)
            {
                var link = new HtmlAnchor();
                link.InnerText = ResHelper.LocalizeString(variant.ABVariantDisplayName);
                link.HRef      = DocumentURLProvider.GetUrl(variant.ABVariantPath);
                link.Target    = "_blank";
                return(link);
            }
            break;

        case METRIC_CONVERSIONS_OVER_VISITS:
            return(variantData.ConversionsCount + " / " + variantData.Visits);

        case METRIC_CHANCE_TO_BEAT_ORIGINAL:
            if ((currentVariantName != OriginalVariant.ABVariantName) && (VariantPerformanceCalculator != null) && (variantData.Visits > 0))
            {
                double chanceToBeatOriginal = VariantPerformanceCalculator.GetChanceToBeatOriginal(variantData.ConversionsCount, variantData.Visits);

                // Check whether the variant is most probably winning already and mark the row green
                if ((chanceToBeatOriginal >= WINNING_VARIANT_MIN_CHANCETOBEAT) && (variantData.ConversionsCount >= WINNING_VARIANT_MIN_CONVERSIONS))
                {
                    AddCSSToParentControl(sender as WebControl, "winning-variant-row");
                }

                return(String.Format("{0:P2}", chanceToBeatOriginal));
            }
            break;

        case METRIC_CONVERSION_RATE:
            if ((VariantPerformanceCalculator != null) && (variantData.Visits > 0) &&
                ABConversionRateIntervals.ContainsKey(currentVariantName) && ABConversionRateIntervals.ContainsKey(OriginalVariant.ABVariantName))
            {
                // Render the picture representing how the challenger variant is performing against the original variant
                return(new ABConversionRateIntervalVisualizer(
                           mMinConversionRateLowerBound, mConversionRateRange, ABConversionRateIntervals[currentVariantName], ABConversionRateIntervals[OriginalVariant.ABVariantName]));
            }
            break;

        case METRIC_CONVERSION_VALUE:
            return(variantData.ConversionsValue);

        case METRIC_AVG_CONVERSION_VALUE:
            return(String.Format("{0:#.##}", variantData.AverageConversionValue));

        case "improvement":
            if ((currentVariantName != OriginalVariant.ABVariantName) && VariantsStatisticsData.ContainsKey(OriginalVariant.ABVariantName))
            {
                var originalData = VariantsStatisticsData[OriginalVariant.ABVariantName];
                switch (drpSuccessMetric.SelectedValue)
                {
                case METRIC_CONVERSION_COUNT:
                    if (!originalData.ConversionsCount.Equals(0))
                    {
                        return(GetPercentageImprovementPanel((variantData.ConversionsCount / (double)originalData.ConversionsCount) - 1));
                    }
                    break;

                case METRIC_CONVERSION_VALUE:
                    if (!originalData.ConversionsValue.Equals(0))
                    {
                        return(GetPercentageImprovementPanel((variantData.ConversionsValue / originalData.ConversionsValue) - 1));
                    }
                    break;

                case METRIC_CONVERSION_RATE:
                    if (!originalData.ConversionRate.Equals(0))
                    {
                        return(GetPercentageImprovementPanel((variantData.ConversionRate / originalData.ConversionRate) - 1));
                    }
                    break;

                case METRIC_AVG_CONVERSION_VALUE:
                    if (!originalData.AverageConversionValue.Equals(0))
                    {
                        return(GetPercentageImprovementPanel((variantData.AverageConversionValue / originalData.AverageConversionValue) - 1));
                    }
                    break;
                }
            }
            break;
        }

        return(string.Empty);
    }
 /// <summary>
 /// Gets resource string.
 /// </summary>
 /// <param name="stringKey">Resource string key.</param>
 private string GetString(string stringKey)
 {
     return(ResHelper.GetString(stringKey));
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Adds the "Select as winner" option for each variant of the test.
 /// </summary>
 /// <param name="actions">Header actions list to be filled</param>
 private void AddSelectAsWinnerOptions(List <HeaderAction> actions)
 {
     foreach (var variant in ABVariants)
     {
         actions.Add(new HeaderAction
         {
             Text            = String.Format(GetString("abtesting.selectvariantaswinner"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(variant.ABVariantDisplayName))),
             Tooltip         = String.Format(GetString("abtesting.selectvariantaswinner.tooltip"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(variant.ABVariantDisplayName))),
             CommandName     = "selectwinner",
             CommandArgument = variant.ABVariantName,
             OnClientClick   = "return confirm('" + String.Format(GetString("abtesting.winnerselectionconfirmation"), ScriptHelper.GetString(ResHelper.LocalizeString(variant.ABVariantDisplayName), false)) + "');",
             Enabled         = IsUserAuthorizedToManageTest
         });
     }
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Generate info text for given setting key
 /// </summary>
 /// <param name="ski">Setting key object</param>
 private String GenerateInfoText(SettingsKeyInfo ski)
 {
     return(String.Format(GetString(InfoTextResourceString), ResHelper.GetString(ski.KeyDisplayName)));
 }
    /// <summary>
    /// Restores objects selected in UniGrid.
    /// </summary>
    private void Restore(BinSettingsContainer settings, Action action)
    {
        try
        {
            // Begin log
            AddLog(ResHelper.GetString("objectversioning.recyclebin.restoringobjects", mCurrentCulture));

            if (settings.User.IsAuthorizedPerResource("cms.globalpermissions", "RestoreObjects"))
            {
                DataSet recycleBin = GetRecycleBinSeletedItems(settings, "VersionID, VersionObjectDisplayName, VersionObjectType, VersionObjectID");

                if (!DataHelper.DataSourceIsEmpty(recycleBin))
                {
                    RestoreDataSet(recycleBin, action);
                }
            }
            else
            {
                CurrentError = ResHelper.GetString("objectversioning.recyclebin.restorationfailedpermissions");
                AddLog(CurrentError);
            }
        }
        catch (ThreadAbortException ex)
        {
            if (CMSThread.Stopped(ex))
            {
                // When canceled
                CurrentInfo = ResHelper.GetString("Recyclebin.RestorationCanceled", mCurrentCulture);
                AddLog(CurrentInfo);
            }
            else
            {
                // Log error
                CurrentError = ResHelper.GetString("objectversioning.recyclebin.restorationfailed", mCurrentCulture) + ": " + ResHelper.GetString("general.seeeventlog", mCurrentCulture);
                AddLog(CurrentError);

                // Log to event log
                LogException("OBJECTRESTORE", ex);
            }
        }
        catch (Exception ex)
        {
            // Log error
            CurrentError = ResHelper.GetString("objectversioning.recyclebin.restorationfailed", mCurrentCulture) + ": " + ResHelper.GetString("general.seeeventlog", mCurrentCulture);
            AddLog(CurrentError);

            // Log to event log
            LogException("OBJECTRESTORE", ex);
        }
    }
Ejemplo n.º 22
0
    /// <summary>
    /// Validates the form. If validation succeeds returns true, otherwise returns false.
    /// </summary>
    private bool Validate()
    {
        DateTime from = ValidationHelper.GetDateTime(form.GetFieldValue("MVTestOpenFrom"), DateTimeHelper.ZERO_TIME);
        DateTime to   = ValidationHelper.GetDateTime(form.GetFieldValue("MVTestOpenTo"), DateTimeHelper.ZERO_TIME);

        if (!DateTimeHelper.IsValidFromTo(from, to))
        {
            ShowError(GetString("om.wrongtimeinterval"));
            return(false);
        }

        MVTestInfo info = new MVTestInfo
        {
            MVTestEnabled  = (bool)form.GetFieldValue("MVTestEnabled"),
            MVTestSiteID   = CurrentSite.SiteID,
            MVTestID       = ((MVTestInfo)form.EditedObject).MVTestID,
            MVTestOpenFrom = from,
            MVTestOpenTo   = to,
            MVTestCulture  = (string)form.GetFieldValue("MVTestCulture"),
            MVTestPage     = String.IsNullOrEmpty(QueryHelper.GetString("AliasPath", null)) ? form.GetFieldValue("MVTestPage").ToString() : QueryHelper.GetString("AliasPath", null)
        };

        MVTestInfo conflictingTest = MVTestInfoProvider.GetConflicting(info).FirstOrDefault();

        if (conflictingTest != null)
        {
            ShowError(String.Format(GetString("om.twotestsonepageerror"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(conflictingTest.MVTestDisplayName)), info.MVTestPage));
            return(false);
        }

        return(true);
    }
    /// <summary>
    /// Empties recycle bin.
    /// </summary>
    private void EmptyBin(BinSettingsContainer settings)
    {
        // Begin log
        AddLog(ResHelper.GetString("Recyclebin.EmptyingBin", mCurrentCulture));

        try
        {
            DataSet recycleBin = GetRecycleBinSeletedItems(settings, "VersionID, VersionObjectType, VersionObjectID, VersionObjectDisplayName, VersionObjectSiteID");
            if (!DataHelper.DataSourceIsEmpty(recycleBin))
            {
                foreach (DataRow dr in recycleBin.Tables[0].Rows)
                {
                    string   versionObjType = Convert.ToString(dr["VersionObjectType"]);
                    string   objName        = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ValidationHelper.GetString(dr["VersionObjectDisplayName"], string.Empty)));
                    SiteInfo currentSite    = settings.Site;

                    string siteName;
                    if (currentSite != null)
                    {
                        siteName = currentSite.SiteName;
                    }
                    else
                    {
                        int siteId = ValidationHelper.GetInteger(dr["VersionObjectSiteID"], 0);
                        siteName = SiteInfoProvider.GetSiteName(siteId);
                    }

                    // Check permissions
                    UserInfo currentUserInfo = settings.User;
                    if (!currentUserInfo.IsAuthorizedPerObject(PermissionsEnum.Destroy, versionObjType, siteName))
                    {
                        CurrentError = String.Format(ResHelper.GetString("objectversioning.Recyclebin.DestructionFailedPermissions", mCurrentCulture), objName);
                        AddLog(CurrentError);
                    }
                    else
                    {
                        AddLog(ResHelper.GetString("general.object", mCurrentCulture) + " '" + objName + "'");

                        // Destroy the version
                        int versionObjId = ValidationHelper.GetInteger(dr["VersionObjectID"], 0);
                        ObjectVersionManager.DestroyObjectHistory(versionObjType, versionObjId);
                        LogContext.LogEventToCurrent(EventType.INFORMATION, "Objects", "DESTROYOBJECT", String.Format(ResHelper.GetString("objectversioning.Recyclebin.objectdestroyed"), objName), RequestContext.RawURL, currentUserInfo.UserID, currentUserInfo.UserName, 0, null, RequestContext.UserHostAddress, (currentSite != null) ? currentSite.SiteID : 0, SystemContext.MachineName, RequestContext.URLReferrer, RequestContext.UserAgent, DateTime.Now);
                    }
                }
                if (!String.IsNullOrEmpty(CurrentError))
                {
                    CurrentError = ResHelper.GetString("objectversioning.recyclebin.errorsomenotdestroyed", mCurrentCulture);
                    AddLog(CurrentError);
                }
                else
                {
                    CurrentInfo = ResHelper.GetString("ObjectVersioning.Recyclebin.DestroyOK", mCurrentCulture);
                    AddLog(CurrentInfo);
                }
            }
        }
        catch (ThreadAbortException ex)
        {
            if (!CMSThread.Stopped(ex))
            {
                // Log error
                CurrentError = "Error occurred: " + ResHelper.GetString("general.seeeventlog", mCurrentCulture);
                AddLog(CurrentError);

                // Log to event log
                LogException("EMPTYINGBIN", ex);
            }
        }
        catch (Exception ex)
        {
            // Log error
            CurrentError = "Error occurred: " + ResHelper.GetString("general.seeeventlog", mCurrentCulture);
            AddLog(CurrentError);

            // Log to event log
            LogException("EMPTYINGBIN", ex);
        }
    }
Ejemplo n.º 24
0
    protected override void OnLoad(EventArgs e)
    {
        plImg  = GetImageUrl("CMSModules/CMS_PortalEngine/WebpartProperties/plus.png");
        minImg = GetImageUrl("CMSModules/CMS_PortalEngine/WebpartProperties/minus.png");

        if (WebpartID != String.Empty)
        {
            wpi = WebPartInfoProvider.GetWebPartInfo(WebpartID);
        }


        // Ensure correct view mode
        if (String.IsNullOrEmpty(AliasPath))
        {
            // Ensure the dashboard mode for the dialog
            if (!string.IsNullOrEmpty(DashboardName))
            {
                PortalContext.SetRequestViewMode(ViewModeEnum.DashboardWidgets);
                PortalContext.DashboardName     = DashboardName;
                PortalContext.DashboardSiteName = DashboardSiteName;
            }
            // Ensure the design mode for the dialog
            else
            {
                PortalContext.SetRequestViewMode(ViewModeEnum.Design);
            }
        }

        if (WidgetID != String.Empty)
        {
            PageInfo pi = null;
            try
            {
                // Load page info from alias path and page template
                pi = CMSWebPartPropertiesPage.GetPageInfo(AliasPath, PageTemplateID, CultureCode);
            }
            catch (PageNotFoundException)
            {
                // Do not throw exception if page info not found (e.g. bad alias path)
            }

            if (pi != null)
            {
                PageTemplateInstance templateInstance = CMSPortalManager.GetTemplateInstanceForEditing(pi);

                if (templateInstance != null)
                {
                    // Get the instance of widget
                    WebPartInstance widgetInstance = templateInstance.GetWebPart(InstanceGUID, WidgetID);

                    // Info for zone type
                    WebPartZoneInstance zone = templateInstance.GetZone(ZoneID);

                    if (zone != null)
                    {
                        zoneType = zone.WidgetZoneType;
                    }

                    if (widgetInstance != null)
                    {
                        // Create widget from webpart instance
                        wi = WidgetInfoProvider.GetWidgetInfo(widgetInstance.WebPartType);
                    }
                }
            }

            // If inline widget display columns as in editor zone
            if (IsInline)
            {
                zoneType = WidgetZoneTypeEnum.Editor;
            }


            // If no zone set (only global admins allowed to continue)
            if (zoneType == WidgetZoneTypeEnum.None)
            {
                if (!CMSContext.CurrentUser.UserSiteManagerAdmin)
                {
                    RedirectToAccessDenied(GetString("attach.actiondenied"));
                }
            }

            // If wi is still null (new item f.e.)
            if (wi == null)
            {
                // Try to get widget info directly by ID
                if (!IsNew)
                {
                    wi = WidgetInfoProvider.GetWidgetInfo(WidgetID);
                }
                else
                {
                    wi = WidgetInfoProvider.GetWidgetInfo(ValidationHelper.GetInteger(WidgetID, 0));
                }
            }
        }

        String itemDescription   = String.Empty;
        String itemType          = String.Empty;
        String itemDisplayName   = String.Empty;
        String itemDocumentation = String.Empty;
        int    itemID            = 0;

        // Check whether webpart was found
        if (wpi != null)
        {
            itemDescription   = wpi.WebPartDescription;
            itemType          = PortalObjectType.WEBPART;
            itemID            = wpi.WebPartID;
            itemDisplayName   = wpi.WebPartDisplayName;
            itemDocumentation = wpi.WebPartDocumentation;
        }
        // Or widget was found
        else if (wi != null)
        {
            itemDescription   = wi.WidgetDescription;
            itemType          = PortalObjectType.WIDGET;
            itemID            = wi.WidgetID;
            itemDisplayName   = wi.WidgetDisplayName;
            itemDocumentation = wi.WidgetDocumentation;
        }

        if ((wpi != null) || (wi != null))
        {
            // Get WebPart (widget) image
            DataSet ds = MetaFileInfoProvider.GetMetaFiles(itemID, itemType);

            // Set image url of exists
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                MetaFileInfo mtfi = new MetaFileInfo(ds.Tables[0].Rows[0]);
                if (mtfi != null)
                {
                    if (mtfi.MetaFileImageWidth > 385)
                    {
                        imgTeaser.Width = 385;
                    }

                    imgTeaser.ImageUrl = ResolveUrl("~/CMSPages/GetMetaFile.aspx?fileguid=" + mtfi.MetaFileGUID.ToString());
                }
            }
            else
            {
                // Set default image
                imgTeaser.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/WebpartProperties/imagenotavailable.png");
            }

            // Additional image information
            imgTeaser.ToolTip       = HTMLHelper.HTMLEncode(itemDisplayName);
            imgTeaser.AlternateText = HTMLHelper.HTMLEncode(itemDisplayName);

            // Set description of webpart
            ltlDescription.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(itemDescription));

            // Get description from parent weboart if webpart is inherited
            if ((wpi != null) && (string.IsNullOrEmpty(wpi.WebPartDescription) && (wpi.WebPartParentID > 0)))
            {
                WebPartInfo pwpi = WebPartInfoProvider.GetWebPartInfo(wpi.WebPartParentID);
                if (pwpi != null)
                {
                    ltlDescription.Text = HTMLHelper.HTMLEncode(pwpi.WebPartDescription);
                }
            }

            FormInfo fi = null;

            // Generate properties
            if (wpi != null)
            {
                // Get form info from parent if webpart is inherited
                if (wpi.WebPartParentID != 0)
                {
                    WebPartInfo pwpi = WebPartInfoProvider.GetWebPartInfo(wpi.WebPartParentID);
                    if (pwpi != null)
                    {
                        fi = GetWebPartProperties(pwpi);
                    }
                }
                else
                {
                    fi = GetWebPartProperties(wpi);
                }
            }
            else if (wi != null)
            {
                fi = GetWidgetProperties(wi);
            }

            // Generate properties
            if (fi != null)
            {
                GenerateProperties(fi);
            }

            // Generate documentation text
            if (itemDocumentation == null || itemDocumentation.Trim() == "")
            {
                if ((wpi != null) && (wpi.WebPartParentID != 0))
                {
                    WebPartInfo pwpi = WebPartInfoProvider.GetWebPartInfo(wpi.WebPartParentID);
                    if (pwpi != null && pwpi.WebPartDocumentation.Trim() != "")
                    {
                        ltlContent.Text = HTMLHelper.ResolveUrls(pwpi.WebPartDocumentation, null);
                    }
                    else
                    {
                        ltlContent.Text = "<br /><div style=\"padding-left:5px; font-weight: bold;\">" + GetString("WebPartDocumentation.DocumentationText") + "</div><br />";
                    }
                }
                else
                {
                    ltlContent.Text = "<br /><div style=\"padding-left:5px; font-weight: bold;\">" + GetString("WebPartDocumentation.DocumentationText") + "</div><br />";
                }
            }
            else
            {
                ltlContent.Text = HTMLHelper.ResolveUrls(itemDocumentation, null);
            }
        }
        ScriptHelper.RegisterJQuery(Page);

        string script = @"
$j(document.body).ready(initializeResize);
           
function initializeResize ()  { 
    resizeareainternal();
    $j(window).resize(function() { resizeareainternal(); });
}

function resizeareainternal () {
    var height = document.body.clientHeight ; 
    var panel = document.getElementById ('" + divScrolable.ClientID + @"');
                
    // Get parent footer to count proper height (with padding included)
    var footer = $j('.PageFooterLine');                      
    panel.style.height = (height - footer.outerHeight() - panel.offsetTop) +'px';                  
}";

        ScriptHelper.RegisterClientScriptBlock(Page, typeof(Page), "mainScript", ScriptHelper.GetScript(script));

        string[,] tabs = new string[4, 4];
        tabs[0, 0]     = GetString("webparts.documentation");
        tabs[1, 0]     = GetString("general.properties");

        tabControlElem.Tabs        = tabs;
        tabControlElem.UsePostback = true;

        // Disable caching
        Response.Cache.SetNoStore();

        base.OnLoad(e);
    }
Ejemplo n.º 25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterDialogScript(Page);
        ScriptHelper.RegisterApplicationConstants(Page);

        // Get the object type
        string param       = ContextMenu.Parameter;
        string objectType  = null;
        bool   groupObject = false;

        if (param != null)
        {
            string[] parms = param.Split(';');
            objectType = parms[0];
            if (parms.Length == 2)
            {
                groupObject = ValidationHelper.GetBoolean(parms[1], false);
            }
        }

        // Get empty info
        GeneralizedInfo obj = null;

        if (objectType != null)
        {
            obj = CMSObjectHelper.GetReadOnlyObject(objectType);
            // Get correct info for listings
            if (obj.TypeInfo.Inherited)
            {
                obj = CMSObjectHelper.GetReadOnlyObject(obj.TypeInfo.OriginalObjectType);
            }
        }

        if (obj == null)
        {
            Visible = false;
            return;
        }

        CurrentUserInfo curUser     = CMSContext.CurrentUser;
        string          curSiteName = CMSContext.CurrentSiteName;

        string menuId = ContextMenu.MenuID;

        // Relationships
        if (obj.TypeInfo.HasObjectRelationships)
        {
            iRelationships.ImageUrl = UIHelper.GetImageUrl(Page, "Design/Controls/UniGrid/Actions/Relationships.png");
            iRelationships.Text     = ResHelper.GetString("General.Relationships");
            iRelationships.Attributes.Add("onclick", "ContextRelationships(GetContextMenuParameter('" + menuId + "'));");
        }
        else
        {
            iRelationships.Visible = false;
        }

        // Export
        if (obj.TypeInfo.AllowSingleExport)
        {
            if (curUser.IsAuthorizedPerResource("cms.globalpermissions", "ExportObjects", curSiteName))
            {
                iExport.ImageUrl = UIHelper.GetImageUrl(Page, "Design/Controls/UniGrid/Actions/ExportObject.png");
                iExport.Text     = ResHelper.GetString("General.Export");
                iExport.Attributes.Add("onclick", "ContextExportObject(GetContextMenuParameter('" + menuId + "'), false);");
            }
            else
            {
                iExport.Visible = false;
            }

            if (obj.GUIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN)
            {
                if (curUser.IsAuthorizedPerResource("cms.globalpermissions", "BackupObjects", curSiteName))
                {
                    iBackup.ImageUrl = UIHelper.GetImageUrl(Page, "Design/Controls/UniGrid/Actions/BackupObject.png");
                    iBackup.Text     = ResHelper.GetString("General.Backup");
                    iBackup.Attributes.Add("onclick", "ContextExportObject(GetContextMenuParameter('" + menuId + "'), true);");
                }
                else
                {
                    iBackup.Visible = false;
                }

                if (curUser.IsAuthorizedPerResource("cms.globalpermissions", "RestoreObjects", curSiteName))
                {
                    iRestore.ImageUrl = UIHelper.GetImageUrl(Page, "Design/Controls/UniGrid/Actions/RestoreObject.png");
                    iRestore.Text     = ResHelper.GetString("General.Restore");
                    iRestore.Attributes.Add("onclick", "ContextRestoreObject(GetContextMenuParameter('" + menuId + "'), true);");
                }
                else
                {
                    iRestore.Visible = false;
                }
            }
            else
            {
                iBackup.Visible  = false;
                iRestore.Visible = false;
            }
        }
        else
        {
            iExport.Visible  = false;
            iBackup.Visible  = false;
            iRestore.Visible = false;
        }

        // Versioning
        if (obj.AllowRestore && UniGridFunctions.ObjectSupportsDestroy(obj) && curUser.IsAuthorizedPerObject(PermissionsEnum.Destroy, obj.ObjectType, curSiteName))
        {
            iDestroy.ImageUrl = UIHelper.GetImageUrl(Page, "Design/Controls/UniGrid/Actions/Delete.png");
            iDestroy.Text     = ResHelper.GetString("security.destroy");
            iDestroy.Attributes.Add("onclick", "ContextDestroyObject_" + ClientID + "(GetContextMenuParameter('" + menuId + "'))");
        }
        else
        {
            iDestroy.Visible = false;
        }

        // Clonning
        if (obj.AllowClone)
        {
            iClone.ImageUrl = UIHelper.GetImageUrl(Page, "Design/Controls/UniGrid/Actions/Clone.png");
            iClone.Text     = ResHelper.GetString("general.clone");
            iClone.Attributes.Add("onclick", "ContextCloneObject" + "(GetContextMenuParameter('" + menuId + "'))");
        }
        else
        {
            iClone.Visible = false;
        }

        bool ancestor = iRelationships.Visible;

        sep1.Visible = (iClone.Visible || iDestroy.Visible) && ancestor;
        ancestor    |= (iClone.Visible || iDestroy.Visible);
        sep2.Visible = (iBackup.Visible || iRestore.Visible || iExport.Visible) && ancestor;

        Visible = iRelationships.Visible || iExport.Visible || iBackup.Visible || iDestroy.Visible || iClone.Visible;
    }
Ejemplo n.º 26
0
    /// <summary>
    /// Generate properties.
    /// </summary>
    protected void GenerateProperties(FormInfo fi)
    {
        // Generate script to display and hide  properties groups
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ShowHideProperties", ScriptHelper.GetScript(@"
            function ShowHideProperties(id) {
                var obj = document.getElementById(id);
                var objlink = document.getElementById(id+'_link');
                if ((obj != null)&&(objlink != null)){
                   if (obj.style.display == 'none' ) { obj.style.display=''; objlink.innerHTML = '<img border=""0"" src=""" + minImg + @""" >'; } 
                   else {obj.style.display='none'; objlink.innerHTML = '<img border=""0"" src=""" + plImg + @""" >';}
                objlink.blur();}}"));

        // Get defintion elements
        var infos = fi.GetFormElements(true, false);

        bool isOpenSubTable   = false;
        bool firstLoad        = true;
        bool hasAnyProperties = false;

        string currentGuid = "";
        string newCategory = null;

        // Check all items in object array
        foreach (IFormItem contrl in infos)
        {
            // Generate row for form category
            if (contrl is FormCategoryInfo)
            {
                // Load castegory info
                FormCategoryInfo fci = contrl as FormCategoryInfo;
                if (fci != null)
                {
                    if (isOpenSubTable)
                    {
                        ltlProperties.Text += "<tr class=\"PropertyBottom\"><td class=\"PropertyLeftBottom\">&nbsp;</td><td colspan=\"2\" class=\"Center\">&nbsp;</td><td class=\"PropertyRightBottom\">&nbsp;</td></tr></table>";
                        isOpenSubTable      = false;
                    }

                    if (currentGuid == "")
                    {
                        currentGuid = Guid.NewGuid().ToString().Replace("-", "_");
                    }

                    // Generate properties content
                    newCategory = @"<br />
                        <table cellpadding=""0"" cellspacing=""0"" class=""CategoryTable"">
                          <tr>
                            <td class=""CategoryLeftBorder"">&nbsp;</td>
                            <td class=""CategoryTextCell"">" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(fci.CategoryCaption)) + @"</td>
                            <td class=""HiderCell"">
                              <a id=""" + currentGuid + "_link\" href=\"#\" onclick=\"ShowHideProperties('" + currentGuid + @"'); return false;"">
                              <img border=""0"" src=""" + minImg + @""" ></a>
                            </td>
                           <td class=""CategoryRightBorder"">&nbsp;</td>
                         </tr>
                       </table>";
                }
            }
            else
            {
                hasAnyProperties = true;
                // Get form field info
                FormFieldInfo ffi = contrl as FormFieldInfo;

                if (ffi != null)
                {
                    // If display only in dashboard and not dashbord zone (or none for admins) dont show
                    if ((ffi.DisplayIn == "dashboard") && ((zoneType != WidgetZoneTypeEnum.Dashboard) && (zoneType != WidgetZoneTypeEnum.None)))
                    {
                        continue;
                    }
                    if (newCategory != null)
                    {
                        ltlProperties.Text += newCategory;
                        newCategory         = null;

                        firstLoad = false;
                    }
                    else if (firstLoad)
                    {
                        if (currentGuid == "")
                        {
                            currentGuid = Guid.NewGuid().ToString().Replace("-", "_");
                        }

                        // Generate properties content
                        firstLoad           = false;
                        ltlProperties.Text += @"<br />
                        <table cellpadding=""0"" cellspacing=""0"" class=""CategoryTable"">
                          <tr>
                            <td class=""CategoryLeftBorder"">&nbsp;</td>
                            <td class=""CategoryTextCell"">Default</td>
                            <td class=""HiderCell"">
                               <a id=""" + currentGuid + "_link\" href=\"#\" onclick=\"ShowHideProperties('" + currentGuid + @"'); return false;"">
                               <img border=""0"" src=""" + minImg + @""" ></a>
                            </td>
                            <td class=""CategoryRightBorder"">&nbsp;</td>
                         </tr>
                       </table>";
                    }

                    if (!isOpenSubTable)
                    {
                        isOpenSubTable      = true;
                        ltlProperties.Text += "" +
                                              "<table cellpadding=\"0\" cellspacing=\"0\" id=\"" + currentGuid + "\" class=\"PropertiesTable\" >";
                        currentGuid = "";
                    }

                    string doubleDot = "";
                    if (!ffi.Caption.EndsWithCSafe(":"))
                    {
                        doubleDot = ":";
                    }

                    ltlProperties.Text +=
                        @"<tr>
                            <td class=""PropertyLeftBorder"" >&nbsp;</td>
                            <td class=""PropertyContent"" style=""width:200px;"">" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ffi.Caption)) + doubleDot + @"</td>
                            <td class=""PropertyRow"">" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(DataHelper.GetNotEmpty(ffi.Description, GetString("WebPartDocumentation.DescriptionNoneAvailable")))) + @"</td>
                            <td class=""PropertyRightBorder"">&nbsp;</td>
                        </tr>";
                }
            }
        }

        if (isOpenSubTable)
        {
            ltlProperties.Text += "<tr class=\"PropertyBottom\"><td class=\"PropertyLeftBottom\">&nbsp;</td><td colspan=\"2\" class=\"Center\">&nbsp;</td><td class=\"PropertyRightBottom\">&nbsp;</td></tr></table>";
        }

        if (!hasAnyProperties)
        {
            ltlProperties.Text = "<br /><div style=\"padding-left:5px;padding-right:5px; font-weight: bold;\">" + GetString("documentation.nopropertiesavaible") + "</div>";
        }
    }
    /// <summary>
    /// Generate control output.
    /// </summary>
    public void GenerateContent()
    {
        string templatePath = DepartmentTemplatePath;

        if (String.IsNullOrEmpty(templatePath))
        {
            ltlContent.Text    = ResHelper.GetString("departmentsectionsmanager.notemplate");
            ltlContent.Visible = true;
        }
        else
        {
            if (!DataHelper.DataSourceIsEmpty(TemplateDocuments))
            {
                int   counter = 0;
                Table tb      = new Table();

                string value      = ValidationHelper.GetString(mSelectedValue, "");
                string docAliases = ";" + value.ToLowerCSafe() + ";";

                TreeNode editedNode = (TreeNode)Form.EditedObject;

                if (Form.IsInsertMode)
                {
                    // Alias path for new department has to have special 'child node path' because of correct check for document type scopes
                    editedNode.SetValue("NodeAliasPath", ((TreeNode)Form.ParentObject).NodeAliasPath + "/department");
                }

                TableRow tr = new TableRow();
                foreach (DataRow drDoc in TemplateDocuments.Tables[0].Rows)
                {
                    // For each section td element is generated
                    string docAlias = ValidationHelper.GetString(drDoc["NodeAlias"], "");

                    TableCell   td     = new TableCell();
                    CMSCheckBox cbCell = new CMSCheckBox();
                    cbCell.ID   = "chckSection" + counter;
                    cbCell.Text = docAlias;
                    cbCell.Attributes.Add("Value", docAlias);

                    // Check if child allowed
                    int sourceClassId = ValidationHelper.GetInteger(drDoc["NodeClassID"], 0);
                    if (!DocumentHelper.IsDocumentTypeAllowed(editedNode, sourceClassId))
                    {
                        cbCell.Enabled = false;
                        cbCell.ToolTip = ResHelper.GetString("departmentsectionsmanager.notallowedchild");
                    }

                    // Disable default hidden documents
                    if (HIDDEN_DOCUMENT_ALIAS.Contains(";" + docAlias.ToLowerCSafe() + ";"))
                    {
                        cbCell.Checked = cbCell.Enabled;
                        cbCell.Enabled = false;
                    }


                    // Check for selected value
                    if (docAliases.Contains(";" + docAlias.ToLowerCSafe() + ";") || ((mSelectedValue == null) && (Form.Mode == FormModeEnum.Insert)))
                    {
                        if (cbCell.Enabled)
                        {
                            cbCell.Checked = true;
                        }
                    }

                    // If editing existing document register alert script
                    if ((Form.Mode != FormModeEnum.Insert) && cbCell.Checked)
                    {
                        cbCell.Attributes.Add("OnClick", "if(!this.checked){alert(" + ScriptHelper.GetString(ResHelper.GetString("departmentsectionsmanagerformcontrol.removesectionwarning")) + ");}");
                    }

                    // Add reference to checkbox arraylist
                    CheckboxReferences.Add(cbCell);
                    counter++;

                    td.Controls.Add(cbCell);
                    tr.Cells.Add(td);

                    // If necessary create new row
                    if ((counter % ITEMS_PER_ROW) == 0)
                    {
                        tr.CssClass = "Row";
                        tb.Rows.Add(tr);
                        tr = new TableRow();
                    }
                }
                // If last row contains data add it
                if (counter > 0)
                {
                    tb.Rows.Add(tr);
                }
                pnlContent.Controls.Add(tb);
            }
            else
            {
                ltlContent.Text    = ResHelper.GetString("departmentsectionsmanager.notemplate");
                ltlContent.Visible = true;
            }
        }
    }
Ejemplo n.º 28
0
    /// <summary>
    /// Returns text for azure containing tables which need to be manually copied.
    /// </summary>
    private string GetManualCopyText()
    {
        SeparatedTables tables = new SeparatedTables(Server.MapPath("~/App_Data/DBSeparation"), null);

        return(ResHelper.GetString("separationDB.manualcopy") + tables.GetTableNames("<br />"));
    }
Ejemplo n.º 29
0
    protected void wzdImport_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
        switch (e.CurrentStepIndex)
        {
        case 0:
            // Apply settings
            if (!stpConfigImport.ApplySettings())
            {
                e.Cancel = true;
                return;
            }

            // Update settings
            ImportSettings = stpConfigImport.Settings;

            ltlScriptAfter.Text = ScriptHelper.GetScript(
                "var actDiv = document.getElementById('actDiv'); \n" +
                "if (actDiv != null) { actDiv.style.display='block'; } \n" +
                "var buttonsDiv = document.getElementById('buttonsDiv'); if (buttonsDiv != null) { buttonsDiv.disabled=true; } \n" +
                "BTN_Disable('" + NextButton.ClientID + "'); \n" +
                "StartUnzipTimer();"
                );

            // Create temporary files asynchronously
            ctrlAsync.RunAsync(CreateTemporaryFiles, WindowsIdentity.GetCurrent());

            e.Cancel = true;
            break;

        case 1:
            // Apply settings
            if (!stpSiteDetails.ApplySettings())
            {
                e.Cancel = true;
                return;
            }

            // Update settings
            ImportSettings = stpSiteDetails.Settings;
            //stpImport.SelectedNodeValue = CMSObjectHelper.GROUP_OBJECTS;
            stpImport.ReloadData(true);

            wzdImport.ActiveStepIndex++;
            break;

        case 2:
            // Apply settings
            if (!stpImport.ApplySettings())
            {
                e.Cancel = true;
                return;
            }

            // Check licences
            string error = ImportExportControl.CheckLicenses(ImportSettings);
            if (!string.IsNullOrEmpty(error))
            {
                SetErrorLabel(error);

                e.Cancel = true;
                return;
            }

            ImportSettings = stpImport.Settings;

            // Init the Mimetype helper (required for the Import)
            MimeTypeHelper.LoadMimeTypes();

            // Start asynchronnous Import
            ImportSettings.DefaultProcessObjectType = ProcessObjectEnum.Selected;
            if (ImportSettings.SiteIsIncluded)
            {
                ImportSettings.EventLogSource = string.Format(ImportSettings.GetAPIString("ImportSite.EventLogSiteSource", "Import '{0}' site"), ResHelper.LocalizeString(ImportSettings.SiteDisplayName));
            }
            ImportManager.Settings = ImportSettings;

            AsyncWorker worker = new AsyncWorker();
            worker.OnFinished += worker_OnFinished;
            worker.OnError    += worker_OnError;
            worker.RunAsync(ImportManager.Import, WindowsIdentity.GetCurrent());

            wzdImport.ActiveStepIndex++;
            break;
        }

        ReloadSteps();
    }
    /// <summary>
    /// Initializes menu.
    /// </summary>
    protected void InitalizeMenu()
    {
        string             zoneId      = QueryHelper.GetString("zoneid", "");
        string             culture     = QueryHelper.GetString("culture", CMSContext.PreferredCultureCode);
        bool               isNewWidget = QueryHelper.GetBoolean("isnew", false);
        WidgetZoneTypeEnum zoneType    = WidgetZoneTypeEnum.None;

        if (!String.IsNullOrEmpty(widgetId) || !String.IsNullOrEmpty(widgetName))
        {
            WidgetInfo wi = null;

            // get pageinfo
            PageInfo pi = null;
            try
            {
                pi = CMSWebPartPropertiesPage.GetPageInfo(aliasPath, templateId, culture);
            }
            catch (PageNotFoundException)
            {
                // Do not throw exception if page info not found (e.g. bad alias path)
            }

            if (pi == null)
            {
                Visible = false;
                return;
            }

            // Get template instance
            PageTemplateInstance templateInstance = CMSPortalManager.GetTemplateInstanceForEditing(pi);

            if (templateInstance != null)
            {
                // Get zone type
                WebPartZoneInstance zoneInstance = templateInstance.GetZone(zoneId);

                if (zoneInstance != null)
                {
                    zoneType = zoneInstance.WidgetZoneType;
                }
                if (!isNewWidget)
                {
                    // Get web part
                    WebPartInstance widget = templateInstance.GetWebPart(instanceGuid, widgetId);

                    if ((widget != null) && widget.IsWidget)
                    {
                        // WebPartType = codename, get widget by codename
                        wi = WidgetInfoProvider.GetWidgetInfo(widget.WebPartType);

                        // Set the variant mode (MVT/Content personalization)
                        variantMode = widget.VariantMode;
                    }
                }
            }
            // New widget
            if (isNewWidget)
            {
                int id = ValidationHelper.GetInteger(widgetId, 0);
                if (id > 0)
                {
                    wi = WidgetInfoProvider.GetWidgetInfo(id);
                }
                else if (!String.IsNullOrEmpty(widgetName))
                {
                    wi = WidgetInfoProvider.GetWidgetInfo(widgetName);
                }
            }

            // Get widget info from name if not found yet
            if ((wi == null) && (!String.IsNullOrEmpty(widgetName)))
            {
                wi = WidgetInfoProvider.GetWidgetInfo(widgetName);
            }

            if (wi != null)
            {
                PageTitle.TitleText = GetString("Widgets.Properties.Title") + " (" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(wi.WidgetDisplayName)) + ")";
            }

            // Use live or non live dialogs
            string documentationUrl = String.Empty;

            // If no zonetype defined or not inline dont show documentation
            switch (zoneType)
            {
            case WidgetZoneTypeEnum.Dashboard:
            case WidgetZoneTypeEnum.Editor:
            case WidgetZoneTypeEnum.Group:
            case WidgetZoneTypeEnum.User:
                documentationUrl = ResolveUrl("~/CMSModules/Widgets/Dialogs/WidgetDocumentation.aspx");
                break;

            // If no zone set dont create documentation link
            default:
                if (isInline)
                {
                    documentationUrl = ResolveUrl("~/CMSModules/Widgets/Dialogs/WidgetDocumentation.aspx");
                }
                else
                {
                    return;
                }
                break;
            }

            // Generate documentation link
            Literal ltr = new Literal();
            PageTitle.RightPlaceHolder.Controls.Add(ltr);

            // Ensure correct parameters in documentation url
            documentationUrl += URLHelper.GetQuery(URLHelper.CurrentURL);
            if (!String.IsNullOrEmpty(widgetName))
            {
                documentationUrl = URLHelper.UpdateParameterInUrl(documentationUrl, "widgetname", widgetName);
            }
            if (!String.IsNullOrEmpty(widgetId))
            {
                documentationUrl = URLHelper.UpdateParameterInUrl(documentationUrl, "widgetid", widgetId);
            }
            string docScript = "NewWindow('" + documentationUrl + "', 'WebPartPropertiesDocumentation', 800, 800); return false;";

            ltr.Text += "<a onclick=\"" + docScript + "\" href=\"#\"><img src=\"" + ResolveUrl(GetImageUrl("General/HelpLargeDark.png")) + "\" style=\"border-width: 0px;\"></a>";

            tabsElem.OnTabCreated           += tabElem_OnTabCreated;
            tabsElem.UrlTarget               = "widgetpropertiescontent";
            tabsElem.OpenTabContentAfterLoad = !isInline;
        }
    }