protected void Page_Load(object sender, EventArgs args) { KnowledgeBaseQuery.Attributes["placeholder"] = Html.SnippetLiteral("Knowledge Base Search Query Placeholder", "Search the knowledge base"); if (IsPostBack) { return; } KnowledgeBaseQuery.Text = Request.QueryString["kbquery"]; Tuple <string, Guid, SubjectSource> subjectName; if (TryGetSubjectName(out subjectName)) { SubjectId = subjectName.Item2; SubjectName = subjectName.Item1; KnowledgeBaseSubjectFilter.Items.Add(new ListItem(SubjectName, SubjectId.ToString()) { Selected = true }); KnowledgeBaseSubjectFilter.Items.Add(new ListItem(Html.SnippetLiteral("Knowledge Base Default Search Filter Text", "All Articles"), string.Empty)); Subject.Visible = true; } }
/// <inheritdoc /> protected override void AddAttributesToRender(HtmlTextWriter writer) { long uid = 0; long.TryParse(Uid, out uid); if (Uid == "0" && Uid != "profileowner" && Uid != "loggedinuser") { throw new MissingRequiredAttribute("FbUserID", Uid); } writer.AddAttribute("uid", Uid.ToString(CultureInfo.InvariantCulture)); if (!Linked) { writer.AddAttribute("linked", FbmlConstants.FALSE); } if (FirstNameOnly) { writer.AddAttribute("firstnameonly", FbmlConstants.TRUE); } else if (LastNameOnly) { writer.AddAttribute("lastnameonly", FbmlConstants.TRUE); } if (Possessive) { writer.AddAttribute("possessive", FbmlConstants.TRUE); } if (Reflexive) { writer.AddAttribute("reflexive", FbmlConstants.TRUE); } if (ShowNetwork) { writer.AddAttribute("shownetwork", FbmlConstants.TRUE); } if (!UseYou) { writer.AddAttribute("useyou", FbmlConstants.FALSE); } if (!string.IsNullOrEmpty(DisplayIfUserIsInaccessible)) { writer.AddAttribute("ifcantsee", DisplayIfUserIsInaccessible, true); } if (CapitalizeYou) { writer.AddAttribute("capitalize", FbmlConstants.TRUE); } if (SubjectId != 0) { writer.AddAttribute("subjectid", SubjectId.ToString(CultureInfo.InvariantCulture)); } base.AddAttributesToRender(writer); }
//--------------------------------------------------------------------------------------------------------------------- public override void Store() { string sql = null; string valuesPrefix = String.Format("{0}, {1}{2}", Service.Id, StringUtils.EscapeSql(ServiceParameter.Name), SubjectType == ConfigurationSubjectType.Group || SubjectType == ConfigurationSubjectType.User ? ", " + SubjectId.ToString() : String.Empty ); if (values != null) { if (ServiceParameter.IsConstant) { sql = String.Format("({0}, {1})", valuesPrefix, StringUtils.EscapeSql(values) ); } else { string pair; int line = 0; StringReader valueReader = new StringReader(values); while ((pair = valueReader.ReadLine()) != null) { line++; int pos = pair.IndexOf('='); string caption = pair.Substring(0, pos).Trim(); string value = pair.Substring(pos + 1).Trim(); if (sql == null) { sql = String.Empty; } else { sql += ", "; } sql += String.Format("({0}, {1}, {2})", valuesPrefix, StringUtils.EscapeSql(caption), StringUtils.EscapeSql(value) ); } } } context.Execute( String.Format("DELETE FROM serviceconfig WHERE id_service={0} AND name={1} AND {2}", Service.Id, StringUtils.EscapeSql(ServiceParameter.Name), SubjectType == ConfigurationSubjectType.Group ? "id_grp=" + SubjectId : SubjectType == ConfigurationSubjectType.User ? "id_usr="******"true" ) ); if (sql != null) { sql = String.Format("INSERT INTO serviceconfig (id_service, name{0}, {1}value) VALUES {2};", SubjectType == ConfigurationSubjectType.Group ? ", id_grp" : SubjectType == ConfigurationSubjectType.User ? ", id_usr" : String.Empty, ServiceParameter.IsConstant ? String.Empty : "caption, ", sql ); //context.AddError(sql); context.Execute(sql); } }