Beispiel #1
0
        public ActionResult Flickr()
        {
            ViewBag.Albums          = UnigateObject.Query(Manager.Settings.Current.AlbumListTableName).Where("SiteLanguageId", MCMS.Common.SettingContext.Current.DefaultSiteLanguageId).SortAsc("Title").ToList <Models.BaseModel>();
            ViewBag.SelectedAlbumId = string.Empty;

            return(View(this.GetPhotosFromFlickr()));
        }
Beispiel #2
0
        public static Field SaveField(Field field)
        {
            MDataSourceResult result;
            var _field = UnigateObject.Query("Editable")
                         .WhereEqualTo("FieldKey", field.FieldKey)
                         .WhereEqualTo("SiteLanguageId", field.SiteLanguageId)
                         .WhereEqualTo("PageId", field.PageId)
                         .ToList <Field>()
                         .FirstOrDefault();

            if (_field == null)
            {
                result = UnigateObject.Insert <Field>("Editable", field)
                         .Column("SiteLanguageId", field.SiteLanguageId)
                         .Execute();
                _field = field;
            }
            else
            {
                result = UnigateObject.Update("Editable")
                         .Column("Value", field.Value ?? "&nbsp;")
                         .WhereEqualTo("ContentId", _field.ContentId)
                         .Execute();
                _field.Value = field.Value;
            }
            if (result.ResultCode != ResultCode.Successfull)
            {
                _field.Errors = result.ResultMessage;
            }
            return(_field);
        }
Beispiel #3
0
        List <Models.PhotoViewModel> GetPhotosByAlbumId(Guid albumId)
        {
            Query query = UnigateObject.Query(Manager.Settings.Current.PhotoListTableName)
                          .Where(Manager.Settings.Current.PhotoListTableAlbumRelationField.Name, albumId.ToString());

            if (Manager.Settings.Current.PhotoListTableOrderNoField != null && !string.IsNullOrEmpty(Manager.Settings.Current.PhotoListTableOrderNoField.Name))
            {
                query = query.SortAsc(Manager.Settings.Current.PhotoListTableOrderNoField.Name);
            }
            else
            {
                query = query.SortDesc("CreateDate");
            }

            DataTable photos = query.ToDataTable();

            List <Models.PhotoViewModel> retVal = null;

            if (photos != null && photos.Rows.Count > 0)
            {
                retVal = photos.AsEnumerable().Select(p => new Models.PhotoViewModel()
                {
                    ContentId      = p.Field <Guid>("ContentId"),
                    Id             = p.Field <int>("Id"),
                    Photo          = p.Field <string>(Manager.Settings.Current.PhotoListTablePhotoField.Name),
                    SiteLanguageId = p.Field <Guid>("SiteLanguageId"),
                    Slug           = p.Field <string>("Slug"),
                    Title          = (Manager.Settings.Current.PhotoListTableTitleField != null && !string.IsNullOrEmpty(Manager.Settings.Current.PhotoListTableTitleField.Name) && !p.IsNull(Manager.Settings.Current.PhotoListTableTitleField.Name)) ? p.Field <string>(Manager.Settings.Current.PhotoListTableTitleField.Name) : string.Empty,
                    OrderNo        = (Manager.Settings.Current.PhotoListTableOrderNoField != null && !string.IsNullOrEmpty(Manager.Settings.Current.PhotoListTableOrderNoField.Name) && !p.IsNull(Manager.Settings.Current.PhotoListTableOrderNoField.Name)) ? p.Field <int>(Manager.Settings.Current.PhotoListTableOrderNoField.Name) : 0
                }).ToList();
            }

            return(retVal);
        }
Beispiel #4
0
        public UserModel GetUserByContentId(Guid contentId)
        {
            var user = UnigateObject.Query("ayMembers")
                       .Where("ContentId", contentId)
                       .ToList <UserModel>()
                       .FirstOrDefault();

            return(user);
        }
Beispiel #5
0
        public UserModel GetUserByMail(string mailAddress)
        {
            var user = UnigateObject.Query("ayMembers")
                       .Where("Email", mailAddress)
                       .ToList <UserModel>()
                       .FirstOrDefault();

            return(user);
        }
        public ActionResult SiteRedirects_Read([DataSourceRequest] DataSourceRequest request)
        {
            var model = UnigateObject.Query("SiteRedirect").Join("Page", "Page.Id=SiteRedirect.PageId").ToList <SiteRedirectModel>();

            var result = new DataSourceResult
            {
                Data  = model,
                Total = model.Count
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult New()
        {
            var sites = UnigateObject.Query("Page")
                        .WhereEqualTo("Page.ParentPageId", null)
                        .ToList <PageViewModel>();

            ViewData["Sites"] = sites.Select(x => new SelectListItem
            {
                Text  = x.Title,
                Value = x.Id.ToString()
            });

            return(View(new SiteRedirectModel()));
        }
Beispiel #8
0
        public ActionResult Index(Guid?albumId)
        {
            ViewBag.Albums          = UnigateObject.Query(Manager.Settings.Current.AlbumListTableName).Where("SiteLanguageId", MCMS.Common.SettingContext.Current.DefaultSiteLanguageId).SortAsc("Title").ToList <Models.BaseModel>();
            ViewBag.SelectedAlbumId = string.Empty;

            List <Models.PhotoViewModel> viewModel = null;

            if (albumId.HasValue && albumId.Value != Guid.Empty)
            {
                ViewBag.SelectedAlbumId = albumId.ToString();

                viewModel = this.GetPhotosByAlbumId(albumId.Value);
            }

            return(View(viewModel));
        }
Beispiel #9
0
        public static Field GetField(string fieldName, Guid siteLanguageId, int pageId, string fieldType = "text", bool pageBased = true)
        {
            Query query = UnigateObject.Query("Editable")
                          .WhereEqualTo("FieldKey", fieldName)
                          .WhereEqualTo("SiteLanguageId", siteLanguageId);

            if (pageBased)
            {
                query = query.WhereEqualTo("PageId", pageId);
            }

            Field field = query
                          .ToList <Field>()
                          .FirstOrDefault();

            return(field);
        }
Beispiel #10
0
        List <Models.FlickrPhoto> GetPhotosFromFlickr(int pageindex = 0)
        {
            List <Models.FlickrPhoto> retVal = null;

            FlickrNet.Flickr flickr = new FlickrNet.Flickr(Manager.Settings.Current.FlickrAPIKey);
            flickr.InstanceCacheDisabled = true;

            FlickrNet.FoundUser userInfo = flickr.PeopleFindByUserName(Manager.Settings.Current.FlickrUserName);
            string flickrUserId          = userInfo.UserId;

            ViewBag.FlickrFullName = userInfo.FullName;

            FlickrNet.Person user = flickr.PeopleGetInfo(flickrUserId);
            ViewBag.FlickrFullName = user.RealName;

            FlickrNet.PhotoSearchOptions option = new FlickrNet.PhotoSearchOptions();
            option.UserId = flickrUserId;
            option.Page   = pageindex;

            FlickrNet.PhotoCollection photosets = flickr.PhotosSearch(option);
            if (photosets != null && photosets.Count > 0)
            {
                DataTable photos = UnigateObject.Query(Manager.Settings.Current.PhotoListTableName)
                                   .Column("Slug")
                                   .SortDesc("CreateDate")
                                   .ToDataTable();

                List <string> slugs = new List <string>();
                if (photos != null && photos.Rows.Count > 0)
                {
                    slugs = photos.AsEnumerable().Select(p => p.Field <string>("Slug")).ToList();
                }

                retVal = photosets.Where(p => !slugs.Any(s => s == p.PhotoId)).Select(p => new Models.FlickrPhoto()
                {
                    DownloadUrl = !string.IsNullOrEmpty(p.LargeUrl) ? p.LargeUrl : (!string.IsNullOrEmpty(p.MediumUrl) ? p.MediumUrl : p.SmallUrl),
                    ViewUrl     = p.SmallUrl,
                    Title       = p.Title,
                    PhotoId     = p.PhotoId
                }).ToList <Models.FlickrPhoto>();
            }

            return(retVal);
        }
        public ActionResult Edit(Guid id)
        {
            var sites = UnigateObject.Query("Page")
                        .WhereEqualTo("ParentPageId", null)
                        .ToList <PageViewModel>();

            var redirect = UnigateObject.Query("SiteRedirect")
                           .WhereEqualTo("ContentId", id)
                           .FirstOrDefault <SiteRedirectModel>();

            ViewData["Sites"] = sites.Select(x => new SelectListItem
            {
                Selected = redirect.PageId == x.Id,
                Text     = x.Title,
                Value    = x.Id.ToString()
            });

            return(View(redirect));
        }
        public ActionResult Save(EditableImage image)
        {
            if (!EditableImageAuthorization.Authorization())
            {
                throw new Exception("Bu işlemi yapmak için yetkiniz yok.");
            }

            EditableImage existsImage = UnigateObject.Query("EditableImage")
                                        .WhereEqualTo("Code", image.Code)
                                        .FirstOrDefault <EditableImage>();

            Guid imageGuid = Guid.Empty;

            if (existsImage != null)
            {
                var update = UnigateObject.Update("EditableImage")
                             .Column("Code", image.Code)
                             .Column("ImageFile", image.ImageFile)
                             .WhereEqualTo("ContentId", existsImage.ContentId)
                             .Execute();

                if (update.ResultCode == ResultCode.Successfull)
                {
                    imageGuid = existsImage.ContentId;
                }
            }
            else
            {
                var insert = UnigateObject.Insert("EditableImage", image).Execute();
                if (insert.ResultCode == ResultCode.Successfull)
                {
                    imageGuid = Guid.Parse(insert.OutParameters.Get("ContentId"));
                }
            }

            return(new JsonResult()
            {
                Data = imageGuid,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Beispiel #13
0
        public static string EditableImage(this HtmlHelper helper, string fileCode, string cssclass = null)
        {
            var auth = EditableImageAuthorization.Authorization();

            EditableImage file = UnigateObject.Query("EditableImage")
                                 .WhereEqualTo("Code", fileCode).FirstOrDefault <EditableImage>();

            if (file == null)
            {
                file           = new EditableImage();
                file.ImageFile = "/Modules/Plugins/Unigate.Plugins.EditableImage/Assets/Images/noimage.png";
                file.ContentId = new Guid();
            }

            var image = "<img id=\"" + file.ContentId + "\" class=\"" + cssclass + "\" src=\"" + file.ImageFile + "\" />";

            if (auth)
            {
                string pencil = "<img class=\"filebrowser pencil\" data-code=\"" + fileCode + "\" src=\"/Modules/Plugins/Unigate.Plugins.EditableImage/Assets/Images/pencil.png\">";
                return("<span class=\"editable-imageholder\">" + pencil + image + "</span>");
            }

            return(image);
        }
Beispiel #14
0
        public JsonResult Upload(Guid albumId)
        {
            if (Request.Files != null && Request.Files.Count > 0)
            {
                int orderno = 1;
                if (Manager.Settings.Current.PhotoListTableOrderNoField != null && !string.IsNullOrEmpty(Manager.Settings.Current.PhotoListTableOrderNoField.Name))
                {
                    orderno = UnigateObject.Query(Manager.Settings.Current.PhotoListTableName).ToList <Models.BaseModel>().Count + 1;
                }

                string photofolderpath = Server.MapPath(string.Format("~/documents/file/{0}", Manager.Settings.Current.PhotoListTableName));

                for (int i = 0; i < Request.Files.Count; i++)
                {
                    string filename = Path.GetFileName(Request.Files[i].FileName);

                    Stream stream          = Request.Files[i].InputStream;
                    byte[] photobinarydata = new byte[stream.Length];
                    stream.Read(photobinarydata, 0, Convert.ToInt32(stream.Length));
                    Size imagesize = Manager.PhotoManager.GetImageSize(photobinarydata);

                    this.ChangeFileFieldType(false);
                    Insert insert = UnigateObject.Insert(Manager.Settings.Current.PhotoListTableName)
                                    .Column("Slug", filename.Replace(".", "-"))
                                    .Column("CreateDate", DateTime.Now.ToString())
                                    .Column("UpdateDate", DateTime.Now.ToString());

                    if (Manager.Settings.Current.PhotoListTableTitleField != null && !string.IsNullOrEmpty(Manager.Settings.Current.PhotoListTableTitleField.Name))
                    {
                        if (Manager.Settings.Current.PhotoListTableTitleField.DefaultValue != null)
                        {
                            switch (Manager.Settings.Current.PhotoListTableTitleField.DefaultValue.ToString())
                            {
                            case "FileName":
                                insert = insert.Column(Manager.Settings.Current.PhotoListTableTitleField.Name, filename);
                                break;

                            case "Now":
                                insert = insert.Column(Manager.Settings.Current.PhotoListTableTitleField.Name, DateTime.Now.ToString());
                                break;

                            case "Today":
                                insert = insert.Column(Manager.Settings.Current.PhotoListTableTitleField.Name, DateTime.Today.ToShortDateString());
                                break;

                            default:
                                insert = insert.Column(Manager.Settings.Current.PhotoListTableTitleField.Name, string.Empty);
                                break;
                            }
                        }
                        else
                        {
                            insert = insert.Column(Manager.Settings.Current.PhotoListTableTitleField.Name, string.Empty);
                        }
                    }

                    bool   uploaded       = false;
                    string uploadfilename = Manager.PhotoManager.GetUnigateFileName(filename);
                    if (Manager.Settings.Current.PhotoListTablePhotoField != null && !string.IsNullOrEmpty(Manager.Settings.Current.PhotoListTablePhotoField.Name))
                    {
                        string uploadpath = string.Format("{0}/{1}", photofolderpath, uploadfilename);

                        if (Manager.Settings.Current.PhotoSize != null && Manager.Settings.Current.PhotoSize.Width != null && Manager.Settings.Current.PhotoSize.Height != null)
                        {
                            uploaded = Manager.PhotoManager.SavePhoto(Manager.PhotoManager.ImageResize(photobinarydata, Manager.Settings.Current.PhotoSize.Width, Manager.Settings.Current.PhotoSize.Height, false), uploadpath);
                        }
                        else
                        {
                            uploaded = Manager.PhotoManager.SavePhoto(photobinarydata, uploadpath);
                        }

                        insert = insert.Column(Manager.Settings.Current.PhotoListTablePhotoField.Name, string.Format("/documents/file/{0}/{1}", Manager.Settings.Current.PhotoListTableName, uploadfilename));
                    }

                    if (uploaded)
                    {
                        if (Manager.Settings.Current.PhotoListTableThumbnailField != null && !string.IsNullOrEmpty(Manager.Settings.Current.PhotoListTableThumbnailField.Name))
                        {
                            string uploadthumbnailname = Manager.PhotoManager.GetUnigateFileName(filename);
                            string uploadthumbnailpath = string.Format("{0}/{1}", photofolderpath, uploadthumbnailname);

                            if (Manager.Settings.Current.ThumbnailPhotoSize != null && Manager.Settings.Current.ThumbnailPhotoSize.Width != null && Manager.Settings.Current.ThumbnailPhotoSize.Height != null)
                            {
                                Manager.PhotoManager.SavePhoto(Manager.PhotoManager.ImageResize(photobinarydata, Manager.Settings.Current.ThumbnailPhotoSize.Width, Manager.Settings.Current.ThumbnailPhotoSize.Height, false), uploadthumbnailpath);
                            }
                            else
                            {
                                uploadthumbnailname = uploadfilename;
                            }

                            insert = insert.Column(Manager.Settings.Current.PhotoListTableThumbnailField.Name, string.Format("/documents/file/{0}/{1}", Manager.Settings.Current.PhotoListTableName, uploadthumbnailname));
                        }

                        if (Manager.Settings.Current.PhotoListTableAlbumRelationField != null && !string.IsNullOrEmpty(Manager.Settings.Current.PhotoListTableAlbumRelationField.Name))
                        {
                            insert = insert.Column(Manager.Settings.Current.PhotoListTableAlbumRelationField.Name, albumId);
                        }

                        if (Manager.Settings.Current.PhotoListTableOrderNoField != null && !string.IsNullOrEmpty(Manager.Settings.Current.PhotoListTableOrderNoField.Name))
                        {
                            insert = insert.Column(Manager.Settings.Current.PhotoListTableOrderNoField.Name, orderno);
                            orderno++;
                        }

                        MDataSourceResult result = insert.Execute();
                        this.ChangeFileFieldType(true);
                    }
                }
            }

            return(Json("/unigate/" + Unigate.PhotoGallery.AdminPlugin.Manager.PluginProperties.PluginName + "/?albumId=" + albumId.ToString()));
        }
        public override void Application_BeginRequest(object sender, EventArgs e)
        {
            var context     = HttpContext.Current;
            var request     = context.Request;
            var response    = context.Response;
            var application = context.Application;

            string domainName  = RouteUtility.DomainName(context);
            var    allPages    = PageUtility.GetAllPages();
            var    currentPage = allPages.FirstOrDefault(x => x.RouteValue == domainName);

            if (currentPage == null)
            {
                return;
            }

            if (request.Url.ToString().Contains(".ashx") || request.Url.ToString().Contains(".axd") || request.Url.ToString().Contains(".asmx") || request.Url.ToString().Contains("DataSource"))
            {
                return;
            }

            base.Application_BeginRequest(sender, e);

            #region Check RouteMap

            var siteMapLastUpdate = (SiteMapLastUpdateViewModel)application["SiteMapLastUpdate"];

            var siteMapLastUpdateFromService = UnigateObject.Query("SiteMapLastUpdate").FirstOrDefault <SiteMapLastUpdateViewModel>();

            if (siteMapLastUpdateFromService.SiteRedirectLastUpdateDate > siteMapLastUpdate.SiteRedirectLastUpdateDate)
            {
                if (Monitor.TryEnter(ObjectLockSiteRedirect))
                {
                    if (siteMapLastUpdateFromService.SiteRedirectLastUpdateDate > siteMapLastUpdate.SiteRedirectLastUpdateDate)
                    {
                        FillRedirects();

                        siteMapLastUpdate.SiteLanguageLastUpdateDate = siteMapLastUpdateFromService.SiteRedirectLastUpdateDate;
                        application["SiteMapLastUpdate"]             = siteMapLastUpdate;
                    }
                    Monitor.Exit(ObjectLockSiteRedirect);
                }
            }
            #endregion

            #region Site Redirect Check
            var redirects = application[AppRedirectName] as List <SiteRedirectModel>;

            if (redirects == null)
            {
                redirects = new List <SiteRedirectModel>();
            }

            var redirectUrl = redirects.FirstOrDefault(i => i.LocalAddress == request.Path.ToLowerInvariant());

            if (redirectUrl != null && !string.IsNullOrEmpty(redirectUrl.LocalAddress))
            {
                //İlgili domain için yönlendirme yapılmalı
                if (redirectUrl.PageId != currentPage.Id)
                {
                    return;
                }

                var siteRedirect = redirectUrl;
                if (siteRedirect.TransferQuerystring)
                {
                    if (!siteRedirect.IsTemporary)
                    {
                        response.RedirectPermanent(siteRedirect.RouteAddress + request.Url.Query);
                    }
                    else
                    {
                        response.Redirect(siteRedirect.RouteAddress + request.Url.Query);
                    }
                }
                else
                {
                    if (siteRedirect.IsTemporary == true)
                    {
                        response.RedirectPermanent(siteRedirect.RouteAddress);
                    }
                    else
                    {
                        response.Redirect(siteRedirect.RouteAddress);
                    }
                }
            }
            else
            {
                var siteRedirectsWithAsterisk = (application[AppRedirectName] as List <SiteRedirectModel>).Where(x => x.LocalAddress.Contains("*"));
                var siteRedirect = siteRedirectsWithAsterisk.FirstOrDefault(delegate(SiteRedirectModel s)
                {
                    var regexString = String.Format(@"^{0}$", s.LocalAddress.Trim().Replace("*", "(.*)"));

                    var isMached = Regex.IsMatch(request.Path.ToLowerInvariant(), regexString);
                    return(isMached);
                });

                if (siteRedirect != null)
                {
                    //İlgili domain için yönlendirme yapılmalı
                    if (siteRedirect.PageId != currentPage.Id)
                    {
                        return;
                    }

                    var    is301          = !siteRedirect.IsTemporary;
                    string responseStatus = string.Empty;
                    if (is301)
                    {
                        responseStatus = "301 Moved Permanently";
                    }
                    else
                    {
                        responseStatus = "302 Moved Temprorarily";
                    }

                    response.Status = responseStatus;
                    if (siteRedirect.TransferQuerystring)
                    {
                        if (is301)
                        {
                            response.RedirectPermanent(siteRedirect.RouteAddress + request.Url.Query);
                        }
                        else
                        {
                            response.Redirect(siteRedirect.RouteAddress + request.Url.Query);
                        }
                    }
                    else
                    {
                        if (is301)
                        {
                            response.RedirectPermanent(siteRedirect.RouteAddress);
                        }
                        else
                        {
                            response.Redirect(siteRedirect.RouteAddress);
                        }
                    }
                }
                else
                {
                    application["Redirects"] = redirects;
                }
            }

            #endregion
        }
        void FillRedirects()
        {
            var siteRedirects = UnigateObject.Query("SiteRedirect").ToList <SiteRedirectModel>();

            HttpContext.Current.Application[AppRedirectName] = siteRedirects;
        }