internal static void InitializeAll(IEnumerable <DataItemBase> items, SecurePage page, string groupName) { foreach (var item in items) { item.InitializeItem(page); } InitializeGroup(page, groupName); }
public static string Local_Code() { var viewStateLocalCode = SecurePage.GetViewStateLocalCode(); if (viewStateLocalCode != null) { return(viewStateLocalCode); } var localCode = string.Empty; if ( !VotePage.IsSessionStateEnabled || !SecurePage.IsSignedIn ) { if (!string.IsNullOrEmpty(VotePage.QueryElection)) { localCode = Elections.GetLocalCodeFromKey( VotePage.QueryElection); } else if (!string.IsNullOrEmpty(VotePage.QueryOffice)) { localCode = Offices.GetLocalCodeFromKey(VotePage.QueryOffice); } else if (!string.IsNullOrEmpty(VotePage.QueryLocal)) { localCode = VotePage.QueryLocal; } if ( (localCode == "00") || //Directory of Local Districts (LocalDistricts.IsValid(State_Code() , County_Code() , localCode)) ) { return(localCode); } return(string.Empty); } if (!string.IsNullOrEmpty(VotePage.QueryLocal)) { //Session["UserLocalCode"] = db.QueryString("Local"); Session_Put("UserLocalCode", VotePage.QueryLocal); } //Local_Code = db.User_LocalCode(); if (LocalDistricts.IsValid( State_Code() , User_CountyCode() , User_LocalCode())) { return(User_LocalCode()); } return(string.Empty); }
public SecurePage.UpdateStatus DoUpdate(bool reportUnchanged) { SecurePage.UpdateStatus updateStatus; try { DataControl.AddCssClasses("badupdate"); // in case of exception if (!Validate()) { return(SecurePage.UpdateStatus.Failure); } var newValue = GetControlValue(); newValue = Feedback.StripHtml(newValue); newValue = newValue.StripRedundantSpaces(); var oldValue = GetCurrentValue(); if (oldValue == newValue) { DataControl.SetValue(newValue); updateStatus = SecurePage.UpdateStatus.Unchanged; } else { SecurePage.ThrowRandomException(); Log(oldValue, newValue); SetControlValue(newValue); if (Update(Convert(newValue))) { Feedback.AddInfo("The " + Description + " entry was updated."); updateStatus = SecurePage.UpdateStatus.Success; } else { updateStatus = SecurePage.UpdateStatus.Unchanged; } } AfterUpdate(newValue); if (updateStatus == SecurePage.UpdateStatus.Unchanged && reportUnchanged) { Feedback.AddInfo("The " + Description + " entry was unchanged."); } DataControl.RemoveCssClass("badupdate"); // ok now } catch (Exception ex) { Feedback.AddError("There was an unexpected error updating the " + Description); Feedback.HandleException(ex); updateStatus = SecurePage.UpdateStatus.Failure; } if (updateStatus == SecurePage.UpdateStatus.Success) { IncrementUpdateCount(); } return(updateStatus); }
private static void CreateTextSubTabContent(HtmlControl parent, AnswersViewRow row, string moreClasses, MonitorInstance monitor) { // the text answer field SecurePage.AddTextAreaInputElement(parent, "TextBox" + row.QuestionKey, monitor.GetDataClass("shadow answer-textbox for-star " + moreClasses, "answer"), row.Answer, "Type or paste your response into this box", true, null, false, "Text Response", "answer wide", null, null, null); // the remove-line-breaks button if (!SecurePage.IsPoliticianUser) { SecurePage.AddButtonInputElement(parent, null, "remove-line-breaks button-2 button-smallest", "Remove Line Breaks", "remove-line-breaks"); } if (!SecurePage.IsPoliticianUser) // add source and date boxes { var textSourceAndDateDiv = new HtmlDiv().AddTo(parent, "text-source-and-date-container source-and-date-container"); var textSourceDiv = new HtmlDiv().AddTo(textSourceAndDateDiv, "text-source-container source-container"); var sourceRequiredSpan = row.IsTextSourceOptional.GetValueOrDefault() ? string.Empty : " <span class=\"reqd\">◄</span>"; SecurePage.AddTextAreaInputElement(textSourceDiv, "Source" + row.QuestionKey, monitor.GetDataClass("shadow source-textbox " + moreClasses, "source"), row.Source, "Copy and paste the url of the web page (with or without http://) where" + " you obtained the answer or a description of the source into this box.", false, "Copy and paste the url of the web page (with or without http://) where" + " you obtained the answer or a description of the source into this box.", false, "Text Source" + sourceRequiredSpan, "text-source source", null, null, null); var textDateDiv = new HtmlDiv().AddTo(textSourceAndDateDiv, "text-date-container date-container"); SecurePage.AddTextInputElement(textDateDiv, "Date" + row.QuestionKey, monitor.GetDataClass("shadow-2 date-textbox date-picker " + moreClasses, "date sourcedate"), row.DateStamp.DbDateToShortDate(), "Enter the date of the answer if today is not an appropriate date. For" + " example if you obtained the answer from the candidate's campaign website," + " and the election is over, enter some date a couple days prior to the" + " election.", false, "Text Date", "date", null, null, null); SecurePage.AddButtonInputElement(textDateDiv, null, "today-button for-date button-1 button-smallest", "Today", "today for-date"); } }
public static string State_Code() { //**Test var stateCode = SecurePage.GetViewStateStateCode(); if (stateCode != null) { return(stateCode); } if (VotePage.IsPublicPage) { return(StateCode_Domain_This()); } if (SecurePage.IsMasterUser) { if (!string.IsNullOrEmpty(VotePage.QueryState)) { Session_Put("UserCountyCode", string.Empty); Session_Put("UserLocalCode", string.Empty); Session_Put("UserStateCode", VotePage.QueryState); return(VotePage.QueryState); } return(!string.IsNullOrEmpty(User_StateCode()) ? User_StateCode() : string.Empty); } if (!SecurePage.IsStateAdminUser) { return(string.Empty); } if (StateCache.IsValidStateOrFederalCode(User_StateCode(), false)) { return(User_StateCode()); } return(StateCache.IsValidStateOrFederalCode(Domain_StateCode_This(), false) ? Domain_StateCode_This() : string.Empty); }
private static void CreateYouTubeSubTabContent(HtmlControl parent, AnswersViewRow row, string moreClasses, MonitorInstance monitor) { var wasUploadedByCandidate = !string.IsNullOrWhiteSpace(row.YouTubeUrl) && row.YouTubeSource == YouTubeInfo.VideoUploadedByCandidateMessage; var wasUploadedByVoteUsa = !string.IsNullOrWhiteSpace(row.YouTubeUrl) && row.YouTubeSource != YouTubeInfo.VideoUploadedByCandidateMessage; // the Source heading and Uploaded by candidate checkbox (only for master users) if (!SecurePage.IsPoliticianUser) { var heading = new HtmlDiv().AddTo(parent, "category-heading"); new HtmlSpan { InnerText = "Select Type of Video to be Shown" }.AddTo(heading); SecurePage.AddCheckboxInputElement(parent, "YouTubeFromCandidate" + row.QuestionKey, monitor.GetDataClass("youtubefrom-checkbox youtubefromcandidate-checkbox " + moreClasses, "youtubefromcandidate"), null, wasUploadedByCandidate, "Complete Video on YouTube (not created by Vote USA)", "fromcandidate clearfix", null, null, null, string.Empty); SecurePage.AddCheckboxInputElement(parent, "YouTubeFromVoteUSA" + row.QuestionKey, monitor.GetDataClass("youtubefrom-checkbox youtubefromvoteusa-checkbox " + moreClasses, "youtubefromvoteusa"), null, wasUploadedByVoteUsa, "Shortened Video Extracted from an Existing Video (on Vote USA or other Private Channel)", "fromvoteusa clearfix", null, null, null, string.Empty); } // the Vote-USA heading (only for master users) //if (!SecurePage.IsPoliticianUser) //{ // var heading = new HtmlDiv().AddTo(parent, "category-heading"); // new HtmlSpan {InnerText = "Uploaded Vote USA YouTube Video"}.AddTo(heading); //} var youTubeSourceFields = new HtmlDiv().AddTo(parent, "youtube-source-fields"); if (!SecurePage.IsPoliticianUser) { SecurePage.AddTextInputElement(youTubeSourceFields, "YouTubeSourceUrl" + row.QuestionKey, monitor.GetDataClass("shadow-2 youtubesourceurl-textbox " + moreClasses, "youtubesourceurl"), row.YouTubeSourceUrl, "Enter the url (with or without http://) of the source video.", false, "Url of Longer Video Used to Extract Shortened Video (on Vote USA or Private Channel)", "youtubeurl wide", null, null, null); } var youTubeSourceAndDateDiv = new HtmlDiv().AddTo(youTubeSourceFields, "youtube-source-and-date-container source-and-date-container"); if (wasUploadedByCandidate) { youTubeSourceFields.AddCssClasses("hidden"); } else { youTubeSourceFields.RemoveCssClass("hidden"); } if (!SecurePage.IsPoliticianUser) { var youTubeSourceDiv = new HtmlDiv().AddTo(youTubeSourceAndDateDiv, "youtube-source-container source-container"); SecurePage.AddTextAreaInputElement(youTubeSourceDiv, "YouTubeSource" + row.QuestionKey, monitor.GetDataClass("shadow youtubesource-textbox " + moreClasses, "youtube-source source"), row.YouTubeSource, "Enter a description of the source video into this box.", false, "Enter a description of the source video into this box.", true, "Source Description of Longer Video", "source", null, null, null); var youTubeDateDiv = new HtmlDiv().AddTo(youTubeSourceAndDateDiv, "youtube-date-container date-container"); SecurePage.AddTextInputElement(youTubeDateDiv, "YouTubeDate" + row.QuestionKey, monitor.GetDataClass("shadow-2 youtubedate-textbox date-picker " + moreClasses, "youtubedate sourcedate"), row.YouTubeDate.DbDateToShortDate(), "Enter the date of the video if today is not an appropriate date.", false, "Source Date", "youtubedate", null, null, null); SecurePage.AddButtonInputElement(youTubeDateDiv, null, "today-button for-youtubedate button-1 button-smallest", "Today", "today for-youtubedate"); } SecurePage.AddTextInputElement(parent, "YouTubeUrl" + row.QuestionKey, monitor.GetDataClass("shadow-2 youtubeurl-textbox for-star " + moreClasses, "youtubeurl"), row.YouTubeUrl, SecurePage.IsPoliticianUser ? "Enter a YouTube url that addresses the question." : "Enter the YouTube url of the Vote-USA video.", false, //SecurePage.IsPoliticianUser // ? "YouTube Url" // : "Url Provided by YouTube", "YouTube Url to be Shown", "youtubeurl wide", null, null, null); new HtmlP { InnerText = "When you Update, the Video Description and Running Time will be automatically retrieved from YouTube." }.AddTo(parent, "url-message"); var displayYouTubeDescription = row.YouTubeDescription.SafeString(); var displayYouTubeRunningTime = row.YouTubeRunningTime.FormatRunningTime(); if (!string.IsNullOrWhiteSpace(row.YouTubeAutoDisable)) { displayYouTubeDescription = ">>> This video has been temporarily disabled on Vote-USA: " + row.YouTubeAutoDisable; displayYouTubeRunningTime = string.Empty; } var youTubeDescriptionAndTimeDiv = new HtmlDiv().AddTo(parent, "youtube-description-and-time-container"); var youTubeDescriptionDiv = new HtmlDiv().AddTo(youTubeDescriptionAndTimeDiv, "youtube-description-container"); SecurePage.AddTextAreaInputElement(youTubeDescriptionDiv, "YouTubeDescription" + row.QuestionKey, monitor.GetDataClass("shadow youtubedescription-textbox " + moreClasses, "youtubedescription"), displayYouTubeDescription, null, false, null, false, "Video Description", "youtubedescription wide", null, null, null, true); var youTubeTimeDiv = new HtmlDiv().AddTo(youTubeDescriptionAndTimeDiv, "youtube-time-container"); SecurePage.AddTextInputElement(youTubeTimeDiv, "YouTubeRunningTime" + row.QuestionKey, monitor.GetDataClass("shadow-2 youtuberunningtime-textbox " + moreClasses, "youtuberunningtime"), displayYouTubeRunningTime, null, false, "Running Time", "youtuberunningtime", null, null, null, true); }
public void CreateControls(HtmlContainerControl parent, IList <AnswersViewRow> responses, MonitorInstance monitor, Dictionary <string, string> alternateHeadings = null) { var row = responses.First(); var responsesAsDataRow = responses.Where(r => r.Sequence != null).Cast <DataRow>().ToList(); parent.AddCssClasses("answer-panel " + (_Usage == Usage.ForIssues ? "issues-answer-panel " : "intro-answer-panel ") + (SecurePage.IsPoliticianUser ? "politician-answer-panel" : "master-answer-panel")); // The panel title var heading = SecurePage.AddContainer(parent, null, null); var headingText = alternateHeadings != null && alternateHeadings.ContainsKey(row.QuestionKey) ? alternateHeadings[row.QuestionKey] : row.Question; SecurePage.AddHeading(heading, 4, null, null, headingText); SecurePage.Center(heading, true, true, "heading"); if (_Usage == Usage.ForIssues) { heading.Visible = false; } // Add undo button as next sibling to heading var undo = SecurePage.CreateUndoButton("Undo" + row.QuestionKey, monitor.GetUndoClass(null), $"Revert \"{row.Question}\" to the latest saved version"); heading.AddAfter(undo); // Same for clear button var clear = SecurePage.CreateClearButton("Clear" + row.QuestionKey, monitor.GetClearClass(null), $"Clear \"{row.Question}\""); heading.AddAfter(clear); var updatePanel = SecurePage.AddAjaxUpdatePanel(parent, "UpdatePanel" + row.QuestionKey); var container = SecurePage.AddContainer(updatePanel.ContentTemplateContainer, "Container" + row.QuestionKey, monitor.GetContainerClass("update-all updated answer-container")); SecurePage.AddHiddenField(container, "Description" + row.QuestionKey, monitor.GetDescriptionClass(null, "answer"), row.Question); SecurePage.AddHiddenField(container, "SubTab" + row.QuestionKey, "subtab subtab-" + row.QuestionKey); var hasNoResponses = row.Sequence == null; var sequenceItem = SecurePage.AddHiddenField(container, "Sequence" + row.QuestionKey, "answer-sequence", hasNoResponses ? "?" : row.Sequence.Value.ToString(CultureInfo.InvariantCulture)); SetResponseData(responsesAsDataRow, row, sequenceItem); // the action menu var menuContainer = SecurePage.AddContainer(container, "Action" + row.QuestionKey, "action-menu"); CreateActionMenu(menuContainer, responsesAsDataRow, row.Sequence == null); new HtmlP { InnerHtml = "To completely delete a response (Text and YouTube), use the Clear button (red <span>X</span> upper right) then Update." }.AddTo(container, "delete-message"); var subTabs = new HtmlDiv { ID = "answer-subtabs-" + row.QuestionKey, ClientIDMode = ClientIDMode.Static }.AddTo(container, "answer-sub-tabs shadow"); var subTabsTabs = new HtmlUl().AddTo(subTabs, "htabs unselectable"); var textSubTab = new HtmlLi { EnableViewState = false }.AddTo(subTabsTabs, "tab htab"); new HtmlAnchor { HRef = "#tab-textanswer-" + row.QuestionKey, InnerHtml = "Text<br />Response", EnableViewState = false }.AddTo(textSubTab); var youTubeSubTab = new HtmlLi { EnableViewState = false }.AddTo(subTabsTabs, "tab htab"); new HtmlAnchor { HRef = "#tab-youtubeanswer-" + row.QuestionKey, InnerHtml = "YouTube<br />Response", EnableViewState = false }.AddTo(youTubeSubTab); var textSubTabContent = new HtmlDiv { ID = "tab-textanswer-" + row.QuestionKey, ClientIDMode = ClientIDMode.Static }.AddTo(subTabs); var youTubeSubTabContent = new HtmlDiv { ID = "tab-youtubeanswer-" + row.QuestionKey, ClientIDMode = ClientIDMode.Static }.AddTo(subTabs); string moreClasses; switch (_Usage) { case Usage.ForIntroReasons: moreClasses = "mc-mt-reasons"; break; case Usage.ForIntroBio: moreClasses = "mc-mt-bio2"; break; default: var tabPrefix = MonitorPrefix + "-" + MonitorTabPrefix + "-issue" + row.IssueKey; var superTabPrefix = MonitorPrefix + "-" + MonitorSuperTabPrefix + "-igroup" + row.IssueGroupKey; moreClasses = tabPrefix + " " + superTabPrefix; break; } SecurePage.AddHiddenField(container, "HasValue" + row.QuestionKey, monitor.GetDataClass(moreClasses, "hasvalue"), string.IsNullOrWhiteSpace(row.Answer) && string.IsNullOrWhiteSpace(row.YouTubeUrl) ? string.Empty : "Y"); CreateTextSubTabContent(textSubTabContent, row, moreClasses, monitor); CreateYouTubeSubTabContent(youTubeSubTabContent, row, moreClasses, monitor); new HtmlHr().AddTo(container); // feedback AddFeedbackWithIe7Floater(container, "Feedback" + row.QuestionKey, monitor.GetFeedbackClass(null)); // update button SecurePage.AddUpdateButtonInContainer(container, "Button" + row.QuestionKey, "update-button", monitor.GetButtonClass("update-button button-1"), $"Update \"{row.Question}\"", ButtonUpdate_OnClick); SecurePage.AddClearBoth(container); }
internal static void Initialize(this IEnumerable <DataItemBase> items, SecurePage page, string groupName) { DataItemBase.InitializeAll(items, page, groupName); }
public static string County_Code() { var viewStateCountyCode = SecurePage.GetViewStateCountyCode(); if (viewStateCountyCode != null) { return(viewStateCountyCode); } var countyCode = string.Empty; if ( !VotePage.IsSessionStateEnabled || !SecurePage.IsSignedIn ) //if (db.Is_User_Anonymous()) { if (!string.IsNullOrEmpty(VotePage.QueryElection)) { //could be old ElectionKey format countyCode = Elections.GetCountyCodeFromKey( //db.ElectionKey_New_Format(db.QueryString("Election"))); VotePage.QueryElection); } else if (!string.IsNullOrEmpty(VotePage.QueryOffice)) { countyCode = Offices.GetCountyCodeFromKey(VotePage.QueryOffice); } else if (!string.IsNullOrEmpty(VotePage.QueryCounty)) { countyCode = VotePage.QueryCounty; } if ( (countyCode == "000") || //Directory of Counties (CountyCache.CountyExists(State_Code() , countyCode)) ) { return(countyCode); } return(string.Empty); } //only MASTER or State ADMIN can change CountyCode of county //Setting UserLocalCode empty resets to County level security if ((SecurePage.IsMasterUser || (SecurePage.IsStateAdminUser)) && !string.IsNullOrEmpty(VotePage.QueryCounty) ) { Session_Put("UserCountyCode", VotePage.QueryCounty); Session_Put("UserLocalCode", string.Empty); } else { //Need to reset CountyCode to empty //When there is a StateCode query string //but no CountyCode query string if (!string.IsNullOrEmpty(State_Code())) { Session_Put("UserCountyCode", string.Empty); Session_Put("UserLocalCode", string.Empty); } } if (CountyCache.CountyExists( State_Code() , User_CountyCode())) { return(User_CountyCode()); } return(string.Empty); }