本文整理汇总了C#中Template.Parse方法的典型用法代码示例。如果您正苦于以下问题:C# Template.Parse方法的具体用法?C# Template.Parse怎么用?C# Template.Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template
的用法示例。
在下文中一共展示了Template.Parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTemplate
/// <summary>
/// Creates an isolated template class for the module to render
/// inside.
/// </summary>
public new void CreateTemplate()
{
template = new Template(core.Http.TemplatePath, "1301.html");
template.Parse("U_ACCOUNT", core.Hyperlink.AppendSid(Owner.AccountUriStub, true));
if (assembly != null)
{
template.AddPageAssembly(assembly);
template.SetProse(core.Prose);
}
List<string[]> breadCrumbParts = new List<string[]>();
breadCrumbParts.Add(new string[] { "forum", core.Prose.GetString("FORUM") });
breadCrumbParts.Add(new string[] { "mcp", core.Prose.GetString("MODERATOR_CONTROL_PANEL") });
Owner.ParseBreadCrumbs(core.Template, "BREADCRUMBS", breadCrumbParts);
}
示例2: PostContent
void PostContent(HookEventArgs e)
{
Template template = new Template(Assembly.GetExecutingAssembly(), "postevent");
template.Medium = core.Template.Medium;
template.SetProse(core.Prose);
string formSubmitUri = core.Hyperlink.AppendSid(e.Owner.AccountUriStub, true);
template.Parse("U_ACCOUNT", formSubmitUri);
template.Parse("S_ACCOUNT", formSubmitUri);
int year = core.Functions.RequestInt("year", core.Tz.Now.Year);
int month = core.Functions.RequestInt("month", core.Tz.Now.Month);
int day = core.Functions.RequestInt("day", core.Tz.Now.Day);
DateTimePicker startDateTimePicker = new DateTimePicker(core, "start-date");
startDateTimePicker.ShowTime = true;
startDateTimePicker.ShowSeconds = false;
DateTimePicker endDateTimePicker = new DateTimePicker(core, "end-date");
endDateTimePicker.ShowTime = true;
endDateTimePicker.ShowSeconds = false;
UserSelectBox inviteesUserSelectBox = new UserSelectBox(core, "invitees");
/* */
SelectBox timezoneSelectBox = UnixTime.BuildTimeZoneSelectBox("timezone");
DateTime startDate = new DateTime(year, month, day, 8, 0, 0);
DateTime endDate = new DateTime(year, month, day, 9, 0, 0);
timezoneSelectBox.SelectedKey = core.Tz.TimeZoneCode.ToString();
template.Parse("S_YEAR", year.ToString());
template.Parse("S_MONTH", month.ToString());
template.Parse("S_DAY", day.ToString());
startDateTimePicker.Value = startDate;
endDateTimePicker.Value = endDate;
template.Parse("S_START_DATE", startDateTimePicker);
template.Parse("S_END_DATE", endDateTimePicker);
template.Parse("S_TIMEZONE", timezoneSelectBox);
template.Parse("S_INVITEES", inviteesUserSelectBox);
e.core.AddPostPanel(e.core.Prose.GetString("EVENT"), template);
}
示例3: ResendConfirmationKey
public void ResendConfirmationKey(Core core, NetworkMember member)
{
string activateKey = member.MemberActivationCode;
int isActive = (networkInfo.RequireConfirmation) ? 0 : 1;
string activateUri = string.Format("http://zinzam.com/network/{0}?mode=activate&id={1}&key={2}",
networkNetwork, member.UserId, activateKey);
if (networkInfo.RequireConfirmation)
{
Template emailTemplate = new Template(core.Http.TemplateEmailPath, "join_network.html");
emailTemplate.Parse("SITE_TITLE", core.Settings.SiteTitle);
emailTemplate.Parse("U_SITE", core.Hyperlink.StripSid(core.Hyperlink.AppendAbsoluteSid(core.Hyperlink.BuildHomeUri())));
emailTemplate.Parse("TO_NAME", member.DisplayName);
emailTemplate.Parse("U_ACTIVATE", activateUri);
emailTemplate.Parse("S_EMAIL", member.MemberEmail);
core.Email.SendEmail(member.MemberEmail, core.Settings.SiteTitle + " Network Registration Confirmation", emailTemplate);
}
}
示例4: CreateTemplate
/// <summary>
/// Creates an isolated template class for the module to render
/// inside.
/// </summary>
private new void CreateTemplate()
{
string formSubmitUri = string.Empty;
template = new Template(core.Http.TemplatePath, "1301.html");
if (Owner != null)
{
formSubmitUri = core.Hyperlink.AppendSid(Owner.UriStub + "forum/mcp", true);
template.Parse("U_MCP", core.Hyperlink.AppendSid(Owner.UriStub + "forum/mcp/", true));
template.Parse("S_MCP", core.Hyperlink.AppendSid(Owner.UriStub + "forum/mcp/", true));
}
template.AddPageAssembly(Assembly.GetCallingAssembly());
template.SetProse(core.Prose);
Form = new Form("control-panel", formSubmitUri);
Form.SetValues(core.Http.Form);
if (core.Http.Form["save"] != null)
{
Form.IsFormSubmission = true;
}
core.Template.Parse("IS_CONTENT", "FALSE");
List<string[]> breadCrumbParts = new List<string[]>();
breadCrumbParts.Add(new string[] { "forum", core.Prose.GetString("FORUM") });
breadCrumbParts.Add(new string[] { "mcp", core.Prose.GetString("MODERATOR_CONTROL_PANEL") });
Owner.ParseBreadCrumbs(core.Template, "BREADCRUMBS", breadCrumbParts);
}
示例5: AccountContactManage_VerifyEmail
void AccountContactManage_VerifyEmail(object sender, ModuleModeEventArgs e)
{
AuthoriseRequestSid();
UserEmail email = new UserEmail(core, core.Functions.RequestLong("id", 0));
if (email.UserId == LoggedInMember.Id)
{
if (!email.IsActivated)
{
string activateKey = User.GenerateActivationSecurityToken();
string activateUri = string.Format("http://" + Hyperlink.Domain + "/register/?mode=activate-email&id={0}&key={1}",
email.Id, activateKey);
UpdateQuery query = new UpdateQuery(typeof(UserEmail));
query.AddField("email_activate_code", activateKey);
query.AddCondition("email_id", email.Id);
core.Db.Query(query);
Template emailTemplate = new Template(core.Http.TemplateEmailPath, "email_activation.html");
emailTemplate.Parse("TO_NAME", Owner.DisplayName);
emailTemplate.Parse("U_ACTIVATE", activateUri);
emailTemplate.Parse("USERNAME", ((User)Owner).UserName);
core.Email.SendEmail(email.Email, core.Settings.SiteTitle + " email activation", emailTemplate);
SetRedirectUri(BuildUri());
core.Display.ShowMessage("Verification e-mail send", "A verification code has been sent to the e-mail address along with verification instructions.");
}
else
{
SetRedirectUri(BuildUri());
core.Display.ShowMessage("Already verified", "You have already verified your email address.");
}
}
else
{
SetRedirectUri(BuildUri());
core.Display.ShowMessage("Error", "An error has occured.");
}
}
示例6: ShowGroupGallery
/// <summary>
/// Hook showing gallery items on a group profile.
/// </summary>
/// <param name="e">Hook event arguments</param>
public void ShowGroupGallery(HookEventArgs e)
{
UserGroup thisGroup = (UserGroup)e.Owner;
if (!(!thisGroup.IsGroupMember(e.core.LoggedInMemberItemKey) && thisGroup.GroupType == "CLOSED"))
{
Template template = new Template(Assembly.GetExecutingAssembly(), "viewprofilegallery");
template.Medium = core.Template.Medium;
template.SetProse(core.Prose);
// show recent photographs in the gallery
Gallery gallery = new Gallery(e.core, thisGroup);
List<GalleryItem> galleryItems = gallery.GetItems(e.core, 1, 6, 0);
template.Parse("PHOTOS", thisGroup.GalleryItems.ToString());
foreach (GalleryItem galleryItem in galleryItems)
{
VariableCollection galleryVariableCollection = template.CreateChild("photo_list");
galleryVariableCollection.Parse("TITLE", galleryItem.ItemTitle);
galleryVariableCollection.Parse("PHOTO_URI", galleryItem.Uri);
galleryVariableCollection.Parse("THUMBNAIL", galleryItem.ThumbnailUri);
}
template.Parse("U_GROUP_GALLERY", Gallery.BuildGalleryUri(core, thisGroup));
e.core.AddMainPanel(template);
}
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string redirect = (Request.Form["redirect"] != null) ? Request.Form["redirect"] : Request.QueryString["redirect"];
string domain = (Request.Form["domain"] != null) ? Request.Form["domain"] : Request.QueryString["domain"];
DnsRecord record = null;
template.Parse("IS_CONTENT", "FALSE");
template.Parse("S_POST", core.Hyperlink.AppendSid("/sign-in/", true));
if (!string.IsNullOrEmpty(domain))
{
try
{
if (domain != Hyperlink.Domain)
{
record = new DnsRecord(core, domain);
}
if (core.Http["mode"] == "sign-out")
{
if (record != null)
{
session.SessionEnd(Request.QueryString["sid"], loggedInMember.UserId, record);
}
else
{
session.SessionEnd(Request.QueryString["sid"], loggedInMember.UserId);
}
if (!string.IsNullOrEmpty(redirect))
{
Response.Redirect(core.Hyperlink.AppendSid("http://" + record.Domain + "/" + redirect.TrimStart(new char[] { '/' }), true));
}
else
{
Response.Redirect(core.Hyperlink.AppendSid("http://" + record.Domain + "/", true));
}
}
else if (core.LoggedInMemberId > 0)
{
string sessionId = Request.QueryString["sid"];
if (!string.IsNullOrEmpty(sessionId))
{
core.Session.SessionEnd(sessionId, 0, record);
}
sessionId = core.Session.SessionBegin(core.LoggedInMemberId, false, false, false, record, null);
Response.Redirect(core.Hyperlink.AppendSid("http://" + record.Domain + "/" + redirect.TrimStart(new char[] { '/' }), true));
}
}
catch (InvalidDnsRecordException)
{
core.Display.ShowMessage("Error", "Error starting remote session");
return;
}
}
if (core.Http["mode"] == "sign-out")
{
string sessionId = Request.QueryString["sid"];
if (!string.IsNullOrEmpty(sessionId))
{
core.Session.SessionEnd(sessionId, loggedInMember.UserId);
}
if (!string.IsNullOrEmpty(redirect))
{
Response.Redirect(redirect, true);
}
else
{
Response.Redirect("/", true);
}
return;
}
if (Request.Form["submit"] != null)
{
if (core.Http["mode"] == "reset-password")
{
string email = Request.Form["email"];
if (string.IsNullOrEmpty(email))
{
core.Display.ShowMessage("Error", "An error occured");
return;
}
else
{
try
{
UserEmail userEmail = new UserEmail(core, email);
if (userEmail.IsActivated)
{
string newPassword = BoxSocial.Internals.User.GenerateRandomPassword();
string activateCode = BoxSocial.Internals.User.GenerateActivationSecurityToken();
db.UpdateQuery(string.Format("UPDATE user_info SET user_new_password = '{0}', user_activate_code = '{1}' WHERE user_id = {2}",
//.........这里部分代码省略.........
示例8: RenderPreview
public Template RenderPreview()
{
Template template = new Template("search_result.user.html");
template.Medium = core.Template.Medium;
template.SetProse(core.Prose);
template.Parse("USER_DISPLAY_NAME", DisplayName);
template.Parse("ICON", Icon);
template.Parse("TILE", Tile);
template.Parse("U_PROFILE", Uri);
template.Parse("JOIN_DATE", core.Tz.DateTimeToString(UserInfo.GetRegistrationDate(core.Tz)));
template.Parse("USER_AGE", Profile.AgeString);
template.Parse("USER_COUNTRY", Profile.Country);
if (core.Session.IsLoggedIn)
{
List<long> friendIds = core.Session.LoggedInMember.GetFriendIds();
if (!friendIds.Contains(Id))
{
template.Parse("U_ADD_FRIEND", core.Hyperlink.BuildAddFriendUri(Id, true));
}
}
return template;
}
示例9: NotifyMessage
public static void NotifyMessage(Core core, Job job)
{
Message ev = new Message(core, job.ItemId);
List<MessageRecipient> recipients = ev.GetRecipients();
foreach (MessageRecipient recipient in recipients)
{
core.LoadUserProfile(recipient.UserId);
}
foreach (MessageRecipient recipient in recipients)
{
// TODO: notify everyone via push notifications
if (ev.SenderId == recipient.UserId)
{
// don't need to notify ourselves via e-mail
continue;
}
User receiver = core.PrimitiveCache[recipient.UserId];
if (receiver.UserInfo.EmailNotifications)
{
string notificationString = string.Format("[user]{0}[/user] [iurl=\"{1}\"]" + core.Prose.GetString("_SENT_YOU_A_MESSAGE") + "[/iurl]",
ev.SenderId, ev.Uri);
Template emailTemplate = new Template(core.TemplateEmailPath, "notification.html");
emailTemplate.Parse("SITE_TITLE", core.Settings.SiteTitle);
emailTemplate.Parse("U_SITE", core.Hyperlink.StripSid(core.Hyperlink.AppendAbsoluteSid(core.Hyperlink.BuildHomeUri())));
emailTemplate.Parse("TO_NAME", receiver.DisplayName);
core.Display.ParseBbcode(emailTemplate, "NOTIFICATION_MESSAGE", notificationString, receiver, false, string.Empty, string.Empty, true);
emailTemplate.Parse("NOTIFICATION_BODY", job.Body);
core.Email.SendEmail(receiver.UserInfo.PrimaryEmail, HttpUtility.HtmlDecode(core.Bbcode.Flatten(HttpUtility.HtmlEncode(notificationString))), emailTemplate);
}
}
}
示例10: Register
//.........这里部分代码省略.........
query = new InsertQuery("user_profile");
query.AddField("user_id", userId);
query.AddField("profile_date_of_birth_ut", -30610224000L);
// TODO: ACLs
db.Query(query);
User newUser = new User(core, userId);
UserEmail registrationEmail = UserEmail.Create(core, newUser, eMail, EmailAddressTypes.Personal, true);
// Install a couple of applications
try
{
ApplicationEntry profileAe = new ApplicationEntry(core, "Profile");
profileAe.Install(core, newUser);
}
catch
{
}
try
{
ApplicationEntry mailAe = new ApplicationEntry(core, "Mail");
mailAe.Install(core, newUser);
}
catch
{
}
try
{
ApplicationEntry galleryAe = new ApplicationEntry(core, "Gallery");
galleryAe.Install(core, newUser);
}
catch
{
}
try
{
ApplicationEntry guestbookAe = new ApplicationEntry(core, "GuestBook");
guestbookAe.Install(core, newUser);
}
catch
{
}
try
{
ApplicationEntry groupsAe = new ApplicationEntry(core, "Groups");
groupsAe.Install(core, newUser);
}
catch
{
}
try
{
ApplicationEntry networksAe = new ApplicationEntry(core, "Networks");
networksAe.Install(core, newUser);
}
catch
{
}
try
{
ApplicationEntry calendarAe = new ApplicationEntry(core, "Calendar");
calendarAe.Install(core, newUser);
}
catch
{
}
string activateUri = string.Format("{0}register/?mode=activate&id={1}&key={2}",
core.Hyperlink.Uri, userId, activateKey);
Template emailTemplate = new Template(core.Http.TemplateEmailPath, "registration_welcome.html");
emailTemplate.Parse("SITE_TITLE", core.Settings.SiteTitle);
emailTemplate.Parse("U_SITE", core.Hyperlink.StripSid(core.Hyperlink.AppendAbsoluteSid(core.Hyperlink.BuildHomeUri())));
emailTemplate.Parse("TO_NAME", userName);
emailTemplate.Parse("U_ACTIVATE", activateUri);
emailTemplate.Parse("USERNAME", userName);
emailTemplate.Parse("PASSWORD", passwordClearText);
core.Email.SendEmail(eMail, "Activate your account. Welcome to " + core.Settings.SiteTitle, emailTemplate);
Access.CreateAllGrantsForOwner(core, newUser);
Access.CreateGrantForPrimitive(core, newUser, User.GetEveryoneGroupKey(core), "VIEW");
Access.CreateGrantForPrimitive(core, newUser, User.GetEveryoneGroupKey(core), "VIEW_STATUS");
Access.CreateGrantForPrimitive(core, newUser, Friend.GetFriendsGroupKey(core), "COMMENT");
Access.CreateGrantForPrimitive(core, newUser, Friend.GetFriendsGroupKey(core), "VIEW_FRIENDS");
Access.CreateGrantForPrimitive(core, newUser, Friend.GetFamilyGroupKey(core), "VIEW_FAMILY");
core.Search.Index(newUser);
return newUser;
}
示例11: core_FootHooks
void core_FootHooks(HookEventArgs e)
{
if (e.PageType == AppPrimitives.Musician)
{
Template template = new Template(Assembly.GetExecutingAssembly(), "music_footer");
template.Medium = core.Template.Medium;
template.SetProse(core.Prose);
if (e.Owner.Type == "MUSIC")
{
if (((Musician)e.Owner).IsMusicianMember(core.Session.LoggedInMember.ItemKey))
{
template.Parse("U_MUSICIAN_ACCOUNT", core.Hyperlink.AppendSid(e.Owner.AccountUriStub));
}
}
e.core.AddFootPanel(template);
}
}
示例12: ShowToday
void ShowToday(HookEventArgs e)
{
Template template = new Template(Assembly.GetExecutingAssembly(), "todayupcommingevents");
template.Medium = core.Template.Medium;
template.SetProse(core.Prose);
long startTime = e.core.Tz.GetUnixTimeStamp(new DateTime(e.core.Tz.Now.Year, e.core.Tz.Now.Month, e.core.Tz.Now.Day, 0, 0, 0));
long endTime = startTime + 60 * 60 * 24 * 7; // skip ahead one week into the future
Calendar cal = null;
try
{
cal = new Calendar(core, core.Session.LoggedInMember);
}
catch (InvalidCalendarException)
{
cal = Calendar.Create(core, core.Session.LoggedInMember);
}
List<Event> events = cal.GetEvents(core, e.core.Session.LoggedInMember, startTime, endTime);
template.Parse("U_NEW_EVENT", core.Hyperlink.AppendSid(string.Format("{0}calendar/new-event",
e.core.Session.LoggedInMember.AccountUriStub)));
template.Parse("U_CALENDAR", core.Hyperlink.AppendSid(string.Format("{0}calendar",
e.core.Session.LoggedInMember.UriStub)));
VariableCollection appointmentDaysVariableCollection = null;
DateTime lastDay = e.core.Tz.Now;
if (events.Count > 0)
{
template.Parse("HAS_EVENTS", "TRUE");
}
foreach(Event calendarEvent in events)
{
DateTime eventDay = calendarEvent.GetStartTime(e.core.Tz);
DateTime eventEnd = calendarEvent.GetEndTime(e.core.Tz);
if (appointmentDaysVariableCollection == null || lastDay.Day != eventDay.Day)
{
lastDay = eventDay;
appointmentDaysVariableCollection = template.CreateChild("appointment_days_list");
appointmentDaysVariableCollection.Parse("DAY", core.Tz.DateTimeToDateString(eventDay));
}
VariableCollection appointmentVariableCollection = appointmentDaysVariableCollection.CreateChild("appointments_list");
appointmentVariableCollection.Parse("TIME", eventDay.ToShortTimeString() + " - " + eventEnd.ToShortTimeString());
appointmentVariableCollection.Parse("SUBJECT", calendarEvent.Subject);
appointmentVariableCollection.Parse("LOCATION", calendarEvent.Location);
appointmentVariableCollection.Parse("URI", Event.BuildEventUri(core, calendarEvent));
}
e.core.AddMainPanel(template);
//
// Tasks panel
//
template = new Template(Assembly.GetExecutingAssembly(), "todaytaskspanel");
template.SetProse(core.Prose);
List<Task> tasks = cal.GetTasks(core, e.core.Session.LoggedInMember, startTime, endTime, true);
VariableCollection taskDaysVariableCollection = null;
lastDay = e.core.Tz.Now;
if (tasks.Count > 0)
{
template.Parse("HAS_TASKS", "TRUE");
}
template.Parse("U_TASKS", Task.BuildTasksUri(e.core, e.core.Session.LoggedInMember));
foreach (Task calendarTask in tasks)
{
DateTime taskDue = calendarTask.GetDueTime(e.core.Tz);
if (taskDaysVariableCollection == null || lastDay.Day != taskDue.Day)
{
lastDay = taskDue;
taskDaysVariableCollection = template.CreateChild("task_days");
taskDaysVariableCollection.Parse("DAY", taskDue.DayOfWeek.ToString());
}
VariableCollection taskVariableCollection = taskDaysVariableCollection.CreateChild("task_list");
taskVariableCollection.Parse("DATE", taskDue.ToShortDateString() + " (" + taskDue.ToShortTimeString() + ")");
taskVariableCollection.Parse("TOPIC", calendarTask.Topic);
taskVariableCollection.Parse("ID", calendarTask.Id.ToString());
taskVariableCollection.Parse("URI", Task.BuildTaskUri(core, calendarTask));
taskVariableCollection.Parse("U_MARK_COMPLETE", Task.BuildTaskMarkCompleteUri(core, calendarTask));
if (calendarTask.Status == TaskStatus.Overdue)
{
taskVariableCollection.Parse("OVERDUE", "TRUE");
taskVariableCollection.Parse("CLASS", "overdue-task");
//.........这里部分代码省略.........
示例13: ShowMiniCalendar
void ShowMiniCalendar(HookEventArgs e)
{
Template template = new Template(Assembly.GetExecutingAssembly(), "todaymonthpanel");
template.Medium = core.Template.Medium;
template.SetProse(core.Prose);
template.Parse("URI", Calendar.BuildMonthUri(e.core, e.core.Session.LoggedInMember, e.core.Tz.Now.Year, e.core.Tz.Now.Month));
Calendar.DisplayMiniCalendar(e.core, template, e.core.Session.LoggedInMember, e.core.Tz.Now.Year, e.core.Tz.Now.Month);
e.core.AddSidePanel(template);
}
示例14: CreateTemplate
/// <summary>
/// Creates an isolated template class for the module to render
/// inside.
/// </summary>
private void CreateTemplate()
{
string formSubmitUri = string.Empty;
template = new Template(core.Http.TemplatePath, "1301.html");
template.Medium = core.Template.Medium;
if (Owner != null)
{
formSubmitUri = core.Hyperlink.AppendSid(Owner.AccountUriStub, true);
template.Parse("U_ACCOUNT", formSubmitUri);
template.Parse("S_ACCOUNT", formSubmitUri);
}
template.AddPageAssembly(Assembly.GetCallingAssembly());
template.SetProse(core.Prose);
Form = new Form("control-panel", formSubmitUri);
Form.SetValues(core.Http.Form);
if (core.Http.Form["save"] != null)
{
Form.IsFormSubmission = true;
}
core.Template.Parse("IS_CONTENT", "FALSE");
template.Parse("SITE_TITLE", core.Settings.SiteTitle);
}
示例15: ParsePagination
public void ParsePagination(Template template, string templateVar, string baseUri, int pageLevel, int itemsPerPage, long totalItems, bool minimal)
{
int maxPages = (int)Math.Ceiling(totalItems / (double)itemsPerPage);
template.ParseRaw(templateVar, GeneratePagination(baseUri, pageLevel, core.PageNumber, core.PageOffset, maxPages, (minimal ? PaginationOptions.Minimal : PaginationOptions.Normal)));
if (maxPages > 1)
{
template.Parse(templateVar + "_MORE", "TRUE");
}
}