public static IHtmlString RenderEditLink(this HtmlHelper helper, IPageTeaser teaser, string label) { if (DataScopeManager.CurrentDataScope != DataScopeIdentifier.Administrated) { return(helper.Raw(String.Empty)); } var editWorkflowAttribute = teaser.DataSourceId.InterfaceType.GetCustomAttributes(true).OfType <EditWorkflowAttribute>().FirstOrDefault(); if (editWorkflowAttribute == null) { return(helper.Raw(String.Empty)); } var page = PageManager.GetPageById(teaser.PageId); var entityToken = new PageTeaserInstanceEntityToken(page, teaser); var serializedEntityToken = EntityTokenSerializer.Serialize(entityToken, true); var editActionToken = new WorkflowActionToken(editWorkflowAttribute.EditWorkflowType); var serializedActionToken = ActionTokenSerializer.Serialize(editActionToken, true); var html = String.Format("<a href=\"#\" data-providername=\"{0}\" data-entitytoken=\"{1}\" data-actiontoken=\"{2}\" data-piggybag=\"{3}\" data-piggybaghash=\"{4}\" onclick=\"executeAction(this)\">{5}</a>", teaser.DataSourceId.ProviderName, serializedEntityToken, serializedActionToken, String.Empty, HashSigner.GetSignedHash(string.Empty).Serialize(), label); return(helper.Raw(html)); }
protected void Page_Load(object sender, EventArgs e) { if (!UserValidationFacade.IsLoggedIn()) { Response.Redirect("/Composite/Login.aspx?ReturnUrl=" + Request.Url.PathAndQuery); return; } ScriptLoader.Render("sub"); rptCountryList.DataSource = DataFacade.GetData <Country>().Take(10) .ToArray() .Select(x => { var editLink = new EditLink() { Label = x.Name }; if (DataScopeManager.CurrentDataScope != DataScopeIdentifier.Administrated) { editLink.Link = String.Empty; return(editLink); } var teaser = x; //var editWorkflowAttribute = teaser.DataSourceId.InterfaceType.GetCustomAttributes(true).OfType<EditWorkflowAttribute>().FirstOrDefault(); //if (editWorkflowAttribute == null) //{ // editLink.Link = string.Empty; // return editLink; //} var page = PageManager.GetPageById(Guid.Parse("63ec1a73-b1ed-4ec8-923f-2840448c43ce")); var entityToken = new PageTeaserInstanceEntityToken(page, teaser); var serializedEntityToken = EntityTokenSerializer.Serialize(entityToken, true); var editActionToken = new WorkflowActionToken(typeof(EditWorkflowAttribute)); var serializedActionToken = ActionTokenSerializer.Serialize(editActionToken, true); var html = String.Format("<a href=\"#\" data-providername='{0}' data-entitytoken='{1}' data-actiontoken=\"{2}\" data-piggybag='{3}' data-piggybaghash='{4}' onclick=\"executeAction(this)\">{5}</a>", teaser.DataSourceId.ProviderName, serializedEntityToken, serializedActionToken, String.Empty, HashSigner.GetSignedHash(string.Empty).Serialize(), "edit"); editLink.Link = html; return(editLink); }); rptCountryList.DataBind(); }
public static IHtmlString RenderFocusLink(this HtmlHelper helper, IPageTeaser teaser, string label) { if (DataScopeManager.CurrentDataScope != DataScopeIdentifier.Administrated) { return(helper.Raw(String.Empty)); } var page = PageManager.GetPageById(teaser.PageId); var token = new PageTeaserInstanceEntityToken(page, teaser); var serializedToken = EntityTokenSerializer.Serialize(token, true); return(helper.Raw("<a href=\"#\" data-token=\"" + serializedToken + "\" onclick=\"setFocus(this)\">" + label + "</a>")); }