Exemplo n.º 1
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static string Search()
        {
            var dataSet = Get(
                searchIndexes: QueryStrings.Data("text").SearchIndexes(),
                offset: QueryStrings.Int("offset"),
                pageSize: Parameters.General.SearchPageSize);

            return(MainContainer(
                       text: QueryStrings.Data("text"),
                       offset: 0,
                       results: dataSet?.Tables["Main"].AsEnumerable(),
                       count: Rds.Count(dataSet)).ToString());
        }
        /// <summary>
        /// Fixed:
        /// </summary>
        public static string Search()
        {
            var ss      = new SiteSettings();
            var dataSet = Get(
                searchText: QueryStrings.Data("text"),
                dataTableName: "SearchResults",
                offset: QueryStrings.Int("offset"),
                pageSize: Parameters.General.SearchPageSize);

            return(MainContainer(
                       ss: ss,
                       text: QueryStrings.Data("text"),
                       offset: 0,
                       results: dataSet?.Tables["SearchResults"].AsEnumerable(),
                       count: Rds.Count(dataSet)).ToString());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static string SearchJson(Context context)
        {
            var ss         = new SiteSettings();
            var offset     = QueryStrings.Int("offset");
            var searchText = QueryStrings.Data("text");
            var dataSet    = Get(
                context: context,
                searchText: searchText,
                dataTableName: "SearchResults",
                offset: offset,
                pageSize: Parameters.General.SearchPageSize);
            var dataRows = dataSet?.Tables["SearchResults"].AsEnumerable();
            var res      = new ResponseCollection();

            return(offset == 0
                ? res
                   .ReplaceAll(
                       "#MainContainer",
                       MainContainer(
                           context: context,
                           ss: ss,
                           text: searchText,
                           offset: 0,
                           results: dataRows,
                           count: Rds.Count(dataSet)))
                   .Focus("#Search")
                   .ToJson()
                : res
                   .Append(
                       "#SearchResults",
                       new HtmlBuilder().Results(
                           context: context,
                           ss: ss,
                           text: searchText,
                           offset: offset,
                           dataRows: dataRows))
                   .Val(
                       "#SearchOffset",
                       (dataRows != null &&
                        dataRows.Any() &&
                        dataRows.Count() == Parameters.General.SearchPageSize
                            ? offset + Parameters.General.SearchPageSize
                            : -1).ToString())
                   .ToJson());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static string SearchJson()
        {
            var offset  = QueryStrings.Int("offset");
            var text    = QueryStrings.Data("text");
            var dataSet = Get(
                searchIndexes: text.SearchIndexes(),
                offset: offset,
                pageSize: Parameters.General.SearchPageSize);
            var results = dataSet?.Tables["Main"].AsEnumerable();
            var res     = new ResponseCollection();

            if (offset == 0)
            {
                res
                .ReplaceAll(
                    "#MainContainer",
                    MainContainer(
                        text: text,
                        offset: 0,
                        results: results,
                        count: Rds.Count(dataSet)))
                .Focus("#Search");
            }
            else
            {
                res
                .Append(
                    "#SearchResults",
                    new HtmlBuilder().Results(text: text, offset: offset, results: results))
                .Val(
                    "#SearchOffset",
                    (results != null &&
                     results.Any() &&
                     results.Count() == Parameters.General.SearchPageSize
                            ? offset + Parameters.General.SearchPageSize
                            : -1).ToString());
            }
            return(res.ToJson());
        }
Exemplo n.º 5
0
        private static string BackUrl(
            long siteId, long parentId, string referenceType, string siteReferenceType)
        {
            var controller = Routes.Controller();
            var referer    = HttpUtility.UrlDecode(Url.UrlReferrer());

            switch (controller)
            {
            case "admins":
                return(Locations.Top());

            case "versions":
                return(referer != null
                        ? referer
                        : Locations.Top());

            case "depts":
            case "groups":
            case "users":
                switch (Routes.Action())
                {
                case "new":
                case "edit":
                    return(Strings.CoalesceEmpty(
                               referer?.EndsWith("/new") == false
                                    ? referer
                                    : null,
                               Locations.Get(controller)));

                case "editapi":
                    return(referer != null
                                ? referer
                                : Locations.Top());

                default:
                    return(Locations.Get("Admins"));
                }

            default:
                switch (referenceType)
                {
                case "Sites":
                    switch (Routes.Action())
                    {
                    case "new":
                        return(Locations.ItemIndex(siteId));

                    case "edit":
                        switch (siteReferenceType)
                        {
                        case "Wikis":
                            return(Locations.ItemIndex(parentId));

                        default:
                            return(Locations.ItemIndex(siteId));
                        }

                    default:
                        return(Locations.ItemIndex(parentId));
                    }

                case "Wikis":
                    return(QueryStrings.Int("back") == 1 && !referer.IsNullOrEmpty()
                                ? referer
                                : Locations.ItemIndex(parentId));

                default:
                    switch (Routes.Action())
                    {
                    case "new":
                    case "edit":
                        return
                            (QueryStrings.Int("back") == 1 &&
                             !referer.IsNullOrEmpty()
                                            ? referer
                                            : Locations.Get(
                                 "Items",
                                 siteId.ToString(),
                                 Requests.ViewModes.GetBySession(siteId)));

                    default:
                        return(Locations.ItemIndex(parentId));
                    }
                }
            }
        }