Пример #1
0
        public void Load(ReviewContract review, bool censor)
        {
            if (review.User != null)
            {
                this.UserName      = review.User.Name;
                this.AvatarUrl     = Avatar.GetImageUrl(review.User.Avatar);
                this.NavigationUrl = PageUrl.UserProfile(review.User.Id, review.User.Name);
            }

            var text = Html.ConvertToPlainText(review.Body).Trim();

            this.Body    = censor ? Censorship.Censor(text) : text;
            this.Created = review.Created.ParseToLocalDateTimeEnsurePast();
            DateTimeOffset createdDate;

            if (DateTimeOffset.TryParse(review.Created, out createdDate))
            {
                this.Created = createdDate.ToLocalTime().DateTime;
            }
            else
            {
                this.Created = DateTime.Now.AddSeconds(-1);
            }

            if (this.Created > DateTime.Now)
            {
                this.Created = DateTime.Now.AddSeconds(-1);
            }
        }
        /// <summary>
        /// defaults add sessionInfo = true
        /// </summary>
        /// <param name="sUrl"></param>
        /// <param name="addSelfToHistory"></param>
        public void NavigateTo(string sUrl, bool addSelfToHistory)
        {
            string returnId    = null;
            string navigateUrl = "";

            if (IsPageModal)
            {
                MCSUrl url = new MCSUrl(sUrl);
                url.SetParameter(QS_ISPAGEMODAL, "true");
                sUrl = url.ToString();
            }

            #region Add to History
            if (addSelfToHistory)
            {
                returnId = "" + AddUrlToHistory(PageUrl.ToString());
            }
            else
            {
                returnId = returnUrlId.ToString();
            }
            #endregion



            #region Build return URL
            MCSUrl newUrl = new MCSUrl(sUrl);
            newUrl.SetParameter(MCSUrl.ReturnUrl, returnId);
            navigateUrl = newUrl.ToString();
            #endregion

            navigateUrl = Utilities.BuildURL(navigateUrl);
            Response.Redirect(navigateUrl);
        }
        //重写Authorization
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            if (filterContext == null)
            {
                throw new ArgumentNullException("filterContext");
            }

            //获取当前页面地址
            url            = new PageUrl();
            url.Controller = filterContext.RouteData.Values["controller"] as string;
            url.Action     = filterContext.RouteData.Values["action"] as string;

            //判断用户是否登录
            // string  Token=Caching.Get("adminLogin-key").ToString();//缓存
            Model.adminlogin loginModel = HttpContext.Current.Session[CMSKeys.SESSION_ADMIN_INFO] as Model.adminlogin;
            //NHibernate.CMS.RedisFramework.RedisHelper.Single_Get_Itme<Model.adminlogin>(RedisKeys.REDIS_KEY_ADMINLOGIN + Token);

            if (loginModel == null)
            {
                // 未登录,跳转至登录页面
                filterContext.Result = new RedirectResult("/Home/Login");
                return;
            }
            else
            {
                if (!AuthorizeCore(filterContext.HttpContext))
                {
                    filterContext.Result = new RedirectResult("/Home/Error/premission");
                    //filterContext.HttpContext.Response.Write("");
                }
                //redirect to login page
            }
        }
Пример #4
0
        ////protected override AnimatorHelperBase GetAnimation(AnimationType animationType, Uri toOrFrom)
        ////{
        ////    return null;
        ////}


        ////private void MainPage_Unloaded(object sender, RoutedEventArgs e)
        ////{
        ////    this.Unloaded -= this.MainPage_Unloaded;
        ////}


        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            this.historyItemLaunch = false;
            this.playMixId         = null;
            try
            {
                if (e.NavigationMode == NavigationMode.New && NavigationContext.QueryString.ContainsKey(PlayMixKey))
                {
                    // We were launched from a history item.
                    // Change _playingSong even if something was already playing
                    // because the user directly chose a song history item.

                    // Use the navigation context to find the song by name.
                    this.playMixId = NavigationContext.QueryString[PlayMixKey];

                    // Set a flag to indicate that we were started from a
                    // history item and that we should immediately start
                    // playing the song once the UI has finished loading.
                    this.historyItemLaunch = true;

                    if (this.historyItemLaunch)
                    {
                        this.NavigationService.Navigate(PageUrl.Play(this.playMixId, true));
                    }

                    return;
                }

                base.OnNavigatedTo(e);
            }
            catch (InvalidOperationException)
            {
                // Couldn't navigate we're probably being closed
            }
        }
Пример #5
0
 public IEnumerable <byte[]> DownloadPages(int ID)
 {
     foreach (var PageUrl in GetChapterPages(ID))
     {
         yield return(PageUrl.TryDownload(Referer));
     }
 }
Пример #6
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ImageUrl.Length != 0)
            {
                hash ^= ImageUrl.GetHashCode();
            }
            if (PageUrl.Length != 0)
            {
                hash ^= PageUrl.GetHashCode();
            }
            if (Title.Length != 0)
            {
                hash ^= Title.GetHashCode();
            }
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #7
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            var search = new SearchPrompt();

            Observable.FromEvent <PopUpEventArgs <string, PopUpResult> >(search, "Completed").Take(1).ObserveOnDispatcher()
            .Subscribe(
                q =>
            {
                try
                {
                    if (q.EventArgs.PopUpResult == PopUpResult.Ok &&
                        !string.IsNullOrWhiteSpace(q.EventArgs.Result))
                    {
                        this.NavigationService.Navigate(PageUrl.SearchMixes(q.EventArgs.Result));
                    }
                }
                catch (InvalidOperationException)
                {
                    // Couldn't navigate we're probably being closed
                }
            });

            search.ActionPopUpButtons.Clear();
            search.Show();
        }
 public void Load(UserContract data)
 {
     this.userId        = data.Id;
     this.Name          = data.Name;
     this.Location      = data.Location;
     this.Bio           = Html.ConvertToPlainText(data.BioHtml);
     this.AvatarUrl     = Avatar.GetImageUrl(data.Avatar);
     this.NavigationUrl = PageUrl.UserProfile(this.userId, this.Name);
 }
Пример #9
0
 private void UserButton_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     try
     {
         this.NavigationService.Navigate(PageUrl.UserProfile(this.PageViewModel.CreatedByUserId, this.PageViewModel.CreatedByUserName));
     }
     catch (InvalidOperationException)
     {
     }
 }
Пример #10
0
 private void SettingsButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         this.NavigationService.Navigate(PageUrl.Settings());
     }
     catch (InvalidOperationException)
     {
         // Couldn't navigate we're probably being closed
     }
 }
    // show the pager
    public void Show(int currentPage, int howManyPages, string firstPageUrl, string pageUrlFormat, bool showPages)
    {
        // display paging controls
        if (howManyPages > 1)
        {
            // make the pager visible
            this.Visible = true;

            // display the current page
            currentPageLabel.Text  = currentPage.ToString();
            howManyPagesLabel.Text = howManyPages.ToString();

            // create the Previous link
            if (currentPage == 1)
            {
                previousLink.Enabled = false;
            }
            else
            {
                previousLink.NavigateUrl = (currentPage == 2) ?
                                           firstPageUrl : String.Format(pageUrlFormat, currentPage - 1);
            }

            // create the Next link
            if (currentPage == howManyPages)
            {
                nextLink.Enabled = false;
            }
            else
            {
                nextLink.NavigateUrl = String.Format(pageUrlFormat, currentPage + 1);
            }

            // create the page links
            if (showPages)
            {
                // the list of pages and their URLs as an array
                PageUrl[] pages = new PageUrl[howManyPages];
                // generate (page, url) elements
                pages[0] = new PageUrl("1", firstPageUrl);
                for (int i = 2; i <= howManyPages; i++)
                {
                    pages[i - 1] =
                        new PageUrl(i.ToString(), String.Format(pageUrlFormat, i));
                }
                // do not generate a link for the current page
                pages[currentPage - 1] = new PageUrl((currentPage).ToString(), "");
                // feed the pages to the repeater
                pagesRepeater.DataSource = pages;
                pagesRepeater.DataBind();
            }
        }
    }
Пример #12
0
        public static PageUrlOptions ParsePublicUrl(string url, out NameValueCollection notUsedQueryParameters)
        {
            var urlString = new UrlString(url);

            notUsedQueryParameters = null;
            if (!IsPublicUrl(urlString.FilePath))
            {
                return(null);
            }

            string requestPath;
            Uri    uri;

            if (Uri.TryCreate(urlString.FilePath, UriKind.Absolute, out uri))
            {
                requestPath = HttpUtility.UrlDecode(uri.AbsolutePath).ToLower();
            }
            else
            {
                requestPath = urlString.FilePath.ToLower();
            }

            string      requestPathWithoutUrlMappingName;
            CultureInfo locale = PageUrl.GetCultureInfo(requestPath, out requestPathWithoutUrlMappingName);

            if (locale == null)
            {
                return(null);
            }

            string dataScopeName = urlString["dataScope"];

            if (dataScopeName.IsNullOrEmpty())
            {
                dataScopeName = DataScopeIdentifier.GetDefault().Name;
            }

            Guid pageId = Guid.Empty;

            using (new DataScope(DataScopeIdentifier.Deserialize(dataScopeName), locale))
            {
                if (PageStructureInfo.GetLowerCaseUrlToIdLookup().TryGetValue(requestPath.ToLower(), out pageId) == false)
                {
                    return(null);
                }
            }

            urlString["dataScope"] = null;

            notUsedQueryParameters = urlString.GetQueryParameters();

            return(new PageUrlOptions(dataScopeName, locale, pageId, UrlType.Public));
        }
Пример #13
0
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.Append("<div class='i-pager'>");

            if (IsShow)
            {
                if (IsShowPageNum)
                {
                    sb.Append("<span>每页显示条数:<input type='text' value='" + PageSize + "'  name='pagesize'></span>");
                }
                if (HasPreviousPage)
                {
                    sb.Append("<a class='i-pager-first' name='gopage' href=" + PageUrl.Replace(ReplaceNum, "1") + "  page='1' title='" + FirstPageText + "'><span>" + FirstPageText + "</span></a>");
                    sb.Append("<a class='i-pager-prev' name='gopage' href=" + PageUrl.Replace(ReplaceNum, (CurrentPageIndex - 1).ToString()) + "  page='" + (CurrentPageIndex - 1) + "' title='" + PreviousPageText + "'><span>" + PreviousPageText + "</span></a>");
                }

                for (int i = StartPageNum; i <= EndPageNum; i++)
                {
                    if (i == CurrentPageIndex)
                    {
                        sb.Append("<a href='javascript:void(0)' name='gopage'   page='" + i +
                                  "' class='i-pager-item i-pager-item-active'><span>" + i + "</span></a>");
                    }
                    else
                    {
                        sb.Append("<a href=" + PageUrl.Replace(ReplaceNum, i.ToString()) + " name='gopage'   page='" + i +
                                  "' class='i-pager-item'><span>" + i + "</span></a>");
                    }
                }

                if (HasNextPage)
                {
                    sb.Append("<a class='i-pager-next' name='gopage' href=" + PageUrl.Replace(ReplaceNum, (CurrentPageIndex + 1).ToString()) + " page='" + (CurrentPageIndex + 1) +
                              "' title='" + NextPageText + "'><span>" + NextPageText + "</span></a>");
                    sb.Append("<a class='i-pager-last' name='gopage' href=" + PageUrl.Replace(ReplaceNum, TotalPageCount.ToString()) + "  page='" + TotalPageCount +
                              "' title='" + LastPageText + "'><span>" + LastPageText + "</span></a>");
                }

                sb.Append("<span class='i-pager-info'>");

                sb.Append("<span class='i-pager-current'>" + CurrentPageText + "</span><span class='i-pager-info-c'>" + CurrentPageIndex + "</span>");
                sb.Append("<span class='i-pager-info-p'>/" + TotalPageCount + "</span><span class='i-pager-info-t'>" + CountPageText +
                          TotalItemCount + "</span>");
                sb.Append("</span>");
            }

            sb.Append("</div>");

            return(sb.ToString());
        }
Пример #14
0
 /// <summary>
 /// The spider opens the web page and it extracts all the links
 /// </summary>
 private void FindUrls()
 {
     try
     {
         HtmlWeb      web      = new HtmlWeb();
         HtmlDocument document = web.Load(PageUrl.ToString());
         PageLinks = document.DocumentNode.SelectNodes("//a[@href]").Select(node => node.Attributes["href"].Value).ToList();
     }
     catch (Exception)
     {
         this.IsAlive = false;
     }
 }
Пример #15
0
 public void NavigateToCurrentPage()
 {
     if (Driver.Url != PageUrl.ToString())
     {
         if (WaitForPageToLoad)
         {
             Driver.NavigateToUrlAndWaitForPageToLoad(PageUrl);
         }
         else
         {
             Driver.NavigateToUrl(PageUrl);
         }
     }
 }
Пример #16
0
 public void ShowPage(int currentPage, int howManyPages, string firstPageUrl, string pageUrlFormat, bool showPages)
 {
     if (howManyPages > 1)
     {
         this.Visible         = true;
         lblCurrentPage.Text  = currentPage.ToString();
         lblHowManyPages.Text = howManyPages.ToString();
         if (currentPage == 1)
         {
             HyperLinkPrevious.Enabled  = false;// Nghia la neu chi co 1 trang thi khong hien cai lui lai
             HyperLinkPrevious.CssClass = "disable";
         }
         else
         {
             HyperLinkPrevious.NavigateUrl = currentPage == 2 ? firstPageUrl : String.Format(pageUrlFormat, currentPage - 1);
             //Nghia la neu 2 trang thi cai previous se van hien va lui lai so trang
         }
         if (currentPage == howManyPages)
         {
             //Khi so luong trang hien tai = tong so trang thi Next se bi an di
             HyperLinkNext.Enabled  = false;
             HyperLinkNext.CssClass = "disable";
         }
         else
         {
             HyperLinkNext.NavigateUrl = String.Format(pageUrlFormat, currentPage + 1);
             //khi so trang cha bang tong so trang da co thi chung ta co the an Next de tang len 1 trang tiep theo
         }
         if (showPages)
         {
             PageUrl[] pages = new PageUrl[howManyPages]; // Khai bao 1 mang voi gia tri bang tong so luong Page
             pages[0] = new PageUrl("1", firstPageUrl);   // gan vi tri  dau tien la trang 1. Mac dinh la co 1 trang
             for (int i = 2; i <= howManyPages; i++)
             {
                 pages[i - 1] = new PageUrl(i.ToString(), String.Format(pageUrlFormat, i));
             }
             if (currentPage >= 0 && currentPage < howManyPages)// if trang hien tai >=0 va trang hien tai nho hon tong so trang
             {
                 pages[currentPage - 1] = new PageUrl(currentPage.ToString(), "");
             }
             RepeaterPages.DataSource = pages;
             RepeaterPages.DataBind();
         }
     }
     else
     {
         this.Visible = false;
     }
 }
Пример #17
0
 public void ShowPage(int currentPage, int howManyPages, string firstPageUrl, string pageUrlFormat, bool showPages)
 {
     if (howManyPages > 1)
     {
         this.Visible = true;
         lblCurrentPage.Text = currentPage.ToString();
         lblHowManyPages.Text = howManyPages.ToString();
         if (currentPage == 1)
         {
             HyperLinkPrevious.Enabled = false;// Nghia la neu chi co 1 trang thi khong hien cai lui lai
             HyperLinkPrevious.CssClass = "disable";
         }
         else
         {
             HyperLinkPrevious.NavigateUrl = currentPage == 2 ? firstPageUrl : String.Format(pageUrlFormat, currentPage - 1);
             //Nghia la neu 2 trang thi cai previous se van hien va lui lai so trang
         }
         if (currentPage == howManyPages)
         {
             //Khi so luong trang hien tai = tong so trang thi Next se bi an di
             HyperLinkNext.Enabled = false;
             HyperLinkNext.CssClass = "disable";
         }
         else
         {
             HyperLinkNext.NavigateUrl = String.Format(pageUrlFormat, currentPage + 1);
             //khi so trang cha bang tong so trang da co thi chung ta co the an Next de tang len 1 trang tiep theo
         }
         if (showPages)
         {
             PageUrl[] pages = new PageUrl[howManyPages];// Khai bao 1 mang voi gia tri bang tong so luong Page
             pages[0] = new PageUrl("1", firstPageUrl);// gan vi tri  dau tien la trang 1. Mac dinh la co 1 trang
             for (int i = 2; i <= howManyPages; i++)
             {
                 pages[i - 1] = new PageUrl(i.ToString(), String.Format(pageUrlFormat, i));
             }
             if (currentPage >= 0 && currentPage < howManyPages)// if trang hien tai >=0 va trang hien tai nho hon tong so trang
             {
                 pages[currentPage - 1] = new PageUrl(currentPage.ToString(), "");
             }
             RepeaterPages.DataSource = pages;
             RepeaterPages.DataBind();
         }
     }
     else
     {
         this.Visible = false;
     }
 }
Пример #18
0
        public static bool TryParseFriendlyUrl(string relativeUrl, out PageUrlOptions urlOptions)
        {
            if (IsAdminPath(relativeUrl))
            {
                urlOptions = null;
                return(false);
            }

            string      path;
            CultureInfo cultureInfo = PageUrl.GetCultureInfo(relativeUrl, out path);

            if (cultureInfo == null)
            {
                urlOptions = null;
                return(false);
            }

            string loweredRelativeUrl = relativeUrl.ToLower(CultureInfo.InvariantCulture);

            // Getting the site map
            IEnumerable <XElement> siteMap;
            DataScopeIdentifier    dataScope = DataScopeIdentifier.GetDefault();

            using (new DataScope(dataScope, cultureInfo))
            {
                siteMap = PageStructureInfo.GetSiteMap();
            }

            XAttribute matchingAttributeNode = siteMap.DescendantsAndSelf()
                                               .Attributes("FriendlyUrl")
                                               .FirstOrDefault(f => string.Equals(f.Value, loweredRelativeUrl, StringComparison.OrdinalIgnoreCase));

            if (matchingAttributeNode == null)
            {
                urlOptions = null;
                return(false);
            }

            XElement pageNode = matchingAttributeNode.Parent;

            XAttribute pageIdAttr = pageNode.Attributes("Id").FirstOrDefault();

            Verify.IsNotNull(pageIdAttr, "Failed to get 'Id' attribute from the site map");
            Guid pageId = new Guid(pageIdAttr.Value);

            urlOptions = new PageUrlOptions(dataScope.Name, cultureInfo, pageId, UrlType.Friendly);
            return(true);
        }
Пример #19
0
        protected override void OnLoad(EventArgs e)
        {
            string url = PageUrl.ToUpper().Trim();

            if (_IsAuthenticate)
            {
                string rawUrl = PageRawUrl.ToUpper().Trim();
                if (!Permissions.Any(p => p.MOD_URL.ToUpper().Trim() == url ||
                                     p.MOD_URL.ToUpper().Trim() == rawUrl))
                {
                    b_MissingParameter("无权访问该页面.");
                }
            }

            base.OnLoad(e);
        }
Пример #20
0
 public IEnumerable <byte[]> DownloadPages(int ID)
 {
     foreach (var PageUrl in GetChapterPages(ID))
     {
         var Page = PageUrl.TryDownload(Referer: CurrentUrl);
         if (Page == null && CFData != null)
         {
             Page = PageUrl.TryDownload(CFData, Referer: CurrentUrl);
         }
         if (Page == null)
         {
             CFData = JSTools.BypassCloudflare(PageUrl);
             Page   = PageUrl.TryDownload(CFData, Referer: CurrentUrl);
         }
         yield return(Page);
     }
 }
    public void Display(int currentPage, int howManyPages, string firstPageUrl,
    string pageUrlFormat, bool showPages)
    {
        if (howManyPages > 1)
        {
            this.Visible = true;

            currentPageLabel.Text = currentPage.ToString();
            howManyPagesLabel.Text = howManyPages.ToString();

            if (currentPage == 1)
            {
                previousLink.Enabled = false;
            }

            else
            {
                previousLink.NavigateUrl = (currentPage == 2) ?
                  firstPageUrl : String.Format(pageUrlFormat, currentPage - 1);
            }

            if (currentPage == howManyPages)
            {
                nextLink.Enabled = false;
            }
            else
            {
                nextLink.NavigateUrl = String.Format(pageUrlFormat, currentPage + 1);
            }

           if (showPages)
            {
                PageUrl[] pages = new PageUrl[howManyPages];
                pages[0] = new PageUrl("1", firstPageUrl);
                for (int i = 2; i <= howManyPages; i++)
                {
                    pages[i - 1] =
                      new PageUrl(i.ToString(), String.Format(pageUrlFormat, i));
                }
                pages[currentPage - 1] = new PageUrl((currentPage).ToString(), "");
                pagesRepeater.DataSource = pages;
                pagesRepeater.DataBind();
            }
        }
    }
Пример #22
0
        protected Search.IndexItem GetBaseIndexItem()
        {
            var indexItem = new Search.IndexItem {
                Created      = CreatedDate,
                LanguageId   = LanguageId,
                Modified     = UpdateDate,
                PageId       = PageId,
                PublishStart = StartPublish,
                PublishStop  = StopPublish
            };

            if (PageUrl != null)
            {
                indexItem.Path = PageUrl.ToString();
            }

            return(indexItem);
        }
Пример #23
0
        private void PerformSearch()
        {
            if (string.IsNullOrWhiteSpace(this.searchText.Text))
            {
                this.CloseSearch();
                return;
            }

            this.Searches.OnNext(this.searchText.Text);
            try
            {
                this.Navigation.Navigate(PageUrl.SearchMixes(this.searchText.Text));
            }
            catch (InvalidOperationException)
            {
                // Thrown when task is not in the foreground.
            }
        }
Пример #24
0
 public void Show(int currentPage, int howManyPages, string firstPageUrl, string pageUrlFormat, bool showPages)
 {
     if (howManyPages > 1)
     {
         this.Visible = true;
         lblCurrentPage.Text = currentPage.ToString();
         lblHowManyPages.Text = howManyPages.ToString();
         if (currentPage == 1)
         {
             lnkPrevious.Enabled = false;
             lnkPrevious.CssClass = "disabled";
         }
         else
         {
             lnkPrevious.NavigateUrl = currentPage == 2 ? firstPageUrl : String.Format(pageUrlFormat, currentPage - 1);
         }
         if (currentPage == howManyPages)
         {
             lnkNext.Enabled = false;
             lnkNext.CssClass = "disabled";
         }
         else
         {
             lnkNext.NavigateUrl = String.Format(pageUrlFormat, currentPage + 1);
         }
         if (showPages)
         {
             PageUrl[] pages = new PageUrl[howManyPages];
             pages[0] = new PageUrl("1", firstPageUrl);
             for (int i = 2; i <= howManyPages; i++)
             {
                 pages[i - 1] = new PageUrl(i.ToString(), String.Format(pageUrlFormat, i));
             }
             if (currentPage >= 0 && currentPage < howManyPages)
                 pages[currentPage - 1] = new PageUrl(currentPage.ToString(), "");
             repPager.DataSource = pages;
             repPager.DataBind();
         }
     }
     else
     {
         this.Visible = false;
     }
 }
Пример #25
0
    public void Show(int currentPage, int howManyPages, string firstPageUrl, string pageUrlFormat, bool showPages)
    {
        if (howManyPages > 1)
        {
            this.Visible = true;

            //currentPageLabel.Text = currentPage.ToString();
            //howManyPagesLabel.Text = howManyPages.ToString();

            if (currentPage == 1)
            {
                prevLink.Enabled = false;
            }
            else
            {
                prevLink.NavigateUrl = (currentPage == 2) ? firstPageUrl : String.Format(pageUrlFormat, currentPage - 1);
            }
            if (currentPage == howManyPages)
            {
                nextLink.Enabled = false;
            }
            else
            {
                nextLink.NavigateUrl = String.Format(pageUrlFormat, currentPage + 1);
            }

            if (showPages)
            {
                PageUrl[] pages = new PageUrl[howManyPages];
                pages[0] = new PageUrl("1", firstPageUrl);

                for (int i = 2; i <= howManyPages; i++)
                {
                    pages[i - 1] = new PageUrl(i.ToString(), String.Format(pageUrlFormat, i));
                }

                pages[currentPage - 1] = new PageUrl((currentPage).ToString(), "");

                pagesRepeater.DataSource = pages;
                pagesRepeater.DataBind();
            }
        }
    }
Пример #26
0
    public static string AppendToUrlPager2(string Url, string key, string value)
    {
        if (string.IsNullOrEmpty(Url))
        {
            Url = ReadConfiguration.SiteUrl + "default.aspx";
        }
        //Url = Url.ToLower();
        string PageUrl;

        string[] qsKeys;
        if (Url.Contains("?"))
        {
            PageUrl = Url.Substring(0, Url.IndexOf('?') + 1);
            qsKeys  = Url.Substring(Url.IndexOf('?') + 1).Split('&');
            foreach (string sParam in qsKeys)
            {
                if (!string.IsNullOrEmpty(sParam) && !sParam.StartsWith(key + "="))
                {
                    PageUrl += sParam + "&";
                }
            }
        }
        else
        {
            PageUrl = Url + "?";
        }
        if (!string.IsNullOrEmpty(value))
        {
            PageUrl += key + "=" + value;
        }


        if (PageUrl.EndsWith("?"))
        {
            PageUrl = PageUrl.Substring(0, PageUrl.Length - 1);
        }
        if (PageUrl.EndsWith("&"))
        {
            PageUrl = PageUrl.Substring(0, PageUrl.Length - 1);
        }
        return(PageUrl);
    }
Пример #27
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ResourceName.Length != 0)
            {
                hash ^= ResourceName.GetHashCode();
            }
            if (searchTerm_ != null)
            {
                hash ^= SearchTerm.GetHashCode();
            }
            if (headline_ != null)
            {
                hash ^= Headline.GetHashCode();
            }
            if (landingPage_ != null)
            {
                hash ^= LandingPage.GetHashCode();
            }
            if (pageUrl_ != null)
            {
                hash ^= PageUrl.GetHashCode();
            }
            if (hasNegativeKeyword_ != null)
            {
                hash ^= HasNegativeKeyword.GetHashCode();
            }
            if (hasMatchingKeyword_ != null)
            {
                hash ^= HasMatchingKeyword.GetHashCode();
            }
            if (hasNegativeUrl_ != null)
            {
                hash ^= HasNegativeUrl.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #28
0
        /// <summary>
        /// Constructor for the ProductListItemViewModel class.
        /// </summary>
        /// <param name="productPage">Product's page.</param>
        /// <param name="priceDetail">Price of the product.</param>
        /// <param name="publicStatusName">Display name of the product's public status.</param>
        public ProductListItemViewModel(SKUTreeNode productPage, ProductCatalogPrices priceDetail, IPageUrlRetriever urlRetriever, string publicStatusName)
        {
            // Sets the page information
            Name       = productPage.DocumentName;
            ProductUrl = urlRetriever.Retrieve(productPage);

            // Sets the SKU information
            ImagePath = string.IsNullOrEmpty(productPage.SKU.SKUImagePath) ?
                        null : new FileUrl(productPage.SKU.SKUImagePath, true)
                        .WithSizeConstraint(SizeConstraint.MaxWidthOrHeight(400))
                        .RelativePath;

            Available        = !productPage.SKU.SKUSellOnlyAvailable || productPage.SKU.SKUAvailableItems > 0;
            PublicStatusName = publicStatusName;

            // Sets the price format information
            PriceModel = new PriceDetailViewModel
            {
                Price                = priceDetail.Price,
                ListPrice            = priceDetail.ListPrice,
                CurrencyFormatString = priceDetail.Currency.CurrencyFormatString
            };
        }
Пример #29
0
        /// <summary>
        /// Initializes a new instance of the TagViewModel class.
        /// </summary>
        /// <param name="name">
        /// </param>
        public TagViewModel(string name)
        {
            this.TagName = name;
            if (!string.IsNullOrWhiteSpace(this.TagName))
            {
                this.Key = this.TagName.Trim().ToLowerInvariant().First().ToString();
            }

            if (!char.IsLetter(this.Key[0]))
            {
                this.Key = "#";
            }

            if (this.TagName == "more...")
            {
                this.IsLastItem    = true;
                this.NavigationUrl = PageUrl.Tags();
            }
            else
            {
                this.NavigationUrl = PageUrl.SearchMixesByTag(this.TagName);
            }
        }
Пример #30
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (HasPageUrl)
            {
                hash ^= PageUrl.GetHashCode();
            }
            if (HasNextPageUrl)
            {
                hash ^= NextPageUrl.GetHashCode();
            }
            hash ^= Metadata.GetHashCode();
            hash ^= tracks_.GetHashCode();
            if (HasLoading)
            {
                hash ^= Loading.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        private void processReturnURL()
        {
            string prevUrl = Request.QueryString[MCSUrl.ReturnUrl];

            if (prevUrl != null && prevUrl.Length > 0)
            {
                try
                {
                    long urlId = long.Parse(prevUrl);
                    try
                    {
                        prevUrl = GetUrlById(urlId);
                    }
                    catch (NoPageInHistoryException)
                    {
                        prevUrl = PageUrl.ToString();
                    }
                    returnUrlId = urlId;
                }
                catch (FormatException)
                {
                    // the parameter contains the full url.  store it in the url manager.
                    long urlId = AddUrlToHistory(HttpUtility.UrlDecode(prevUrl));
                    PageUrl.SetParameter(MCSUrl.ReturnUrl, urlId.ToString());
                    returnUrlId = urlId;
                }
            }
            else
            {
                MCSUrl eu = new MCSUrl("http://www.monet.k12.ca.us");
                prevUrl = eu.BuildURL();                 //TODO make a contstant
            }
            ClientScript.RegisterHiddenField("PreviousUrl", prevUrl);
            ClientScript.RegisterHiddenField("MyUrl", PageUrl.ToString());
            ClientScript.RegisterHiddenField("ServerUrl", Utilities.GetAppPathURL());
        }
Пример #32
0
    // show the pager
    public void Show(int currentPage, int howManyPages, string firstPageUrl, string pageUrlFormat, bool showPages)
    {
        // display paging controls
        if (howManyPages > 1)
        {
            // make the pager visible
            this.Visible = true;

            // display the current page
            currentPageLabel.Text = currentPage.ToString();
            howManyPagesLabel.Text = howManyPages.ToString();

            // create the Previous link
            if (currentPage == 1)
            {
                previousLink.Enabled = false;
            }
            else
            {
                previousLink.NavigateUrl = (currentPage == 2) ?
                  firstPageUrl : String.Format(pageUrlFormat, currentPage - 1);
            }

            // create the Next link
            if (currentPage == howManyPages)
            {
                nextLink.Enabled = false;
            }
            else
            {
                nextLink.NavigateUrl = String.Format(pageUrlFormat, currentPage + 1);
            }

            // create the page links
            if (showPages)
            {
                // the list of pages and their URLs as an array
                PageUrl[] pages = new PageUrl[howManyPages];
                // generate (page, url) elements
                pages[0] = new PageUrl("1", firstPageUrl);
                for (int i = 2; i <= howManyPages; i++)
                {
                    pages[i - 1] =
                      new PageUrl(i.ToString(), String.Format(pageUrlFormat, i));
                }
                // do not generate a link for the current page
                pages[currentPage - 1] = new PageUrl((currentPage).ToString(), "");
                // feed the pages to the repeater
                pagesRepeater.DataSource = pages;
                pagesRepeater.DataBind();
            }
        }
    }
Пример #33
0
        internal static void FilledInTagList(string tagdef, ArrayList tagList, IResourceDependency res)
        {
            int idxBegin = 0, idxEnd = 0;
            idxBegin = tagdef.IndexOf("#}");
            idxEnd = tagdef.LastIndexOf("{#");
            tagdef = tagdef.Substring(idxBegin+2, idxEnd - idxBegin-2).Trim();

            Regex regEx = new Regex(TagBase.TagDefinitionPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
            idxBegin = idxEnd = 0;
            MatchCollection mc = regEx.Matches(tagdef, idxBegin);
            HtmlTextTag htmlTag = null;
            while (mc.Count > 0)
            {
                Match m = mc[0];
                idxEnd = m.Index;

                if (idxEnd > idxBegin)
                {
                    htmlTag = new HtmlTextTag(tagdef.Substring(idxBegin, idxEnd - idxBegin));
                    tagList.Add(htmlTag);
                }

                TagBase tag = new TagBase(m.Value, m.Index, ref tagdef);
                //Util.Debug(tag.Category);
                if (tag.Category == TagCategory.AutoTag)
                {
                    AutoItem item = AutoItem.Parse(tag);
                    if (res.GetType() == typeof(PagerTag))
                    {
                        item.CallerTag = (PagerTag)res;
                    }
                    tagList.Add(item);
                }
                else if (tag.Category == TagCategory.DefineTag)
                {
                    //数据库标签定义格式为 {#%FieldName%#}
                    if (res != null)
                    {
                        htmlTag = new HtmlTextTag(res.GetDefinition(tag.OuterDefineText).ToString());
                        tagList.Add(htmlTag);
                    }
                }
                else if (tag.Category == TagCategory.CustomTag)
                {
                    #region 数据定义标签内包含数据定义标签
                    DbStoredCustomTag dbTag = DbStoredCustomTag.Parse(tag);
                    dbTag.SetResourceDependency(res);
                    if (dbTag.IsExist == true)
                    {
                        htmlTag = new HtmlTextTag(dbTag.GetTagValue().ToString());
                        tagList.Add(htmlTag);
                    }
                    #endregion
                }
                else if (tag.Category == TagCategory.SystemTag)
                {
                    string pageURLKey = ",FirstUrl,PreUrl,NextUrl,LastUrl,CurUrl,";
                    string tagName = tag.TagName.Trim('$');
                    if (pageURLKey.IndexOf("," + tagName + ",", StringComparison.InvariantCultureIgnoreCase) != -1)
                    {
                        tagName = tagName.ToLower();
                        PageUrl url = new PageUrl(tag.OuterDefineText);
                        url.IsAutoItem = (res != null && res.GetType() == typeof(AutoItem));
                        url.SetResourceDependency(res);
                        switch (tagName)
                        {
                            case "firsturl": url.UrlCategory = PageUrlCategory.FirstPage; break;
                            case "preurl": url.UrlCategory = PageUrlCategory.PrePage; break;
                            case "nexturl": url.UrlCategory = PageUrlCategory.NextPage; break;
                            case "lasturl": url.UrlCategory = PageUrlCategory.LastPage; break;
                            case "cururl": url.UrlCategory = PageUrlCategory.ThisPage; break;
                            default:
                                url.UrlCategory = PageUrlCategory.ThisPage;
                                break;
                        }
                        tagList.Add(url);
                    }
                    else
                    {
                        SystemTag sys = new SystemTag(tag.OuterDefineText);
                        //Util.Debug(false, res.GetType().ToString());
                        sys.SetResourceDependency(res);
                        tagList.Add(sys);
                    }
                }
                else
                {
                    tagList.Add(tag);
                }
                //Util.Debug(false, "#####\n" + tag.OuterDefineText + "\n#####");
                //TagList.Add(tag);

                idxBegin = tag.DefinedIndexEnd;
                mc = regEx.Matches(tagdef, idxBegin);
            }

            if (idxBegin < tagdef.Length)
            {
                htmlTag = new HtmlTextTag(tagdef.Substring(idxBegin));
                tagList.Add(htmlTag);
            }
        }
Пример #34
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            _jsObjName = String.IsNullOrEmpty(ID) ? "pageNavigator" + UniqueID.Replace('$', '_') : ID;

            if (HttpContext.Current != null && HttpContext.Current.Request != null && AutoDetectCurrentPage)
            {
                if (!String.IsNullOrEmpty(HttpContext.Current.Request[this.ParamName]))
                {
                    try
                    {
                        CurrentPageNumber = Convert.ToInt32(HttpContext.Current.Request[this.ParamName]);
                    }
                    catch
                    {
                        CurrentPageNumber = 0;
                    }
                }
            }

            if (CurrentPageNumber <= 0)
            {
                CurrentPageNumber = 1;
            }

            var scriptNav = String.Format(@"window.{0} = new ASC.Controls.PageNavigator.init('{0}', 'body', '{1}', {2}, {3}, '{4}', '{5}');",
                                          _jsObjName,
                                          EntryCountOnPage,
                                          VisiblePageCount,
                                          CurrentPageNumber,
                                          UserControlsCommonResource.PreviousPage,
                                          UserControlsCommonResource.NextPage);

            Page.RegisterInlineScript(scriptNav, onReady: false);


            _page_amount = Convert.ToInt32(Math.Ceiling(EntryCount / (EntryCountOnPage * 1.0)));
            _start_page  = CurrentPageNumber - 1 - VisiblePageCount / 2;

            if (_start_page + VisiblePageCount > _page_amount)
            {
                _start_page = _page_amount - VisiblePageCount;
            }

            if (_start_page < 0)
            {
                _start_page = 0;
            }

            _end_page = _start_page + VisiblePageCount;

            if (_end_page > _page_amount)
            {
                _end_page = _page_amount;
            }

            if ((_page_amount == 1 && VisibleOnePage) || _start_page >= _end_page || _end_page - _start_page <= 1)
            {
                return;
            }

            var spliter = "&";

            if (PageUrl.IndexOf("?") == -1)
            {
                spliter = "&";
            }

            var isFirst = (CurrentPageNumber == 1);
            var isLast  = (CurrentPageNumber == _page_amount);

            var prevURL = PageUrl + spliter + ParamName + "=" + (CurrentPageNumber - 1).ToString();
            var nextURL = PageUrl + spliter + ParamName + "=" + (CurrentPageNumber + 1).ToString();

            var script = @"document.onkeydown = function(e)
                            {
                                var code;
                                if (!e) var e = window.event;
                                if (e.keyCode) code = e.keyCode;
                                else if (e.which) code = e.which;" +

                         ((!isFirst) ?
                          @"if ((code == 37) && (e.ctrlKey == true))
                                {
                                    window.open('" + prevURL + @"','_self');
                                }" : "") +

                         ((!isLast) ?
                          @"if ((code == 39) && (e.ctrlKey == true))
                                {
                                    window.open('" + nextURL + @"','_self');
                                }" : "") +
                         @"}; ";

            Page.RegisterInlineScript(script, onReady: false);
        }
Пример #35
0
 /// <summary>
 /// Returns the page url.
 /// </summary>
 /// <returns></returns>
 public override string ToString() => PageUrl.ToString();