Ejemplo n.º 1
0
    /// <summary>
    /// Gets a list of links of tags assigned for the specific document pointing to the page with URL specified.
    /// </summary>
    /// <param name="documentGroupId">ID of the group document tags belong to</param>
    /// <param name="documentTags">String containing all the tags related to the document</param>
    /// <param name="nodeAliasPath">Node alias path</param>
    /// <param name="documentListPage">Path or URL of the page displaying other documents of the specified tag</param>
    public static string GetDocumentTags(object documentGroupId, object documentTags, object nodeAliasPath, string documentListPage)
    {
        string result = "";
        string tags   = ValidationHelper.GetString(documentTags, "");

        if (tags.Trim() != "")
        {
            // If list page was specified make a list of links, otherwise return just list of tags
            bool   renderLink  = !string.IsNullOrEmpty(documentListPage);
            string listPageUrl = "";
            int    groupId     = ValidationHelper.GetInteger(documentGroupId, 0);

            if (renderLink)
            {
                // If page specified by URL
                if (ValidationHelper.IsURL(documentListPage))
                {
                    // Resolve URL
                    listPageUrl = URLHelper.ResolveUrl(documentListPage);
                }
                else
                {
                    // Resolve path
                    listPageUrl = CMSContext.CurrentResolver.ResolvePath(documentListPage);
                }

                // Look for group ID of document parent if not supplied
                if (groupId == 0)
                {
                    string aliasPath  = ValidationHelper.GetString(nodeAliasPath, CMSContext.CurrentPageInfo.NodeAliasPath);
                    string strGroupId = PageInfoProvider.GetParentProperty(CMSContext.CurrentSiteID,
                                                                           (String.IsNullOrEmpty(aliasPath) ? CMSContext.CurrentPageInfo.NodeAliasPath : aliasPath),
                                                                           "DocumentTagGroupID IS NOT NULL", "DocumentTagGroupID");
                    groupId = ValidationHelper.GetInteger(strGroupId, 0);
                }
            }

            // Go through the specified tags and make a list of them
            string[] tagsArr = tags.Split(',');
            for (int i = 0; i < tagsArr.Length; i++)
            {
                tagsArr[i] = tagsArr[i].Replace("\"", "").Trim();
            }
            Array.Sort(tagsArr);
            foreach (string tag in tagsArr)
            {
                if (renderLink)
                {
                    result += "<a href=\"" + listPageUrl + "?tagname=" + HttpUtility.UrlPathEncode(tag) + "&amp;groupid=" + groupId + "\">" + HTMLHelper.HTMLEncode(tag) + "</a>, ";
                }
                else
                {
                    result += HTMLHelper.HTMLEncode(tag) + ",";
                }
            }
            result = result.Trim().TrimEnd(',');
        }

        return(result);
    }
Ejemplo n.º 2
0
    protected void chkCssStyle_CheckedChanged(object sender, EventArgs e)
    {
        if (chkCssStyle.Checked)
        {
            // Set stylesheet to stylesheet selector
            ctrlSiteSelectStyleSheet.Enabled          = false;
            ctrlSiteSelectStyleSheet.ButtonNewEnabled = false;

            string value = PageInfoProvider.GetParentProperty(SiteContext.CurrentSite.SiteID, Node.NodeAliasPath, "(DocumentStylesheetID <> -1 OR DocumentStylesheetID IS NULL) AND DocumentCulture = N'" + SqlHelper.GetSafeQueryString(Node.DocumentCulture, false) + "'", "DocumentStylesheetID");
            if (String.IsNullOrEmpty(value))
            {
                ctrlSiteSelectStyleSheet.Value = GetDefaultStylesheet();
            }
            else
            {
                try
                {
                    ctrlSiteSelectStyleSheet.Value = value;
                }
                catch
                {
                }
            }
        }
        else
        {
            ctrlSiteSelectStyleSheet.Enabled          = true;
            ctrlSiteSelectStyleSheet.ButtonNewEnabled = true;
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Gets value from parent node
    /// </summary>
    private string GetParentProperty()
    {
        var where = new WhereCondition()
                    .WhereNotEquals("DocumentStylesheetID", -1)
                    .Or()
                    .WhereNull("DocumentStylesheetID");

        return(PageInfoProvider.GetParentProperty <string>(Node.NodeSiteID, Node.NodeAliasPath, "DocumentStylesheetID", Node.DocumentCulture, where));
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Gets a list of links of tags assigned for the specific document pointing to the page with URL specified.
    /// </summary>
    /// <param name="documentGroupId">ID of the group document tags belong to</param>
    /// <param name="documentTags">String containing all the tags related to the document</param>
    /// <param name="nodeAliasPath">Node alias path</param>
    /// <param name="documentListPage">Path or URL of the page displaying other documents of the specified tag</param>
    public static string GetDocumentTags(object documentGroupId, object documentTags, object nodeAliasPath, string documentListPage)
    {
        var groupId  = ValidationHelper.GetInteger(documentGroupId, 0);
        var tags     = ValidationHelper.GetString(documentTags, null);
        var path     = ValidationHelper.GetString(nodeAliasPath, null);
        var listPage = ValidationHelper.GetString(documentListPage, null);

        if ((tags == null) || (tags.Trim() == string.Empty))
        {
            return(string.Empty);
        }

        // If list page was specified make a list of links, otherwise return just list of tags
        bool renderLink = !string.IsNullOrEmpty(listPage);

        if (renderLink)
        {
            // Get list page URL
            listPage = ValidationHelper.IsURL(listPage) ? URLHelper.ResolveUrl(listPage) : MacroContext.CurrentResolver.ResolvePath(listPage);

            // Look for group ID of document parent if not supplied
            if (groupId == 0)
            {
                var culture         = MembershipContext.AuthenticatedUser.PreferredCultureCode;
                var currentPageInfo = DocumentContext.CurrentPageInfo;

                // Get context data
                if (path == null)
                {
                    path    = currentPageInfo.NodeAliasPath;
                    culture = currentPageInfo.DocumentCulture;
                }
                groupId = PageInfoProvider.GetParentProperty <int>(currentPageInfo.NodeSiteID, path, "DocumentTagGroupID", culture, "DocumentTagGroupID IS NOT NULL");
            }
        }

        // Get sorted list of document tags
        var tagList = TagHelper.GetTags(tags);
        var list    = tagList.Values.Cast <string>().ToList();

        list = list.Select(t => t.Replace("\"", "").Trim()).ToList();
        list.Sort();

        var result = list.Select(t =>
        {
            var encodedTag = HTMLHelper.HTMLEncode(t);

            if (renderLink)
            {
                return("<a href=\"" + listPage + "?tagname=" + HttpUtility.UrlEncode(t) + "&amp;groupid=" + groupId + "\">" + encodedTag + "</a>");
            }

            return(encodedTag);
        });

        return(result.Join(", "));
    }
Ejemplo n.º 5
0
    protected void chkCssStyle_CheckedChanged(object sender, EventArgs e)
    {
        if (chkCssStyle.Checked)
        {
            // Set stylesheet to stylesheet selector
            ctrlSiteSelectStyleSheet.CurrentDropDown.Enabled = false;
            ctrlSiteSelectStyleSheet.ButtonNewEnabled        = false;

            string value = PageInfoProvider.GetParentProperty(CMSContext.CurrentSite.SiteID, Node.NodeAliasPath, "(DocumentStylesheetID <> -1 OR DocumentStylesheetID IS NULL) AND DocumentCulture = N'" + SqlHelperClass.GetSafeQueryString(Node.DocumentCulture, false) + "'", "DocumentStylesheetID");
            if (String.IsNullOrEmpty(value))
            {
                // If default site stylesheet not exist edit is set to -1 - disabled
                if (CMSContext.CurrentSiteStylesheet != null)
                {
                    ctrlSiteSelectStyleSheet.CurrentDropDown.SelectedValue = "default";
                }
                else
                {
                    ctrlSiteSelectStyleSheet.CurrentDropDown.SelectedValue = "-1";
                }
            }
            else
            {
                try
                {
                    ctrlSiteSelectStyleSheet.CurrentDropDown.SelectedValue = value;
                }
                catch
                {
                }
            }
        }
        else
        {
            ctrlSiteSelectStyleSheet.CurrentDropDown.Enabled = true;
            ctrlSiteSelectStyleSheet.ButtonNewEnabled        = true;
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Gets stylesheet identifier value from parent node
    /// </summary>
    private string GetStylesheetParentValue()
    {
        var where = new WhereCondition().WhereNotEquals("DocumentInheritsStylesheet", true);

        return(PageInfoProvider.GetParentProperty <string>(Node.NodeSiteID, Node.NodeAliasPath, "DocumentStylesheetID", Node.DocumentCulture, where));
    }
Ejemplo n.º 7
0
    private void ReloadData()
    {
        if (Node != null)
        {
            // Log activities checkboxes
            if (!RequestHelper.IsPostBack())
            {
                bool?logVisit = Node.DocumentLogVisitActivity;
                chkLogPageVisit.Checked = (logVisit == true);
                if (Node.NodeParentID > 0)  // Init "inherit" option for child nodes (and hide option for root)
                {
                    chkPageVisitInherit.Checked = (logVisit == null);
                    if (logVisit == null)
                    {
                        chkPageVisitInherit_CheckedChanged(null, EventArgs.Empty);
                    }
                }
                chkLogPageVisit.Enabled = !chkPageVisitInherit.Checked;
            }

            // Check modify permission
            canEdit = (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) != AuthorizationResultEnum.Denied);

            // Show document group owner selector
            if (ModuleEntry.IsModuleLoaded(ModuleEntry.COMMUNITY) && canEditOwner && LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.Groups))
            {
                plcOwnerGroup.Controls.Clear();
                // Initialize table
                TableRow  rowOwner     = new TableRow();
                TableCell cellTitle    = new TableCell();
                TableCell cellSelector = new TableCell();

                // Initialize caption
                LocalizedLabel lblOwnerGroup = new LocalizedLabel();
                lblOwnerGroup.EnableViewState = false;
                lblOwnerGroup.ResourceString  = "community.group.documentowner";
                lblOwnerGroup.ID = "lblOwnerGroup";
                cellTitle.Controls.Add(lblOwnerGroup);

                // Initialize selector
                fcDocumentGroupSelector                = (FormEngineUserControl)Page.LoadUserControl("~/CMSAdminControls/UI/Selectors/DocumentGroupSelector.ascx");
                fcDocumentGroupSelector.ID             = "fcDocumentGroupSelector";
                fcDocumentGroupSelector.StopProcessing = pnlUIOwner.IsHidden;
                cellSelector.Controls.Add(fcDocumentGroupSelector);
                fcDocumentGroupSelector.Value = ValidationHelper.GetInteger(Node.GetValue("NodeGroupID"), 0);
                fcDocumentGroupSelector.SetValue("siteid", CMSContext.CurrentSiteID);
                fcDocumentGroupSelector.SetValue("nodeid", Node.NodeID);

                // Add controls to containers
                rowOwner.Cells.Add(cellTitle);
                rowOwner.Cells.Add(cellSelector);
                plcOwnerGroup.Controls.Add(rowOwner);
                plcOwnerGroup.Visible = true;
            }

            // Show owner editing only when authorized to change the permissions
            if (canEditOwner)
            {
                lblOwner.Visible = false;
                usrOwner.Visible = true;
                usrOwner.SetValue("AdditionalUsers", new int[] { Node.NodeOwner });
            }
            else
            {
                usrOwner.Visible = false;
            }

            if (!RequestHelper.IsPostBack())
            {
                if (canEditOwner)
                {
                    usrOwner.Value = Node.GetValue("NodeOwner");
                }
            }

            // Load the data
            lblName.Text      = HttpUtility.HtmlEncode(Node.GetDocumentName());
            lblNamePath.Text  = HttpUtility.HtmlEncode(Convert.ToString(Node.GetValue("DocumentNamePath")));
            lblAliasPath.Text = Convert.ToString(Node.NodeAliasPath);
            string typeName = DataClassInfoProvider.GetDataClass(Node.NodeClassName).ClassDisplayName;
            lblType.Text   = HttpUtility.HtmlEncode(ResHelper.LocalizeString(typeName));
            lblNodeID.Text = Convert.ToString(Node.NodeID);

            // Modifier
            SetUserLabel(lblLastModifiedBy, "DocumentModifiedByUserId");

            // Get modified time
            TimeZoneInfo usedTimeZone = null;
            DateTime     lastModified = ValidationHelper.GetDateTime(Node.GetValue("DocumentModifiedWhen"), DateTimeHelper.ZERO_TIME);
            lblLastModified.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(lastModified, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone);
            ScriptHelper.AppendTooltip(lblLastModified, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help");

            if (!canEditOwner)
            {
                // Owner
                SetUserLabel(lblOwner, "NodeOwner");
            }

            // Creator
            SetUserLabel(lblCreatedBy, "DocumentCreatedByUserId");
            DateTime createdWhen = ValidationHelper.GetDateTime(Node.GetValue("DocumentCreatedWhen"), DateTimeHelper.ZERO_TIME);
            lblCreated.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(createdWhen, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone);
            ScriptHelper.AppendTooltip(lblCreated, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help");


            // URL
            string liveUrl = Node.IsLink ? CMSContext.GetUrl(Node.NodeAliasPath, null) : CMSContext.GetUrl(Node.NodeAliasPath, Node.DocumentUrlPath);
            lnkLiveURL.Text        = URLHelper.ResolveUrl(liveUrl, true, false);
            lnkLiveURL.NavigateUrl = URLHelper.ResolveUrl(liveUrl);

            bool isRoot = (Node.NodeClassName.ToLowerCSafe() == "cms.root");

            // Preview URL
            if (!isRoot)
            {
                plcPreview.Visible = true;
                string path = canEdit ? "/CMSModules/CMS_Content/Properties/resetlink.png" : "/CMSModules/CMS_Content/Properties/resetlinkdisabled.png";
                btnResetPreviewGuid.ImageUrl      = GetImageUrl(path);
                btnResetPreviewGuid.ToolTip       = GetString("GeneralProperties.InvalidatePreviewURL");
                btnResetPreviewGuid.ImageAlign    = ImageAlign.AbsBottom;
                btnResetPreviewGuid.Click        += btnResetPreviewGuid_Click;
                btnResetPreviewGuid.OnClientClick = "if(!confirm('" + GetString("GeneralProperties.GeneratePreviewURLConf") + "')){return false;}";

                InitPreviewUrl();
            }

            lblGUID.Text    = Convert.ToString(Node.NodeGUID);
            lblDocGUID.Text = (Node.DocumentGUID == Guid.Empty) ? ResHelper.Dash : Node.DocumentGUID.ToString();
            lblDocID.Text   = Convert.ToString(Node.DocumentID);

            // Culture
            CultureInfo ci = CultureInfoProvider.GetCultureInfo(Node.DocumentCulture);
            lblCulture.Text = ((ci != null) ? ResHelper.LocalizeString(ci.CultureName) : Node.DocumentCulture);

            lblPublished.Text = (Node.IsPublished ? "<span class=\"DocumentPublishedYes\">" + GetString("General.Yes") + "</span>" : "<span class=\"DocumentPublishedNo\">" + GetString("General.No") + "</span>");

            if (!RequestHelper.IsPostBack())
            {
                // Init radio buttons for cache settings
                if (isRoot)
                {
                    radInherit.Visible   = false;
                    radFSInherit.Visible = false;
                    chkCssStyle.Visible  = false;
                }

                string cacheMinutes = "";

                switch (Node.NodeCacheMinutes)
                {
                case -1:
                    // Cache is off
                {
                    radNo.Checked      = true;
                    radYes.Checked     = false;
                    radInherit.Checked = false;
                    if (!isRoot)
                    {
                        radInherit.Checked = true;
                        radNo.Checked      = false;
                    }
                }
                break;

                case 0:
                    // Cache is off
                    radNo.Checked      = true;
                    radYes.Checked     = false;
                    radInherit.Checked = false;
                    break;

                default:
                    // Cache is enabled
                    radNo.Checked      = false;
                    radYes.Checked     = true;
                    radInherit.Checked = false;
                    cacheMinutes       = Node.NodeCacheMinutes.ToString();
                    break;
                }

                // Set secured radio buttons
                switch (Node.NodeAllowCacheInFileSystem)
                {
                case 0:
                    radFSNo.Checked = true;
                    break;

                case 1:
                    radFSYes.Checked = true;
                    break;

                default:
                    if (!isRoot)
                    {
                        radFSInherit.Checked = true;
                    }
                    else
                    {
                        radFSYes.Checked = true;
                    }
                    break;
                }

                txtCacheMinutes.Text = cacheMinutes;

                if (!radYes.Checked)
                {
                    txtCacheMinutes.Enabled = false;
                }

                if (Node.GetValue("DocumentStylesheetID") == null)
                {
                    // If default site not exist edit is set to -1 - disabled
                    if (CMSContext.CurrentSiteStylesheet != null)
                    {
                        ctrlSiteSelectStyleSheet.Value = "default";
                    }
                    else
                    {
                        ctrlSiteSelectStyleSheet.Value = -1;
                    }
                }
                else
                {
                    // If stylesheet is inherited from parent document
                    if (ValidationHelper.GetInteger(Node.GetValue("DocumentStylesheetID"), 0) == -1)
                    {
                        if (!isRoot)
                        {
                            chkCssStyle.Checked = true;

                            // Get parent stylesheet
                            string value = PageInfoProvider.GetParentProperty(CMSContext.CurrentSite.SiteID, Node.NodeAliasPath, "(DocumentStylesheetID <> -1 OR DocumentStylesheetID IS NULL) AND DocumentCulture = N'" + SqlHelperClass.GetSafeQueryString(Node.DocumentCulture, false) + "'", "DocumentStylesheetID");

                            if (String.IsNullOrEmpty(value))
                            {
                                // If default site stylesheet not exist edit is set to -1 - disabled
                                if (CMSContext.CurrentSiteStylesheet != null)
                                {
                                    ctrlSiteSelectStyleSheet.Value = "default";
                                }
                                else
                                {
                                    ctrlSiteSelectStyleSheet.Value = -1;
                                }
                            }
                            else
                            {
                                // Set parent stylesheet to current document
                                ctrlSiteSelectStyleSheet.Value = value;
                            }
                        }
                    }
                    else
                    {
                        ctrlSiteSelectStyleSheet.Value = Node.GetValue("DocumentStylesheetID");
                    }
                }
            }

            // Disable new button if document inherit stylesheet
            bool disableCssSelector = (!isRoot && chkCssStyle.Checked);
            ctrlSiteSelectStyleSheet.Enabled          = !disableCssSelector;
            ctrlSiteSelectStyleSheet.ButtonNewEnabled = !disableCssSelector;

            // Initialize Rating control
            RefreshCntRatingResult();

            double rating = 0.0f;
            if (Node.DocumentRatings > 0)
            {
                rating = Node.DocumentRatingValue / Node.DocumentRatings;
            }
            ratingControl.MaxRating     = 10;
            ratingControl.CurrentRating = rating;
            ratingControl.Visible       = true;
            ratingControl.Enabled       = false;

            // Initialize Reset button for rating
            btnResetRating.Text          = GetString("general.reset");
            btnResetRating.OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("GeneralProperties.ResetRatingConfirmation")) + ")) return false;";

            object[] param = new object[1];
            param[0] = Node.DocumentID;

            plcAdHocForums.Visible = hasAdHocForum;
            plcAdHocBoards.Visible = hasAdHocBoard;

            if (!canEdit)
            {
                // Disable form editing
                DisableFormEditing();
            }
        }
        else
        {
            btnResetRating.Visible = false;
        }
    }