protected
override
void
InitializeControls(GenericContainer container, IContentViewDefinition definition)
{
// ensure a valid definition is passed
var masterDefinition = definition
as
IContentViewMasterDefinition;
if
(masterDefinition ==
null
)
return
;
// retrieve locations from the manager
var manager = LocationsManager.GetManager(
this
.Host.ControlDefinition.ProviderName);
var query = manager.GetLocations();
// check for filters on the locations query
if
(masterDefinition.AllowUrlQueries.HasValue && masterDefinition.AllowUrlQueries.Value)
{
query =
this
.EvaluateUrl(query,
"Date"
,
"PublicationDate"
,
this
.Host.UrlEvaluationMode,
this
.Host.UrlKeyPrefix);
query =
this
.EvaluateUrl(query,
"Author"
,
"Owner"
,
this
.Host.UrlEvaluationMode,
this
.Host.UrlKeyPrefix);
query =
this
.EvaluateUrl(query,
"Taxonomy"
,
""
,
typeof
(LocationItem),
this
.Host.UrlEvaluationMode,
this
.Host.UrlKeyPrefix);
}
// modify pager based on query results
int
? totalCount = 0;
int
? itemsToSkip = 0;
if
(masterDefinition.AllowPaging.HasValue && masterDefinition.AllowPaging.Value)
itemsToSkip =
this
.GetItemsToSkipCount(masterDefinition.ItemsPerPage,
this
.Host.UrlEvaluationMode,
this
.Host.UrlKeyPrefix);
// culture for Urls in pager
CultureInfo uiCulture =
null
;
if
(Config.Get<ResourcesConfig>().Multilingual)
uiCulture = System.Globalization.CultureInfo.CurrentUICulture;
// check for additional filters set by the definition
var filterExpression = String.Empty;
// modify the query with everything from above
query = Telerik.Sitefinity.Data.DataProviderBase.SetExpressions(
query,
filterExpression,
masterDefinition.SortExpression,
uiCulture,
itemsToSkip,
masterDefinition.ItemsPerPage,
ref
totalCount);
this
.IsEmptyView = (totalCount == 0);
// display results
if
(totalCount == 0)
this
.LocationsListControl.Visible =
false
;
else
{
this
.ConfigurePager(totalCount.Value, masterDefinition);
this
.LocationsListControl.DataSource = query.ToList();
}
}