Beispiel #1
0
 /// <summary>
 /// WriteXml converts the object to Xml (serializes it) and writes it using the XmlWriter passed
 /// </summary>
 /// <remarks></remarks>
 /// <param name="writer">The XmlWriter that contains the xml for the object</param>
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteStartElement("Announcement");
     writer.WriteElementString("ItemID", ItemID.ToString(CultureInfo.InvariantCulture));
     writer.WriteElementString("ModuleID", ModuleID.ToString(CultureInfo.InvariantCulture));
     writer.WriteElementString("Title", Title);
     writer.WriteElementString("URL", URL);
     writer.WriteElementString("ViewOrder", ViewOrder.ToString(CultureInfo.InvariantCulture));
     writer.WriteElementString("Description", Description);
     writer.WriteElementString("ImageSource", ImageSource);
     writer.WriteElementString("TrackClicks", TrackClicks.ToString());
     writer.WriteElementString("NewWindow", NewWindow.ToString());
     writer.WriteElementString("PublishDate", PublishDate.ToString());
     writer.WriteElementString("ExpireDate", ExpireDate.ToString());
     writer.WriteEndElement();
 }
        public virtual string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, DotNetNuke.Entities.Users.UserInfo accessingUser, DotNetNuke.Services.Tokens.Scope accessLevel, ref bool propertyNotFound)
        {
            switch (strPropertyName.ToLower())
            {
            case "sponsorid": // Int
                return(SponsorId.ToString(strFormat, formatProvider));

            case "conferenceid": // Int
                return(ConferenceId.ToString(strFormat, formatProvider));

            case "name": // NVarChar
                return(PropertyAccess.FormatString(Name, strFormat));

            case "url": // VarChar
                if (Url == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Url, strFormat));

            case "description": // NVarCharMax
                if (Description == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Description, strFormat));

            case "vieworder": // Int
                return(ViewOrder.ToString(strFormat, formatProvider));

            case "sponsorlevel": // NVarChar
                if (SponsorLevel == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(SponsorLevel, strFormat));

            default:
                propertyNotFound = true;
                break;
            }

            return(Null.NullString);
        }
Beispiel #3
0
        public string GetProperty(string strPropertyName, string strFormat, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
        {
            PropertyNotFound = false;
            FAQsController faqController;

            switch (strPropertyName.ToLower())
            {
            case "question":
                return(PropertyAccess.FormatString(Question, strFormat));

            case "answer":
                return(PropertyAccess.FormatString(Answer, strFormat));

            case "user":
                UserInfo user = UserController.GetUserById(PortalSettings.Current.PortalId, Convert.ToInt32(CreatedByUser));
                return(PropertyAccess.FormatString(user.DisplayName, strFormat));

            case "viewcount":
                return(ViewCount.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider));

            case "vieworder":
                return(ViewOrder.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider));

            case "categoryname":
                faqController = new FAQsController();
                return(PropertyAccess.FormatString(faqController.GetCategory(CategoryId).FaqCategoryName, strFormat));

            case "categorydesc":
                faqController = new FAQsController();
                return(PropertyAccess.FormatString(faqController.GetCategory(CategoryId).FaqCategoryDescription, strFormat));

            case "datecreated":
                return(CreatedDate.ToString(String.IsNullOrEmpty(strFormat) ? "d" : strFormat, formatProvider));

            case "datemodified":
                return(DateModified.ToString(String.IsNullOrEmpty(strFormat) ? "d" : strFormat, formatProvider));

            case "index":
                return(Index.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider));

            default:
                PropertyNotFound = true;
                return(String.Empty);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Writes a ModuleControlInfo to an XmlWriter
        /// </summary>
        /// <param name="writer">The XmlWriter to use</param>
        /// -----------------------------------------------------------------------------
        public void WriteXml(XmlWriter writer)
        {
            //Write start of main elemenst
            writer.WriteStartElement("moduleControl");

            //write out properties
            WriteXmlInternal(writer);
            writer.WriteElementString("controlTitle", ControlTitle);
            writer.WriteElementString("controlType", ControlType.ToString());
            writer.WriteElementString("iconFile", IconFile);
            writer.WriteElementString("helpUrl", HelpURL);
            writer.WriteElementString("supportsPopUps", SupportsPopUps.ToString());
            if (ViewOrder > Null.NullInteger)
            {
                writer.WriteElementString("viewOrder", ViewOrder.ToString());
            }
            //Write end of main element
            writer.WriteEndElement();
        }
        public string GetProperty(string strPropertyName, string strFormat, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
        {
            PortalSettings portalSettings = PortalController.GetCurrentPortalSettings();
            string         outputFormat   = strFormat == string.Empty ? "D" : strFormat;

            switch (strPropertyName.ToLowerInvariant())
            {
            case "edit":
                if (IsEditable)
                {
                    string editUrl = Globals.NavigateURL(portalSettings.ActiveTab.TabID, false, portalSettings,
                                                         "Edit",
                                                         CultureInfo.CurrentCulture.Name,
                                                         "mid=" + ModuleID.ToString(CultureInfo.InvariantCulture),
                                                         "itemid=" + ItemID.ToString(CultureInfo.InvariantCulture));
                    if (portalSettings.EnablePopUps)
                    {
                        editUrl = UrlUtils.PopUpUrl(editUrl, null, portalSettings, false, false);
                    }
                    return("<a href=\"" + editUrl + "\"><img border=\"0\" src=\"" + Globals.ApplicationPath + "/icons/sigma/Edit_16X16_Standard_2.png\" alt=\"" + Localization.GetString("EditAnnouncement.Text", _localResourceFile) + "\" /></a>");
                }
                return(string.Empty);

            case "itemid":
                return(ItemID.ToString(outputFormat, formatProvider));

            case "moduleid":
                return(ModuleID.ToString(outputFormat, formatProvider));

            case "title":
                return(PropertyAccess.FormatString(Title, strFormat));

            case "url":
                return(PropertyAccess.FormatString(string.IsNullOrEmpty(URL) ? URL : Utilities.FormatUrl(URL, portalSettings.ActiveTab.TabID, ModuleID, TrackClicks), strFormat));

            case "description":
                return(HttpUtility.HtmlDecode(Description));

            case "imagesource":
            case "rawimage":
                string strValue = ImageSource;
                if (strPropertyName.ToLowerInvariant() == "imagesource" && string.IsNullOrEmpty(strFormat))
                {
                    strFormat = "<img src=\"{0}\" alt=\"" + Title + "\" />";
                }

                //Retrieve the path to the imagefile
                if (strValue != "")
                {
                    //Get path from filesystem only when the image comes from within DNN.
                    // this is now legacy, from version 7.0.0, a real filename is saved in the DB
                    if (ImageSource.StartsWith("FileID="))
                    {
                        var      fileCnt = new FileController();
                        FileInfo objFile = fileCnt.GetFileById(Convert.ToInt32(strValue.Substring(7)),
                                                               portalSettings.PortalId);
                        if (objFile != null)
                        {
                            strValue = portalSettings.HomeDirectory + objFile.Folder + objFile.FileName;
                        }
                        else
                        {
                            strValue = "";
                        }
                    }
                    else
                    {
                        if (!ImageSource.ToLowerInvariant().StartsWith("http"))
                        {
                            strValue = portalSettings.HomeDirectory + ImageSource;
                        }
                    }
                    strValue = PropertyAccess.FormatString(strValue, strFormat);
                }
                return(strValue);

            case "vieworder":
                return(ViewOrder.ToString(outputFormat, formatProvider));

            case "createdbyuserid":
                return(CreatedByUserID.ToString(outputFormat, formatProvider));

            case "createdbyuser":
                UserInfo tmpUser = CreatedByUser(portalSettings.PortalId);
                return(tmpUser != null ? tmpUser.DisplayName : Localization.GetString("userUnknown.Text", _localResourceFile));

            case "lastmodifiedbyuserid":
                return(LastModifiedByUserID.ToString(outputFormat, formatProvider));

            case "lastmodifiedbyuser":
                UserInfo tmpUser2 = LastModifiedByUser(portalSettings.PortalId);
                return(tmpUser2 != null ? tmpUser2.DisplayName : Localization.GetString("userUnknown.Text", _localResourceFile));

            case "trackclicks":
                return(PropertyAccess.Boolean2LocalizedYesNo(TrackClicks, formatProvider));

            case "newwindow":
                return(NewWindow ? "_blank" : "_self");

            case "createddate":
            case "createdondate":
                return(CreatedOnDate.ToString(outputFormat, formatProvider));

            case "lastmodifiedondate":
                return(LastModifiedOnDate.ToString(outputFormat, formatProvider));

            case "publishdate":
                return(PublishDate.HasValue ? (PublishDate.Value.ToString(outputFormat, formatProvider)) : "");

            case "expiredate":
                return(ExpireDate.HasValue ? (ExpireDate.Value.ToString(outputFormat, formatProvider)) : "");

            case "more":
                return(Localization.GetString("More.Text", _localResourceFile));

            case "readmore":
                string strTarget = NewWindow ? "_new" : "_self";

                return(!(string.IsNullOrEmpty(URL))
                               ? "<a href=\"" + Utilities.FormatUrl(URL, portalSettings.ActiveTab.TabID, ModuleID, TrackClicks) +
                       "\" target=\"" + strTarget + "\">" + Localization.GetString("More.Text", _localResourceFile) +
                       "</a>"
                               : "");

            case "permalink":
                return(Permalink());

            case "subscribe":

            default:
                PropertyNotFound = true;
                break;
            }

            return(Null.NullString);
        }