private void LoadForm() {
			GalleryHelper gh = new GalleryHelper(SiteID);
			var meta = gh.GalleryMetaDataGetByFilename(sImageFile);

			if (meta != null) {
				txtMetaInfo.Text = meta.ImageMetaData;
				txtTitle.Text = meta.ImageTitle;
			}
		}
        private void LoadForm()
        {
            GalleryHelper gh   = new GalleryHelper(SiteID);
            var           meta = gh.GalleryMetaDataGetByFilename(sImageFile);

            if (meta != null)
            {
                txtMetaInfo.Text = meta.ImageMetaData;
                txtTitle.Text    = meta.ImageTitle;
            }
        }
		protected void btnSave_Click(object sender, EventArgs e) {

			GalleryHelper gh = new GalleryHelper(SiteID);
			var meta = gh.GalleryMetaDataGetByFilename(sImageFile);

			if (meta == null) {
				meta = new GalleryMetaData();
				meta.GalleryImageMetaID = Guid.Empty;
				meta.SiteID = SiteID;
				meta.GalleryImage = sImageFile.ToLower();
			}

			meta.ImageMetaData = txtMetaInfo.Text;
			meta.ImageTitle = txtTitle.Text;

			meta.Save();

			Response.Redirect(SiteData.CurrentScriptName + "?" + Request.QueryString.ToString());
		}
        protected void btnSave_Click(object sender, EventArgs e)
        {
            GalleryHelper gh   = new GalleryHelper(SiteID);
            var           meta = gh.GalleryMetaDataGetByFilename(sImageFile);

            if (meta == null)
            {
                meta = new GalleryMetaData();
                meta.GalleryImageMetaID = Guid.Empty;
                meta.SiteID             = SiteID;
                meta.GalleryImage       = sImageFile.ToLower();
            }

            meta.ImageMetaData = txtMetaInfo.Text;
            meta.ImageTitle    = txtTitle.Text;

            meta.Save();

            Response.Redirect(SiteData.CurrentScriptName + "?" + Request.QueryString.ToString());
        }
        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();
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
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();
                        }
                    }
                }
            }
        }