Exemple #1
0
        public static IPageMeta GetPageMeta(Page page)
        {
            string url            = GetUrl(page);
            int    publicatrionId = SiteGlobal.PublicationId;

            using (PageMetaFactory factory = new PageMetaFactory(publicatrionId))
            {
                return(factory.GetMetaByUrl(publicatrionId, url));
            }
        }
        public DateTime GetLastPublishedDateByUrl(string url)
        {
            int pubId = PublicationId;

            LoggerService.Debug("GetLastPublishedDateByUrl found publication id {0}, url = {1}", pubId, url);
            using (var pMetaFactory = new PageMetaFactory(pubId))
            {
                IPageMeta pageInfo = pMetaFactory.GetMetaByUrl(pubId, url); // TODO: Temporarily removed using statement, because IPageMeta is not IDisposable (yet) in CDaaS build #422
                {
                    return(pageInfo?.LastPublicationDate ?? DateTime.Now);
                }
            }
        }
Exemple #3
0
        public DateTime GetLastPublishedDateByUrl(string url)
        {
            PageMetaFactory pMetaFactory = new PageMetaFactory(PublicationId);
            var             pageInfo     = pMetaFactory.GetMetaByUrl(url);

            if (pageInfo == null || pageInfo.Count <= 0)
            {
                return(DateTime.Now);
            }
            else
            {
                IPageMeta pInfo = pageInfo[0] as IPageMeta;
                return(pInfo.LastPublicationDate);
            }
        }
        public DateTime GetLastPublishedDateByUrl(string url)
        {
            int pubId = PublicationId;

            LoggerService.Debug("GetLastPublishedDateByUrl found publication id {0}, url = {1}", pubId, url);
            PageMetaFactory pMetaFactory = new PageMetaFactory(pubId);
            IPageMeta       pageInfo     = pMetaFactory.GetMetaByUrl(pubId, url);

            if (pageInfo == null)
            {
                return(DateTime.Now);
            }
            else
            {
                return(pageInfo.LastPublicationDate);
            }
        }
Exemple #5
0
        public static IPageMeta GetPageMetaFromSEO(HttpRequestBase request, string url)
        {
            PageMetaFactory pageMetaFactory = new PageMetaFactory(SiteGlobal.PublicationId);
            IPageMeta       pageMeta        = pageMetaFactory.GetMetaByUrl(SiteGlobal.PublicationId, url);

            if (pageMeta == null)
            {
                // Check if it is a Vanity URL
                var publicationCriteria = new PublicationCriteria(SiteGlobal.PublicationId);
                var pageCriteria        = new ItemTypeCriteria((int)TridionItemType.Page);
                var vanityUrlCriteria   = new CustomMetaValueCriteria(new CustomMetaKeyCriteria("SEOUrl", Criteria.Equal), url);

                // --

                Query query = new Query();
                query.Criteria = CriteriaFactory.And(new Criteria[] { publicationCriteria, pageCriteria, vanityUrlCriteria });
                IEnumerable <string> pages = query.ExecuteQuery();

                //If no result, we try taking the ApplicationPath ['/en'] fro the url
                if (!pages.Any() && url.ToLower().StartsWith(request.ApplicationPath.ToLower()))
                {
                    var urlWithoutAppPath  = url.Substring(request.ApplicationPath.Length);
                    var vanityUrlCriteria2 = new CustomMetaValueCriteria(new CustomMetaKeyCriteria("SEOUrl", Criteria.Equal), urlWithoutAppPath);
                    query.Criteria = CriteriaFactory.And(new Criteria[] { publicationCriteria, pageCriteria, vanityUrlCriteria2 });
                    pages          = query.ExecuteQuery();

                    //If no result, we try taking the '/' from the begining of the url.
                    if (!pages.Any())
                    {
                        urlWithoutAppPath  = urlWithoutAppPath.TrimStart('/');
                        vanityUrlCriteria2 = new CustomMetaValueCriteria(new CustomMetaKeyCriteria("SEOUrl", Criteria.Equal), urlWithoutAppPath);
                        query.Criteria     = CriteriaFactory.And(new Criteria[] { publicationCriteria, pageCriteria, vanityUrlCriteria2 });
                        pages = query.ExecuteQuery();
                    }
                }

                if (pages.Any())
                {
                    pageMeta = pageMetaFactory.GetMeta(pages.First());
                }
            }
            return(pageMeta);
        }
        public DateTime GetLastPublishedDateByUrl(string url)
        {
            int pubId = PublicationId;
            LoggerService.Debug("GetLastPublishedDateByUrl found publication id {0}, url = {1}", pubId, url);
            using (var pMetaFactory = new PageMetaFactory(pubId))
            {
                using (IPageMeta pageInfo = pMetaFactory.GetMetaByUrl(pubId, url))
                {
                    if (pageInfo == null)
                    {
                        return DateTime.Now;
                    }

                    return pageInfo.LastPublicationDate;
                }
            }
        }
        public DateTime GetLastPublishedDateByUrl(string url)
        {
            int pubId = PublicationId;
            LoggerService.Debug("GetLastPublishedDateByUrl found publication id {0}, url = {1}", pubId, url);
            using (var pMetaFactory = new PageMetaFactory(pubId))
            {
                IPageMeta pageInfo = pMetaFactory.GetMetaByUrl(pubId, url); // TODO: Temporarily removed using statement, because IPageMeta is not IDisposable (yet) in CDaaS build #422
                {
                    if (pageInfo == null)
                    {
                        return DateTime.Now;
                    }

                    return pageInfo.LastPublicationDate;
                }
            }
        }
        public DateTime GetLastPublishedDateByUrl(string url)
        {
            PageMetaFactory pMetaFactory = new PageMetaFactory(PublicationId);
            var pageInfo = pMetaFactory.GetMetaByUrl(url);

            if (pageInfo == null || pageInfo.Count <=0)
            {
                return DateTime.Now;
            }
            else
            {
                    IPageMeta pInfo = pageInfo[0] as IPageMeta;
                    return pInfo.LastPublicationDate;
            }
        }