Esempio n. 1
0
        CategoryInfo[] IMetaWeblog.GetCategories(string blogid, string username, string password)
        {
            return(LogExceptions(() =>
            {
                this.LocatePortal(this.Context.Request);
                DotNetNuke.Entities.Users.UserInfo ui = this.Authenticate(username, password);
                if (ui != null)
                {
                    var categoryInfos = new List <CategoryInfo>();

                    DataTable dt = Publish.Category.GetCategoriesByPortalId(PortalId);
                    foreach (DataRow dr in dt.Rows)
                    {
                        var ci = new CategoryInfo
                        {
                            title = dr["Name"].ToString(),
                            categoryid = dr["ItemId"].ToString(),
                            description = dr["Description"].ToString(),
                            htmlUrl = UrlGenerator.GetItemLinkUrl((int)dr["ItemId"], Globals.GetPortalSettings(), (dr["DisplayTabId"] as int?) ?? Null.NullInteger, (int)dr["ModuleId"]),
                            rssUrl = ModuleBase.GetRssLinkUrl(dr["ItemId"].ToString(), 25, Null.NullInteger, PortalId, string.Empty)
                        };
                        categoryInfos.Add(ci);
                    }

                    return categoryInfos.ToArray();
                }

                throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", this.LocalResourceFile));
            }));
        }
Esempio n. 2
0
 private void LoadSelf(int itemId)
 {
     if (itemId > -1)
     {
         Item i = Item.GetItem(itemId, this.PortalId, Item.GetItemTypeId(itemId), true);
         if (i != null)
         {
             string linkUrl = UrlGenerator.GetItemLinkUrl(i, this.PortalSettings);
             this.bci.Add(i.Name, linkUrl);
         }
     }
 }
Esempio n. 3
0
 private void DisplayItem(Item item)
 {
     if (item != null && !item.IsLinkable() && Null.IsNull(ModuleBase.DefaultDisplayTabIdForPortal(item.PortalId)))
     {
         this.DisplayBrokenLinkMessage(item);
     }
     else
     {
         this.Response.Status           = "301 Moved Permanently";
         this.Response.RedirectLocation = item != null?UrlGenerator.GetItemLinkUrl(item, this.PortalSettings) : Globals.NavigateURL();
     }
 }
 private void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (this.ItemId > -1)
         {
             this.Response.Redirect(UrlGenerator.GetItemLinkUrl(this.ItemId, this.PortalSettings), true);
         }
     }
     catch (Exception exc)
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
Esempio n. 5
0
        private void LoadParents(int itemId)
        {
            if (itemId > -1)
            {
                int parentId = Category.GetParentCategory(itemId, this.PortalId);

                if (parentId > 0)
                {
                    Item   i           = Item.GetItem(parentId, this.PortalId, ItemType.Category.GetId(), true);
                    string categoryUrl = UrlGenerator.GetItemLinkUrl(i, this.PortalSettings);
                    this.bci.InsertBeginning(i.Name, categoryUrl);
                    this.LoadParents(i.ItemId);
                }
            }
        }
Esempio n. 6
0
        private void Page_Load(object sender, EventArgs e)
        {
            // PortalSettings ps = (PortalSettings)HttpContext.Current.Items["PortalSettings"];
            PortalSettings ps = Utility.GetPortalSettings(this.PortalId);

            this.Response.ContentType     = "text/xml";
            this.Response.ContentEncoding = Encoding.UTF8;

            var sw = new StringWriter(CultureInfo.InvariantCulture);
            var wr = new XmlTextWriter(sw);

            wr.WriteStartElement("rss");
            wr.WriteAttributeString("version", "2.0");
            wr.WriteAttributeString("xmlns:wfw", "http://wellformedweb.org/CommentAPI/");
            wr.WriteAttributeString("xmlns:slash", "http://purl.org/rss/1.0/modules/slash/");
            wr.WriteAttributeString("xmlns:dc", "http://purl.org/dc/elements/1.1/");
            wr.WriteAttributeString("xmlns:trackback", "http://madskills.com/public/xml/rss/module/trackback/");

            wr.WriteStartElement("channel");
            wr.WriteElementString("title", ps.PortalName);
            if (ps.PortalAlias.HTTPAlias.IndexOf("http://", StringComparison.OrdinalIgnoreCase) == -1)
            {
                wr.WriteElementString("link", "http://" + ps.PortalAlias.HTTPAlias);
            }
            else
            {
                wr.WriteElementString("link", ps.PortalAlias.HTTPAlias);
            }

            wr.WriteElementString("description", "RSS Feed for " + ps.PortalName);
            wr.WriteElementString("ttl", "120");

            // TODO: look into options for how to display the "Title" of the RSS feed
            var dt = new DataTable
            {
                Locale = CultureInfo.InvariantCulture
            };

            if (this.DisplayType == "ItemListing" || this.DisplayType == null)
            {
                dt = this.ItemId == -1
                         ? DataProvider.Instance().GetMostRecent(this.ItemTypeId, this.NumberOfItems, this.PortalId)
                         : DataProvider.Instance().GetMostRecentByCategoryId(this.ItemId, this.ItemTypeId, this.NumberOfItems, this.PortalId);
            }
            else if (this.DisplayType == "CategoryFeature")
            {
                DataSet ds = DataProvider.Instance().GetParentItems(this.ItemId, this.PortalId, this.RelationshipTypeId);
                dt = ds.Tables[0];
            }
            else if (this.DisplayType == "TagFeed")
            {
                if (this.AllowTags && this._tagQuery != null && this._tagQuery.Count > 0)
                {
                    string tagCacheKey = Utility.CacheKeyPublishTag + this.PortalId + this.ItemTypeId.ToString(CultureInfo.InvariantCulture) +
                                         this._qsTags;

                    // +"PageId";
                    dt = DataCache.GetCache(tagCacheKey) as DataTable;
                    if (dt == null)
                    {
                        // ToDo: we need to make getitemsfromtags use the numberofitems value
                        dt = Tag.GetItemsFromTags(this.PortalId, this._tagQuery);

                        // TODO: we should sort the tags
                        // TODO: should we set a 5 minute cache on RSS?
                        DataCache.SetCache(tagCacheKey, dt, DateTime.Now.AddMinutes(5));
                        Utility.AddCacheKey(tagCacheKey, this.PortalId);
                    }
                }
            }

            if (dt != null)
            {
                DataView dv = dt.DefaultView;
                if (dv.Table.Columns.IndexOf("dateColumn") > 0)
                {
                    dv.Table.Columns.Add("dateColumn", typeof(DateTime));
                    foreach (DataRowView dr in dv)
                    {
                        dr["dateColumn"] = Convert.ToDateTime(dr["startdate"]);
                    }

                    dv.Sort = " dateColumn desc ";
                }

                for (int i = 0; i < dv.Count; i++)
                {
                    // DataRow r = dt.Rows[i];
                    DataRow r = dv[i].Row;
                    wr.WriteStartElement("item");

                    //              wr.WriteElementString("slash:comments", objArticle.CommentCount.ToString());
                    // wr.WriteElementString("wfw:commentRss", "http://" & Request.Url.Host & Me.ResolveUrl("RssComments.aspx?TabID=" & m_tabID & "&ModuleID=" & m_moduleID & "&ArticleID=" & objArticle.ArticleID.ToString()).Replace(" ", "%20"));
                    // wr.WriteElementString("trackback:ping", "http://" & Request.Url.Host & Me.ResolveUrl("Tracking/Trackback.aspx?ArticleID=" & objArticle.ArticleID.ToString() & "&PortalID=" & _portalSettings.PortalId.ToString() & "&TabID=" & _portalSettings.ActiveTab.TabID.ToString()).Replace(" ", "%20"));
                    string title       = string.Empty,
                           description = string.Empty,
                           childItemId = string.Empty,
                           thumbnail   = string.Empty,
                           guid        = string.Empty,
                           author      = string.Empty;

                    DateTime startDate = DateTime.MinValue;

                    if (this.DisplayType == null || string.Equals(this.DisplayType, "ItemListing", StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(this.DisplayType, "TagFeed", StringComparison.OrdinalIgnoreCase))
                    {
                        title       = r["ChildName"].ToString();
                        description = r["ChildDescription"].ToString();
                        childItemId = r["ChilditemId"].ToString();
                        guid        = r["itemVersionIdentifier"].ToString();
                        startDate   = (DateTime)r["StartDate"];
                        thumbnail   = r["Thumbnail"].ToString();
                        author      = r["Author"].ToString();

                        // UserController uc = new UserController();
                        // UserInfo ui = uc.GetUser(PortalId, Convert.ToInt32(r["AuthorUserId"].ToString()));
                        // if(ui!=null)
                        // author = ui.DisplayName;
                    }
                    else if (string.Equals(this.DisplayType, "CategoryFeature", StringComparison.OrdinalIgnoreCase))
                    {
                        title       = r["Name"].ToString();
                        description = r["Description"].ToString();
                        childItemId = r["itemId"].ToString();
                        guid        = r["itemVersionIdentifier"].ToString();
                        startDate   = (DateTime)r["StartDate"];
                        thumbnail   = r["Thumbnail"].ToString();
                        author      = r["Author"].ToString();

                        // UserController uc = new UserController();
                        // UserInfo ui = uc.GetUser(PortalId, Convert.ToInt32(r["AuthorUserId"].ToString()));
                        // if (ui != null)
                        // author = ui.DisplayName;
                    }

                    if (!Uri.IsWellFormedUriString(thumbnail, UriKind.Absolute) && thumbnail != string.Empty)
                    {
                        var thumnailLink = new Uri(this.Request.Url, ps.HomeDirectory + thumbnail);
                        thumbnail = thumnailLink.ToString();
                    }

                    wr.WriteElementString("title", title);

                    // if the item isn't disabled add the link
                    if (!Utility.IsDisabled(Convert.ToInt32(childItemId, CultureInfo.InvariantCulture), this.PortalId))
                    {
                        wr.WriteElementString("link", UrlGenerator.GetItemLinkUrl(childItemId, this.PortalSettings));
                    }

                    // wr.WriteElementString("description", Utility.StripTags(this.Server.HtmlDecode(description)));
                    description = Utility.ReplaceTokens(description);
                    wr.WriteElementString("description", this.Server.HtmlDecode(description));

                    // wr.WriteElementString("author", Utility.StripTags(this.Server.HtmlDecode(author)));
                    wr.WriteElementString("thumbnail", thumbnail);

                    wr.WriteElementString("dc:creator", author);

                    wr.WriteElementString("pubDate", startDate.ToUniversalTime().ToString("r", CultureInfo.InvariantCulture));

                    // file attachment enclosure
                    ItemVersionSetting attachmentSetting = ItemVersionSetting.GetItemVersionSetting(
                        Convert.ToInt32(r["ItemVersionId"].ToString()), "ArticleSettings", "ArticleAttachment", this.PortalId);
                    if (attachmentSetting != null)
                    {
                        if (attachmentSetting.PropertyValue.Length > 7)
                        {
                            var       fileManager = FileManager.Instance;
                            int       fileId      = Convert.ToInt32(attachmentSetting.PropertyValue.Substring(7));
                            IFileInfo fi          = fileManager.GetFile(fileId);
                            string    fileurl     = "http://" + this.PortalSettings.PortalAlias.HTTPAlias + this.PortalSettings.HomeDirectory + fi.Folder +
                                                    fi.FileName;
                            wr.WriteStartElement("enclosure");
                            wr.WriteAttributeString("url", fileurl);
                            wr.WriteAttributeString("length", fi.Size.ToString());
                            wr.WriteAttributeString("type", fi.ContentType);
                            wr.WriteEndElement();
                        }
                    }

                    wr.WriteStartElement("guid");

                    wr.WriteAttributeString("isPermaLink", "false");

                    wr.WriteString(guid);

                    // wr.WriteString(itemVersionId);
                    wr.WriteEndElement();

                    wr.WriteEndElement();
                }
            }

            wr.WriteEndElement();
            wr.WriteEndElement();
            this.Response.Write(sw.ToString());
        }