void DayRenderHandler(Object source, DayRenderEventArgs e) { SharedBasePage requestPage = this.Page as SharedBasePage; e.Day.IsSelectable = false; foreach (DateTime day in daysWithEntries) { if (e.Day.Date == day) { e.Cell.Controls.Clear(); HyperLink link = new HyperLink(); link.Text = e.Day.DayNumberText; link.NavigateUrl = SiteUtilities.GetDayViewUrl(requestPage.SiteConfig, e.Day.Date); e.Cell.Controls.Add(link); e.Day.IsSelectable = true; break; } } // Because we are using the CssClass property, we explicitely want to check // whether a day is both weekend _and_ lastmonth. // Otherwise this day would show up either // with 'hCalendarOtherMonthStyle' or with 'hCalendarWeekendStyle'. if ((e.Day.IsWeekend) && (e.Day.IsOtherMonth)) { e.Cell.CssClass = "hCalendarOtherMonthWeekendStyle"; } }
public void HtmlAttributeFilterTest() { ValidTagCollection tags = new ValidTagCollection("a@href@title,img@src"); string one = "aa<a href=\"attValue\" title=\"attTitle\">bb</a>"; string one_result = one; Assert.AreEqual(one_result, SiteUtilities.FilterHtml(one, tags), "Test one failed."); string two = "aa<a onclick=\"evil javascript\" href=\"link\">bb</a>"; string two_result = "aa<a href=\"link\">bb</a>"; Assert.AreEqual(two_result, SiteUtilities.FilterHtml(two, tags), "Test two failed."); string three = "aa<a href=attValue title=attTitle>bb</a>"; string three_result = "aa<a href=\"attValue\" title=\"attTitle\">bb</a>"; Assert.AreEqual(three_result, SiteUtilities.FilterHtml(three, tags), "Test three failed."); string four = "aa<a href title=\"title\">bb</a>"; string four_result = "aa<a title=\"title\">bb</a>"; Assert.AreEqual(four_result, SiteUtilities.FilterHtml(four, tags), "Test four failed."); string five = "aa<a title=\"title\" href>bb</a>"; string five_result = "aa<a title=\"title\">bb</a>"; Assert.AreEqual(five_result, SiteUtilities.FilterHtml(five, tags), "Test five failed."); }
string GetProfilePath() { SharedBasePage requestPage = this.Page as SharedBasePage; string profileFilename = string.Format("{0}.format.html", requestPage.User.Identity.Name); return(SiteUtilities.MapPath(Path.Combine(requestPage.SiteConfig.ProfilesDir, profileFilename))); }
public static List <SelectListItem> GetSelectListItems <T>(string defaultValue) where T : struct, IConvertible { if (!typeof(T).IsEnum) { throw new ArgumentException("T must be an enumerated type"); } List <SelectListItem> items = new List <SelectListItem>() { new SelectListItem() { Text = "Please select a lunch break...", Value = string.Empty } }; foreach (T item in Enum.GetValues(typeof(T))) { items.Add(new SelectListItem() { Text = SiteUtilities.GetEnumDescription((Enum)(object)item), Value = Convert.ToInt32(item).ToString() }); } return(items); }
public string CreateEntry(Entry entry, string username, string password) { SiteConfig siteConfig = SiteConfig.GetSiteConfig(); if (!siteConfig.EnableEditService) { throw new ServiceDisabledException(); } Authenticate(username, password); // ensure that the entryId was filled in // if (entry.EntryId == null || entry.EntryId.Length == 0) { entry.EntryId = Guid.NewGuid().ToString(); } // ensure the dates were filled in, otherwise use NOW if (entry.CreatedUtc == DateTime.MinValue) { entry.CreatedUtc = DateTime.UtcNow; } if (entry.ModifiedUtc == DateTime.MinValue) { entry.ModifiedUtc = DateTime.UtcNow; } ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService); SiteUtilities.SaveEntry(entry, string.Empty, null, siteConfig, logService, dataService); return(entry.EntryId); }
protected void initJobs(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var jobday = e.Item.FindControl("day") as Label; var personal = e.Item.FindControl("personal") as Label; Repeater repeater = e.Item.FindControl("jobs") as Repeater; JobList jobList = e.Item.DataItem as JobList; List <Person> persons = new List <Person>(); if (jobList != null && repeater != null && jobday != null) { if (personal != null) { persons = SiteUtilities.GetAvaliablePersonal(jobList.Date); for (int i = 0; i < persons.Count; i++) { if (persons[i].Active) { string name = persons[i].Firstname + " " + persons[i].Lastname.Substring(0, 1) + " "; personal.Text += name; } } } jobday.Text = jobList.Date.ToString("dddd", new System.Globalization.CultureInfo("sv-SE")) + " " + jobList.Date.ToString("m"); repeater.DataSource = jobList.Jobs; repeater.DataBind(); } } }
public string UpdateEntry(Entry entry, string username, string password) { SiteConfig siteConfig = SiteConfig.GetSiteConfig(); if (!siteConfig.EnableEditService) { throw new ServiceDisabledException(); } Authenticate(username, password); ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService); EntrySaveState val = SiteUtilities.UpdateEntry(entry, null, null, siteConfig, logService, dataService); string rtn = string.Empty; if (val.Equals(EntrySaveState.Updated)) { rtn = entry.EntryId; } else { rtn = val.ToString(); } return(rtn); }
public static string CreateAMPSeoMetaInformation(EntryCollection weblogEntries, IBlogDataService dataService) { string metaTags = "\r\n"; string blogPostDescription; string postImage = string.Empty; if (weblogEntries.Count >= 1) { Entry entry = weblogEntries[0]; metaTags += string.Format(CanonicalLinkPattern, SiteUtilities.GetPermaLinkUrl(entry)); blogPostDescription = entry.Content; try { postImage = FindFirstImage(blogPostDescription); } catch (Exception ex) { Trace.WriteLine("Exception looking for Images and Video: " + ex.ToString()); postImage = string.Empty; } metaTags += MetaSchemeOpenScript; metaTags += MetaSchemeContext; metaTags += MetaSchemeNewsType; metaTags += string.Format(MetaSchemeHeadline, entry.Title); metaTags += string.Format(MetaSchemeDatePublished, entry.CreatedUtc.ToString("yyyy-MM-dd")); metaTags += string.Format(MetaSchemeImage, postImage); metaTags += MetaSchemeCloseScript; } return(metaTags); }
string IMetaWeblog.metaweblog_newPost(string blogid, string username, string password, newtelligence.DasBlog.Web.Services.MetaWeblog.Post post, bool publish) { if (!siteConfig.EnableBloggerApi) { throw new ServiceDisabledException(); } UserToken token = SiteSecurity.Login(username, password); if (token == null) { throw new System.Security.SecurityException(); } Entry newPost = new Entry(); newPost.Initialize(); newPost.Author = username; TrackbackInfoCollection trackbackList = FillEntryFromMetaWeblogPost(newPost, post); newPost.IsPublic = publish; newPost.Syndicated = publish; // give the XSS upstreamer a hint that things have changed //FIX: XSSUpstreamer.TriggerUpstreaming(); SiteUtilities.SaveEntry(newPost, trackbackList, siteConfig, this.logService, this.dataService); return(newPost.EntryId); }
protected override void OnLoad(EventArgs e) { if (SiteConfig.EnableComments) { // implement the Comment API if (SiteConfig.EnableCommentApi && Request.ContentType == "text/xml" && Request.RequestType == "POST" && Request.QueryString["guid"] != null) { CommentAPI commentAPI = new CommentAPI(); commentAPI.ProcessRequest(Context); } //Setup the Live Comment Preview with an allowed tags array "'a', 'b', 'p', 'strong', 'blockquote', 'i', 'em', 'u', 'strike', 'sup', 'sub', 'code'" Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "allowedHtmlTags", String.Format(@" <script type=""text/javascript""> var allowedHtmlTags = [{0}]; </script> <script type=""text/javascript"" src=""scripts/LiveCommentPreview.js"" defer=""defer""></script>" , SiteConfig.AllowedTags.ToJavaScriptArray())); base.OnLoad(e); } else { this.Redirect(SiteUtilities.GetPermaLinkUrl(Request.QueryString["guid"])); } }
protected virtual DataRow GetRandomBook() { DataCache cache = CacheFactory.GetCache(); DataTable dt = (DataTable)cache["BooksTable"]; if (dt == null) { string path = SiteUtilities.MapPath(BookXML); DataSet ds = new DataSet(); ds.ReadXml(path); dt = ds.Tables[0]; cache.Insert("BooksTable", dt, new CacheDependency(path)); } int seed = DateTime.Now.Millisecond; //if we add more than one control to the page, we want to make sure our seeds are unique if (this.ID != null) { seed += this.ID.GetHashCode(); } //Not really random...but good enough Random rnd = new Random(seed); return(dt.Rows[rnd.Next(dt.Rows.Count)]); }
public string Editor() { SetSite(); switch (ReferenceType) { case "Sites": return(SiteUtilities.Editor(ReferenceId, clearSessions: true)); case "Issues": return(IssueUtilities.Editor( ss: Site.IssuesSiteSettings(ReferenceId), issueId: ReferenceId, clearSessions: true)); case "Results": return(ResultUtilities.Editor( ss: Site.ResultsSiteSettings(ReferenceId), resultId: ReferenceId, clearSessions: true)); case "Wikis": return(WikiUtilities.Editor( ss: Site.WikisSiteSettings(ReferenceId), wikiId: ReferenceId, clearSessions: true)); default: return(HtmlTemplates.Error(Error.Types.NotFound)); } }
string IBlogger.blogger_newPost( string appKey, string blogid, string username, string password, string content, bool publish) { if (!siteConfig.EnableBloggerApi) { throw new ServiceDisabledException(); } UserToken token = SiteSecurity.Login(username, password); if (token == null) { throw new System.Security.SecurityException(); } Entry newPost = new Entry(); newPost.Initialize(); FillEntryFromBloggerPost(newPost, content, username); newPost.IsPublic = publish; newPost.Syndicated = publish; SiteUtilities.SaveEntry(newPost, siteConfig, this.logService, this.dataService); return(newPost.EntryId); }
// handles the button click protected void doSignIn_Click(object sender, System.EventArgs e) { if (SiteConfig.EncryptLoginPassword) { string viewStateChallenge = ViewState["challenge"] as string; if (viewStateChallenge == null) { throw new ArgumentException("Password Challenge was null in ViewState!"); } UserToken token = SiteSecurity.Login(username.Text, challenge.Value, viewStateChallenge.ToString()); if (token != null) { SetAuthCookie(token.Name, username.Text); Response.Redirect(SiteUtilities.GetAdminPageUrl(), true); } else { challenge.Value = Session.SessionID.ToString(); ViewState["challenge"] = challenge.Value; } } else { UserToken token = SiteSecurity.Login(username.Text, password.Text); if (token != null) { SetAuthCookie(token.Name, username.Text); Response.Redirect(SiteUtilities.GetAdminPageUrl(), true); } } }
public void InitMembershipInfo(ListBox listBoxSelectedItems, ListBox listBoxExistingItems) { try { DataTable tableSelectedItems = new DataTable(); DataTable tableExistingItems = new DataTable(); DataRow dataRow; Hashtable hashSelected = new Hashtable(); List <Person> personlist = new List <Person>(); List <JobPersonList> persononJoblist = new List <JobPersonList>(); Collection <Person> persons = new Collection <Person>(); personlist = SiteUtilities.GetAllPersonal(); if (Request.QueryString["JobID"] != null) { persononJoblist = SiteUtilities.GetJobPersonal(new Guid(Request.QueryString["JobID"])); if (personlist != null) { if (personlist.Count > 0) { tableSelectedItems.Columns.Add(new DataColumn("Name", typeof(string))); tableSelectedItems.Columns.Add(new DataColumn("Id", typeof(Guid))); foreach (JobPersonList person in persononJoblist) { dataRow = tableSelectedItems.NewRow(); dataRow[0] = person.Firstname + " " + person.Lastname; dataRow[1] = person.PersonId; tableSelectedItems.Rows.Add(dataRow); hashSelected.Add(person.PersonId, "isSelected"); c_hiddenSelectedItems.Value += person.PersonId.ToString() + DELIMITER_LIST_BOX_SELECTION; } listBoxSelectedItems.DataTextField = "Name"; listBoxSelectedItems.DataValueField = "Id"; listBoxSelectedItems.DataSource = tableSelectedItems; listBoxSelectedItems.DataBind(); } } // Existing Items, (all the persons that the job is not allready added to) tableExistingItems.Columns.Add(new DataColumn("Name", typeof(string))); tableExistingItems.Columns.Add(new DataColumn("Id", typeof(Guid))); foreach (Person person in personlist) { AddPersons(tableExistingItems, hashSelected, person); } listBoxExistingItems.DataTextField = "Name"; listBoxExistingItems.DataValueField = "Id"; listBoxExistingItems.DataSource = tableExistingItems; listBoxExistingItems.DataBind(); } } catch { } }
public string SortSiteMenu(IContext context, long id) { var log = new SysLogModel(context: context); var json = SiteUtilities.SortSiteMenu(context: context, siteId: id); log.Finish(context: context, responseSize: json.Length); return(json); }
public string PreviewTemplate(IContext context, long id) { var log = new SysLogModel(context: context); var json = SiteUtilities.PreviewTemplate(context: context); log.Finish(context: context, responseSize: json.Length); return(json); }
public string SortSiteMenu(long id) { var log = new SysLogModel(); var json = SiteUtilities.SortSiteMenu(id); log.Finish(json.Length); return(json); }
public string CreateLink(IContext context, long id) { var log = new SysLogModel(context: context); var json = SiteUtilities.CreateLink(context: context, id: id); log.Finish(context: context, responseSize: json.Length); return(json); }
public string CreateLink(long id) { var log = new SysLogModel(); var json = SiteUtilities.CreateLink(id); log.Finish(json.Length); return(json); }
public string PreviewTemplate(long id) { var log = new SysLogModel(); var json = SiteUtilities.PreviewTemplate(); log.Finish(json.Length); return(json); }
protected void BuildUserDomainRow(TableRow row, StatisticsItem item, object unused) { Label userDomainLabel = new Label(); string text = SiteUtilities.ClipString(item.identifier, 80); userDomainLabel.Text = text; row.Cells[0].Controls.Add(userDomainLabel); row.Cells[1].Text = item.count.ToString(); }
private void calendarMonth_SelectionChanged(object sender, EventArgs e) { //If we post back because of a Select Day click then redirect to the Day view with that day. // TODO: It'd be cleaner to override the Day rendering and make the link direct // and avoid this silly postback. SharedBasePage requestPage = this.Page as SharedBasePage; Response.Redirect(SiteUtilities.GetDayViewUrl(requestPage.SiteConfig, calendarMonth.SelectedDate)); }
public string MoveSiteMenu(long id) { var context = new Context(); var log = new SysLogModel(context: context); var json = SiteUtilities.MoveSiteMenu(context: context, id: id); log.Finish(context: context, responseSize: json.Length); return(json); }
protected void initOverdue(object sender, EventArgs e) { Repeater repeater = sender as Repeater; var jobs = SiteUtilities.GetRentalOverDue(DateTime.Now); repeater.DataSource = jobs; repeater.DataBind(); }
protected void Job(object sender, EventArgs e) { if (Request.QueryString["JobID"] == null) { EditArea.Visible = false; return; } JobNewDate.Text = DateTime.Now.ToShortDateString(); InitButtons(); if (!Page.IsPostBack) { try { InitMembershipInfo(c_listBoxSelectedItems, c_listBoxExistingItems); if (Request.QueryString["JobID"] != null) { string jobdatetime = ""; TextBox textBox = sender as TextBox; var jobslist = SiteUtilities.GetJobsByJobId(new Guid(Request.QueryString["JobID"])); if (jobslist.Count > 0) { JobContactPhone.Text = jobslist[0].Phone; if (jobslist[0].JobStartTime.Hour.ToString() != "23") { ListItem starttime = StartTime.Items.FindByText(jobslist[0].JobStartTime.ToShortTimeString().Substring(0, 5)) as ListItem; starttime.Selected = true; } else { StartTime.Items[0].Selected = true; } if (jobslist[0].JobEndTime.Hour.ToString() != "23") { ListItem endtime = EndTime.Items.FindByText(jobslist[0].JobEndTime.ToShortTimeString().Substring(0, 5)) as ListItem; endtime.Selected = true; } else { EndTime.Items[18].Selected = true; } } } } catch { } } }
public string SiteMenu() { SetSite(); switch (Site.ReferenceType) { case "Sites": return(SiteUtilities.SiteMenuJson(siteModel: Site)); default: return(Messages.ResponseNotFound().ToJson()); } }
public void ApplyContentFilters_MultipleWordRegexReplaceWithUrlEncode() { string content = "This is a $g(compound query)"; string expectedContent = "This is a search?q=compound+query"; SiteConfig siteConfig = createSiteConfigWithFilter(@"\$g\((?<expr>[\w\s\d]+)\)", "search?q=$url(${expr})", true); string modifiedContent = SiteUtilities.ApplyContentFilters(siteConfig, content); Assert.AreEqual(expectedContent, modifiedContent, "Should have replaced $g with a URL encoded search URL."); }
public void ApplyContentFilters_MultipleReplaceWithUrlEncode() { string content = "This is a $g(compound query) and $g(another one)"; string expectedContent = "This is a search?q=compound+query and search?q=another+one"; SiteConfig siteConfig = createSiteConfigWithFilter(@"\$g\((?<expr>[\w\s\d]+)\)", "search?q=$url(${expr})", true); string modifiedContent = SiteUtilities.ApplyContentFilters(siteConfig, content); Assert.AreEqual(expectedContent, modifiedContent, "Should have replaced both expressions"); }
override protected void OnInit(EventArgs e) { if (User.Identity.IsAuthenticated) { Response.Redirect(SiteUtilities.GetAdminPageUrl(), true); } InitializeComponent(); base.OnInit(e); }
protected void Page_Load(object sender, EventArgs e) { int mgProjectId; if (!base.IsPostBack) { this.ViewState.Add("SESSION", base.Request["SESSION"]); this.ViewState.Add("MAPNAME", base.Request["MAPNAME"]); this.ViewState.Add("LAYOUT", base.Request["LAYOUT"]); this.ViewState.Add("UIDKEY", string.IsNullOrEmpty(base.Request["UIDKEY"]) ? "FeatId" : base.Request["UIDKEY"]); if (!int.TryParse(GetRequestParameters()["mgProjectId"], out mgProjectId)) return; ViewState.Add("mgProjectId", mgProjectId); this.ViewState.Add("ProjectName", base.Request["ProjectName"]); this.FileUploadControl.IdField ="FeatId"; this.ViewState.Add("UIDKEY","FeatId"); this.ViewState.Add("IdField", "FeatId"); } else { if (Session["SESSION"] == null) { Session["SESSION"] = ViewState["SESSION"]; } mgProjectId = (int)ViewState["mgProjectId"]; } // this._config = new LayoutModulesConfiguration(this.ViewState["LAYOUT"].ToString()); SiteUtilities siteUtilities = new SiteUtilities(new MapSettings(mgProjectId)); // get properties from the xml // ModuleConfig configProperties = this._config.GetProperties("FeatureCard"); //if (configProperties.Count == 0) //{ // DefineControlProperties.Define("FeatureCard"); // configProperties = this._config.GetProperties("FeatureCard"); //} this._helper = new HtzMgHelper(this.ViewState["SESSION"].ToString(), this.ViewState["MAPNAME"].ToString(), this.ViewState["LAYOUT"].ToString()); _helper._projectname = this.ViewState["ProjectName"].ToString(); // fpCollection = new FeatPropertyCollection(siteUtilities, ViewState["LayerName"].ToString(), ViewState["Filter"].ToString()); // this.Master.ErrorVisible = false; if (!base.IsPostBack) { if (this._helper.Selection.GetLayers() == null) { // this.Master.ShowErrorMessage("לא נבחר האובייקט"); return; } this.ViewState.Add("LayerName", this._helper.Selection.GetLayers().GetItem(0).GetName()); } MgLayer layer = (MgLayer)this._helper.Map.GetLayers().GetItem(this.ViewState["LayerName"].ToString()); if (!base.IsPostBack) { string filter = this._helper.Selection.GenerateFilter(layer, layer.GetFeatureClassName()); if (filter == "") { base.Response.Write("האופציה הזו לא קיימת לפרית הזאת."); base.Response.End(); } this.ViewState.Add("Filter", filter); } this.featureEditorControl.Filter = this.ViewState["Filter"].ToString(); try { Feature feature = Feature.GetSingleFeature(this._helper, this.ViewState["Filter"].ToString(), this.ViewState["LayerName"].ToString(), this.ViewState["UIDKEY"].ToString()); this.featureEditorControl.Activate(this._helper, feature); // this.featureEditorControl.Activate(this._helper, feature); //((bool)configProperties["MaintenanceAllowed"].Value) || //if (( feature.Layer.GetFeatureSourceId().Contains("Markup")) && feature.HaveUID) //{ // this.maintenanceControl.Activate(this._helper, this.ViewState["UIDKEY"].ToString(), feature.UID, feature.Layer); // if (this.maintenanceControl.Activated) // { // this.MaintenanceDisabledPanel.Visible = false; // this.maintenanceControl.Visible = true; // } // else // { // this.MaintenanceDisabledPanel.Visible = true; // this.maintenanceControl.Visible = false; // } //} //else //{ // this.MaintenanceDisabledPanel.Visible = true; // this.maintenanceControl.Visible = false; //} //this.MaintenanceDisabledPanel.Visible = false; //this.maintenanceControl.Visible = false; // this.FileUploadControl.Activate(this._helper, configProperties); // GetConfiguration From XML this.FileUploadControl.Visible = true; //(bool)configProperties["FileUploadAllowed"].Value; //!((bool)configProperties["FileUploadAllowed"].Value); this.FileUploaderDisabled.Visible= false; } catch (Exception ex) { // this.Master.ShowErrorMessage(ex.Message); } this.FileUploadControl.ControlError += new EventHandler<ErrorEventArgs>(this.OnControlError); this.lblLayerLegend.Text = this.featureEditorControl.LayerLegend; MgLayerGroup group = layer.GetGroup(); this.LayerLegend = layer.GetLegendLabel(); while (group != null) { this.LayerLegend = string.Format("{0} > {1}", group.GetLegendLabel(), this.LayerLegend); group = group.GetGroup(); } this.lblLayerLegend.Text = this.LayerLegend; }