Beispiel #1
0
        /// <summary>
        /// Gets the image.
        /// </summary>
        /// <returns></returns>
        protected virtual SfImage GetImage()
        {
            LibrariesManager librariesManager = LibrariesManager.GetManager(this.ProviderName);

            return(librariesManager.GetImages().Where(i => i.Id == this.Id).Where(PredefinedFilters.PublishedItemsFilter <Telerik.Sitefinity.Libraries.Model.Image>()).FirstOrDefault());
        }
        private Image UploadTemplateImage(LibrariesManager libraryManager, Album templateThumbsImageLibrary, string templateName, string iconResource)
        {
            Image image = null;

            var suppressSecurityChecks = libraryManager.Provider.SuppressSecurityChecks;
            try
            {
                libraryManager.Provider.SuppressSecurityChecks = true;

                image = libraryManager.CreateImage();
                image.Parent = templateThumbsImageLibrary;
                image.Title = templateName;
                image.UrlName = templateName.ToLower().Replace(' ', '-');
                image.Description = "Description_" + templateName;
                image.AlternativeText = "AltText_" + templateName;
                image.ApprovalWorkflowState = "Published";
                libraryManager.RecompileItemUrls<Image>(image);

                using (var imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(iconResource))
                {
                    using (var resourceImage = System.Drawing.Image.FromStream(imageStream))
                    {
                        var resourceImageStream = new MemoryStream();
                        resourceImage.Save(resourceImageStream, System.Drawing.Imaging.ImageFormat.Png);

                        libraryManager.Upload(image, resourceImageStream, ".png");
                        libraryManager.Lifecycle.Publish(image);
                        libraryManager.SaveChanges();
                    }
                }
            }
            finally
            {
                libraryManager.Provider.SuppressSecurityChecks = suppressSecurityChecks;
            }

            return image;
        }
Beispiel #3
0
        /// <summary>
        /// Tries to resolve parent filter mode.
        /// </summary>
        /// <param name="urlParams">The URL params.</param>
        /// <param name="requestContext">The request context.</param>
        /// <returns></returns>
        protected virtual bool TryResolveParentFilterMode(string[] urlParams, RequestContext requestContext, LibrariesManager manager = null)
        {
            var libraryManager = manager ?? LibrariesManager.GetManager(this.Model.ProviderName);

            string param = RouteHelper.GetUrlParameterString(urlParams);

            string redirectUrl;

            var item = libraryManager.GetItemFromUrl(typeof(Library), param, out redirectUrl);

            if (item != null)
            {
                requestContext.RouteData.Values["action"]     = "Successors";
                requestContext.RouteData.Values["parentItem"] = item;

                if (this.Request["page"] != null)
                {
                    requestContext.RouteData.Values["page"] = int.Parse(this.Request["page"]);
                }

                return(true);
            }

            if (urlParams.Length > 1)
            {
                this.TryResolveParentFilterMode(urlParams.Take(urlParams.Length - 1).ToArray(), requestContext, manager);
            }

            return(false);
        }
        private Album GetProfileImagesAlbum(LibrariesManager manager)
        {
            var album = manager.GetAlbums().FirstOrDefault(l => l.Title == ProfileModel.ProfileImagesAlbumTitle);
            if (album == null)
            {
                album = manager.CreateAlbum();
                album.Title = ProfileModel.ProfileImagesAlbumTitle;
                album.UrlName = ProfileModel.ProfileImagesAlbumUrl;
            }

            return album;
        }
        private Guid CreateImageNativeAPI(string imageTitle, Stream imageStream, string imageExtension, LibrariesManager librariesManager)
        {
            Album album = librariesManager.GetAlbums().Where(al => al.Title == "Facebook Users").FirstOrDefault();
            if (album == null)
            {
                Guid albumId = Guid.NewGuid();

                album = librariesManager.GetAlbums().Where(a => a.Id == albumId).FirstOrDefault();

                if (album == null)
                {
                    //Create the album.
                    album = librariesManager.CreateAlbum(albumId);

                    //Set the properties of the album.
                    album.Title = "Facebook Users";
                    album.DateCreated = DateTime.UtcNow;
                    album.LastModified = DateTime.UtcNow;
                    album.UrlName = Regex.Replace("Facebook Users".ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");

                    //Save the changes.
                    librariesManager.SaveChanges();
                }

                album = librariesManager.GetAlbum(albumId);
            }

                //The album post is created as master. The masterImageId is assigned to the master version.
                Image image = librariesManager.CreateImage();

                librariesManager.SaveChanges();
                librariesManager.Provider.SuppressSecurityChecks = true;
                //Set the parent album.

                //Set the properties of the profile image
                image.Title = imageTitle;
                image.DateCreated = DateTime.UtcNow;
                image.PublicationDate = DateTime.UtcNow;
                image.LastModified = DateTime.UtcNow;
                image.UrlName = Regex.Replace(imageTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");

                librariesManager.Provider.SuppressSecurityChecks = true;
                image.Parent = album;

                //Upload the image file.
                librariesManager.Upload(image, imageStream, imageExtension);

                //Save the changes.
                librariesManager.SaveChanges();

                //Publish the Albums item. The live version acquires new ID.
                var bag = new Dictionary<string, string>();
                bag.Add("ContentType", typeof(Image).FullName);
                WorkflowManager.MessageWorkflow(image.Id, typeof(Image), null, "Publish", false, bag);

                return image.Id;
        }
Beispiel #6
0
        /// <summary>
        /// Convert to sitefinity model.
        /// </summary>
        /// <returns>
        /// This object as an Image.
        /// </returns>
        public virtual Image ToSitefinityModel()
        {
            var   manager   = LibrariesManager.GetManager();
            Image sfContent = null;
            Album sfAlbum   = null;

            //CONSTRUCT MODEL FROM SF API
            if (Id == Guid.Empty)
            {
                //CREATE NEW MODEL
                sfContent = manager.CreateImage();

                //SET DEFAULT DATA
                sfContent.DateCreated  = DateCreated = DateTime.UtcNow;
                sfContent.LastModified = DateTime.UtcNow;

                //GENERATE URL FROM TITLE IF APPLICABLE
                if (!string.IsNullOrWhiteSpace(Slug))
                {
                    sfContent.UrlName = Slug;
                }
                else if (!string.IsNullOrWhiteSpace(Title))
                {
                    sfContent.UrlName = Slug = ContentHelper.GenerateUrlName(Title);
                }
            }
            else
            {
                //GET LIVE ITEM FROM STORAGE
                sfContent = manager.GetImage(Id);

                //CHECK OUT ITEM FOR UPDATE IF APPLICABLE
                if (sfContent != null)
                {
                    //EDIT MODE ON CONTENT AND RETURNED CHECKED OUT ITEM
                    var master = manager.Lifecycle.Edit(sfContent) as Image;
                    sfContent = manager.Lifecycle.CheckOut(master) as Image;
                }
            }

            //MERGE DEFAULT PROPERTIES
            sfContent.Title           = Title;
            sfContent.Description     = Description;
            sfContent.AlternativeText = AlternativeText;
            sfContent.Author          = Author;
            sfContent.Height          = Height;
            sfContent.Width           = Width;
            sfContent.Ordinal         = Ordinal;

            //MERGE CUSTOM PROPERTIES
            if (sfContent.DoesFieldExist("Link"))
            {
                Link = sfContent.GetValue <string>("Link");
            }

            //ASSIGN LIBRARY IF APPLICABLE
            if (Parent != null)
            {
                if (Parent.Id != Guid.Empty)
                {
                    sfAlbum = manager.GetAlbum(Parent.Id);
                }
                else if (!string.IsNullOrWhiteSpace(Parent.Slug))
                {
                    sfAlbum = manager.GetAlbums().FirstOrDefault(a => a.UrlName == Parent.Slug);
                }

                if (sfAlbum == null && !string.IsNullOrWhiteSpace(Parent.Title))
                {
                    sfAlbum = Parent.Id != Guid.Empty
                        ? manager.CreateAlbum(Parent.Id) : manager.CreateAlbum();
                    sfAlbum.Title           = Parent.Title;
                    sfAlbum.Description     = Parent.Description;
                    sfAlbum.DateCreated     = DateTime.UtcNow;
                    sfAlbum.PublicationDate = DateTime.UtcNow;
                    sfAlbum.LastModified    = DateTime.UtcNow;
                    if (!string.IsNullOrWhiteSpace(Parent.Slug))
                    {
                        sfAlbum.UrlName = Parent.Slug;
                    }
                    else if (!string.IsNullOrWhiteSpace(Parent.Title))
                    {
                        sfAlbum.UrlName = Parent.Slug = ContentHelper.GenerateUrlName(Parent.Title);
                    }
                    manager.SaveChanges();
                }

                //STORE LIBRARY TO CONTENT
                sfContent.Parent = sfAlbum;
            }

            //MERGE TAXONOMIES
            sfContent.SetTaxa("Category", Categories);
            sfContent.SetTaxa("Tags", Tags);

            //RETURN SITEFINITY MODEL
            return(sfContent);
        }
        private void UploadImageFile(LibrariesManager libManager, MediaContent mediaItem)
        {
            var imageResource = "ProductsIntegrationTests.Images.1.jpg";
            var assembly = this.GetType().Assembly;
            var stream = assembly.GetManifestResourceStream(imageResource);

            libManager.Upload(mediaItem, stream, ".jpg");
        }
Beispiel #8
0
        public static Guid CreateDocumentNativeAPI(Stream documentStream, string fileExtension)
        {
            LibrariesManager librariesManager = LibrariesManager.GetManager();

            librariesManager.Provider.SuppressSecurityChecks = true;
            WorkflowManager.GetManager().Provider.SuppressSecurityChecks = true;

            Guid documentId = Guid.Empty;

            try
            {
                var documentLibrary = librariesManager.GetDocumentLibraries().Where(x => x.Title == "Image requests uploaded").FirstOrDefault();

                #region create document library
                //create document library if it doesnt exist
                if (documentLibrary == null)
                {
                    documentLibrary = librariesManager.CreateDocumentLibrary();

                    documentLibrary.Title        = "Image requests uploaded";
                    documentLibrary.DateCreated  = DateTime.UtcNow;
                    documentLibrary.LastModified = DateTime.UtcNow;
                    documentLibrary.UrlName      = Regex.Replace(documentLibrary.Title.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");

                    //Recompiles and validates the url of the library.
                    librariesManager.RecompileAndValidateUrls(documentLibrary);

                    //Save the changes.
                    librariesManager.SaveChanges();
                }
                #endregion

                documentId = Guid.NewGuid();
                var document = librariesManager.CreateDocument(documentId);

                document.Parent = documentLibrary;

                document.Title            = "Resume-" + documentId.ToString();
                document.DateCreated      = DateTime.UtcNow;
                document.PublicationDate  = DateTime.UtcNow;
                document.LastModified     = DateTime.UtcNow;
                document.UrlName          = Regex.Replace(document.Title.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
                document.MediaFileUrlName = Regex.Replace((document.Title + fileExtension).ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");

                //Upload the document file.
                librariesManager.Upload(document, documentStream, fileExtension);
                //Recompiles and validates the url of the document.
                librariesManager.RecompileAndValidateUrls(document);
                librariesManager.Lifecycle.Publish(document);
                //Save the changes.
                librariesManager.SaveChanges();


                //Publish the DocumentLibraries item. The live version acquires new ID.
                var bag = new Dictionary <string, string>();
                bag.Add("ContentType", typeof(Document).FullName);
                WorkflowManager.MessageWorkflow(documentId, typeof(Document), null, "Publish", false, bag);
            }
            catch (Exception ex)
            {
                Log.Write(ex, System.Diagnostics.TraceEventType.Error);
                return(documentId);
            }
            finally
            {
                librariesManager.Provider.SuppressSecurityChecks = false;
                WorkflowManager.GetManager().Provider.SuppressSecurityChecks = false;
            }
            return(documentId);
        }
Beispiel #9
0
        private DocumentTreeNode GetChildNodes(IFolder folder, IQueryable <IFolder> folders, DocumentLibrary album, LibrariesManager manager, IQueryable <Document> docsInLibrary)
        {
            var folderNode = new DocumentTreeNode();

            folderNode.Expanded = this.Expanded;
            folderNode.Title    = folder.Title;
            this.SetImage(folderNode);
            folderNode.Id        = folder.Id;
            folderNode.IsFolder  = true;
            folderNode.CssClass += " folder";

            //Load Documents
            var docsInFolder = manager.GetDocuments().Where(x => x.Parent.Id == album.Id && x.FolderId == folder.Id).Where(this.FilterExpressionForDocuments);

            foreach (var doc in docsInFolder)
            {
                DocumentTreeNode docNode = this.CreateDocNode(album, doc);
                folderNode.Nodes.Add(docNode);
            }

            //Load Children
            foreach (var child in folders.Where(x => x.ParentId == folder.Id))
            {
                folderNode.Nodes.Add(this.GetChildNodes(child, folders, album, manager, docsInLibrary));
            }

            return(folderNode);
        }
Beispiel #10
0
        public override void Execute()
        {
            WriteLiteral("\n<div");

            WriteAttribute("class", Tuple.Create(" class=\"", 310), Tuple.Create("\"", 334)

            #line 9 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                           , Tuple.Create(Tuple.Create(" ", 318), Tuple.Create <System.Object, System.Int32>(Model.CssClass

            #line default
            #line hidden
                                                                                                             , 319), false)
                           );

            WriteLiteral(">\n\n    <div");

            WriteLiteral(" class=\"row\"");

            WriteLiteral(">\n        <div");

            WriteLiteral(" class=\"col-lg-8\"");

            WriteLiteral(">\n");


            #line 13 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"


            #line default
            #line hidden

            #line 13 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
            if (@Model.Results.TotalCount > 0)
            {
                if (ViewBag.IsFilteredbyPermission)
                {
            #line default
            #line hidden
                    WriteLiteral("                        <h1");

                    WriteLiteral(" role=\"alert\"");

                    WriteLiteral(" aria-live=\"assertive\"");

                    WriteLiteral(">");


            #line 17 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    Write(Html.HtmlSanitize(Model.ResultText));


            #line default
            #line hidden
                    WriteLiteral("</h1>\n");


            #line 18 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                }
                else
                {
            #line default
            #line hidden
                    WriteLiteral("                        <h1");

                    WriteLiteral(" role=\"alert\"");

                    WriteLiteral(" aria-live=\"assertive\"");

                    WriteLiteral(">");


            #line 21 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    Write(Model.Results.TotalCount);


            #line default
            #line hidden
                    WriteLiteral(" ");


            #line 21 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    Write(Html.HtmlSanitize(Model.ResultText));


            #line default
            #line hidden
                    WriteLiteral("</h1>\n");


            #line 22 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                }
            }
            else
            {
            #line default
            #line hidden
                WriteLiteral("                    <h1");

                WriteLiteral(" role=\"alert\"");

                WriteLiteral(" aria-live=\"assertive\"");

                WriteLiteral(">");


            #line 26 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                Write(Html.Resource("No"));


            #line default
            #line hidden
                WriteLiteral(" ");


            #line 26 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                Write(Html.HtmlSanitize(Model.ResultText));


            #line default
            #line hidden
                WriteLiteral("</h1>\n");


            #line 27 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("        </div>\n        <div");

            WriteLiteral(" class=\"col-lg-4\"");

            WriteLiteral(">\n");


            #line 30 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"


            #line default
            #line hidden

            #line 30 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
            if (Model.AllowSorting && @Model.Results.TotalCount > 0)
            {
            #line default
            #line hidden
                WriteLiteral("                <label>");


            #line 32 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                Write(Html.Resource("SortBy"));


            #line default
            #line hidden
                WriteLiteral("\n                    <select");

                WriteLiteral(" class=\"userSortDropdown\"");

                WriteAttribute("title", Tuple.Create(" title=\"", 1292), Tuple.Create("\"", 1330)

            #line 33 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                               , Tuple.Create(Tuple.Create("", 1300), Tuple.Create <System.Object, System.Int32>(Html.Resource("SortDropdown")

            #line default
            #line hidden
                                                                                                                 , 1300), false)
                               );

                WriteLiteral(">\n                        <option");

                WriteAttribute("value", Tuple.Create(" value=\"", 1364), Tuple.Create("\"", 1397)

            #line 34 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                               , Tuple.Create(Tuple.Create("", 1372), Tuple.Create <System.Object, System.Int32>(OrderByOptions.Relevance

            #line default
            #line hidden
                                                                                                                 , 1372), false)
                               );

                WriteLiteral(" ");


            #line 34 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                Write(Model.OrderBy == OrderByOptions.Relevance ? "selected=selected" : "");


            #line default
            #line hidden
                WriteLiteral(">");


            #line 34 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                Write(Html.Resource("Relevance"));


            #line default
            #line hidden
                WriteLiteral("</option>\n                        <option");

                WriteAttribute("value", Tuple.Create(" value=\"", 1539), Tuple.Create("\"", 1569)

            #line 35 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                               , Tuple.Create(Tuple.Create("", 1547), Tuple.Create <System.Object, System.Int32>(OrderByOptions.Newest

            #line default
            #line hidden
                                                                                                                 , 1547), false)
                               );

                WriteLiteral(" ");


            #line 35 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                Write(Model.OrderBy == OrderByOptions.Newest ? "selected=selected" : "");


            #line default
            #line hidden
                WriteLiteral(">");


            #line 35 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                Write(Html.Resource("NewestFirst"));


            #line default
            #line hidden
                WriteLiteral("</option>\n                        <option");

                WriteAttribute("value", Tuple.Create(" value=\"", 1710), Tuple.Create("\"", 1740)

            #line 36 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                               , Tuple.Create(Tuple.Create("", 1718), Tuple.Create <System.Object, System.Int32>(OrderByOptions.Oldest

            #line default
            #line hidden
                                                                                                                 , 1718), false)
                               );

                WriteLiteral(" ");


            #line 36 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                Write(Model.OrderBy == OrderByOptions.Oldest ? "selected=selected" : "");


            #line default
            #line hidden
                WriteLiteral(">");


            #line 36 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                Write(Html.Resource("OldestFirst"));


            #line default
            #line hidden
                WriteLiteral("</option>\n                    </select>\n                </label>\n");


            #line 39 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("        </div>\n    </div>\n\n");


            #line 43 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"


            #line default
            #line hidden

            #line 43 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
            if (Model.Languages.Length > 1)
            {
            #line default
            #line hidden
                WriteLiteral("        <div>\n            <span>");


            #line 46 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                Write(Html.Resource("ChangeResultsLanguageLabel"));


            #line default
            #line hidden
                WriteLiteral(" </span>\n");


            #line 47 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"


            #line default
            #line hidden

            #line 47 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                for (var i = 0; i < Model.Languages.Length; i++)
                {
            #line default
            #line hidden
                    WriteLiteral("                <a");

                    WriteAttribute("href", Tuple.Create(" href=\"", 2168), Tuple.Create("\"", 2251)

            #line 49 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                                   , Tuple.Create(Tuple.Create("", 2175), Tuple.Create <System.Object, System.Int32>(String.Format(ViewBag.LanguageSearchUrlTemplate, Model.Languages[i].Name)

            #line default
            #line hidden
                                                                                                                     , 2175), false)
                                   );

                    WriteLiteral(">");


            #line 49 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    Write(Model.Languages[i].DisplayName);


            #line default
            #line hidden
                    WriteLiteral("</a>\n");


            #line 50 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    if (i < Model.Languages.Length - 2)
                    {
            #line default
            #line hidden
                        WriteLiteral("                    <span>, </span>\n");


            #line 53 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    }
                    else if (i == Model.Languages.Length - 2)
                    {
            #line default
            #line hidden
                        WriteLiteral("                    <span> ");


            #line 56 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                        Write(Html.Resource("OrLabel"));


            #line default
            #line hidden
                        WriteLiteral(" </span>\n");


            #line 57 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    }
                }


            #line default
            #line hidden
                WriteLiteral("        </div>\n");


            #line 60 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("             \n    <div");

            WriteLiteral(" class=\"sf-search-results media-list\"");

            WriteLiteral(">\n");


            #line 63 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"


            #line default
            #line hidden

            #line 63 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
            foreach (var item in Model.Results.Data)
            {
                var hasLink = item.GetValue("Link") != null && !String.IsNullOrEmpty(item.GetValue("Link").ToString());


            #line default
            #line hidden
                WriteLiteral("            <div");

                WriteLiteral(" class=\"media sf-media\"");

                WriteLiteral(">\n\n");


            #line 68 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"


            #line default
            #line hidden

            #line 68 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                if (((Telerik.Sitefinity.Services.Search.Model.Document)item).ItemType.ToString() == typeof(Telerik.Sitefinity.Libraries.Model.Image).ToString())
                {
            #line default
            #line hidden
                    WriteLiteral("            <div");

                    WriteLiteral(" class=\"media-left pr-2 sf-img-thmb\"");

                    WriteLiteral(">\n                <a");

                    WriteAttribute("href", Tuple.Create(" href=\"", 3135), Tuple.Create("\"", 3164)

            #line 72 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                                   , Tuple.Create(Tuple.Create("", 3142), Tuple.Create <System.Object, System.Int32>(item.GetValue("Link")

            #line default
            #line hidden
                                                                                                                     , 3142), false)
                                   );

                    WriteLiteral(">\n                    <img");

                    WriteAttribute("src", Tuple.Create(" src=\"", 3191), Tuple.Create("\"", 3219)

            #line 73 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                                   , Tuple.Create(Tuple.Create("", 3197), Tuple.Create <System.Object, System.Int32>(item.GetValue("Link")

            #line default
            #line hidden
                                                                                                                     , 3197), false)
                                   );

                    WriteAttribute("alt", Tuple.Create(" alt=\"", 3220), Tuple.Create("\"", 3249)

            #line 73 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                                   , Tuple.Create(Tuple.Create("", 3226), Tuple.Create <System.Object, System.Int32>(item.GetValue("Title")

            #line default
            #line hidden
                                                                                                                     , 3226), false)
                                   );

                    WriteLiteral(" width=\"120\"");

                    WriteLiteral("/>\n                </a>\n            </div>\n");


            #line 76 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                }

                else if (((Telerik.Sitefinity.Services.Search.Model.Document)item).ItemType.ToString() == typeof(Telerik.Sitefinity.Libraries.Model.Video).ToString())
                {
                    LibrariesManager librariesManager = LibrariesManager.GetManager();
                    var   videoTmbId = new Guid((string)item.GetValue("Id"));
                    Video video      = librariesManager.GetVideo(videoTmbId);
                    if (video != null)
                    {
                        var thumbUrl = video.ThumbnailUrl;



            #line default
            #line hidden
                        WriteLiteral("                <div");

                        WriteLiteral(" class=\"media-left pr-2\"");

                        WriteLiteral(">\n                    <div");

                        WriteLiteral(" class=\"sf-video-thmb\"");

                        WriteLiteral(">\n\n                        <a");

                        WriteAttribute("href", Tuple.Create(" href=\"", 3967), Tuple.Create("\"", 3996)

            #line 90 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                                       , Tuple.Create(Tuple.Create("", 3974), Tuple.Create <System.Object, System.Int32>(item.GetValue("Link")

            #line default
            #line hidden
                                                                                                                         , 3974), false)
                                       );

                        WriteLiteral(">\n                            <img");

                        WriteAttribute("src", Tuple.Create(" src=\"", 4031), Tuple.Create("\"", 4046)

            #line 91 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                                       , Tuple.Create(Tuple.Create("", 4037), Tuple.Create <System.Object, System.Int32>(thumbUrl

            #line default
            #line hidden
                                                                                                                         , 4037), false)
                                       );

                        WriteAttribute("alt", Tuple.Create(" alt=\"", 4047), Tuple.Create("\"", 4076)

            #line 91 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                                       , Tuple.Create(Tuple.Create("", 4053), Tuple.Create <System.Object, System.Int32>(item.GetValue("Title")

            #line default
            #line hidden
                                                                                                                         , 4053), false)
                                       );

                        WriteLiteral(" width=\"120\"");

                        WriteLiteral("/>\n                        \n                            <div");

                        WriteLiteral(" class=\"sf-icon-play\"");

                        WriteLiteral("></div>\n                        \n                        </a>\n                   " +
                                     " </div>\n                </div>\n");


            #line 98 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    }
                }

                else
                {
                }


            #line default
            #line hidden
                WriteLiteral("            \n            \n            <div");

                WriteLiteral(" class=\"media-body sf-media-body\"");

                WriteLiteral(">\n\n                <h3>\n");


            #line 111 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"


            #line default
            #line hidden

            #line 111 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                if (hasLink)
                {
            #line default
            #line hidden
                    WriteLiteral("                        <a");

                    WriteAttribute("href", Tuple.Create(" href=\"", 4543), Tuple.Create("\"", 4572)

            #line 113 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                                   , Tuple.Create(Tuple.Create("", 4550), Tuple.Create <System.Object, System.Int32>(item.GetValue("Link")

            #line default
            #line hidden
                                                                                                                     , 4550), false)
                                   );

                    WriteLiteral(">");


            #line 113 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    Write(item.GetValue("Title"));


            #line default
            #line hidden
                    WriteLiteral("</a>\n");


            #line 114 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                }
                else
                {
            #line default
            #line hidden

            #line 117 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    Write(item.GetValue("Title"));


            #line default
            #line hidden

            #line 117 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("                </h3>\n\n                <p>");


            #line 121 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                Write(Html.HtmlSanitize((string)item.GetValue("HighLighterResult")));


            #line default
            #line hidden
                WriteLiteral("</p>\n");


            #line 122 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"


            #line default
            #line hidden

            #line 122 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                if (hasLink)
                {
            #line default
            #line hidden
                    WriteLiteral("                    <a");

                    WriteAttribute("href", Tuple.Create(" href=\"", 4920), Tuple.Create("\"", 4949)

            #line 124 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                                   , Tuple.Create(Tuple.Create("", 4927), Tuple.Create <System.Object, System.Int32>(item.GetValue("Link")

            #line default
            #line hidden
                                                                                                                     , 4927), false)
                                   );

                    WriteLiteral(">");


            #line 124 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    Write(item.GetValue("Link"));


            #line default
            #line hidden
                    WriteLiteral("</a>\n");


            #line 125 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("            </div>\n            </div>\n");


            #line 128 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("\n    </div>\n\n");


            #line 132 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"


            #line default
            #line hidden

            #line 132 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
            if (Model.DisplayMode == ListDisplayMode.Paging && Model.TotalPagesCount != null && Model.TotalPagesCount > 1)
            {
                if (ViewBag.IsFilteredbyPermission)
                {
            #line default
            #line hidden
                    WriteLiteral("             <ul");

                    WriteLiteral(" class=\"pagination\"");

                    WriteLiteral(">\n");


            #line 137 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"


            #line default
            #line hidden

            #line 137 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    if (Model.CurrentPage > 1)
                    {
            #line default
            #line hidden
                        WriteLiteral("                    <li");

                        WriteLiteral(" class=\"page-item\"");

                        WriteLiteral(">\n\t\t\t\t\t    <a");

                        WriteLiteral(" class=\"page-link\"");

                        WriteAttribute("href", Tuple.Create(" href=\'", 5392), Tuple.Create("\'", 5469)

            #line 140 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                                       , Tuple.Create(Tuple.Create("", 5399), Tuple.Create <System.Object, System.Int32>(string.Format(ViewBag.RedirectPageUrlTemplate, Model.CurrentPage - 1)

            #line default
            #line hidden
                                                                                                                         , 5399), false)
                                       );

                        WriteLiteral(">");


            #line 140 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                        Write(Html.Resource("Prev"));


            #line default
            #line hidden
                        WriteLiteral("</a>\n                    </li>\n");


            #line 142 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    }


            #line default
            #line hidden
                    WriteLiteral("                ");


            #line 143 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    if (Model.CurrentPage < @Model.TotalPagesCount)
                    {
            #line default
            #line hidden
                        WriteLiteral("                    <li");

                        WriteLiteral(" class=\"page-item\"");

                        WriteLiteral(">\n                        <a");

                        WriteLiteral(" class=\"page-link\"");

                        WriteAttribute("href", Tuple.Create(" href=\'", 5688), Tuple.Create("\'", 5765)

            #line 146 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                                       , Tuple.Create(Tuple.Create("", 5695), Tuple.Create <System.Object, System.Int32>(string.Format(ViewBag.RedirectPageUrlTemplate, Model.CurrentPage + 1)

            #line default
            #line hidden
                                                                                                                         , 5695), false)
                                       );

                        WriteLiteral(">");


            #line 146 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                        Write(Html.Resource("Next"));


            #line default
            #line hidden
                        WriteLiteral("</a>\n                    </li>\n");


            #line 148 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    }


            #line default
            #line hidden
                    WriteLiteral("            </ul>\n");


            #line 150 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                }
                else
                {
                    if (Model.CurrentPage == Model.TotalPagesCount)
                    {
            #line default
            #line hidden
                        WriteLiteral("                <em");

                        WriteLiteral(" class=\"text-muted\"");

                        WriteLiteral(">");


            #line 155 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                        Write((Model.ItemsPerPage * Model.TotalPagesCount) - Model.Results.TotalCount);


            #line default
            #line hidden
                        WriteLiteral(" of ");


            #line 155 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                        Write(Model.Results.TotalCount);


            #line default
            #line hidden
                        WriteLiteral(" results</em>\n");


            #line 156 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    }
                    else
                    {
            #line default
            #line hidden
                        WriteLiteral("                <em");

                        WriteLiteral(" class=\"text-muted\"");

                        WriteLiteral(">");


            #line 159 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                        Write(Model.ItemsPerPage);


            #line default
            #line hidden
                        WriteLiteral(" of ");


            #line 159 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                        Write(Model.Results.TotalCount);


            #line default
            #line hidden
                        WriteLiteral(" results</em>\n");


            #line 160 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    }



            #line default
            #line hidden
                    WriteLiteral("            <div>\n");

                    WriteLiteral("                ");


            #line 163 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                    Write(Html.Action("Index", "ContentPager", new
                    {
                        currentPage         = Model.CurrentPage,
                        totalPagesCount     = Model.TotalPagesCount,
                        redirectUrlTemplate = ViewBag.RedirectPageUrlTemplate
                    }));


            #line default
            #line hidden
                    WriteLiteral("\n            </div>\n");


            #line 170 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                }
            }


            #line default
            #line hidden
            WriteLiteral("\n    <input");

            WriteLiteral(" type=\"hidden\"");

            WriteLiteral(" data-sf-role=\"searchResOrderBy\"");

            WriteAttribute("value", Tuple.Create(" value=\'", 6674), Tuple.Create("\'", 6713)

            #line 173 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                           , Tuple.Create(Tuple.Create("", 6682), Tuple.Create <System.Object, System.Int32>(Request.QueryString["orderBy"]

            #line default
            #line hidden
                                                                                                             , 6682), false)
                           );

            WriteLiteral(" />\n    <input");

            WriteLiteral(" type=\"hidden\"");

            WriteLiteral(" data-sf-role=\"searchResLanguage\"");

            WriteAttribute("value", Tuple.Create(" value=\'", 6775), Tuple.Create("\'", 6815)

            #line 174 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                           , Tuple.Create(Tuple.Create("", 6783), Tuple.Create <System.Object, System.Int32>(Request.QueryString["language"]

            #line default
            #line hidden
                                                                                                             , 6783), false)
                           );

            WriteLiteral(" />\n    <input");

            WriteLiteral(" type=\"hidden\"");

            WriteLiteral(" data-sf-role=\"searchResIndexCatalogue\"");

            WriteAttribute("value", Tuple.Create(" value=\'", 6883), Tuple.Create("\'", 6929)

            #line 175 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                           , Tuple.Create(Tuple.Create("", 6891), Tuple.Create <System.Object, System.Int32>(Request.QueryString["indexCatalogue"]

            #line default
            #line hidden
                                                                                                             , 6891), false)
                           );

            WriteLiteral(" />\n    <input");

            WriteLiteral(" type=\"hidden\"");

            WriteLiteral(" data-sf-role=\"searchResQuery\"");

            WriteAttribute("value", Tuple.Create(" value=\'", 6988), Tuple.Create("\'", 7031)

            #line 176 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                           , Tuple.Create(Tuple.Create("", 6996), Tuple.Create <System.Object, System.Int32>(Request.QueryString["searchQuery"]

            #line default
            #line hidden
                                                                                                             , 6996), false)
                           );

            WriteLiteral(" />\n    <input");

            WriteLiteral(" type=\"hidden\"");

            WriteLiteral(" data-sf-role=\"searchResWordsMode\"");

            WriteAttribute("value", Tuple.Create(" value=\'", 7094), Tuple.Create("\'", 7135)

            #line 177 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
                           , Tuple.Create(Tuple.Create("", 7102), Tuple.Create <System.Object, System.Int32>(Request.QueryString["wordsMode"]

            #line default
            #line hidden
                                                                                                             , 7102), false)
                           );

            WriteLiteral(" />\n        \n</div>\n\n");


            #line 181 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
            Write(Html.Script(ScriptRef.JQuery, "top", true));


            #line default
            #line hidden
            WriteLiteral("\n");


            #line 182 "..\..\ResourcePackages\Bootstrap4\MVC\Views\SearchResults\SearchResults.cshtml"
            Write(Html.Script(Url.WidgetContent("Mvc/Scripts/SearchResults/Search-results.js"), "bottom", true));


            #line default
            #line hidden
        }
        /// <summary>
        /// Get the Library of a given Folder
        /// </summary>
        /// <param name="manager">Library Manager</param>
        /// <param name="folder">The folder</param>
        /// <returns>The Library containing the folder</returns>
        private Library GetLibraryByFolder(LibrariesManager manager, IFolder folder)
        {
            while (!(folder is Library))
            {
                folder = manager.GetFolder(folder.ParentId);
            }

            var folderToBeCast = folder;

            return folderToBeCast as Library;
        }
        public void CreateHotel()
        {
            DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
            Type           hotelType = TypeResolutionService.ResolveType(HierarchicalDynamicContentTests.HotelType);
            DynamicContent hotelItem = dynamicModuleManager.CreateDataItem(hotelType, HierarchicalDynamicContentTests.HotelId, dynamicModuleManager.Provider.ApplicationName);

            hotelItem.SetValue("Name", "Test Name");
            hotelItem.SetValue("Overview", "Test Overview");
            hotelItem.SetValue("Checkin", "Test Checkin");
            hotelItem.SetValue("Checkout", "Test Checkout");
            hotelItem.SetValue("FoodAndDrink", new string[] { "Option2" });
            hotelItem.SetValue("Activities", new string[] { "Option2" });
            hotelItem.SetValue("Rating", 25);

            TaxonomyManager taxonomyManager = TaxonomyManager.GetManager();
            var             Tag             = taxonomyManager.GetTaxa <FlatTaxon>().Where(t => t.Taxonomy.Name == "Tags").FirstOrDefault();

            if (Tag != null)
            {
                hotelItem.Organizer.AddTaxa("Tags", Tag.Id);
            }

            Address        location        = new Address();
            CountryElement locationCountry = Config.Get <LocationsConfig>().Countries.Values.First(x => x.Name == "United States");

            location.CountryCode  = locationCountry.IsoCode;
            location.StateCode    = locationCountry.StatesProvinces.Values.First().Abbreviation;
            location.City         = "Test City";
            location.Street       = "Test Street";
            location.Zip          = "12345";
            location.Latitude     = 0.00;
            location.Longitude    = 0.00;
            location.MapZoomLevel = 8;
            hotelItem.SetValue("Location", location);

            LibrariesManager mainPictureManager = LibrariesManager.GetManager();
            var mainPictureItem = mainPictureManager.GetImages().FirstOrDefault(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master);

            if (mainPictureItem != null)
            {
                hotelItem.CreateRelation(mainPictureItem, "MainPicture");
            }

            hotelItem.SetString("UrlName", "TestUrlName");
            hotelItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
            hotelItem.SetValue("PublicationDate", DateTime.Now);

            hotelItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Draft");

            dynamicModuleManager.SaveChanges();

            var actualHotel = dynamicModuleManager.GetDataItem(hotelType, hotelItem.Id);

            Assert.IsNotNull(actualHotel);
            Assert.AreEqual(hotelItem.GetValue("Name").ToString(), actualHotel.GetValue("Name").ToString());
            Assert.AreEqual(hotelItem.GetValue("Overview").ToString(), actualHotel.GetValue("Overview").ToString());
            Assert.AreEqual(hotelItem.GetValue("Checkin").ToString(), actualHotel.GetValue("Checkin").ToString());
            Assert.AreEqual(hotelItem.GetValue("Checkout").ToString(), actualHotel.GetValue("Checkout").ToString());
            Assert.AreEqual(hotelItem.GetValue("FoodAndDrink").ToString(), actualHotel.GetValue("FoodAndDrink").ToString());
            Assert.AreEqual(hotelItem.GetValue("Activities").ToString(), actualHotel.GetValue("Activities").ToString());
            Assert.AreEqual(hotelItem.GetValue("Rating"), actualHotel.GetValue("Rating"));
            Assert.AreEqual(hotelItem.GetValue("MainPicture"), actualHotel.GetValue("MainPicture"));
            Assert.AreEqual(hotelItem.GetValue("Location"), actualHotel.GetValue("Location"));
            Assert.AreEqual(hotelItem.GetValue("UrlName").ToString(), actualHotel.GetValue("UrlName").ToString());
            Assert.AreEqual(hotelItem.GetValue("Owner"), actualHotel.GetValue("Owner"));
            Assert.AreEqual(hotelItem.GetValue("PublicationDate"), actualHotel.GetValue("PublicationDate"));
        }
Beispiel #13
0
        private void RepublishLibrariesAndFolders(IEnumerable <string> providers)
        {
            foreach (var provider in providers)
            {
                var librariesManager = LibrariesManager.GetManager(provider);
                librariesManager.Provider.SuppressSecurityChecks = false;
                var documentLibraries = librariesManager.GetDocumentLibraries().ToList();
                var count             = 0;

                foreach (var documentLibrary in documentLibraries)
                {
                    documentLibrary.Title = documentLibrary.Title.Trim();
                    var folders = librariesManager.GetAllFolders(documentLibrary);

                    foreach (var folder in folders)
                    {
                        folder.Title = folder.Title.Trim();
                    }

                    count++;
                    if (count % 200 == 0)
                    {
                        librariesManager.SaveChanges();
                    }
                }

                var imageLibraries = librariesManager.GetAlbums().ToList();
                foreach (var imageLibrary in imageLibraries)
                {
                    imageLibrary.Title = imageLibrary.Title.Trim();

                    var folders = librariesManager.GetAllFolders(imageLibrary);

                    foreach (var folder in folders)
                    {
                        folder.Title = folder.Title.Trim();
                    }

                    count++;
                    if (count % 200 == 0)
                    {
                        librariesManager.SaveChanges();
                    }
                }

                var videoLibraries = librariesManager.GetVideoLibraries().ToList();
                foreach (var videoLibrary in videoLibraries)
                {
                    videoLibrary.Title = videoLibrary.Title.Trim();

                    var folders = librariesManager.GetAllFolders(videoLibrary);

                    foreach (var folder in folders)
                    {
                        folder.Title = folder.Title.Trim();
                    }

                    count++;
                    if (count % 200 == 0)
                    {
                        librariesManager.SaveChanges();
                    }
                }
            }
        }
        protected void CreateNewAlbum(out Album album, string AlbumTitle, LibrariesManager librariesManager)
        {
            album = librariesManager.CreateAlbum(Guid.NewGuid());

            //Set the properties of the album.
            album.Title = AlbumTitle;
            album.DateCreated = DateTime.UtcNow;
            album.LastModified = DateTime.UtcNow;
            album.UrlName = Regex.Replace(AlbumTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");

            //Save the changes.
            librariesManager.SaveChanges();
        }
        private Image UploadImage(LibrariesManager manager, string iTitle, string iUrlName, string iDescription, long iTotalSize, Guid iOwner, Album album)
        {
            var mediaItem = manager.CreateImage(ProductsIntegrationTests.imageId);
            mediaItem.Title = iTitle;
            mediaItem.UrlName = iUrlName;
            mediaItem.Description = iDescription;
            mediaItem.Parent = album;
            manager.RecompileItemUrls<Image>(mediaItem);

            UploadImageFile(manager, mediaItem);
            iTotalSize = mediaItem.TotalSize;
            iOwner = mediaItem.Owner;

            manager.SaveChanges();

            return mediaItem;
        }
        /// <summary>
        /// Tries to resolve parent filter mode.
        /// </summary>
        /// <param name="urlParams">The URL params.</param>
        /// <param name="requestContext">The request context.</param>
        /// <param name="manager">The LibrariesManager.</param>
        /// <returns></returns>
        protected virtual bool TryResolveParentFilterMode(string[] urlParams, RequestContext requestContext, LibrariesManager manager = null)
        {
            var libraryManager = manager ?? LibrariesManager.GetManager(this.Model.ProviderName);

            string param = RouteHelper.GetUrlParameterString(urlParams);

            string redirectUrl;

            var item = libraryManager.GetItemFromUrl(typeof(VideoLibrary), param, out redirectUrl);

            if (item != null)
            {
                requestContext.RouteData.Values["action"] = "Successors";
                requestContext.RouteData.Values["parentItem"] = item;

                if (this.Request["page"] != null)
                    requestContext.RouteData.Values["page"] = int.Parse(this.Request["page"]);

                return true;
            }
            if (urlParams.Length > 1)
            {
                this.TryResolveParentFilterMode(urlParams.Take(urlParams.Length - 1).ToArray(), requestContext, manager);
            }
            return false;
        }
Beispiel #17
0
        private Guid CreateImageNativeAPI(string imageTitle, Stream imageStream, string imageExtension, LibrariesManager librariesManager)
        {
            Album album = librariesManager.GetAlbums().Where(al => al.Title == "Facebook Users").FirstOrDefault();

            if (album == null)
            {
                Guid albumId = Guid.NewGuid();

                album = librariesManager.GetAlbums().Where(a => a.Id == albumId).FirstOrDefault();

                if (album == null)
                {
                    //Create the album.
                    album = librariesManager.CreateAlbum(albumId);

                    //Set the properties of the album.
                    album.Title        = "Facebook Users";
                    album.DateCreated  = DateTime.UtcNow;
                    album.LastModified = DateTime.UtcNow;
                    album.UrlName      = Regex.Replace("Facebook Users".ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");

                    //Save the changes.
                    librariesManager.SaveChanges();
                }

                album = librariesManager.GetAlbum(albumId);
            }

            //The album post is created as master. The masterImageId is assigned to the master version.
            Image image = librariesManager.CreateImage();


            librariesManager.SaveChanges();
            librariesManager.Provider.SuppressSecurityChecks = true;
            //Set the parent album.



            //Set the properties of the profile image
            image.Title           = imageTitle;
            image.DateCreated     = DateTime.UtcNow;
            image.PublicationDate = DateTime.UtcNow;
            image.LastModified    = DateTime.UtcNow;
            image.UrlName         = Regex.Replace(imageTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");

            librariesManager.Provider.SuppressSecurityChecks = true;
            image.Parent = album;

            //Upload the image file.
            librariesManager.Upload(image, imageStream, imageExtension);

            //Save the changes.
            librariesManager.SaveChanges();

            //Publish the Albums item. The live version acquires new ID.
            var bag = new Dictionary <string, string>();

            bag.Add("ContentType", typeof(Image).FullName);
            WorkflowManager.MessageWorkflow(image.Id, typeof(Image), null, "Publish", false, bag);

            return(image.Id);
        }