/// <summary> /// �������������������� /Forum1/Forum/Index.aspx /// </summary> /// <param name="app"></param> /// <param name="ctx"></param> /// <returns></returns> public static String ToApp( IApp app, MvcContext ctx ) { if (ctx.IsMock && ctx.GetItem( "_makeHtml" ) != null) return HtmlLink.ToApp( app ); String appName = strUtil.TrimEnd( app.GetType().Name, "App" ); return getAppLink( app.OwnerType, app.OwnerUrl, appName, app.Id ); }
private void logtest( MvcContext ctx ) { List<String> list = getContentList(); for (int i = 0; i < list.Count; i++) { Microblog blog = getBlog( null, list[i], i ); } }
private String getCacheKey( MvcContext ctx ) { IMember owner = ctx.owner.obj; int appId = ctx.app.Id; return "__action_"+owner.GetType().FullName + "_" + owner.Url.Replace( "/", "" ) + "_" + typeof( wojilu.Web.Controller.Forum.RecentController ).FullName + "_" + getActionName() + "_app" + appId; }
public override void AfterAction( MvcContext ctx ) { if (!HtmlHelper.CanHtml( ctx )) return; // 1)文章添加之后,app首页和侧边栏都要更新 HtmlMaker.GetHome().Process( ctx.app.Id ); logger.Info( "PostAddObserver make app home" ); // 2)新创建的文章,需要通过 ctx 传递 ContentPost post = HtmlHelper.GetPostFromContext( ctx ); if (post != null) { DetailMaker mk = HtmlMaker.GetDetail(); mk.Process( post ); ContentPost prev = postService.GetPrevPost( post ); if (prev != null) { mk.Process( prev ); } // 3) 侧边栏 HtmlMaker.GetSidebar().Process( post.AppId ); // 4) 其他生成工作放到队列中 JobManager.PostAdd( post ); } }
private static void bindUserInfo( IBlock block, MvcContext ctx, Microblog blog, Boolean showUserFace ) { IBlock ufBlock = block.GetBlock( "userFace" ); if (showUserFace) { ufBlock.Set( "blog.UserName", blog.User.Name ); ufBlock.Set( "blog.UserFace", blog.User.PicSmall ); if (ctx.GetItemString( "_showType" ) == "microblog") { ufBlock.Set( "blog.UserLink", alink.ToUserMicroblog( blog.User ) ); ufBlock.Set( "userNameInfo", string.Format( "<a href=\"{0}\">{1}</a>", alink.ToUserMicroblog( blog.User ), blog.User.Name ) ); } else { ufBlock.Set( "blog.UserLink", Link.ToMember( blog.User ) ); ufBlock.Set( "userNameInfo", string.Format( "<a href=\"{0}\">{1}</a>", Link.ToMember( blog.User ), blog.User.Name ) ); } String deleteCmd = getDeleteCmd( ctx, blog ); ufBlock.Set( "blog.DeleteCmd", deleteCmd ); ufBlock.Next(); if (ctx.GetItemString( "_showType" ) == "microblog") { block.Set( "userNameInfo", string.Format( "<a href=\"{0}\">{1}</a>", alink.ToUserMicroblog( blog.User ), blog.User.Name ) ); } else { block.Set( "userNameInfo", string.Format( "<a href=\"{0}\">{1}</a>", Link.ToMember( blog.User ), blog.User.Name ) ); } } else { block.Set( "userNameInfo", "" ); } }
protected virtual List<String> getFriendlyUrls( MvcContext ctx, IMember owner, String rawUrl ) { List<String> furls = new List<String>(); List<IMenu> list = InitHelperFactory.GetHelper( owner.GetType(), ctx ).GetMenus( owner ); foreach (IMenu menu in list) { if (strUtil.EqualsIgnoreCase( rawUrl, getFullUrl( menu.RawUrl ) )) { String urlKey = "/" + menu.Url + MvcConfig.Instance.UrlExt; furls.Add( urlKey ); if (menu.Url == "default") { // 在静态页面的时候,有多种结果:/和/Default.aspx furls.Add( "/" ); furls.Add( "/default" + MvcConfig.Instance.UrlExt ); furls.Add( "/Default" + MvcConfig.Instance.UrlExt ); } } } return furls; }
public static String GetBoard( List<ForumBoard> boards, MvcContext ctx ) { StringBuilder sb = getBuilder( boards, ctx ); int length = separator.Length + 1; sb.Remove( sb.Length - length, separator.Length + 1 ); appendEnd( sb ); return sb.ToString(); }
public virtual Result CreatePost( Result uploadResult, String photoName, int albumId, MvcContext ctx ) { String path = uploadResult.Info.ToString(); if (strUtil.IsNullOrEmpty( photoName )) { photoName = Path.GetFileNameWithoutExtension( path ); } photoName = strUtil.CutString( photoName, 30 ); PhotoAlbum album = getAlbum( albumId, ctx.viewer.obj as User ); PhotoPost photo = new PhotoPost(); photo.AppId = album.AppId; photo.Creator = (User)ctx.viewer.obj; photo.CreatorUrl = ctx.viewer.obj.Url; photo.OwnerId = ctx.owner.Id; photo.OwnerUrl = ctx.owner.obj.Url; photo.OwnerType = ctx.owner.obj.GetType().FullName; photo.Title = photoName; photo.DataUrl = path; photo.PhotoAlbum = album; photo.Ip = ctx.Ip; Result result = db.insert( photo ); if (result.IsValid) { this.updatePostCount( ctx.app.obj as PhotoApp ); } return result; }
private static String showErrorInfo( String result, MvcContext ctx ) { if (ctx.errors.HasErrors && ctx.errors.AutoShow) { result = Regex.Replace( result, "(<form.+?>)", "$1 " + ctx.errors.ErrorsHtml, RegexOptions.IgnoreCase ); } return result; }
public override bool BeforeAction( MvcContext ctx ) { ContentPost post = postService.GetById( ctx.route.id, ctx.owner.Id ); _contentPost = post; return base.BeforeAction( ctx ); }
public void Init( MvcContext ctx ) { if (ctx.utils.isEnd()) return; CurrentRequest.setItem( "_user_factory", new UserFactory() ); User user = this.getViewer( ctx ); if (user.Id == UserFactory.Guest.Id && ctx.web.UserIsLogin) { signOut( ctx ); return; } else if (user.Status == MemberStatus.Deleted || user.Status == MemberStatus.Approving) { signOut( ctx ); return; } if (ctx.web.UserIsLogin) loginService.UpdateLastLogin( user, ctx.Ip ); ViewerContext context = new ViewerContext(); context.Id = user.Id; context.obj = user; context.IsLogin = ctx.web.UserIsLogin; ctx.utils.setViewerContext( context ); }
public string GetCacheKey( MvcContext ctx, string actionName ) { User owner = ctx.owner.obj as User; int appId = ctx.app.Id; return typeof( User ).FullName + owner.Url + "_blogapp" + appId; }
public override string GetCacheKey( MvcContext ctx, string actionName ) { if (actionName != "Index") return null; if (ctx.route.page > 1) return null; // 只缓存第一页 return getCacheKey( ctx ); }
public static ForumBoard ValidateBoard( ForumBoard board, MvcContext ctx ) { if (board == null) board = new ForumBoard(); String name = ctx.Post( "Name" ); if (strUtil.IsNullOrEmpty( name )) { ctx.errors.Add( lang.get( "exName" ) ); } String description = ctx.Post( "Description" ); int parentId = ctx.PostInt( "ParentId" ); String notice = ctx.PostHtml( "Notice" ); board.ParentId = parentId; board.Name = name; board.Description = description; board.Notice = notice; board.AppId = ctx.app.Id; board.Creator = (User)ctx.viewer.obj; board.CreatorUrl = ctx.viewer.obj.Url; board.OwnerId = ctx.owner.Id; board.OwnerUrl = ctx.owner.obj.Url; board.OwnerType = ctx.owner.obj.GetType().FullName; board.Ip = ctx.Ip; board.IsCategory = ctx.PostInt( "IsCategory" ); board.ViewId = ctx.PostInt( "ViewId" ); return board; }
//---------------------------------------------------------------------- public static IList GetTopicAdminCmds( User user, ForumBoard board, MvcContext ctx ) { IList results = new ArrayList(); // 1、获取用户的角色 SecurityTool tool = ForumSecurityService.GetSecurityTool( board, ctx ); IList actions = tool.GetActionsByRole( user.Role ); addAdminActionsToResults( actions, results ); // 2、获取用户的等级 if (user.RankId > 0) { actions = tool.GetActionsByRole( user.Rank ); addAdminActionsToResults( actions, results ); } // 3、owner的角色 if (ctx.owner.obj.GetType() != typeof( Site )) { IRole roleInOwner = ctx.owner.obj.GetUserRole( user ); actions = tool.GetActionsByRole( roleInOwner ); addAdminActionsToResults( actions, results ); } // 3、版主 ModeratorService moderatorService = new ModeratorService(); if (moderatorService.IsModerator( board, user )) { IList moderatorActions = tool.GetActionsByRole( ForumRole.Moderator ); addAdminActionsToResults( moderatorActions, results ); } return results; }
public static MvcContext GetOne( IMember objOwner, int appId ) { IWebContext webContext = MockWebContext.New( 1, "http://localhost/", new System.IO.StringWriter() ); MvcContext ctx = new MvcContext( webContext ); // route Route route = new wojilu.Web.Mvc.Routes.Route(); route.setAppId( appId ); // 为了让生成的link链接中有appId,必须设置此项 ctx.utils.setRoute( route ); // viewer: 某些地方需要判断viewer ViewerContext viewer = new ViewerContext(); viewer.obj = new User(); ctx.utils.setViewerContext( viewer ); // owner OwnerContext owner = new OwnerContext(); owner.Id = objOwner.Id; owner.obj = objOwner; ctx.utils.setOwnerContext( owner ); // app IAppContext app = new AppContext(); app.Id = appId; app.obj = BlogApp.findById( appId ); app.setAppType( typeof( BlogApp ) ); // 如果要使用alang语言包,必须设置此项 ctx.utils.setAppContext( app ); return ctx; }
public override void UpdateCache( MvcContext ctx ) { IMember owner = Site.Instance; IApp forum = ctx.app.obj as IApp; // 1) ForumIndexCache if (forum != null) { String forumUrl = alink.ToApp( forum, ctx ); base.updateAllUrl( forumUrl, ctx ); } // 2) SiteLayoutCache else { List<ForumApp> siteForums = ForumApp.find( "OwnerId=" + owner.Id + " and OwnerType=:otype" ) .set( "otype", owner.GetType().FullName ) .list(); foreach (ForumApp app in siteForums) { String forumUrl = alink.ToApp( app, ctx ); base.updateAllUrl( forumUrl, ctx ); } } }
public override string GetCacheKey( MvcContext ctx, string actionName ) { if (actionName != "Layout") return null; if (ctx.owner.obj.GetType() != typeof( Site )) return null; return getCacheKey( ctx ); }
public override string GetCacheKey( MvcContext ctx, string actionName ) { if (!(ctx.owner.obj is Site)) return null; if (ctx.route.isAdmin || ctx.route.isUserDataAdmin) return null; return getKey(); }
public static String clearUrl( String rawUrl, MvcContext ctx, String memberTypeFullName, String memberUrl ) { String ownerPath = Link.GetMemberPathPrefix( memberTypeFullName, memberUrl ); ownerPath = ownerPath.TrimStart( '/' ); return clearUrl( rawUrl, ownerPath, ctx ); }
// 0) path => Blog.Admin // 1) path => Blog // 2) path => "" private static String addLayoutPrivate( String path, String actionContent, MvcContext ctx, Boolean isLastLayout ) { ControllerBase controller = ControllerFactory.FindLayoutController( path, ctx ); if (controller == null) return actionContent; ctx.controller.utils.addHidedLayouts( controller ); // ��controller���ᵽ��Ҫ���صĿ��������� if (ctx.controller.utils.isHided( controller.GetType() )) return actionContent; // ��黺�� ActionCacheChecker ci = ActionCacheChecker.InitLayout( ctx, controller ); Object cacheContent = ci.GetCache(); if (cacheContent != null) { logger.Info( "load from nsLayoutCache=" + ci.CacheKey ); return HtmlCombiner.combinePage( cacheContent.ToString(), actionContent ); } controller.utils.switchViewToLayout(); ActionRunner.runLayoutAction( ctx, controller, controller.Layout ); if (ctx.utils.isEnd()) { return ctx.utils.getCurrentOutputString(); } String actionResult = controller.utils.getActionResult(); if (ci.IsActionCache) { ci.AddCache( actionResult ); } return HtmlCombiner.combinePage( actionResult, actionContent ); }
public static String GetTitleStyle( MvcContext ctx ) { String fontStyle = ctx.Post( "fontStyle" ); String fontColor = ctx.Post( "fontColor" ); String fontSize = ctx.Post( "fontSize" ); String fontFamily = ctx.Post( "fontFamily" ); StringBuilder builder = new StringBuilder(); if (strUtil.HasText( fontColor )) { builder.Append( "color:" ); builder.Append( fontColor ); builder.Append( ";" ); } if (strUtil.HasText( fontSize )) { builder.Append( "font-size:" ); builder.Append( fontSize ); builder.Append( ";" ); } if (strUtil.HasText( fontFamily )) { builder.Append( "font-family:" ); builder.Append( fontFamily ); builder.Append( ";" ); } if (strUtil.HasText( fontStyle )) { builder.Append( fontStyle.Replace( ",", ";" ) ); } return builder.ToString(); }
/// <summary> /// 不包括http、域名、application path和网址后缀(仅仅是path) /// </summary> /// <param name="ctx"></param> /// <param name="menu"></param> /// <returns></returns> public static String getMenuFullPath( MvcContext ctx, IMenu menu ) { String url = menu.RawUrl; String ownerPathAndUrl = getMemberPathUrlByMenu( menu ); // 带http的完整网址 Boolean isFullUrl = PathHelper.IsFullUrl( url ); if (isFullUrl) return url; // 包括完整的ownerPath if (url.StartsWith( "/" )) { return url + MvcConfig.Instance.UrlExt; } String result = url; if (url.StartsWith( ctx.url.AppPath )) { result = strUtil.TrimStart( url, ctx.url.AppPath ); } if (result.StartsWith( ownerPathAndUrl )) { result = strUtil.TrimStart( result, ownerPathAndUrl ); } if (result.StartsWith( "/" + ownerPathAndUrl ) && strUtil.HasText( ownerPathAndUrl )) { result = strUtil.TrimStart( result, "/" + ownerPathAndUrl ); } String location = strUtil.Join( ctx.url.AppPath, ownerPathAndUrl ); result = strUtil.Join( location, result ); return result; }
//---------------------------------------------------------------------------------------------------- public static void CheckUserSpace( User user, MvcContext ctx ) { // 开启空间 if (Component.IsEnableUserSpace()) { addUserAppAndMenus( user, ctx ); } }
public string GetCacheKey( MvcContext ctx, string actionName ) { IMember owner = ctx.owner.obj; int appId = ctx.app.Id; return owner.GetType().FullName + "_" + owner.Url + "_" + typeof( wojilu.Web.Controller.Content.Section.LayoutController ).FullName + ".Layout" + "_app" + appId; }
public static void bindListItem( IBlock block, ContentPost post, MvcContext ctx ) { block.Set( "post.SectionName", post.PageSection.Title ); block.Set( "post.SectionUrl", ctx.to( new SectionController().Show, post.PageSection.Id ) ); String typeIcon = BinderUtils.getTypeIcon( post ); block.Set( "post.ImgIcon", typeIcon ); String att = post.Attachments > 0 ? "<img src=\"" + strUtil.Join( sys.Path.Img, "attachment.gif" ) + "\"/>" : ""; block.Set( "post.AttachmentIcon", att ); block.Set( "post.TitleCss", post.Style ); block.Set( "post.Title", strUtil.SubString( post.GetTitle(), 50 ) ); block.Set( "post.Created", post.Created ); block.Set( "post.Hits", post.Hits ); block.Set( "post.Url", alink.ToAppData( post ) ); if (post.Creator != null) { block.Set( "post.Submitter", string.Format( "<a href=\"{0}\" target=\"_blank\">{1}</a>", Link.ToMember( post.Creator ), post.Creator.Name ) ); } else { block.Set( "post.Submitter", "" ); } }
public virtual void CreateAppAndMenu( Group group, MvcContext ctx ) { // 添加程序 IMemberApp forumApp = appService.Add( (User)ctx.viewer.obj, @group, lang.get( "groupBoard" ), 1, AccessStatus.Public ); // 论坛 ForumApp app = forumService.GetById( forumApp.AppOid ); ForumPermission.AddOwnerAdminPermission( app ); // 添加一个论坛板块 ForumBoard board = new ForumBoard(); board.Name = lang.get( "groupBoard" ); board.ParentId = 0; board.AppId = forumApp.AppOid; board.Creator = (User)ctx.viewer.obj; board.CreatorUrl = ctx.viewer.obj.Url; board.OwnerId = group.Id; board.OwnerUrl = group.Url; board.OwnerType = typeof( Group ).FullName; board.Ip = ctx.Ip; board.Security = app.Security; db.insert( board ); // 添加menuUrl String forumUrl = UrlConverter.clearUrl( board, ctx ); menuService.AddMenuByApp( forumApp, forumApp.Name, "default", forumUrl ); }
public static String clearUrl( IAppData data, MvcContext ctx ) { String ownerPath = Link.GetMemberPathPrefix( data.OwnerType, data.OwnerUrl ); ownerPath = ownerPath.TrimStart( '/' ); return clearUrl( alink.ToAppData( data ), ownerPath, ctx ); }
public static ForumCategory ValidateCategory( ForumCategory category, MvcContext ctx ) { if (category == null) category = new ForumCategory(); String name = ctx.Post( "Name" ); if (strUtil.IsNullOrEmpty( name )) ctx.errors.Add( lang.get( "exName" ) ); String nameColor = ctx.Post( "NameColor" ); if (strUtil.HasText( nameColor )) { String errorInfo = alang( ctx, "exColorFormat" ); if (nameColor.Length != 7) ctx.errors.Add( errorInfo ); if (nameColor.StartsWith( "#" ) == false) ctx.errors.Add( errorInfo ); } int boardId = ctx.PostInt( "BoardId" ); category.Name = name; category.NameColor = nameColor; category.BoardId = boardId; category.OwnerId = ctx.owner.Id; category.OwnerType = ctx.owner.obj.GetType().FullName; category.Creator = (User)ctx.viewer.obj; return category; }
public override void AfterAction( MvcContext ctx ) { if (!HtmlHelper.CanHtml( ctx )) return; HtmlMaker.GetHome().Process( ctx.app.Id ); logger.Info( "HomeObserver make app home" ); }
//-------------------------------------------- public T Validate(MvcContext ctx) { String title = ctx.Post("Title"); String question = ctx.PostHtml("Question"); string[] answers = ctx.web.postValuesByKey("Answer"); StringBuilder builder = new StringBuilder(); int acount = 0; foreach (String answer in answers) { if ((strUtil.HasText(answer) && (answer.Length > 0)) && (answer.Length < 80)) { builder.Append(answer); builder.Append("\n"); acount++; } } String strAnswer = builder.ToString(); int polltype = ctx.PostInt("PollType"); int days = ctx.PostInt("Days"); int voterRank = ctx.PostInt("VoterRank"); String strIsVisible = ctx.Post("IsVisible"); String openVoter = ctx.Post("OpenVoter"); if (strUtil.IsNullOrEmpty(title)) { ctx.errors.Add(lang.get("exTitle")); } if (strUtil.IsNullOrEmpty(strAnswer)) { ctx.errors.Add(alang(ctx, "exPollOptions")); } if (strUtil.HasText(strAnswer)) { if (acount < 2) { ctx.errors.Add(alang(ctx, "exPollMinTwoOptions")); } if (acount > 20) { ctx.errors.Add(alang(ctx, "exPollMaxTwoOptions")); } } if (days > 365 * 10) { ctx.errors.Add(alang(ctx, "exPollMaxDay")); days = 0; } T poll = (T)ObjectContext.CreateObject(typeof(T)); poll.Title = title; poll.Question = question; poll.Answer = strAnswer; poll.ExpiryDate = DateTime.Now.AddDays((double)days); poll.VoterRank = voterRank; int isVisible = 0; if (strUtil.HasText(strIsVisible) && strIsVisible.Equals("on")) { isVisible = 1; } int isOpenVoter = 0; if (strUtil.HasText(openVoter) && openVoter.Equals("on")) { isOpenVoter = 1; } poll.Type = polltype; poll.IsVisible = isVisible; poll.IsOpenVoter = isOpenVoter; poll.Creator = (User)ctx.viewer.obj; poll.CreatorUrl = ctx.viewer.obj.Url; poll.OwnerId = ctx.owner.Id; poll.OwnerType = ctx.owner.obj.GetType().FullName; poll.OwnerUrl = ctx.owner.obj.Url; poll.AppId = ctx.app.Id; poll.Ip = ctx.Ip; return(poll); }
private static String alang(MvcContext ctx, String key) { return(ctx.controller.alang(key)); }
public override void Process(ProcessContext context) { MvcEventPublisher.Instance.BeginProcessAction(context.ctx); if (context.ctx.utils.isSkipCurrentProcessor()) { return; } MvcContext ctx = context.ctx; ControllerBase controller = ctx.controller; // 1) 检查 action 缓存 ActionCacheChecker xChecker = ActionCacheChecker.InitAction(ctx); Object cacheContent = xChecker.GetCache(); if (cacheContent != null) { logger.Info("load from actionCache=" + xChecker.CacheKey); context.setContent(cacheContent.ToString()); setPageMeta_FromCache(ctx, xChecker.CacheKey); return; } // 2) 运行 before action (获取所有的 ActionObserver) List <ActionObserver> actionObservers = ControllerMeta.GetActionObservers(controller.GetType(), ctx.route.action); if (actionObservers != null) { foreach (ActionObserver x in actionObservers) { ActionObserver ob = (ActionObserver)ObjectContext.CreateObject(x.GetType()); Boolean isContinue = ob.BeforeAction(ctx); if (!isContinue) { return; } } } // 3) 运行 action MethodInfo actionMethod = ctx.ActionMethodInfo; // context.getActionMethod(); // 设值模板并载入全局变量 setControllerView(controller, actionMethod); // 运行并处理post值 ActionRunner.runAction(ctx, controller, actionMethod, controller.utils.runAction); if (ctx.utils.isEnd()) { afterAction(ctx); return; } String actionContent = controller.utils.getActionResult(); // 4) 后续缓存处理 if (xChecker.IsActionCache) { xChecker.AddCache(actionContent); addPageMeta_ToCache(ctx, xChecker.CacheKey); } actionContent = PostValueProcessor.ProcessPostValue(actionContent, ctx); if (ctx.utils.isAjax) { context.showEnd(actionContent); } else if (ctx.utils.isFrame()) { int intNoLayout = ctx.utils.getNoLayout(); if (intNoLayout == 0) { String content = MvcUtil.getFrameContent(actionContent); context.showEnd(content); } else { context.setContent(actionContent); } } else { context.setContent(actionContent); } afterAction(ctx); }
public static void bindMashupData(IBlock block, IBinderValue item, int itemIndex, MvcContext ctx) { block.Set("post.ItemIndex", itemIndex); block.Set("post.Title", item.Title); block.Set("post.Created", item.Created.Day); block.Set("post.CreatedDay", item.Created.ToShortDateString()); block.Set("post.CreatedTime", item.Created.ToShortTimeString()); block.Set("post.CreatorName", item.CreatorName); block.Set("post.CreatorLink", item.CreatorLink); block.Set("post.CreatorPic", item.CreatorPic); block.Set("post.Content", item.Content); block.Set("post.Summary", strUtil.CutString(item.Content, 200)); block.Set("post.PicUrl", item.PicUrl); block.Set("post.Replies", item.Replies); String lnk = getDataLink(item, ctx); block.Set("post.Url", lnk); block.Bind("post", item); }
public static String GetAuthCookieJson(MvcContext ctx) { return("{ \"" + ctx.web.CookieAuthName() + "\":\"" + ctx.web.CookieAuthValue() + "\", \"ASPNET_SESSIONID\":\"" + ctx.web.SessionId + "\", \"" + adminCookieName + "\":\"" + ctx.web.CookieAuthValue(adminCookieName) + "\" }"); }
public static void runAction(MvcContext ctx, ControllerBase controller, MethodInfo actionMethod, aAction run) { runAction(ctx, controller, actionMethod, run, false); }
public virtual Result CreatePost(Result uploadResult, String photoName, int albumId, MvcContext ctx) { String path = uploadResult.Info.ToString(); if (strUtil.IsNullOrEmpty(photoName)) { photoName = Path.GetFileNameWithoutExtension(path); } photoName = strUtil.CutString(photoName, 30); PhotoAlbum album = getAlbum(albumId, ctx.viewer.obj as User); PhotoPost photo = new PhotoPost(); photo.AppId = album.AppId; photo.Creator = (User)ctx.viewer.obj; photo.CreatorUrl = ctx.viewer.obj.Url; photo.OwnerId = ctx.owner.Id; photo.OwnerUrl = ctx.owner.obj.Url; photo.OwnerType = ctx.owner.obj.GetType().FullName; photo.Title = photoName; photo.DataUrl = path; photo.PhotoAlbum = album; photo.Ip = ctx.Ip; Result result = db.insert(photo); if (result.IsValid) { this.updateCountApp(ctx.app.obj as PhotoApp); } return(result); }
private static String getLocation(MvcContext ctx) { String result = ctx.url.PathAndQuery; return(result); }
public ItemsController(MvcContext context) { _context = context; }
/// <summary> /// Gets the object. /// </summary> /// <param name="model">The model.</param> /// <param name="db">The db.</param> /// <returns></returns> /// <exception cref="Glass.Mapper.MapperException">Failed to find context {0}.Formatted(ContextName)</exception> public virtual object GetObject(string model, Database db, Rendering renderingItem) { if (model.IsNullOrEmpty()) { return(null); } //must be a path to a Model item if (model.StartsWith("/sitecore")) { var target = db.GetItem(model); if (target == null) { return(null); } string newModel = target[ModelTypeField]; return(GetObject(newModel, db, renderingItem)); } //if guid must be that to Model item Guid targetId; if (Guid.TryParse(model, out targetId)) { var target = db.GetItem(new ID(targetId)); if (target == null) { return(null); } string newModel = target[ModelTypeField]; return(GetObject(newModel, db, renderingItem)); } var type = Type.GetType(model, false); if (type == null || renderingModelType.IsAssignableFrom(type)) { return(null); } IMvcContext mvcContext = new MvcContext(new SitecoreService(Sitecore.Context.Database)); //this is really aggressive if (!mvcContext.SitecoreService.GlassContext.TypeConfigurations.ContainsKey(type)) { //if the config is null then it is probably an ondemand mapping so we have to load the ondemand part IConfigurationLoader loader = new OnDemandLoader <SitecoreTypeConfiguration>(type); mvcContext.SitecoreService.GlassContext.Load(loader); } if (renderingItem.DataSource.HasValue()) { var getOptions = new GetItemByPathOptions() { Path = renderingItem.DataSource, Type = type }; return(mvcContext.SitecoreService.GetItem(getOptions)); } if (renderingItem.RenderingItem.DataSource.HasValue()) { var getOptions = new GetItemByPathOptions() { Path = renderingItem.RenderingItem.DataSource, Type = type }; return(mvcContext.SitecoreService.GetItem(getOptions)); } /** * Issues #82: * Check Item before defaulting to the current item. */ if (renderingItem.Item != null) { var getOptions = new GetItemByItemOptions() { Item = renderingItem.Item, Type = type }; return(mvcContext.SitecoreService.GetItem(getOptions)); } else { //TODO? shoudl we use the GetCurrentitem var getOptions = new GetItemByItemOptions() { Item = mvcContext.ContextItem, Type = type }; return(mvcContext.SitecoreService.GetItem(getOptions)); } }
public MvcEventArgs(String s, MvcContext ctx) { msg = s; context = ctx; }
public ProgramasController(MvcContext context) { _context = context; }
public virtual Result Create(User creator, String name, String url, String description, int categoryId, int accessStats, MvcContext ctx) { Group g = populateGroup(creator, name, url, description, categoryId, accessStats); Result result = insertGroup(g); if (result.IsValid) { mgrService.JoinCreateGroup(creator, g, ctx.Ip); } return(result); }
public static void runLayoutAction(MvcContext ctx, ControllerBase layoutController, aAction action) { runAction(ctx, layoutController, action.Method, action, true); }
public CategoriesController(MvcContext context) { _context = context; }
public static Route Recognize(MvcContext context) { String url = context.url.ToString(); return(RecognizePath(processCleanUrl(url, context.web.PathApplication))); }
//---------------------------------------------------------------------- public static ActionCacheChecker InitAction(MvcContext ctx) { return(initPrivate(ctx, ctx.controller, false)); }
public CitaController(MvcContext context) { _context = context; }
public PageMeta(MvcContext ctx) { this.ctx = ctx; }
public virtual void Login(User user, LoginTime expiration, String ip, MvcContext ctx) { updateLastLogin(user, ip); ctx.web.UserLogin(user.Id, user.Name, expiration); OnlineStats.Instance.AddMemberCount(); }
public static ActionCacheChecker InitLayout(MvcContext ctx, ControllerBase controller) { return(initPrivate(ctx, controller, true)); }
public static void SetSession(MvcContext ctx) { ctx.web.UserLogin(adminCookieName, ctx.viewer.Id, "", wojilu.Common.LoginTime.Never); }
/// <summary> /// 服务器端正确的验证码 /// </summary> /// <param name="ctx"></param> /// <returns></returns> public String CorrectCode(MvcContext ctx) { return(ctx.web.SessionGet(sessionName) as string); }
public static void ClearSession(MvcContext ctx) { ctx.web.UserLogout(adminCookieName); }
private void setService(MvcContext ctx) { this.appService = ServiceMap.GetUserAppService(this.owner.GetType()); this.menuService = ServiceMap.GetMenuService(this.owner.GetType()); }
public static Boolean HasSession(MvcContext ctx) { int adminId = ctx.web.UserId(adminCookieName); return(adminId > 0 && adminId == ctx.viewer.Id); }
private void afterAction(MvcContext ctx) { runAfterAction(ctx); MvcEventPublisher.Instance.EndProcessAction(ctx); }
private static void addPageMeta_ToCache(MvcContext ctx, String cacheKey) { CacheManager.GetApplicationCache().Put(cacheKey + "_pageMeta", ctx.Page); }
public static void updateParamValues(ContentSection section, IContentSectionService sectionService, MvcContext ctx) { IList parms = ServiceContext.Get(section.ServiceId).GetParams(); int count = parms.Count; StringBuilder builder = new StringBuilder(); for (int i = 0; i < count; i++) { ParamControl control = parms[i] as ParamControl; builder.Append("param"); builder.Append(i); builder.Append("="); String strVal = ctx.Post("param" + i); object val = control.ChangeType(strVal); builder.Append(val); if (i < (count - 1)) { builder.Append(";"); } } section.ServiceParams = builder.ToString(); sectionService.Update(section); }
public static IPageAdminSection GetPageSectionAdmin(ContentSection articleSection, MvcContext ctx, String currentView) { if (articleSection == null) { return(new NullSectionAdmin()); } String adminSectionControllerName = getAdminControllerName(articleSection); ControllerBase controller = ControllerFactory.FindController(adminSectionControllerName, ctx) as ControllerBase; if (controller == null) { return(new NullSectionAdmin()); } controller.view(currentView); return(controller as IPageAdminSection); }