コード例 #1
0
        /// <summary>
        /// Creates a Metaweblog Page object from the XML struct
        /// </summary>
        /// <param name="node">
        /// XML contains a Metaweblog Page Struct
        /// </param>
        /// <returns>
        /// Metaweblog Page Struct Obejct
        /// </returns>
        private static MWAPage GetPage(XmlNode node)
        {
            var temp = new MWAPage();

            // Require Title and Description
            var title = node.SelectSingleNode("value/struct/member[name='title']");

            if (title == null)
            {
                throw new MetaWeblogException("06", "Page Struct Element, Title, not Sent.");
            }

            temp.title = title.LastChild.InnerText;

            var description = node.SelectSingleNode("value/struct/member[name='description']");

            if (description == null)
            {
                throw new MetaWeblogException("06", "Page Struct Element, Description, not Sent.");
            }

            temp.description = description.LastChild.InnerText;

            var link = node.SelectSingleNode("value/struct/member[name='link']");

            if (link != null)
            {
                temp.link = node.SelectSingleNode("value/struct/member[name='link']") == null ? null : link.LastChild.InnerText;
            }

            var dateCreated = node.SelectSingleNode("value/struct/member[name='dateCreated']");

            if (dateCreated != null)
            {
                try
                {
                    var tempDate = dateCreated.LastChild.InnerText;
                    temp.pageDate = DateTime.ParseExact(
                        tempDate,
                        "yyyyMMdd'T'HH':'mm':'ss",
                        CultureInfo.InvariantCulture,
                        DateTimeStyles.AssumeUniversal);
                }
                catch (Exception ex)
                {
                    // Ignore PubDate Error
                    log.Error("swallowed pub date error", ex);
                    //Debug.WriteLine(ex.Message);
                }
            }

            // Keywords
            var keywords = node.SelectSingleNode("value/struct/member[name='mt_keywords']");

            temp.mt_keywords = keywords == null ? string.Empty : keywords.LastChild.InnerText;

            var pageParentId = node.SelectSingleNode("value/struct/member[name='wp_page_parent_id']");

            temp.pageParentID = pageParentId == null ? null : pageParentId.LastChild.InnerText;

            var pageOrder = node.SelectSingleNode("value/struct/member[name='wp_page_order']");

            temp.pageOrder = pageOrder == null ? null : pageOrder.LastChild.InnerText;

            var allowComments = node.SelectSingleNode("value/struct/member[name='mt_allow_comments']");

            temp.commentPolicy = allowComments == null ? string.Empty : allowComments.LastChild.InnerText;

            return(temp);
        }
コード例 #2
0
        /// <summary>
        /// wp.getPages method
        /// </summary>
        /// <param name="blogId">
        /// blogID in string format
        /// </param>
        /// <param name="userName">
        /// login username
        /// </param>
        /// <param name="password">
        /// login password
        /// </param>
        /// <returns>
        /// a list of pages
        /// </returns>
        internal List<MWAPage> GetPages(string blogId, string userName, string password)
        {
            List<MWAPage> allPages = new List<MWAPage>();

            HtmlRepository repository = new HtmlRepository();

            using (IDataReader reader = repository.GetHtmlForMetaWeblogApi(siteSettings.SiteId))
            {
                while (reader.Read())
                {
                    MWAPage p = new MWAPage();
                    p.description = reader["Body"].ToString();
                    p.link = FormatPageUrl(Convert.ToInt32(reader["PageID"]), reader["Url"].ToString(), Convert.ToBoolean(reader["UseUrl"]));

                    // adjust from utc to user time zone
                    if (reader["PublishBeginDate"] != DBNull.Value)
                    {
                        p.pageUtcDate = Convert.ToDateTime(reader["PublishBeginDate"]);
                        p.pageDate = Convert.ToDateTime(reader["PublishBeginDate"]).ToLocalTime(timeZone);
                        //p.pageDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.SpecifyKind(Convert.ToDateTime(reader["PublishBeginDate"]), DateTimeKind.Utc), timeZone);
                    }
                    else
                    {
                        p.pageUtcDate = DateTime.UtcNow;
                        p.pageDate = DateTime.UtcNow.AddMinutes(-5).ToLocalTime(timeZone);
                    }

                    p.pageID = reader["PageGuid"].ToString().ToLowerInvariant();
                    p.pageParentID = reader["ParentGuid"].ToString().ToLowerInvariant();

                    p.pageOrder = Convert.ToInt32(reader["PageOrder"]).ToInvariantString();

                    p.title = reader["PageName"].ToString();
                    p.pageEditRoles = reader["EditRoles"].ToString();
                    p.moduleEditRoles = reader["AuthorizedEditRoles"].ToString();

                    bool allowComments = Convert.ToBoolean(reader["EnableComments"]);
                    if (allowComments)
                    {
                        p.commentPolicy = "1";
                    }
                    else
                    {
                        p.commentPolicy = "0";
                    }

                    bool isDraft = Convert.ToBoolean(reader["IsPending"]);
                    if (isDraft)
                    {
                        p.published = "draft";
                    }
                    else
                    {
                        p.published = "publish";
                    }

                    allPages.Add(p);

                }
            }

            List<MWAPage> allowedPages = new List<MWAPage>();

            foreach (MWAPage p in allPages)
            {
                // filter out all except the first html instance on the page
                if (Contains(allowedPages, p.pageID)) { continue; }
                if (UserCanEdit(p)) { allowedPages.Add(p); }
            }

            return allowedPages;
        }
コード例 #3
0
ファイル: XMLRPCRequest.cs プロジェクト: saiesh86/TravelBlog
        /// <summary>
        /// Creates a Metaweblog Page object from the XML struct
        /// </summary>
        /// <param name="node">
        /// XML contains a Metaweblog Page Struct
        /// </param>
        /// <returns>
        /// Metaweblog Page Struct Obejct
        /// </returns>
        private static MWAPage GetPage(XmlNode node)
        {
            var temp = new MWAPage();

            // Require Title and Description
            var title = node.SelectSingleNode("value/struct/member[name='title']");
            if (title == null)
            {
                throw new MetaWeblogException("06", "Page Struct Element, Title, not Sent.");
            }

            temp.title = title.LastChild.InnerText;

            var description = node.SelectSingleNode("value/struct/member[name='description']");
            if (description == null)
            {
                throw new MetaWeblogException("06", "Page Struct Element, Description, not Sent.");
            }

            temp.description = description.LastChild.InnerText;

            var link = node.SelectSingleNode("value/struct/member[name='link']");
            if (link != null)
            {
                temp.link = node.SelectSingleNode("value/struct/member[name='link']") == null ? null : link.LastChild.InnerText;
            }

            var dateCreated = node.SelectSingleNode("value/struct/member[name='dateCreated']");
            if (dateCreated != null)
            {
                try
                {
                    var tempDate = dateCreated.LastChild.InnerText;
                    temp.pageDate = DateTime.ParseExact(
                        tempDate,
                        "yyyyMMdd'T'HH':'mm':'ss",
                        CultureInfo.InvariantCulture,
                        DateTimeStyles.AssumeUniversal);
                }
                catch (Exception ex)
                {
                    // Ignore PubDate Error
                    log.Error("swallowed pub date error", ex);
                    //Debug.WriteLine(ex.Message);
                }
            }

            // Keywords
            var keywords = node.SelectSingleNode("value/struct/member[name='mt_keywords']");
            temp.mt_keywords = keywords == null ? string.Empty : keywords.LastChild.InnerText;

            var pageParentId = node.SelectSingleNode("value/struct/member[name='wp_page_parent_id']");
            temp.pageParentID = pageParentId == null ? null : pageParentId.LastChild.InnerText;

            var pageOrder = node.SelectSingleNode("value/struct/member[name='wp_page_order']");
            temp.pageOrder = pageOrder == null ? null : pageOrder.LastChild.InnerText;

            var allowComments = node.SelectSingleNode("value/struct/member[name='mt_allow_comments']");
            temp.commentPolicy = allowComments == null ? string.Empty : allowComments.LastChild.InnerText;

            return temp;
        }
コード例 #4
0
        /// <summary>
        /// wp.getPageList method
        /// </summary>
        /// <param name="blogId">
        /// blogID in string format
        /// </param>
        /// <param name="userName">
        /// login username
        /// </param>
        /// <param name="password">
        /// login password
        /// </param>
        /// <returns>
        /// a list of pages used to populate the parent page dropdown
        /// here we have to include all viewrole allowed pages because this is for the parent page dropdown and we
        /// cannot assume anything about the hierarchy. If we left out the parent page on edit it would try to move it to root
        /// so we must make sure this list contains the parent page for any page the user can edit
        /// </returns>
        internal List<MWAPage> GetPageList(string blogId, string userName, string password)
        {
            List<MWAPage> allPages = new List<MWAPage>();

            using (IDataReader reader = PageSettings.GetChildPagesSortedAlphabetic(siteSettings.SiteId, -2))
            {
                while (reader.Read())
                {
                    MWAPage p = new MWAPage();

                    p.pageID = reader["PageGuid"].ToString().ToLowerInvariant();
                    p.pageParentID = reader["ParentGuid"].ToString().ToLowerInvariant();
                    p.pageOrder = Convert.ToInt32(reader["PageOrder"]).ToInvariantString();
                    p.title = reader["PageName"].ToString();
                    p.pageEditRoles = reader["EditRoles"].ToString();

                    // we are purposely leaving out the dates for lists because wlw interprets them strangely for pages
                    // and filters out things with future dates, but since it seems to treat local time as utc
                    // it filters thing sout thsat it shouldn't and really using UTC causes other problems.
                    // we are setting the dates here but they are not rendered for the lists in
                    // XMLRPCResponse.cs
                    p.pageUtcDate = DateTime.UtcNow.AddDays(-2);
                    p.pageDate = DateTime.UtcNow.AddDays(-2).ToLocalTime(timeZone);

                    string viewRoles = reader["AuthorizedRoles"].ToString();
                    if (UserCanView(viewRoles))
                    {
                        allPages.Add(p);
                    }

                }
            }

            return allPages;
        }
コード例 #5
0
        /// <summary>
        /// wp.getPage method
        /// </summary>
        /// <param name="blogId">
        /// blogID in string format
        /// </param>
        /// <param name="pageId">
        /// page guid in string format
        /// </param>
        /// <param name="userName">
        /// login username
        /// </param>
        /// <param name="password">
        /// login password
        /// </param>
        /// <returns>
        /// struct with post details
        /// </returns>
        internal MWAPage GetPage(string blogId, string pageId, string userName, string password)
        {
            var p = new MWAPage();
            PageSettings page = CacheHelper.GetPage(new Guid(pageId));

            if (page.PageId == -1)
            { //doesn't exist
                throw new MetaWeblogException("11", MetaweblogResources.PageNotFound);
            }

            Module m  = GetFirstCenterPaneHtmlModule(page);

            if (m == null)
            {
                throw new MetaWeblogException("11", MetaweblogResources.ContentInstanceNotFound);
            }

            HtmlRepository repository = new HtmlRepository();
            HtmlContent html = repository.Fetch(m.ModuleId);

            // html does not immediately exist as soon as module is added to the page
            // it is created upon first edit if it does not so we need to check for null
            if (html != null)
            {
                p.description = html.Body;

            }

            p.pageUtcDate = page.LastModifiedUtc;
            p.pageDate = page.LastModifiedUtc.ToLocalTime(timeZone);
            if (page.UrlHasBeenAdjustedForFolderSites)
            {
                p.link = FormatPageUrl(page.PageId, page.UnmodifiedUrl, page.UseUrl);
            }
            else
            {
                p.link = FormatPageUrl(page.PageId, page.Url, page.UseUrl);
            }

            p.pageID = page.PageGuid.ToString();
            p.pageParentID = page.ParentGuid.ToString();

            if (page.ParentGuid != Guid.Empty)
            {
                PageSettings parentPage = new PageSettings(page.ParentGuid);
                p.parentTitle = parentPage.PageName;
            }
            else
            {
                p.pageParentID = string.Empty; // we don't want to pass Guid.Empty it causes problems in wlw
            }

            p.pageOrder = page.PageOrder.ToInvariantString();

            // generally module title and page name should be the same
            // except on the home page since we don't want to change the pagename of the home page
            // to match th emodule title we must return the module title when getting the page for edit purposes
            p.title = m.ModuleTitle;
            p.pageEditRoles = page.EditRoles;
            p.moduleEditRoles = m.AuthorizedEditRoles;

            if (page.EnableComments)
            {
                p.commentPolicy = "1";
            }
            else
            {
                p.commentPolicy = "2";
            }

            if (!UserCanEdit(p))
            {
                throw new MetaWeblogException("11", "User doesn't have permission on this content");
            }

            return p;
        }
コード例 #6
0
        /// <summary>
        /// Edits the page.
        /// </summary>
        /// <param name="blogId">
        /// The blog id.
        /// </param>
        /// <param name="pageId">
        /// The page id.
        /// </param>
        /// <param name="userName">
        /// The user name.
        /// </param>
        /// <param name="password">
        /// The password.
        /// </param>
        /// <param name="mwaPage">
        /// The m page.
        /// </param>
        /// <param name="publish">
        /// The publish.
        /// </param>
        /// <returns>
        /// The edit page.
        /// </returns>
        internal bool EditPage(string blogId, string pageId, string userName, string password, MWAPage mwaPage, bool publish)
        {
            if ((string.IsNullOrEmpty(pageId))||(pageId.Length != 36))
            {
                throw new MetaWeblogException("11", MetaweblogResources.PageNotFound);
            }

            PageSettings page = CacheHelper.GetPage(new Guid(pageId));

            if (page.PageId == -1)
            { //doesn't exist
                throw new MetaWeblogException("11", MetaweblogResources.PageNotFound);
            }

            if (page.SiteId != siteSettings.SiteId)
            { //doesn't exist
                throw new MetaWeblogException("11", MetaweblogResources.PageNotFound);
            }

            //if (!publish)
            //{
            //    throw new MetaWeblogException("11", "Sorry draft pages are not supported through this API.");
            //}

            Module m = GetFirstCenterPaneHtmlModule(page);

            if (m == null)
            {
                throw new MetaWeblogException("11", MetaweblogResources.ContentInstanceNotFound);
            }

            if (!UserCanEdit(page, m))
            {
                throw new MetaWeblogException("11", MetaweblogResources.AccessDenied);
            }

            PageSettings parentPage = null;
            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(m.ModuleId);
            HtmlConfiguration config = new HtmlConfiguration(moduleSettings);

            HtmlRepository repository = new HtmlRepository();
            HtmlContent html = repository.Fetch(m.ModuleId);

            if (html == null)
            {
                html = new HtmlContent();
                html.ModuleId = m.ModuleId;
                html.ModuleGuid = m.ModuleGuid;
            }

            bool titleChanged = (m.ModuleTitle != mwaPage.title);
            // updated 2011-11-30 don't change page name for existing pages
            // only update the module title
            // avoid changing the home page name
            // while most content pages should have the module title the same as the page name for best seo
            // this is usually not the case for the home page, ie the content is not titled "home"
            //if (!IsHomePage(page.PageId))
            //{
            //    page.PageName = mwaPage.title;
            //}

            if (titleChanged)
            {
                m.ModuleTitle = mwaPage.title;
                m.Save();

            }

            html.Body = mwaPage.description;
            if ((mwaPage.mt_keywords != null) &&(mwaPage.mt_keywords.Length > 0))
            {
                page.PageMetaKeyWords = mwaPage.mt_keywords;
            }

            bool needToClearSiteMapCache = false;
            bool pageOrderChanged = false;
            if ((mwaPage.pageOrder != null)&&(mwaPage.pageOrder.Length > 0))
            {
                int newPageOrder = Convert.ToInt32(mwaPage.pageOrder);
                if (page.PageOrder != newPageOrder)
                {
                    page.PageOrder = newPageOrder;
                    needToClearSiteMapCache = true;
                    pageOrderChanged = true;
                }
            }

            bool makeDraft = !publish;

            if (page.IsPending != makeDraft)
            {
                page.IsPending = makeDraft;
                needToClearSiteMapCache = true;
            }

            if ((mwaPage.pageParentID != null) &&(mwaPage.pageParentID.Length == 36))
            {
                Guid parentGuid = new Guid(mwaPage.pageParentID);

                if (page.PageGuid == parentGuid)
                {
                    throw new MetaWeblogException("11", MetaweblogResources.PageCantBeItsOwnParent);
                }

                // if parent pageid hasn't changed no need to doo anything
                if (parentGuid != page.ParentGuid)
                {
                    if (parentGuid == Guid.Empty)
                    {
                        if (UserCanCreateRootLevelPages())
                        {
                            page.ParentId = -1;
                            page.PageGuid = Guid.Empty;
                            needToClearSiteMapCache = true;
                        }
                        else
                        {
                            throw new MetaWeblogException("11", MetaweblogResources.NotAllowedToCreateRootPages);
                        }
                    }
                    else
                    {
                        parentPage = new PageSettings(parentGuid);

                        if (parentPage.SiteId != siteSettings.SiteId)
                        {
                            throw new MetaWeblogException("11", MetaweblogResources.ParentPageNotFound);
                        }

                        if (
                            (parentPage.PageId > -1)
                            && (parentPage.PageId != page.PageId) // page cannot be its own parent
                            && (parentPage.ParentId != page.PageId) // a child of the page cannot become its parent
                            )
                        {
                            // parent page exists

                            //verify user can create pages below parent
                            if (!UserCanCreateChildPages(parentPage))
                            {
                                throw new MetaWeblogException("11", MetaweblogResources.NotAllowedParentPage);
                            }

                            // descendant of page (grandchildren cannot become parent)
                            // so make sure selected parent is not a descendant of the current page
                            if (IsValidParentPage(page, parentPage))
                            {
                                page.ParentId = parentPage.PageId;
                                page.PageGuid = parentPage.PageGuid;
                                needToClearSiteMapCache = true;
                            }
                            else
                            {
                                throw new MetaWeblogException("11", MetaweblogResources.DescendentParentsNotAllowed);
                            }

                        }
                    }
                }
            }

            // keep verison history if enabled
            bool enableContentVersioning = config.EnableContentVersioning;

            if ((siteSettings.ForceContentVersioning) || (WebConfigSettings.EnforceContentVersioningGlobally))
            {
                enableContentVersioning = true;
            }

            if ((html.ItemId > -1)&&(enableContentVersioning))
            {
                html.CreateHistory(siteSettings.SiteGuid);
            }

            html.LastModUserGuid = siteUser.UserGuid;
            html.LastModUtc = DateTime.UtcNow;
            page.LastModifiedUtc = DateTime.UtcNow;
            html.ModuleGuid = m.ModuleGuid;

            html.ContentChanged += new ContentChangedEventHandler(html_ContentChanged);

            repository.Save(html);

            CacheHelper.ClearModuleCache(m.ModuleId);

            switch (mwaPage.commentPolicy)
            {
                //closed
                case "0":
                case "2":
                    page.EnableComments = false;
                    break;
                // open
                case "1":
                    // if the post was previously closed to comments
                    // re-open it using the default allowed days
                    page.EnableComments = true;

                    break;
                //else unspecified, no change
            }

            if (page.UrlHasBeenAdjustedForFolderSites)
            {
                page.Url = page.UnmodifiedUrl;
            }

            page.Save();

            if (pageOrderChanged)
            {
                if ((parentPage == null) && (page.ParentGuid != Guid.Empty))
                {
                    parentPage = new PageSettings(page.ParentGuid);
                }

            }

            if (parentPage != null)
            {
                parentPage.ResortPages();
            }

            if (needToClearSiteMapCache)
            {
                CacheHelper.ResetSiteMapCache(siteSettings.SiteId);
            }

            SiteUtils.QueueIndexing();

            return true;
        }
コード例 #7
0
        private bool UserCanEdit(MWAPage page)
        {
            if (isAdmin) { return true; }

            if (page.pageEditRoles == "Admins") { return false; }

            if (isContentAdmin || isSiteEditor) { return true; }

            if (page.moduleEditRoles == "Admins") { return false; }

            if ((siteUser.IsInRoles(page.pageEditRoles)) || (siteUser.IsInRoles(page.moduleEditRoles)))
            {
                return true;
            }

            return false;
        }
コード例 #8
0
        /// <summary>
        /// wp.newPage method
        /// </summary>
        /// <param name="blogId">blogID in string format</param>
        /// <param name="userName">login username</param>
        /// <param name="password">login password</param>
        /// <param name="mwaPage">The mwa page.</param>
        /// <param name="publish">if set to <c>true</c> [publish].</param>
        /// <returns>The new page.</returns>
        internal string NewPage(string blogId, string userName, string password, MWAPage mwaPage, bool publish)
        {
            PageSettings page = new PageSettings();
            PageSettings parentPage = null;

            Guid parentGuid = Guid.Empty;
            if ((mwaPage.pageParentID != null)&&(mwaPage.pageParentID.Length == 36))
            {
                parentGuid = new Guid(mwaPage.pageParentID);
            }

            if (parentGuid == Guid.Empty) //root level page
            {
                if (!UserCanCreateRootLevelPages())
                {
                    throw new MetaWeblogException("11", MetaweblogResources.NotAllowedToCreateRootPages);
                }

                // TODO: promote these to site settings?
                //page.AuthorizedRoles = WebConfigSettings.DefaultPageRoles;
                //page.EditRoles = WebConfigSettings.DefaultRootPageEditRoles;
                //page.CreateChildPageRoles = WebConfigSettings.DefaultRootPageCreateChildPageRoles;

                page.AuthorizedRoles = siteSettings.DefaultRootPageViewRoles;
                page.EditRoles = siteSettings.DefaultRootPageEditRoles;
                page.CreateChildPageRoles = siteSettings.DefaultRootPageCreateChildPageRoles;
            }
            else
            {
                parentPage = new PageSettings(parentGuid);

                if (parentPage.PageId == -1)
                {
                    throw new MetaWeblogException("11", MetaweblogResources.ParentPageNotFound);
                }

                if (parentPage.SiteId != siteSettings.SiteId)
                {
                    throw new MetaWeblogException("11", MetaweblogResources.ParentPageNotFound);
                }

                if (!UserCanCreateChildPages(parentPage))
                {
                    throw new MetaWeblogException("11", MetaweblogResources.NotAllowedParentPage);
                }
            }

            if (parentPage != null)
            {
                page.ParentId = parentPage.PageId;
                page.ParentGuid = parentPage.PageGuid;
                page.PageOrder = PageSettings.GetNextPageOrder(siteSettings.SiteId, parentPage.PageId);

                // by default inherit settings from parent
                page.AuthorizedRoles = parentPage.AuthorizedRoles;
                page.EditRoles = parentPage.EditRoles;
                page.DraftEditOnlyRoles = parentPage.DraftEditOnlyRoles;
                page.CreateChildPageRoles = parentPage.CreateChildPageRoles;
                page.CreateChildDraftRoles = parentPage.CreateChildDraftRoles;
            }

            if ((mwaPage.pageOrder != null) && (mwaPage.pageOrder.Length > 0))
            {
                 page.PageOrder = Convert.ToInt32(mwaPage.pageOrder);
            }

            page.SiteId = siteSettings.SiteId;
            page.SiteGuid = siteSettings.SiteGuid;
            page.IsPending = !publish;

            page.PageName = mwaPage.title;
            //page.PageTitle = mwaPage.title; // this was the override page title it should not be set here
            if ((mwaPage.mt_keywords != null) && (mwaPage.mt_keywords.Length > 0))
            {
                page.PageMetaKeyWords = mwaPage.mt_keywords;
            }

            if (WebConfigSettings.AutoGeneratePageMetaDescriptionForMetaweblogNewPages)
            {
                page.PageMetaDescription = UIHelper.CreateExcerpt(mwaPage.description, WebConfigSettings.MetaweblogGeneratedMetaDescriptionMaxLength);
            }

            //if (WebConfigSettings.ShowUseUrlSettingInPageSettings)
            //{

            //}

            string friendlyUrlString = SiteUtils.SuggestFriendlyUrl(page.PageName, siteSettings);
            page.Url = "~/" + friendlyUrlString;
            page.UseUrl = true;

            switch (mwaPage.commentPolicy)
            {
                // open
                case "1":
                    // if the post was previously closed to comments
                    // re-open it using the default allowed days
                    page.EnableComments = true;

                    break;

                //closed
                case "0":
                case "2":
                default:
                    page.EnableComments = false;
                    break;

            }

            // I'm not sure we should support the page created event handler here, people may do redirects there
            // that would interupt our next steps
            // maybe need a config setting to decide

            // page.PageCreated += new PageCreatedEventHandler(PageCreated);

            page.Save();

            FriendlyUrl newFriendlyUrl = new FriendlyUrl();
            newFriendlyUrl.SiteId = siteSettings.SiteId;
            newFriendlyUrl.SiteGuid = siteSettings.SiteGuid;
            newFriendlyUrl.PageGuid = page.PageGuid;
            newFriendlyUrl.Url = friendlyUrlString;
            newFriendlyUrl.RealUrl = "~/Default.aspx?pageid=" + page.PageId.ToInvariantString();
            newFriendlyUrl.Save();

            // create html module in center pane
            ModuleDefinition moduleDefinition = new ModuleDefinition(HtmlContent.FeatureGuid);
            Module m = new Module();
            m.SiteId = siteSettings.SiteId;
            m.SiteGuid = siteSettings.SiteGuid;
            m.ModuleDefId = moduleDefinition.ModuleDefId;
            m.FeatureGuid = moduleDefinition.FeatureGuid;
            m.Icon = moduleDefinition.Icon;
            m.CacheTime = moduleDefinition.DefaultCacheTime;
            m.PageId = page.PageId;
            m.ModuleTitle = page.PageTitle;
            m.PaneName = "contentpane";
            m.CreatedByUserId = siteUser.UserId;
            m.ShowTitle = WebConfigSettings.ShowModuleTitlesByDefault;
            m.HeadElement = WebConfigSettings.ModuleTitleTag;
            m.ModuleOrder = 1;
            m.Save();

            HtmlRepository repository = new HtmlRepository();
            HtmlContent html = new HtmlContent();
            html.ModuleId = m.ModuleId;
            html.ModuleGuid = m.ModuleGuid;
            html.Body = mwaPage.description;
            //html.CreatedBy = siteUser.UserId;
            html.UserGuid = siteUser.UserGuid;
            html.CreatedDate = DateTime.UtcNow;
            html.LastModUserGuid = siteUser.UserGuid;
            html.LastModUtc = DateTime.UtcNow;

            html.ContentChanged += new ContentChangedEventHandler(html_ContentChanged);

            repository.Save(html);

            mojoPortal.SearchIndex.IndexHelper.RebuildPageIndexAsync(page);
            SiteUtils.QueueIndexing();

            CacheHelper.ResetSiteMapCache(siteSettings.SiteId);

            return page.PageGuid.ToString();
        }