I've researched this a bit myself and come up with the following answer. If there's a better, more general way of answering this for every dialog, or if anyone has more specific information about how everything is set up please don't hesitate to answer!
As of Sitecore 8.1 Update 3 (I'm not sure how many versions this is applicable for), a certain set of dialoges are defined in the core database under the following location: /sitecore/client/Applications/Dialogs
(Item ID: {648AFADA-20C7-413A-9636-44703A16DFCF}
). Highlighted in the image below is the dialog that I'm specifically asking about: SelectMediaDialog
(Item ID: {ACA0FE9D-0FFD-4043-96DC-B702D1B44F39}
).
Under every node that has a template of Speak-DialogPage
, there's a SearchConfigs
folder that resides under each Speak-DialogPage
's PageSettings
node.
The SearchConfigs
folder contains a set of items that are used to define which search facets are available. The fields on these items are "predefined" and have explicit hardcoded meaning. For example the RecentlyUploadedByMe
item which defines the Recently uploaded by me
facet seen in the first screenshot has the following fields set:
- The
Base Templates
field defines which templates to search on, and is currently set with all known media types:
- Certain filters that limit the search to items created by the current user and items created within the last seven days.
The latter set of "Date" and "User" fields appear to be used by the Sitecore.ItemWebApi.Pipelines.Search.SetSearchParameters
(in "Sitecore.Speak.ItemWebApi.dll") processor. This processor will check for that particular set fields and then modify the search query in the appropriate fashion. So if you wanted to extend the or modify the available behavior, you'd have to extend the SearchPanel Config
template, create your own processor and then patch it in. Here's the currently decompiled code for the Sitecore.ItemWebApi.Pipelines.Search.SetSearchParameters
processor, so you can see it in action:
public override void Process(SearchArgs args)
{
Assert.ArgumentNotNull((object) args, "args");
Item searchDescriptor = args.SearchDescriptor;
if (searchDescriptor == null)
return;
this.SetTemplateFilter(args);
if (searchDescriptor["UpdatedWithin7Days"] == "1")
{
DateTime to = DateTime.UtcNow.AddDays(1.0);
DateTime from = DateTime.UtcNow.AddDays(-7.0);
args.Queryable = Queryable.Where<ConvertedSearchResultItem>(args.Queryable, (Expression<Func<ConvertedSearchResultItem, bool>>) (i => MethodExtensions.Between<DateTime>(i.Updated, from, to, Inclusion.Both)));
}
if (searchDescriptor["CreatedWithin7Days"] == "1")
{
DateTime to = DateTime.UtcNow.AddDays(1.0);
DateTime from = DateTime.UtcNow.AddDays(-7.0);
args.Queryable = Queryable.Where<ConvertedSearchResultItem>(args.Queryable, (Expression<Func<ConvertedSearchResultItem, bool>>) (i => MethodExtensions.Between<DateTime>(i.CreatedDate, from, to, Inclusion.Both)));
}
if (searchDescriptor["UpdatedByCurrentUser"] == "1")
{
string userName = Context.GetUserName().Replace("\\", string.Empty);
args.Queryable = Queryable.Where<ConvertedSearchResultItem>(args.Queryable, (Expression<Func<ConvertedSearchResultItem, bool>>) (i => i["parsedcreatedby"] == userName));
}
if (!string.IsNullOrEmpty(searchDescriptor["UpdatedBySpecificUser"]))
{
string userName = searchDescriptor["UpdatedBySpecificUser"].Replace("\\", string.Empty);
args.Queryable = Queryable.Where<ConvertedSearchResultItem>(args.Queryable, (Expression<Func<ConvertedSearchResultItem, bool>>) (i => i["parsedcreatedby"] == userName));
}
if (searchDescriptor["CreatedByCurrentUser"] == "1")
{
string userName = Context.GetUserName().Replace("\\", string.Empty);
args.Queryable = Queryable.Where<ConvertedSearchResultItem>(args.Queryable, (Expression<Func<ConvertedSearchResultItem, bool>>) (i => i["parsedcreatedby"] == userName));
}
if (!string.IsNullOrEmpty(searchDescriptor["CreatedBySpecificUser"]))
{
string userName = searchDescriptor["CreatedBySpecificUser"].Replace("\\", string.Empty);
args.Queryable = Queryable.Where<ConvertedSearchResultItem>(args.Queryable, (Expression<Func<ConvertedSearchResultItem, bool>>) (i => i["parsedcreatedby"] == userName));
}
string queryString1 = WebUtil.GetQueryString("pageSize", searchDescriptor["PageSize"]);
if (!string.IsNullOrEmpty(queryString1))
args.PageSize = MainUtil.GetInt(queryString1, 0);
string queryString2 = WebUtil.GetQueryString("pageIndex");
if (string.IsNullOrEmpty(queryString2))
return;
args.PageIndex = MainUtil.GetInt(queryString2, 0);
}