예제 #1
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        var user = MembershipContext.AuthenticatedUser;

        // Check 'read' permissions
        if (!user.IsAuthorizedPerResource("CMS.Content", "Read"))
        {
            RedirectToAccessDenied("CMS.Content", "Read");
        }

        // Check UIProfile
        if (!user.IsAuthorizedPerUIElement("CMS.Content", "Properties.General"))
        {
            RedirectToUIElementAccessDenied("CMS.Content", "Properties.General");
        }

        if (!user.IsAuthorizedPerUIElement("CMS.Content", "General.Advanced"))
        {
            RedirectToUIElementAccessDenied("CMS.Content", "General.Advanced");
        }

        // Init document manager events
        DocumentManager.OnSaveData     += DocumentManager_OnSaveData;
        DocumentManager.OnAfterAction  += DocumentManager_OnAfterAction;
        DocumentManager.OnValidateData += DocumentManager_OnValidateData;

        // Initialize node
        node = DocumentManager.Node;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Display separator
        AbstractMasterPage mPage = CurrentMaster as AbstractMasterPage;

        if (mPage != null)
        {
            mPage.DisplaySeparatorPanel = true;
        }

        // Add the document name to the properties header title
        TreeNode node = DocumentManager.Node;

        if (node != null)
        {
            string nodeName = node.GetDocumentName();
            // Get name for root document
            if (node.NodeClassName.ToLowerCSafe() == "cms.root")
            {
                nodeName = CMSContext.CurrentSite.DisplayName;
            }

            CurrentMaster.Title.TitleText += " \"" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(nodeName)) + "\"";
        }
    }
예제 #3
0
    /// <summary>
    /// Fires when the page loads
    /// </summary>
    private void OnLoad(object sender, EventArgs eventArgs)
    {
        var page = (CMSPage)Control.Page;

        var manager = page.DocumentManager;

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

        var node = manager.Node;

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

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

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

            showProductTab = node.HasSKU;

            DocumentUIHelper.EnsureDocumentBreadcrumbs(page.PageBreadcrumbs, node, null, null);
        }
        else
        {
            // Document does not exist -> redirect to new culture version creation dialog
            RedirectToNewCultureVersionPage();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CMSMasterPage currentMaster = Page.Master as CMSMasterPage;

        if (FullscreenMode)
        {
            txtCode.TopOffset = 40;
        }

        // Check master page
        if (currentMaster == null)
        {
            throw new Exception("Page using this control must have CMSMasterPage master page.");
        }

        LabelsInit();

        txtCode.Editor.Width    = new Unit("99%");
        txtCode.Editor.Height   = new Unit("300px");
        txtCode.NamespaceUsings = new List <string> {
            "Transformation"
        };

        // transformation.{classid}.{isascx}
        string resolverName = "transformation." + ClassID + "." + IsAscx;

        txtCode.ResolverName   = resolverName;
        tbWysiwyg.ResolverName = resolverName;

        if (IsAscx)
        {
            DataClassInfo resolverClassInfo = DataClassInfoProvider.GetDataClassInfo(ClassID);
            if (resolverClassInfo != null)
            {
                if (resolverClassInfo.ClassIsCustomTable)
                {
                    txtCode.ASCXRootObject = CustomTableItem.New(resolverClassInfo.ClassName);
                }
                else if (resolverClassInfo.ClassIsDocumentType)
                {
                    txtCode.ASCXRootObject = TreeNode.New(resolverClassInfo.ClassName);
                }
                else
                {
                    txtCode.ASCXRootObject = ModuleManager.GetReadOnlyObjectByClassName(resolverClassInfo.ClassName);
                }
            }

            if (!RequestHelper.IsPostBack() && IsChecked)
            {
                ShowMessage();
            }
        }

        // Hide/Display CSS section
        plcCssLink.Visible = String.IsNullOrEmpty(txtCSS.Text.Trim());

        SetEditor();
    }
    /// <summary>
    /// Returns true if there is at least one translation submission item with target XLIFF.
    /// </summary>
    /// <param name="document">Document to check</param>
    public static bool IsTranslationReady(object document)
    {
        TreeNode doc = document as TreeNode;

        if (doc != null)
        {
            return(TranslationServiceHelper.IsTranslationReady(doc));
        }
        return(false);
    }
    /// <summary>
    /// Sets value to TreeNode property given by field name.
    /// </summary>
    /// <param name="node">Current instance of edited node</param>
    /// <param name="fieldName">Name of field which can have inherited value</param>
    private void SetField(TreeNode node, string fieldName)
    {
        node.SetValue(fieldName, null);

        CMSCheckBox chk = GetCheckBox(fieldName);

        if (!chk.Checked)
        {
            // Set not inherited value
            node.SetValue(fieldName, Control.FieldControls[fieldName].Value);
        }
    }
예제 #7
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        if (!IsCallback)
        {
            string action = QueryHelper.GetString("action", "");

            switch (action.ToLowerCSafe())
            {
            case "movenode":
            case "movenodeposition":
            case "movenodefirst":
            {
                // Setup page title text and image
                CurrentMaster.Title.TitleText  = GetString("dialogs.header.title.movedoc");
                CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/titlemove.png");
            }
            break;

            case "copynode":
            case "copynodeposition":
            case "copynodefirst":
            {
                // Setup page title text and image
                CurrentMaster.Title.TitleText  = GetString("dialogs.header.title.copydoc");
                CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/titlecopy.png");
            }
            break;

            case "linknode":
            case "linknodeposition":
            case "linknodefirst":
            {
                // Setup page title text and image
                CurrentMaster.Title.TitleText  = GetString("dialogs.header.title.linkdoc");
                CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/titlelink.png");
            }
            break;
            }

            TreeNode node = opDrag.Node;
            if (node != null)
            {
                string documentName = ValidationHelper.GetString(node.GetValue("DocumentLastVersionName"), node.GetDocumentName());
                CurrentMaster.Title.TitleText += " \"" + HTMLHelper.HTMLEncode(documentName) + "\"";
            }

            ((Panel)CurrentMaster.PanelBody.FindControl("pnlContent")).CssClass = string.Empty;
        }
    }
예제 #8
0
    /// <summary>
    /// Gets document
    /// </summary>
    /// <param name="parameter">Row parameter</param>
    /// <param name="document">Document received based on parameters</param>
    private bool GetDocument(object parameter, out TreeNode document)
    {
        var view = (DataRowView)parameter;

        string guidColumnName = null;
        string siteColumnName = null;

        switch (Control.ObjectType)
        {
        // Facebook post
        case FacebookPostInfo.OBJECT_TYPE:
            guidColumnName = "FacebookPostDocumentGUID";
            siteColumnName = "FacebookPostSiteID";
            break;

        // LinkedIn post
        case LinkedInPostInfo.OBJECT_TYPE:
            guidColumnName = "LinkedInPostDocumentGUID";
            siteColumnName = "LinkedInPostSiteID";
            break;

        // Twitter post
        case TwitterPostInfo.OBJECT_TYPE:
            guidColumnName = "TwitterPostDocumentGUID";
            siteColumnName = "TwitterPostSiteID";
            break;
        }

        var documentGuid = ValidationHelper.GetGuid(DataHelper.GetDataRowViewValue(view, guidColumnName), Guid.Empty);
        var siteId       = ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue(view, siteColumnName), 0);

        if (documentGuid == Guid.Empty)
        {
            document = null;
            return(false);
        }

        document = new ObjectQuery <TreeNode>().WithGuid(documentGuid).OnSite(siteId).WhereNull("NodeLinkedNodeID").FirstOrDefault();
        return(true);
    }
        public bool DeleteCampaign(int CampaignID)
        {
            bool status = false;

            if (CampaignID > 0)
            {
                CMS.DocumentEngine.TreeProvider tree = new CMS.DocumentEngine.TreeProvider(CMS.Membership.MembershipContext.AuthenticatedUser);

                // Gets the culture version of the page that will be deleted
                CMS.DocumentEngine.TreeNode page = tree.SelectNodes("KDA.Campaign").Where("CampaignID", CMS.DataEngine.QueryOperator.Equals, CampaignID).OnCurrentSite();
                if (page != null)
                {
                    // Deletes the page and moves it to the recycle bin (only the specified culture version)
                    status = page.Delete();

                    //  Creates search tasks that remove the deleted page from the content of related search indexes
                    if (CMS.Search.SearchIndexInfoProvider.SearchEnabled)
                    {
                        CMS.Search.SearchTaskInfoProvider.CreateTask(CMS.Search.SearchTaskTypeEnum.Delete, CMS.DocumentEngine.TreeNode.OBJECT_TYPE, CMS.DataEngine.SearchFieldsConstants.ID, page.GetSearchID(), page.DocumentID);
                    }
                }
            }
            return(status);
        }
예제 #10
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        var user = MembershipContext.AuthenticatedUser;

        // Check 'read' permissions
        if (!user.IsAuthorizedPerResource("CMS.Content", "Read"))
        {
            RedirectToAccessDenied("CMS.Content", "Read");
        }

        // Check UIProfile
        if (!user.IsAuthorizedPerUIElement("CMS.Content", "Properties.General"))
        {
            RedirectToUIElementAccessDenied("CMS.Content", "Properties.General");
        }

        if (!user.IsAuthorizedPerUIElement("CMS.Content", "General.Advanced"))
        {
            RedirectToUIElementAccessDenied("CMS.Content", "General.Advanced");
        }

        // Init document manager events
        DocumentManager.OnSaveData += DocumentManager_OnSaveData;
        DocumentManager.OnAfterAction += DocumentManager_OnAfterAction;
        DocumentManager.OnValidateData += DocumentManager_OnValidateData;

        // Initialize node
        node = DocumentManager.Node;
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing || CMSContext.CurrentDocument == null || CMSContext.CurrentDocument.NodeClassName.ToLowerCSafe() != "cms.bookingevent")
        {
            // Do nothing
            Visible = false;
        }
        else
        {
            // Get current event document
            EventNode = CMSContext.CurrentDocument;

            // Get event date, open from/to, capacity and possibility to register over capacity information
            eventDate = ValidationHelper.GetDateTime(EventNode.GetValue("EventDate"), DataHelper.DATETIME_NOT_SELECTED);
            openFrom = ValidationHelper.GetDateTime(EventNode.GetValue("EventOpenFrom"), DataHelper.DATETIME_NOT_SELECTED);
            openTo = ValidationHelper.GetDateTime(EventNode.GetValue("EventOpenTo"), DataHelper.DATETIME_NOT_SELECTED);
            capacity = ValidationHelper.GetInteger(EventNode.GetValue("EventCapacity"), 0);
            allowRegistrationOverCapacity = ValidationHelper.GetBoolean(EventNode.GetValue("EventAllowRegistrationOverCapacity"), false);

            // Display registration section
            DisplayRegistration();

            // Display link to iCalendar file which adds this event to users Outlook
            if (AllowExportToOutlook)
            {
                lnkOutlook.NavigateUrl = "~/CMSModules/EventManager/CMSPages/AddToOutlook.aspx?eventid=" + EventNode.NodeID.ToString();
                lnkOutlook.Target = "_blank";
                lnkOutlook.Text = GetString("eventmanager.exporttooutlook");
                lnkOutlook.Visible = true;
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    public void SetupControl()
    {
        ltlIcons.Text = "";

        // Fill hashtable with info about all bookmark services
        FillHashTable();

        // Resolve path of images
        string imagesPath = ResolveUrl("~/CMSWebParts/CommunityServices/SocialBookmarking_files");

        // Get current document
        TreeNode node = CMSContext.CurrentDocument;

        if (node != null)
        {
            // Get url of current document
            string liveUrl = URLHelper.CurrentURL;
            liveUrl = URLHelper.GetAbsoluteUrl(liveUrl);

            // Encode url
            liveUrl = Server.UrlEncode(liveUrl);

            // Prepare target
            string target = ShowInNewWindow ? "target=\"_blank\"" : "";

            string[] bookmarkInfo = new string[4];

            // Get all keys from hashtable
            object[] keys = new object[bookmarkServices.Count];
            bookmarkServices.Keys.CopyTo(keys, 0);
            StringBuilder sb = new StringBuilder();

            // Loop thru all items in hashtable
            for (int i = 0; i != keys.Length; i++)
            {
                // Get structure
                bookmarkInfo = (string[])bookmarkServices[keys[i]];
                string currentService = keys[i].ToString();
                if (bookmarkInfo.Length != 0)
                {
                    // If current service is enabled generate html code
                    if (ValidationHelper.GetBoolean(GetValue(currentService), false))
                    {
                        if (sb.Length > 0)
                        {
                            sb.Append(Separator);
                        }
                        sb.Append("<a href=\"", bookmarkInfo[1], liveUrl, bookmarkInfo[2], Server.UrlEncode(node.GetDocumentName()), "\" title=\"", GetString("addtobook.addto"), " ", bookmarkInfo[0], "\" ", target, "><img src=\"", imagesPath, "/", currentService.ToLowerCSafe(), ".gif", "\" alt=\"", GetString("addtobook.addto"), " ", bookmarkInfo[0], "\" style=\"border-style:none;\" /></a>");
                    }
                }
            }


            // If at least one bookmarking service was checked show title
            if (sb.Length > 0)
            {
                if (!string.IsNullOrEmpty(TitleClass))
                {
                    sb.Insert(0, "<span class=\"" + TitleClass + "\">" + Title + "</span>");
                }
                else
                {
                    sb.Insert(0, Title);
                }

                // Wrap with span with class
                sb.Insert(0, "<span class=\"SocialBookmarking\">");
                sb.Append("</span>");
            }

            ltlIcons.Text = sb.ToString();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CMSMasterPage currentMaster = Page.Master as CMSMasterPage;

        if (FullscreenMode)
        {
            txtCode.TopOffset = 40;
        }

        // Check master page
        if (currentMaster == null)
        {
            throw new Exception("Page using this control must have CMSMasterPage master page.");
        }

        ti = CMSContext.EditedObject as TransformationInfo;
        LabelsInit();

        user = CMSContext.CurrentUser;

        if (!RequestHelper.IsPostBack())
        {
            DropDownListInit();

            if (ti != null)
            {
                // Fills form with transformation information
                drpType.SelectedValue = ti.TransformationType.ToString();
                txtCSS.Text           = ti.TransformationCSS;

                if (ti.TransformationType == TransformationTypeEnum.Html)
                {
                    tbWysiwyg.ResolvedValue = ti.TransformationCode;
                    tbWysiwyg.Visible       = true;
                }
                else
                {
                    txtCode.Text    = ti.TransformationCode;
                    txtCode.Visible = true;
                }
            }
            else
            {
                txtCode.Visible = true;
            }
        }

        // Set correct help topic for custom tables
        if (!string.IsNullOrEmpty(ClassName))
        {
            DataClassInfo classInfo = DataClassInfoProvider.GetDataClass(ClassName);
            if ((classInfo != null) && classInfo.ClassIsCustomTable)
            {
                currentMaster.Title.HelpTopicName = "customtable_edit_newedit_transformation";
            }
        }


        txtCode.Editor.Width    = new Unit("99%");
        txtCode.Editor.Height   = new Unit("300px");
        txtCode.NamespaceUsings = new List <string> {
            "Transformation"
        };

        if (IsAscx)
        {
            DataClassInfo classInfo = DataClassInfoProvider.GetDataClass(ClassID);
            if (classInfo != null)
            {
                if (classInfo.ClassIsCustomTable)
                {
                    txtCode.ASCXRootObject = CustomTableItem.New(classInfo.ClassName);
                }
                else
                {
                    CMS.DocumentEngine.TreeNode node = CMS.DocumentEngine.TreeNode.New(classInfo.ClassName);
                    txtCode.ASCXRootObject = node;

                    // Prioritize doc. types fields
                    ContextResolver resolver = ContextResolver.GetInstance();
                    foreach (string prop in node.Generalized.PrioritizedProperties)
                    {
                        resolver.PrioritizeProperty(prop);
                    }
                    txtCode.Resolver = resolver;
                }
            }

            if (!RequestHelper.IsPostBack() && IsChecked)
            {
                ShowMessage();
            }
        }

        txtCode.Resolver.SetNamedSourceData("DataItemCount", "");
        txtCode.Resolver.SetNamedSourceData("DataItemIndex", "");
        txtCode.Resolver.SetNamedSourceData("DisplayIndex", "");

        // Hide/Display CSS section
        plcCssLink.Visible = String.IsNullOrEmpty(txtCSS.Text.Trim());

        SetEditor();
    }