17 using erminas.SmartAPI.CMS.Project.ContentClasses;
18 using erminas.SmartAPI.CMS.Project.Workflows;
19 using erminas.SmartAPI.Utils;
21 namespace erminas.SmartAPI.CMS.Project.Pages
25 string ToSearchItemString();
30 #region EqualityOperatorType enum
40 #region IPageSearchPredicate Members
42 public abstract string ToSearchItemString();
51 protected static string ToSearchItemStringInternal(
string key,
string value,
string @
operator)
53 const string BASIC_SEARCH_ITEM =
@"<SEARCHITEM key=""{0}"" value=""{1}"" operator=""{2}""/>";
54 return string.Format(BASIC_SEARCH_ITEM, key, value, @
operator);
60 #region OperatorType enum
79 public override string ToSearchItemString()
81 return ToSearchItemStringInternal(
"headline", Value, Operator ==
OperatorType.IsLike ?
"like" :
"contains");
96 public override string ToSearchItemString()
98 return ToSearchItemStringInternal(
"keyword", Value, EqualityOperatorToString(Operator));
109 Operator = @
operator;
113 public override string ToSearchItemString()
115 return ToSearchItemStringInternal(
"workflow", Workflow.Guid.ToRQLString(),
116 EqualityOperatorToString(Operator));
122 #region PageCategoryType enum
139 PageCategory = pageCategory;
142 public override string ToSearchItemString()
144 return ToSearchItemStringInternal(
"specialpages", PageCategory.ToString().ToLowerInvariant(),
"eq");
154 _contentClass = contentClass;
157 public override string ToSearchItemString()
159 return ToSearchItemStringInternal(
"contentclassguid", _contentClass.Guid.ToRQLString(),
"eq");
169 _contentClass = contentClass;
172 public override string ToSearchItemString()
174 return ToSearchItemStringInternal(
"contentclassguid", _contentClass.Guid.ToRQLString(),
"ne");
180 #region PageStatusType enum
186 WaitingForCorrection,
194 #region UserType enum
210 PageStatus = pageStatus;
214 public override string ToSearchItemString()
216 const string STATUS_ITEM =
@"<SEARCHITEM key=""pagestate"" value=""{0}"" users=""{1}"" />";
217 return string.Format(STATUS_ITEM, PageStatusTypeToString(PageStatus),
218 User ==
UserType.CurrentUser ?
"myself" :
"all");
221 private static string PageStatusTypeToString(PageStatusType pageStatus)
225 case PageStatusType.WaitingForCorrection:
226 return "waitingforcorrection";
227 case PageStatusType.WaitingForRelease:
228 return "waitingforrelease";
229 case PageStatusType.SavedAsDraft:
231 case PageStatusType.Released:
233 case PageStatusType.Resubmitted:
234 return "resubmitted";
235 case PageStatusType.InWorkflow:
236 return "pagesinworkflow";
239 throw new ArgumentException(String.Format(
"Unknown page status {0}", pageStatus));