void addRow(DropDownList qd, string filter, RevisionStateRequest request, NodeStateRequest nodeRequest, bool toNotFrom, string textPlural, string textSingle) { int n = getRevisionCount(request, nodeRequest, toNotFrom); ListItem listItem = new ListItem(); listItem.Value = filter; if (n > 0) { listItem.Text = n + " " + (n == 1 ? textSingle : textPlural); } else { listItem.Attributes.Add("style", "color:gray;"); listItem.Text = n + " " + textPlural; } qd.Items.Add(listItem); }
AqlQuery getRevisionQuery(RevisionStateRequest request, NodeStateRequest nodeRequest, bool toNotFrom) { var q = WAFContext.Session.CreateQuery(); q.IncludeHiddenNodes = true; q.IncludeUnpublished = true; AqlAliasContentBase alias = new AqlAliasContentBase(); alias.IncludeDeletedNodes = true; alias.IncludeUnpublished = true; q.From(alias); if (nodeRequest == NodeStateRequest.None) { alias.IgnoreSessionCulture = true; alias.IgnoreSessionRevision = true; q.Where(alias.ContentStateRequest == (int)request); q.Where(alias.IsDerived == false); switch (request) { case RevisionStateRequest.AwaitingDeleteApproval: q.Where(alias.Revision == (int)RevisionState.Published); break; case RevisionStateRequest.AwaitingPublicationApproval: q.Where(alias.Revision == (int)RevisionState.Preliminary); break; case RevisionStateRequest.AwaitingUnPublicationApproval: q.Where(alias.Revision == (int)RevisionState.Published); break; default: break; } } else { q.Where(alias.NodeStateRequest == (int)nodeRequest); } if (toNotFrom) { q.WhereMemberOf(alias.PublishGroupId); } else { if (nodeRequest == NodeStateRequest.None) { q.Where(alias.ContentStateRequestById == WAFContext.Session.UserId); } else { q.Where(alias.NodeStateRequestById == WAFContext.Session.UserId); } } q.Select(alias); q.RetrieveTotalCount = true; return q; }
int getRevisionCount(RevisionStateRequest request, NodeStateRequest nodeRequest, bool toNotFrom) { return getRevisionQuery(request, nodeRequest, toNotFrom).Execute().TotalRowCount; }
void addRow(QueryData qd, string filter, RevisionStateRequest request, NodeStateRequest nodeRequest, bool toNotFrom, string textPlural, string textSingle) { int n = getRevisionCount(request, nodeRequest, toNotFrom); if (n > 0) { qd.AddRow(filter, "<strong>" + n + "</strong>", "<span style=\" font-weight:bold;\">" + (n == 1 ? textSingle : textPlural) + "</span>"); } else { qd.AddRow(filter, "<span style=\"color:gray;\">0</span>", "<span style=\"color:gray;\">" + textPlural + "</span>"); } }