/// <summary> /// The render service options. /// </summary> /// <param name="output"> /// The output. /// </param> /// <param name="source"> /// The source. /// </param> /// <param name="controlId"> /// The control id. /// </param> protected void RenderServiceOptions(HtmlTextWriter output, string source, string controlId) { // TODO: Ed, this appears to be very CW centric, can we make it more generalized in name? var current = Client.GetItemNotNull(this.ItemID, global::Sitecore.Context.ContentDatabase); var siteItem = current.Axes.SelectSingleItem("ancestor-or-self::*[contains(@@templatename, 'Site')]"); var luceneQuery = source.Replace("lucene:", string.Empty); var qh = new QueryStringHelper(luceneQuery); var templateid = qh.GetByName("templateid"); var fullSiteSearch = false; if (qh.NameExists("fullsite")) { fullSiteSearch = qh.GetByName<bool>("fullsite"); } using (output.RenderTag(HtmlTextWriterTag.Script, new HtmlAttribute("type", "text/javascript"))) { output.WriteLine("jQuery(\"#{0}\").tokenInput(\"/tokenizedlisthandler.axd\", ".FormatWith(controlId)); output.WriteLine("{theme: \"facebook\", "); output.WriteLine("tokenDelimiter: \"|\", "); output.WriteLine("preventDuplicates: true, "); output.WriteLine("makeSortable: true, "); output.WriteLine("minChars: 3,"); output.WriteLine("luceneFullSite: \"{0}\",".FormatWith(fullSiteSearch)); output.WriteLine("luceneLanguage: \"{0}\",".FormatWith(this.ItemLanguage)); if (siteItem != null && !fullSiteSearch) { output.WriteLine("luceneSiteName: \"{0}\",".FormatWith(siteItem.Key)); } if (!string.IsNullOrEmpty(templateid)) { output.WriteLine("luceneTemplateId: \"{0}\",".FormatWith(templateid)); } output.WriteLine("parseName: function(item) { "); output.WriteLine(" if (typeof item.site !== \"undefined\") { "); output.WriteLine(" if (item.site == null) { "); output.WriteLine(" return \"Unmatched People >\" + item.name; "); output.WriteLine(" } else {"); output.WriteLine(" return item.site + \" >\" + item.name; "); output.WriteLine(" } "); output.WriteLine(" } "); output.WriteLine(" return item.name; "); output.WriteLine("}, "); output.WriteLine("disabled: " + this.Disabled.ToString().ToLowerInvariant()); if (fullSiteSearch) { this.RenderValueWithSite(output); } else { this.RenderValue(output); } output.WriteLine("});"); } }