Exemplo n.º 1
0
        protected void cmdDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(WikiPage) || IsFile)
                {
                    return;
                }
                var pageName = PageNameUtil.Decode(WikiPage);

                var page = Wiki.GetPage(pageName);
                CommunitySecurity.DemandPermissions(new WikiObjectsSecurityObject(page), Common.Constants.Action_RemovePage);

                foreach (var cat in Wiki.GetCategoriesRemovedWithPage(pageName))
                {
                    WikiNotifySource.Instance.GetSubscriptionProvider().UnSubscribe(Common.Constants.AddPageToCat, cat.CategoryName);
                }

                Wiki.RemoveCategories(pageName);

                WikiNotifySource.Instance.GetSubscriptionProvider().UnSubscribe(Common.Constants.EditPage, pageName);

                foreach (var comment in Wiki.GetComments(pageName))
                {
                    CommonControlsConfigurer.FCKUploadsRemoveForItem("wiki_comments", comment.Id.ToString());
                }
                Wiki.RemovePage(pageName);

                Response.RedirectLC("Default.aspx", this);
            }
            catch (Exception err)
            {
                WikiMaster.PrintInfoMessage(err.Message, InfoType.Alert);
            }
        }
Exemplo n.º 2
0
        protected void OnPageEmpty(object sender, EventArgs e)
        {
            var pageName = PageNameUtil.Decode(WikiPage);

            wikiViewPage.Visible     = false;
            wikiEditPage.Visible     = false;
            wikiViewFile.Visible     = false;
            wikiEditFile.Visible     = false;
            pPageIsNotExists.Visible = true;

            if (!(Action.Equals(ActionOnPage.CategoryView) || Action.Equals(ActionOnPage.CategoryEdit)))
            {
                if (IsFile)
                {
                    txtPageEmptyLabel.Text = PrepereEmptyString(WikiResource.MainWikiFileIsNotExists, true, false);
                }
                else
                {
                    if (Wiki.SearchPagesByName(pageName).Count > 0)
                    {
                        txtPageEmptyLabel.Text = PrepereEmptyString(WikiResource.MainWikiPageIsNotExists, false, true);
                    }
                    else
                    {
                        txtPageEmptyLabel.Text = PrepereEmptyString(WikiResource.MainWikiPageIsNotExists, false, false);
                    }
                }
            }

            _isEmptyPage = true;
            InitEditsLink();
            //WikiMaster.UpdateNavigationItems();
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            (Master as WikiMaster).GetNavigateActionsVisible += new WikiMaster.GetNavigateActionsVisibleHandle(PageHistoryList_GetNavigateActionsVisible);

            var page = Wiki.GetPage(PageNameUtil.Decode(WikiPage));

            if (Request["page"] == null || page == null)
            {
                Response.RedirectLC("Default.aspx", this);
            }

            string PageName = page.PageName.Equals(string.Empty) ? WikiResource.MainWikiCaption : page.PageName;

            BreadCrumb.Add(new ASC.Web.Controls.BreadCrumb()
            {
                Caption = PageName, NavigationUrl = ActionHelper.GetViewPagePath(this.ResolveUrlLC("Default.aspx"), page.PageName)
            });
            BreadCrumb.Add(new ASC.Web.Controls.BreadCrumb()
            {
                Caption = WikiResource.wikiHistoryCaption
            });

            if (!IsPostBack)
            {
                cmdDiff.Text     = WikiResource.cmdDiff;
                cmdDiff_Top.Text = WikiResource.cmdDiff;
                BindHistoryList();
            }
        }
Exemplo n.º 4
0
        protected void cmdRevert_Click(object sender, EventArgs e)
        {
            if (CommunitySecurity.IsOutsider())
            {
                throw new SecurityException();
            }

            int ver;

            if (int.TryParse((sender as LinkButton).CommandName, out ver))
            {
                var page = Wiki.GetPage(PageNameUtil.Decode(WikiPage), ver);
                if (page != null)
                {
                    page.Date    = TenantUtil.DateTimeNow();
                    page.UserID  = SecurityContext.CurrentAccount.ID;
                    page.Version = Wiki.GetPageMaxVersion(page.PageName) + 1;

                    Wiki.SavePage(page);
                    Wiki.UpdateCategoriesByPageContent(page);

                    BindHistoryList();
                }
            }
        }
Exemplo n.º 5
0
        private void UpdateBreadCrumb()
        {
            if (OldVer == 0 || NewVer == 0 || OldVer == NewVer)
            {
                Response.RedirectLC(ActionHelper.GetViewPagePath(this.ResolveUrlLC("PageHistoryList.aspx"), PageNameUtil.Decode(WikiPage)), this);
            }

            string pageName = PageNameUtil.Decode(WikiPage);

            if (string.IsNullOrEmpty(pageName))
            {
                pageName = WikiResource.MainWikiCaption;
            }

            BreadCrumb.Clear();
            BreadCrumb.Add(new ASC.Web.Controls.BreadCrumb()
            {
                Caption = pageName, NavigationUrl = ActionHelper.GetViewPagePath(this.ResolveUrlLC("Default.aspx"), PageNameUtil.Decode(WikiPage))
            });
            BreadCrumb.Add(new ASC.Web.Controls.BreadCrumb()
            {
                Caption = WikiResource.wikiHistoryCaption, NavigationUrl = ActionHelper.GetViewPagePath(this.ResolveUrlLC("PageHistoryList.aspx"), PageNameUtil.Decode(WikiPage))
            });
            BreadCrumb.Add(new ASC.Web.Controls.BreadCrumb()
            {
                Caption = string.Format(WikiResource.wikiDiffDescriptionFormat, OldVer, NewVer)
            });
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                return;
            }

            Wiki_FCKEditor.BasePath   = VirtualPathUtility.ToAbsolute(BaseFCKRelPath);
            Wiki_FCKEditor.ToolbarSet = "WikiPanel";

            if (PageName != null && Visible)
            {
                var page      = Wiki.GetPage(PageNameUtil.Decode(PageName));
                var isPageNew = (page == null || IsNew);

                RiseWikiPageLoaded(isPageNew, page);

                if (!isPageNew)
                {
                    txtPageName.Value = page.PageName;
                    if (PageSection < 0)
                    {
                        SetWikiFCKEditorValue(page.PageName, page.Body);
                    }
                    else
                    {
                        SetWikiFCKEditorValue(page.PageName, HtmlWikiUtil.GetWikiSectionBySectionNumber(page.Body, PageSection));
                        txtPageName.Attributes["readonly"] = "readonly";
                        txtPageName.Value += string.Format(WikiUCResource.wikiPageEditSectionCaptionFormat, HtmlWikiUtil.GetWikiSectionNameBySectionNumber(page.Body, PageSection));
                    }

                    //Check for 'help' and 'main' page
                    if (IsStandartName(page))
                    {
                        txtPageName.Attributes["readonly"] = "readonly";
                    }
                    PageVersion = page.Version;

                    //if (page.PageName.Equals(string.Empty))
                    //txtPageName.ReadOnly = true; //We need to disable any changes for the one time saved page.

                    RisePublishVersionInfo(page);
                }
                else if (!string.IsNullOrEmpty(PageName))
                {
                    txtPageName.Value = PageNameUtil.Decode(PageName);
                    if (IsSpecialName)
                    {
                        txtPageName.Attributes["readonly"] = "readonly";
                    }
                }

                phPageName.Visible = txtPageName.Attributes["readonly"] == null;
            }

            hfFCKLastState.Value = (!IsWysiwygDefault).ToString().ToLower();
            //txtPageName.Focus();
        }
Exemplo n.º 7
0
        private void FindDiff()
        {
            var pageName = PageNameUtil.Decode(WikiPage);

            //Page oldPage = PagesProvider.PagesHistGetByNameVersion(pageName, OldVer, TenantId);
            //Page newPage = PagesProvider.PagesHistGetByNameVersion(pageName, NewVer, TenantId);
            var oldPage = Wiki.GetPage(pageName, OldVer);
            var newPage = Wiki.GetPage(pageName, NewVer);

            var oldVersion = oldPage == null ? string.Empty : oldPage.Body;

            var newVersion = newPage == null ? string.Empty : newPage.Body;


            var f      = DiffHelper.DiffText(oldVersion, newVersion, true, true, false);
            var aLines = oldVersion.Split('\n');
            var bLines = newVersion.Split('\n');

            var n  = 0;
            var sb = new StringBuilder();

            foreach (var aItem in f)
            {
                // write unchanged lines
                while ((n < aItem.StartB) && (n < bLines.Length))
                {
                    WriteLine(n, null, bLines[n], sb);
                    n++;
                } // while

                // write deleted lines
                for (var m = 0; m < aItem.deletedA; m++)
                {
                    WriteLine(-1, "d", aLines[aItem.StartA + m], sb);
                } // for

                // write inserted lines
                while (n < aItem.StartB + aItem.insertedB)
                {
                    WriteLine(n, "i", bLines[n], sb);
                    n++;
                } // while
            }     // while

            if (f.Length > 0 || (from bline in bLines where !bline.Trim().Equals(string.Empty) select bline).Count() > 0)
            {
                // write rest of unchanged lines
                while (n < bLines.Length)
                {
                    WriteLine(n, null, bLines[n], sb);
                    n++;
                } // while
            }
            litDiff.Text = sb.ToString();
        }
Exemplo n.º 8
0
        private void InitCommentsView()
        {
            if (m_IsCategory) return;

            int totalCount;
            var pageName = PageNameUtil.Decode(WikiPage);
            commentList.Visible = true;

            commentList.Items = GetCommentsList(pageName, out totalCount);
            ConfigureComments(commentList);
            commentList.TotalCount = totalCount;
        }
Exemplo n.º 9
0
        protected void On_PublishVersionInfo(object sender, VersionEventArgs e)
        {
            if (!e.UserID.Equals(Guid.Empty))
            {
                litAuthorInfo.Text = GetPageInfo(PageNameUtil.Decode(WikiPage), e.UserID, e.Date);
            }
            else
            {
                litAuthorInfo.Text = string.Empty;
            }

            hlVersionPage.Text        = string.Format(WikiResource.cmdVersionTemplate, e.Version);
            hlVersionPage.NavigateUrl = ActionHelper.GetViewPagePath(this.ResolveUrlLC("PageHistoryList.aspx"), PageNameUtil.Decode(WikiPage));
            hlVersionPage.Visible     = Action.Equals(ActionOnPage.View) || Action.Equals(ActionOnPage.CategoryView);
            //litVersionSeparator.Visible = hlEditPage.Visible;
        }
Exemplo n.º 10
0
        private void InitCommentsView()
        {
            if (m_IsCategory)
            {
                return;
            }

            int totalCount;
            var pageName = PageNameUtil.Decode(WikiPage);

            commentList.Visible = true;

            commentList.Items = GetCommentsList(pageName, out totalCount);
            ConfigureComments(commentList, pageName);
            commentList.TotalCount         = totalCount;
            commentList.CommentsCountTitle = commentList.TotalCount.ToString(CultureInfo.CurrentCulture);
        }
Exemplo n.º 11
0
 protected string InitVariables()
 {
     return(string.Format(@"var pageName = '{0}';
                     var appRelativeCurrentExecutionFilePath = '{1}';
                     var imageHandlerUrl = '{2}';
                     var wikiInternalStart = '{3}';
                     var wikiInternalFile = '{4}';
                     var wikiMaxFileUploadSizeString = '{5}'
                     var wikiDenyFileUpload = {6};",
                          PageNameUtil.Decode(PageName).EscapeString(),
                          Page.ResolveUrl(Request.AppRelativeCurrentExecutionFilePath).EscapeString().ToLower(),
                          Page.ResolveUrl(ImageHandlerUrlFormat).EscapeString().ToLower(),
                          string.Format("{0}?page=", mainPath).EscapeString(),
                          string.Format("{0}?file=", mainPath).EscapeString(),
                          GetMaxFileUploadString(),
                          (!CanUploadFiles).ToString().ToLower()
                          ));
 }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var page = Wiki.GetPage(PageNameUtil.Decode(WikiPage));

            if (Request["page"] == null || page == null)
            {
                Response.RedirectLC("Default.aspx", this);
            }

            var pageName = page.PageName.Equals(string.Empty) ? WikiResource.MainWikiCaption : page.PageName;

            WikiPageTitle = pageName;
            WikiPageIn    = CommunityResource.InForParentPage;
            WikiPageURL   = ActionHelper.GetViewPagePath(this.ResolveUrlLC("Default.aspx"), page.PageName);
            //WikiPageIn = CommunityResource.InForParentPage;
            WikiMaster.CurrentPageCaption = WikiResource.wikiHistoryCaption;

            if (!IsPostBack)
            {
                cmdDiff.Text = WikiResource.cmdDiff;
                BindHistoryList();
            }
        }
Exemplo n.º 13
0
        protected void cmdSave_Click(object sender, EventArgs e)
        {
            SaveResult result;
            string     pageName;

            if (IsFile || Action.Equals(ActionOnPage.AddNewFile))
            {
                result = wikiEditFile.Save(SecurityContext.CurrentAccount.ID, out pageName);
            }
            else
            {
                result = wikiEditPage.Save(SecurityContext.CurrentAccount.ID, out pageName);
            }

            PrintResultBySave(result, pageName);
            if (result == SaveResult.OkPageRename)
            {
                //Redirect
                Response.RedirectLC(ActionHelper.GetViewPagePath(this.ResolveUrlLC("Default.aspx"), PageNameUtil.Decode(pageName)), this);
            }
        }
Exemplo n.º 14
0
 protected void cmdCancel_Click(object sender, EventArgs e)
 {
     if (!IsFile)
     {
         Response.RedirectLC(ActionHelper.GetViewPagePath(this.ResolveUrlLC("Default.aspx"), PageNameUtil.Decode(WikiPage)), this);
     }
     else
     {
         Response.RedirectLC(ActionHelper.GetViewFilePath(this.ResolveUrlLC("Default.aspx"), PageNameUtil.Decode(WikiPage)), this);
     }
 }
Exemplo n.º 15
0
 protected void cmdCancel_Click(object sender, EventArgs e)
 {
     Response.RedirectLC(ActionHelper.GetViewPagePath(this.ResolveUrlLC("PageHistoryList.aspx"), PageNameUtil.Decode(WikiPage)), this);
 }
Exemplo n.º 16
0
        private string PrepereEmptyString(string format, bool isFile, bool isSearchResultExists)
        {
            commentList.Visible = false;
            var mainOptions         = RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant;
            var rxLinkCreatePlace   = new Regex(@"{0([\s\S]+?)}", mainOptions);
            var rxLinkSearchResult  = new Regex(@"{1([\s\S]+?)}", mainOptions);
            var rxSearchResultParth = new Regex(@"\[\[([\s\S]+?)\]\]", mainOptions);
            var result = format;

            foreach (Match match in rxLinkCreatePlace.Matches(format))
            {
                if (isFile)
                {
                    if (CommunitySecurity.CheckPermissions(Common.Constants.Action_UploadFile) && !MobileDetector.IsMobile)
                    {
                        result = result.Replace(match.Value, string.Format(@"<a href=""{0}"">{1}</a>", ActionHelper.GetEditFilePath(this.ResolveUrlLC("Default.aspx"), PageNameUtil.Decode(WikiPage)), match.Groups[1].Value));
                    }
                }
                else
                {
                    if (CommunitySecurity.CheckPermissions(Common.Constants.Action_AddPage))
                    {
                        result = result.Replace(match.Value, string.Format(@"<a href=""{0}"">{1}</a>", ActionHelper.GetEditPagePath(this.ResolveUrlLC("Default.aspx"), PageNameUtil.Decode(WikiPage)), match.Groups[1].Value));
                    }
                    else
                    {
                        result = result.Replace(match.Value, match.Groups[1].Value);
                    }
                }
            }

            if (isSearchResultExists && !isFile)
            {
                result = rxSearchResultParth.Replace(result, SearchResultParthMatchEvaluator);

                foreach (Match match in rxLinkSearchResult.Matches(format))
                {
                    result = result.Replace(match.Value, string.Format(@"<a href=""{0}"">{1}</a>", this.ResolveUrlLC(string.Format("Search.aspx?Search={0}&pn=", HttpUtility.UrlEncode(PageNameUtil.Decode(WikiPage)))), match.Groups[1].Value));
                }
            }
            else
            {
                result = rxSearchResultParth.Replace(result, string.Empty);
            }

            return(result);
        }
Exemplo n.º 17
0
        private void UpdateBreadCrumb()
        {
            if (OldVer == 0 || NewVer == 0 || OldVer == NewVer)
            {
                Response.RedirectLC(ActionHelper.GetViewPagePath(this.ResolveUrlLC("PageHistoryList.aspx"), PageNameUtil.Decode(WikiPage)), this);
            }

            WikiMaster.CurrentPageCaption = string.Format(WikiResource.wikiDiffDescriptionFormat, OldVer, NewVer);
        }
Exemplo n.º 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                return;
            }

            _mobileVer = MobileDetector.IsMobile;


            //fix for IE 10
            var browser = HttpContext.Current.Request.Browser.Browser;

            var userAgent  = Context.Request.Headers["User-Agent"];
            var regExp     = new Regex("MSIE 10.0", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
            var regExpIe11 = new Regex("(?=.*Trident.*rv:11.0).+", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);

            if (browser == "IE" && regExp.Match(userAgent).Success || regExpIe11.Match(userAgent).Success)
            {
                _mobileVer = true;
            }

            Wiki_FCKEditor.BasePath   = VirtualPathUtility.ToAbsolute(BaseFCKRelPath);
            Wiki_FCKEditor.ToolbarSet = "WikiPanel";

            if (PageName != null && Visible)
            {
                var page      = Wiki.GetPage(PageNameUtil.Decode(PageName));
                var isPageNew = (page == null || IsNew);

                RiseWikiPageLoaded(isPageNew, page);

                if (!isPageNew)
                {
                    txtPageName.Text = page.PageName;
                    if (PageSection < 0)
                    {
                        SetWikiFCKEditorValue(page.PageName, page.Body);
                    }
                    else
                    {
                        SetWikiFCKEditorValue(page.PageName, HtmlWikiUtil.GetWikiSectionBySectionNumber(page.Body, PageSection));
                        txtPageName.ReadOnly = true;
                        txtPageName.Text    += string.Format(WikiUCResource.wikiPageEditSectionCaptionFormat, HtmlWikiUtil.GetWikiSectionNameBySectionNumber(page.Body, PageSection));
                    }

                    //Check for 'help' and 'main' page
                    if (IsStandartName(page))
                    {
                        txtPageName.ReadOnly = true;
                    }
                    PageVersion = page.Version;

                    //if (page.PageName.Equals(string.Empty))
                    //txtPageName.ReadOnly = true; //We need to disable any changes for the one time saved page.

                    RisePublishVersionInfo(page);
                }
                else if (!string.IsNullOrEmpty(PageName))
                {
                    txtPageName.Text = PageNameUtil.Decode(PageName);
                    if (IsSpecialName)
                    {
                        txtPageName.ReadOnly = true;
                    }
                }

                phPageName.Visible = !txtPageName.ReadOnly;
            }

            hfFCKLastState.Value = (!IsWysiwygDefault).ToString().ToLower();
        }
Exemplo n.º 19
0
        public SaveResult Save(Guid userId, out string pageName)
        {
            try
            {
                if (SetNewFCKMode != null)
                {
                    bool isSource;
                    bool.TryParse(hfFCKLastState.Value, out isSource);
                    SetNewFCKMode(!isSource);

                    IsWysiwygDefault = !isSource; //We need to update the variable if SetNewFCKMode is used only!!!
                }

                Page   page;
                string currentPageName = txtPageName.Text.Trim();
                if (currentPageName.Length > 240)
                {
                    currentPageName = currentPageName.Substring(0, 240).Trim();
                }
                currentPageName = PageNameUtil.Clean(currentPageName);
                if (pageSection >= 0)
                {
                    currentPageName = PageNameUtil.Decode(PageName);
                }

                pageName = currentPageName;
                bool   isPageRename = pageName != PageNameUtil.Decode(PageName) && !string.IsNullOrEmpty(PageName);
                string oldPageName  = PageName;

                if (currentPageName.Equals(string.Empty) && !txtPageName.ReadOnly)
                {
                    SetWikiFCKEditorValue(currentPageName, Wiki_FCKEditor.Value);
                    return(SaveResult.PageNameIsEmpty);
                }

                if (!IsSpecialName && IsNameReserved(currentPageName))
                {
                    SetWikiFCKEditorValue(currentPageName, Wiki_FCKEditor.Value);
                    return(SaveResult.PageNameIsIncorrect);
                }

                if (userId.Equals(Guid.Empty))
                {
                    SetWikiFCKEditorValue(currentPageName, Wiki_FCKEditor.Value);
                    return(SaveResult.UserIdIsEmpty);
                }

                if (!PageNameUtil.Decode(PageName).Equals(currentPageName, StringComparison.InvariantCulture))
                {
                    page = Wiki.GetPage(currentPageName);
                    if (page != null)
                    {
                        SetWikiFCKEditorValue(currentPageName, Wiki_FCKEditor.Value);
                        return(SaveResult.SamePageExists);
                    }
                    page = new Page();
                }
                else
                {
                    page = Wiki.GetPage(currentPageName);
                    if (page == null)
                    {
                        page = new Page();
                    }
                }

                page.PageName = currentPageName;
                string PageResult;
                if (pageSection < 0)
                {
                    PageResult = Wiki_FCKEditor.Value;
                }
                else
                {
                    PageResult = HtmlWikiUtil.SetWikiSectionBySectionNumber(page.Body, pageSection, Wiki_FCKEditor.Value);
                }

                if (PageResult.Equals(page.Body))
                {
                    SetWikiFCKEditorValue(page.PageName, Wiki_FCKEditor.Value);
                    return(SaveResult.NoChanges);
                }

                page.Body = PageResult;

                if (pageVersion > 0 && pageVersion < Wiki.GetPageMaxVersion(page.PageName))
                {
                    SetWikiFCKEditorValue(page.PageName, Wiki_FCKEditor.Value);
                    return(SaveResult.OldVersion);
                }
                page.Date   = TenantUtil.DateTimeNow();
                page.UserID = userId;

                page.Version++;
                Wiki.SavePage(page);

                var newCats = Wiki.UpdateCategoriesByPageContent(page);
                if (newCats.Count > 0 && SaveNewCategoriesAdded != null)
                {
                    SaveNewCategoriesAdded(this, newCats, page.PageName);
                }

                pageVersion = page.Version;
                RisePublishVersionInfo(page);

                SetWikiFCKEditorValue(page.PageName, Wiki_FCKEditor.Value);

                if (pageSection >= 0)
                {
                    return(SaveResult.SectionUpdate);
                }
                if (isPageRename)
                {
                    //create dumb page
                    var oldpage = Wiki.GetPage(PageNameUtil.Decode(oldPageName));
                    if (oldpage != null)
                    {
                        oldpage.Date   = TenantUtil.DateTimeNow();
                        oldpage.UserID = userId;
                        oldpage.Body   = string.Format(WikiUCResource.wikiPageMoved, pageName); //Dummy
                        oldpage.Version++;
                        Wiki.SavePage(oldpage);

                        return(SaveResult.OkPageRename);
                    }
                    else
                    {
                        return(SaveResult.SamePageExists);
                    }
                }
                return(SaveResult.Ok);
            }
            catch (Exception)
            {
                pageName = txtPageName.Text.Trim();
                return(SaveResult.Error);
            }
        }
Exemplo n.º 20
0
    private void LoadWikiPage()
    {
        if (!IsFile)
        {
            wikiViewFile.Visible = false;
            wikiEditFile.Visible = false;

            if (WikiPage.Equals(string.Empty) || !Action.Equals(Action.View))
            {
                if (!Action.Equals(Action.View))
                {
                    wikiEditPage.Visible = true;
                }
                wikiViewPage.Visible = false;


                if (Action.Equals(Action.Edit))
                {
                    wikiEditPage.PageName = WikiPage;
                }
                else
                {
                    wikiEditPage.PageName = string.Empty;
                }


                Title = string.Format("WIKI - Edit/Add page");
            }
            else
            {
                wikiViewPage.Visible = true;
                wikiEditPage.Visible = false;

                wikiViewPage.PageName = WikiPage;
                Title = string.Format("WIKI - {0}", PageNameUtil.Decode(WikiPage));
            }
        }
        else
        {
            wikiViewPage.Visible = false;
            wikiEditPage.Visible = false;

            if (WikiPage.Equals(string.Empty) || !Action.Equals(Action.View))
            {
                if (!Action.Equals(Action.View))
                {
                    wikiEditFile.Visible = true;
                }
                wikiViewFile.Visible = false;


                if (Action.Equals(Action.Edit))
                {
                    wikiEditFile.FileName = WikiPage;
                }
                else
                {
                    wikiEditFile.FileName = string.Empty;
                }


                Title = string.Format("WIKI - Edit/Add file");
            }
            else
            {
                wikiViewFile.Visible = true;
                wikiEditFile.Visible = false;

                cmdEditFile.Visible = true;

                wikiViewFile.FileName = WikiPage;
                Title = string.Format("WIKI - {0}", PageNameUtil.Decode(WikiPage));
            }
        }
    }
Exemplo n.º 21
0
        private void InitActions()
        {
            niMainPage.Name        = WikiResource.menu_MainPage;
            niAllCategories.Name   = WikiResource.menu_ListCategories;
            niAllPages.Name        = WikiResource.menu_ListPages;
            niNewPages.Name        = WikiResource.menu_NewPages;
            niFreshEditsPages.Name = WikiResource.menu_FreshEditPages;
            niAllFiles.Name        = WikiResource.menu_ListFiles;
            niHelp.Name            = WikiResource.menu_Help;

            string mainPath = this.ResolveUrlLC("Default.aspx");

            niMainPage.URL        = this.ResolveUrlLC(ActionHelper.GetViewPagePath(mainPath, ASC.Web.UserControls.Wiki.Constants.WikiInternalHomeKey, ASC.Web.UserControls.Wiki.Constants.WikiInternalKeyCaption));
            niAllCategories.URL   = this.ResolveUrlLC(ActionHelper.GetViewPagePath(mainPath, ASC.Web.UserControls.Wiki.Constants.WikiInternalCategoriesKey, ASC.Web.UserControls.Wiki.Constants.WikiInternalKeyCaption));
            niAllPages.URL        = this.ResolveUrlLC(ActionHelper.GetViewPagePath(mainPath, ASC.Web.UserControls.Wiki.Constants.WikiInternalIndexKey, ASC.Web.UserControls.Wiki.Constants.WikiInternalKeyCaption));
            niNewPages.URL        = this.ResolveUrlLC(ActionHelper.GetViewPagePath(mainPath, ASC.Web.UserControls.Wiki.Constants.WikiInternalNewPagesKey, ASC.Web.UserControls.Wiki.Constants.WikiInternalKeyCaption));
            niFreshEditsPages.URL = this.ResolveUrlLC(ActionHelper.GetViewPagePath(mainPath, ASC.Web.UserControls.Wiki.Constants.WikiInternalRecentlyKey, ASC.Web.UserControls.Wiki.Constants.WikiInternalKeyCaption));
            niAllFiles.URL        = this.ResolveUrlLC(ActionHelper.GetViewPagePath(mainPath, ASC.Web.UserControls.Wiki.Constants.WikiInternalFilesKey, ASC.Web.UserControls.Wiki.Constants.WikiInternalKeyCaption));
            niHelp.URL            = this.ResolveUrlLC(ActionHelper.GetViewPagePath(mainPath, ASC.Web.UserControls.Wiki.Constants.WikiInternalHelpKey, ASC.Web.UserControls.Wiki.Constants.WikiInternalKeyCaption));

            niaAddNewPage.Name    = WikiResource.menu_AddNewPage;
            niaCreateThePage.Name = WikiResource.menu_CreateThePage;
            niaUploadFile.Name    = WikiResource.menu_AddNewFile;
            niaEditThePage.Name   = WikiResource.menu_EditThePage;
            niaShowVersions.Name  = WikiResource.menu_ShowVersions;
            niaPrintPage.Name     = WikiResource.menu_PrintThePage;
            niaDeleteThePage.Name = WikiResource.menu_DeleteThePage;

            if (SecurityContext.IsAuthenticated)
            {
                ASC.Web.Studio.Controls.Common.MenuItem item = GetNewPageSubscription();
                if (item == null)
                {
                    niaSubscriptionOnNewPage.Visible = false;
                }
                else
                {
                    NewsActions.Controls.AddAt(NewsActions.Controls.IndexOf(niaSubscriptionOnNewPage), item);
                    NewsActions.Controls.Remove(niaSubscriptionOnNewPage);
                    niaSubscriptionOnNewPage = item;
                }

                item = GetThePageSubscription();
                if (item == null)
                {
                    niaSubscriptionThePage.Visible = false;
                }
                else
                {
                    NewsActions.Controls.AddAt(NewsActions.Controls.IndexOf(niaSubscriptionThePage), item);
                    NewsActions.Controls.Remove(niaSubscriptionThePage);
                    niaSubscriptionThePage = item;
                }

                item = GetTheCategorySubscription();
                if (item == null)
                {
                    niaSubscriptionOnCategory.Visible = false;
                }
                else
                {
                    NewsActions.Controls.AddAt(NewsActions.Controls.IndexOf(niaSubscriptionOnCategory), item);
                    NewsActions.Controls.Remove(niaSubscriptionOnCategory);
                    niaSubscriptionOnCategory = item;
                }
            }
            else
            {
                NewsActions.Visible = false;
            }

            niaAddNewPage.URL = ActionHelper.GetAddPagePath(this.ResolveUrlLC("Default.aspx"));
            niaUploadFile.URL = "javascript:ShowUploadFileBox();";

            try
            {
                niaCreateThePage.URL = ActionHelper.GetEditPagePath(this.ResolveUrlLC("Default.aspx"), PageNameUtil.Decode((this.Page as WikiBasePage).WikiPage));
            }
            catch (SystemException)
            {
                niaCreateThePage.Visible = false;
            }

            try
            {
                niaEditThePage.URL = ActionHelper.GetEditPagePath(this.ResolveUrlLC("Default.aspx"), PageNameUtil.Decode((this.Page as WikiBasePage).WikiPage));
            }
            catch (SystemException)
            {
                niaEditThePage.Visible = false;
            }

            try
            {
                niaShowVersions.URL = ActionHelper.GetViewPagePath(this.ResolveUrlLC("PageHistoryList.aspx"), PageNameUtil.Decode((this.Page as WikiBasePage).WikiPage));
            }
            catch (SystemException)
            {
                niaShowVersions.Visible = false;
            }

            LinkButton cmdDelete = new LinkButton();

            niaPrintPage.URL = @"javascript:window.print();";
            string delUniqId = GetDeleteUniqueId();

            if (!string.IsNullOrEmpty(delUniqId))
            {
                niaDeleteThePage.URL = string.Format(@"javascript:if(confirm('{0}')) __doPostBack('{1}', '');", WikiResource.cfmDeletePage, delUniqId);
            }
            else
            {
                niaDeleteThePage.Visible = false;
            }

            cmdPageGoButton.Text          = WikiResource.wiki_PageContGoButton;
            cmdPageGoButton.OnClientClick = string.Format(@"javascript: var txt =  document.getElementById('{0}'); if(txt.value.replace(/\s/g, '') == '') {{txt.focus(); return false;}} return true;",
                                                          txtSearchPage.ClientID);

            SetVisibleActions();

            //NotifyOnNews();
        }
Exemplo n.º 22
0
 private void BindHistoryList()
 {
     rptPageHistory.DataSource = Wiki.GetPageHistory(PageNameUtil.Decode(WikiPage));
     rptPageHistory.DataBind();
     cmdDiff.Visible = (rptPageHistory.DataSource as List <Page>).Count > 1;
 }