protected void btnSave_Click(object sender, EventArgs e)
        {
            GalleryHelper gh = new GalleryHelper(SiteID);

            Dictionary<int, string> lstImages = ParseGalleryImages();
            int iPos = 0;

            foreach (var img in lstImages) {
                if (!String.IsNullOrEmpty(img.Value)) {
                    var theImg = gh.GalleryImageEntryGetByFilename(gTheID, img.Value);

                    if (theImg == null) {
                        theImg = new GalleryImageEntry();
                        theImg.GalleryImage = img.Value;
                        theImg.GalleryImageID = Guid.NewGuid();
                        theImg.GalleryID = gTheID;
                    }

                    theImg.ImageOrder = iPos;

                    theImg.Save();
                }

                iPos++;

                List<string> lst = (from l in lstImages
                                    select l.Value.ToLower()).ToList();

                gh.GalleryImageCleanup(gTheID, lst);
            }

            var stringFile = CreateLink(ModuleName, string.Format("id={0}", gTheID));

            Response.Redirect(stringFile);
        }
예제 #2
0
        public GalleryImageEntry GalleryImageEntryGetByID(Guid galleryImageID)
        {
            using (PhotoGalleryDataContext db = PhotoGalleryDataContext.GetDataContext()) {
                GalleryImageEntry ge = (from c in db.tblGalleryImages
                                        where c.GalleryImageID == galleryImageID
                                        select new GalleryImageEntry(c)).FirstOrDefault();

                return(ge);
            }
        }
예제 #3
0
        public GalleryImageEntry GalleryImageEntryGetByFilename(Guid galleryID, string galleryImage)
        {
            using (PhotoGalleryDataContext db = PhotoGalleryDataContext.GetDataContext()) {
                GalleryImageEntry ge = (from c in db.tblGalleryImages
                                        where c.GalleryID == galleryID &&
                                        c.GalleryImage.ToLower() == galleryImage.ToLower()
                                        orderby c.ImageOrder ascending
                                        select new GalleryImageEntry(c)).FirstOrDefault();

                return(ge);
            }
        }
        protected void BuildInstallList()
        {
            pnlReview.Visible = true;
            SiteData site = SiteData.CurrentSite;

            GalleryHelper gh = new GalleryHelper(SiteID);

            foreach (GridViewRow row in gvPages.Rows)
            {
                Guid gGallery = Guid.Empty;

                CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect");

                if (chkSelect.Checked)
                {
                    HiddenField hdnGalleryID = (HiddenField)row.FindControl("hdnGalleryID");

                    gGallery = new Guid(hdnGalleryID.Value);

                    GalleryGroup grpImp = (from g in lstGalleries.TheGalleries
                                           where g.TheGallery.GalleryID == gGallery
                                           select g.TheGallery).FirstOrDefault();

                    GalleryGroup grpSite = gh.GalleryGroupGetByName(grpImp.GalleryTitle);

                    if (grpSite == null)
                    {
                        grpSite        = grpImp;
                        grpSite.SiteID = site.SiteID;
                    }
                    grpSite.Save();

                    grpImp.GalleryImages.ForEach(q => q.GalleryImageID = Guid.NewGuid());
                    grpImp.GalleryImages.ForEach(q => q.GalleryID      = grpSite.GalleryID);

                    foreach (GalleryImageEntry imgImp in grpImp.GalleryImages)
                    {
                        GalleryImageEntry imgSite = gh.GalleryImageEntryGetByFilename(grpSite.GalleryID, imgImp.GalleryImage);

                        if (imgSite == null)
                        {
                            imgSite           = imgImp;
                            imgSite.GalleryID = grpSite.GalleryID;
                        }
                        imgSite.Save();
                    }
                }
            }
        }
예제 #5
0
 public override bool Equals(Object obj)
 {
     //Check for null and compare run-time types.
     if (obj == null || GetType() != obj.GetType())
     {
         return(false);
     }
     if (obj is GalleryImageEntry)
     {
         GalleryImageEntry p = (GalleryImageEntry)obj;
         return((this.GalleryImageID == p.GalleryImageID) &&
                (this.GalleryID == p.GalleryID) &&
                (this.GalleryImage == p.GalleryImage));
     }
     else
     {
         return(false);
     }
 }
예제 #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            GalleryHelper gh = new GalleryHelper(SiteID);

            Dictionary <int, string> lstImages = ParseGalleryImages();
            int iPos = 0;

            foreach (var img in lstImages)
            {
                if (!String.IsNullOrEmpty(img.Value))
                {
                    var theImg = gh.GalleryImageEntryGetByFilename(gTheID, img.Value);

                    if (theImg == null)
                    {
                        theImg = new GalleryImageEntry();
                        theImg.GalleryImage   = img.Value;
                        theImg.GalleryImageID = Guid.NewGuid();
                        theImg.GalleryID      = gTheID;
                    }

                    theImg.ImageOrder = iPos;

                    theImg.Save();
                }

                iPos++;

                List <string> lst = (from l in lstImages
                                     select l.Value.ToLower()).ToList();

                gh.GalleryImageCleanup(gTheID, lst);
            }

            var stringFile = CreateLink(ModuleName, string.Format("id={0}", gTheID));

            Response.Redirect(stringFile);
        }
        protected void BuildWidgetInstall()
        {
            pnlReview.Visible = true;

            SiteData site = SiteData.CurrentSite;

            CMSAdminModuleMenu thisModule = cmsHelper.GetCurrentAdminModuleControl();
            string sDir = thisModule.ControlFile.Substring(0, thisModule.ControlFile.LastIndexOf("/"));
            List<CMSPlugin> lstPlug = cmsHelper.GetPluginsInFolder(sDir);

            CMSPlugin plug = lstPlug.Where(x => x.FilePath.EndsWith("PhotoGalleryPrettyPhoto.ascx")).FirstOrDefault();

            GalleryHelper gh = new GalleryHelper(site.SiteID);

            foreach (GridViewRow row in gvPages.Rows) {
                Guid gRootPage = Guid.Empty;
                Guid gGallery = Guid.Empty;
                int iPost = 0;

                CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect");

                if (chkSelect.Checked) {
                    HiddenField hdnPostID = (HiddenField)row.FindControl("hdnPostID");

                    iPost = int.Parse(hdnPostID.Value);

                    List<WordPressPost> lstA = (from a in wpSite.Content
                                                where a.PostType == WordPressPost.WPPostType.Attachment
                                                && a.ParentPostID == iPost
                                                orderby a.PostDateUTC
                                                select a).Distinct().ToList();

                    lstA.ToList().ForEach(q => q.ImportFileSlug = ddlFolders.SelectedValue + "/" + q.ImportFileSlug);
                    lstA.ToList().ForEach(q => q.ImportFileSlug = q.ImportFileSlug.Replace("//", "/").Replace("//", "/"));

                    WordPressPost post = (from p in wpSite.Content
                                          where p.PostID == iPost
                                          select p).FirstOrDefault();

                    ContentPage cp = null;

                    List<ContentPage> lstCP = pageHelper.FindPageByTitleAndDate(site.SiteID, post.PostTitle, post.PostName, post.PostDateUTC);

                    if (lstCP != null && lstCP.Any()) {
                        cp = lstCP.FirstOrDefault();
                    }

                    if (cp != null) {
                        gRootPage = cp.Root_ContentID;
                        if (cp.PageText.Contains("[gallery]")) {
                            cp.PageText = cp.PageText.Replace("[gallery]", "");
                            cp.SavePageEdit();
                        }
                    }

                    GalleryGroup gal = gh.GalleryGroupGetByName(post.PostTitle);

                    if (gal == null) {
                        gal = new GalleryGroup();
                        gal.SiteID = site.SiteID;
                        gal.GalleryID = Guid.Empty;
                        gal.GalleryTitle = post.PostTitle;

                        gal.Save();
                    }

                    gGallery = gal.GalleryID;

                    int iPos = 0;

                    foreach (var img in lstA) {
                        img.ImportFileSlug = img.ImportFileSlug.Replace("//", "/").Replace("//", "/");

                        if (!chkFileGrab.Checked) {
                            cmsHelper.GetFile(img.AttachmentURL, img.ImportFileSlug);
                        }

                        if (!string.IsNullOrEmpty(img.ImportFileSlug)) {
                            GalleryImageEntry theImg = gh.GalleryImageEntryGetByFilename(gGallery, img.ImportFileSlug);

                            if (theImg == null) {
                                theImg = new GalleryImageEntry();
                                theImg.GalleryImage = img.ImportFileSlug;
                                theImg.GalleryImageID = Guid.Empty;
                                theImg.GalleryID = gGallery;
                            }
                            theImg.ImageOrder = iPos;
                            theImg.Save();

                            GalleryMetaData theMeta = gh.GalleryMetaDataGetByFilename(img.ImportFileSlug);

                            if (theMeta == null) {
                                theMeta = new GalleryMetaData();
                                theMeta.GalleryImageMetaID = Guid.Empty;
                                theMeta.SiteID = site.SiteID;
                            }

                            if (!string.IsNullOrEmpty(img.PostTitle) || !string.IsNullOrEmpty(img.PostContent)) {
                                theMeta.ImageTitle = img.PostTitle;
                                theMeta.ImageMetaData = img.PostContent;

                                theMeta.Save();
                            }
                        }
                        iPos++;
                    }

                    if (gRootPage != Guid.Empty) {
                        List<Widget> lstW = (from w in cp.GetWidgetList()
                                             where w.ControlPath.ToLower() == plug.FilePath.ToLower()
                                                && w.ControlProperties.ToLower().Contains(gGallery.ToString().ToLower())
                                             select w).ToList();

                        if (lstW.Count < 1) {
                            Widget newWidget = new Widget();
                            newWidget.ControlProperties = null;
                            newWidget.Root_ContentID = gRootPage;
                            newWidget.Root_WidgetID = Guid.NewGuid();
                            newWidget.WidgetDataID = newWidget.Root_WidgetID;
                            newWidget.ControlPath = plug.FilePath;
                            newWidget.EditDate = SiteData.CurrentSite.Now;

                            newWidget.IsLatestVersion = true;
                            newWidget.IsWidgetActive = true;
                            newWidget.IsWidgetPendingDelete = false;
                            newWidget.WidgetOrder = -1;
                            newWidget.PlaceholderName = txtPlaceholderName.Text;

                            List<WidgetProps> lstProps = new List<WidgetProps>();
                            lstProps.Add(new WidgetProps { KeyName = "ShowHeading", KeyValue = chkShowHeading.Checked.ToString() });
                            lstProps.Add(new WidgetProps { KeyName = "ScaleImage", KeyValue = chkScaleImage.Checked.ToString() });
                            lstProps.Add(new WidgetProps { KeyName = "ThumbSize", KeyValue = ddlSize.SelectedValue });
                            lstProps.Add(new WidgetProps { KeyName = "PrettyPhotoSkin", KeyValue = ddlSkin.SelectedValue });
                            lstProps.Add(new WidgetProps { KeyName = "GalleryID", KeyValue = gGallery.ToString() });

                            newWidget.SaveDefaultControlProperties(lstProps);

                            newWidget.Save();
                        }
                    }
                }
            }
        }
예제 #8
0
        protected void BuildWidgetInstall()
        {
            pnlReview.Visible = true;

            SiteData site = SiteData.CurrentSite;

            CMSAdminModuleMenu thisModule = cmsHelper.GetCurrentAdminModuleControl();
            string             sDir       = thisModule.ControlFile.Substring(0, thisModule.ControlFile.LastIndexOf("/"));
            List <CMSPlugin>   lstPlug    = cmsHelper.GetPluginsInFolder(sDir);

            CMSPlugin plug = lstPlug.Where(x => x.FilePath.EndsWith("PhotoGalleryPrettyPhoto.ascx")).FirstOrDefault();

            GalleryHelper gh = new GalleryHelper(site.SiteID);

            foreach (GridViewRow row in gvPages.Rows)
            {
                Guid gRootPage = Guid.Empty;
                Guid gGallery  = Guid.Empty;
                int  iPost     = 0;

                CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect");

                if (chkSelect.Checked)
                {
                    HiddenField hdnPostID = (HiddenField)row.FindControl("hdnPostID");

                    iPost = int.Parse(hdnPostID.Value);

                    List <WordPressPost> lstA = (from a in wpSite.Content
                                                 where a.PostType == WordPressPost.WPPostType.Attachment &&
                                                 a.ParentPostID == iPost
                                                 orderby a.PostDateUTC
                                                 select a).Distinct().ToList();

                    lstA.ToList().ForEach(q => q.ImportFileSlug = ddlFolders.SelectedValue + "/" + q.ImportFileSlug);
                    lstA.ToList().ForEach(q => q.ImportFileSlug = q.ImportFileSlug.Replace("//", "/").Replace("//", "/"));

                    WordPressPost post = (from p in wpSite.Content
                                          where p.PostID == iPost
                                          select p).FirstOrDefault();

                    ContentPage cp = null;

                    List <ContentPage> lstCP = pageHelper.FindPageByTitleAndDate(site.SiteID, post.PostTitle, post.PostName, post.PostDateUTC);

                    if (lstCP != null && lstCP.Any())
                    {
                        cp = lstCP.FirstOrDefault();
                    }

                    if (cp != null)
                    {
                        gRootPage = cp.Root_ContentID;
                        if (cp.PageText.Contains("[gallery]"))
                        {
                            cp.PageText = cp.PageText.Replace("[gallery]", "");
                            cp.SavePageEdit();
                        }
                    }

                    GalleryGroup gal = gh.GalleryGroupGetByName(post.PostTitle);

                    if (gal == null)
                    {
                        gal              = new GalleryGroup();
                        gal.SiteID       = site.SiteID;
                        gal.GalleryID    = Guid.Empty;
                        gal.GalleryTitle = post.PostTitle;

                        gal.Save();
                    }

                    gGallery = gal.GalleryID;

                    int iPos = 0;

                    foreach (var img in lstA)
                    {
                        img.ImportFileSlug = img.ImportFileSlug.Replace("//", "/").Replace("//", "/");

                        if (!chkFileGrab.Checked)
                        {
                            cmsHelper.GetFile(img.AttachmentURL, img.ImportFileSlug);
                        }

                        if (!string.IsNullOrEmpty(img.ImportFileSlug))
                        {
                            GalleryImageEntry theImg = gh.GalleryImageEntryGetByFilename(gGallery, img.ImportFileSlug);

                            if (theImg == null)
                            {
                                theImg = new GalleryImageEntry();
                                theImg.GalleryImage   = img.ImportFileSlug;
                                theImg.GalleryImageID = Guid.Empty;
                                theImg.GalleryID      = gGallery;
                            }
                            theImg.ImageOrder = iPos;
                            theImg.Save();

                            GalleryMetaData theMeta = gh.GalleryMetaDataGetByFilename(img.ImportFileSlug);

                            if (theMeta == null)
                            {
                                theMeta = new GalleryMetaData();
                                theMeta.GalleryImageMetaID = Guid.Empty;
                                theMeta.SiteID             = site.SiteID;
                            }

                            if (!string.IsNullOrEmpty(img.PostTitle) || !string.IsNullOrEmpty(img.PostContent))
                            {
                                theMeta.ImageTitle    = img.PostTitle;
                                theMeta.ImageMetaData = img.PostContent;

                                theMeta.Save();
                            }
                        }
                        iPos++;
                    }

                    if (gRootPage != Guid.Empty)
                    {
                        List <Widget> lstW = (from w in cp.GetWidgetList()
                                              where w.ControlPath.ToLower() == plug.FilePath.ToLower() &&
                                              w.ControlProperties.ToLower().Contains(gGallery.ToString().ToLower())
                                              select w).ToList();

                        if (lstW.Count < 1)
                        {
                            Widget newWidget = new Widget();
                            newWidget.ControlProperties = null;
                            newWidget.Root_ContentID    = gRootPage;
                            newWidget.Root_WidgetID     = Guid.NewGuid();
                            newWidget.WidgetDataID      = newWidget.Root_WidgetID;
                            newWidget.ControlPath       = plug.FilePath;
                            newWidget.EditDate          = SiteData.CurrentSite.Now;

                            newWidget.IsLatestVersion       = true;
                            newWidget.IsWidgetActive        = true;
                            newWidget.IsWidgetPendingDelete = false;
                            newWidget.WidgetOrder           = -1;
                            newWidget.PlaceholderName       = txtPlaceholderName.Text;

                            List <WidgetProps> lstProps = new List <WidgetProps>();
                            lstProps.Add(new WidgetProps {
                                KeyName = "ShowHeading", KeyValue = chkShowHeading.Checked.ToString()
                            });
                            lstProps.Add(new WidgetProps {
                                KeyName = "ScaleImage", KeyValue = chkScaleImage.Checked.ToString()
                            });
                            lstProps.Add(new WidgetProps {
                                KeyName = "ThumbSize", KeyValue = ddlSize.SelectedValue
                            });
                            lstProps.Add(new WidgetProps {
                                KeyName = "PrettyPhotoSkin", KeyValue = ddlSkin.SelectedValue
                            });
                            lstProps.Add(new WidgetProps {
                                KeyName = "GalleryID", KeyValue = gGallery.ToString()
                            });

                            newWidget.SaveDefaultControlProperties(lstProps);

                            newWidget.Save();
                        }
                    }
                }
            }
        }