예제 #1
0
        protected override void CreateChildControls()
        {
            string wpPageUrl, otherPartID = Request.QueryString ["wpid"], viewRawID, tmpCssClass = "c" + ProductPage.GuidLower(Guid.NewGuid(), false), propVal, nuPropVal, srcPageUrl = string.Empty;

            ProductPage.LicInfo li = ProductPage.LicInfo.Get(null);
            bool       hasInvalidParams = false, isInvalidParam, isB = ProductPage.LicEdition(ctx, li, 2);
            int        itemID = 0;
            object     sm;
            XmlElement elem;
            Panel      panel                    = HeaderWebParts;
            ArrayList  filters                  = null;
            Hashtable  fht                      = null;
            Guid       viewID                   = Guid.Empty;
            SPLimitedWebPartManager wpMan       = null;
            List <SystemWebPart>    parts       = new List <SystemWebPart> ();
            List <string>           queryString = new List <string> ();
            TitleBarWebPart         tbwp;
            SystemWebPart           pwp;

            ctx = ProductPage.GetContext();
            foreach (string k in Request.QueryString.AllKeys)
            {
                if (!string.IsNullOrEmpty(k))
                {
                    if (!(isInvalidParam = (k.StartsWith("FilterField", StringComparison.InvariantCultureIgnoreCase) || k.StartsWith("FilterValue", StringComparison.InvariantCultureIgnoreCase))))
                    {
                        if (!isB)
                        {
                            foreach (string [] arr in new string [] [] { PrintZenMenuItem.CalendarParams, PrintZenMenuItem.FolderParams, PrintZenMenuItem.PageParams, PrintZenMenuItem.SortParams })
                            {
                                if (isInvalidParam = (Array.IndexOf <string> (arr, k) >= 0))
                                {
                                    break;
                                }
                            }
                        }
                    }
                    if (isInvalidParam)
                    {
                        hasInvalidParams = true;
                    }
                    else
                    {
                        queryString.Add(k + "=" + Server.UrlEncode(Request.QueryString [k]));
                        if ((!"rpzopt".Equals(k, StringComparison.InvariantCultureIgnoreCase)) && !"r".Equals(k, StringComparison.InvariantCultureIgnoreCase))
                        {
                            PhVals ["QueryString_" + k] = Request.QueryString [k];
                        }
                    }
                }
            }
            if ((!string.IsNullOrEmpty(Request.QueryString ["t"])) && (Title != Request.QueryString ["t"]))
            {
                Title = Request.QueryString ["t"];
            }
            if (hasInvalidParams)
            {
                Response.Redirect(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf('?')) + "?" + string.Join("&", queryString.ToArray()), true);
            }
            else if (!ProductPage.isEnabled)
            {
                MainWebPart.Controls.Add(new LiteralControl(ProductPage.GetResource("NotEnabled", "", ProductPage.GetTitle())));
            }
            else
            {
                if ((!string.IsNullOrEmpty(viewRawID = Request.QueryString ["View"])) && !int.TryParse(viewRawID, out itemID))
                {
                    viewID = ProductPage.GetGuid(viewRawID);
                }
                if (ProductPage.LicEdition(ctx, li, 4))
                {
                    if (!string.IsNullOrEmpty(Request.QueryString ["fs"]))
                    {
                        filters = JSON.JsonDecode(Request.QueryString ["fs"]) as ArrayList;
                    }
                    if (!string.IsNullOrEmpty(Request.QueryString ["fj"]))
                    {
                        fht = JSON.JsonDecode(Request.QueryString ["fj"]) as Hashtable;
                    }
                }
                foreach (IDictionary action in Actions)
                {
                    if (Request.QueryString ["a"].Equals(action ["id"]))
                    {
                        try {
                            if ((action ["sm"] is bool) && (bool)action ["sm"])
                            {
                                if (!exAsmTried)
                                {
                                    exAsmTried = true;
                                    try {
                                        exRefl = new Reflector(exAsm = Assembly.Load("System.Web.Extensions, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35"));
                                        exType = exAsm.GetType("System.Web.UI.ScriptManager", false, true);
                                    } catch {
                                    }
                                }
                                if ((exRefl != null) && (exType != null) && (Form != null) && ((sm = exRefl.Call(exType, "GetCurrent", this)) == null))
                                {
                                    theLit.Controls.AddAt(0, (sm = exRefl.New(exType.FullName)) as Control);
                                }
                            }
                            PhVals ["List_Title"]    = string.Empty;
                            PhVals ["Item_Title"]    = string.Empty;
                            PhVals ["View_Title"]    = string.Empty;
                            PhVals ["Context_Title"] = string.Empty;
                            foreach (DictionaryEntry prop in action)
                            {
                                if (prop.Value is string)
                                {
                                    PhVals ["PrintAction_" + prop.Key] = prop.Value + string.Empty;
                                }
                            }
                            AutoPrint        = PrintZenMenuItem.GetBool(action, "dp");
                            ShowPlaceholders = PrintZenMenuItem.GetBool(action, "sp");
                            ShowToolbar      = PrintZenMenuItem.GetBool(action, "tb");
                            site             = new SPSite(ctx.Site.ID);
                            web = site.OpenWeb(ctx.Web.ID);
                            if ((!string.IsNullOrEmpty(wpPageUrl = (action ["wp"] + string.Empty))) && ProductPage.LicEdition(ctx, li, 4))
                            {
                                try {
                                    if ((wpPageUrl.StartsWith("http:", StringComparison.InvariantCultureIgnoreCase) || wpPageUrl.StartsWith("https:", StringComparison.InvariantCultureIgnoreCase)) && !wpPageUrl.StartsWith(web.Url.TrimEnd() + '/', StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        site2 = new SPSite(wpPageUrl);
                                        web2  = site2.OpenWeb();
                                    }
                                    if ((wpMan = ((web2 == null) ? web : web2).GetLimitedWebPartManager(wpPageUrl, PersonalizationScope.Shared)) == null)
                                    {
                                        throw new Exception("xyz");
                                    }
                                } catch (Exception ex) {
                                    Errors.Add(new Exception(ProductPage.GetProductResource("WebPartPageNotFound", wpPageUrl.ToUpperInvariant()), "xyz".Equals(ex.Message) ? null : ex));
                                }
                            }
                            if (!isB)
                            {
                                panel.Controls.Add(new LiteralControl("<div class=\"" + tmpCssClass + "\">Powered by <b>SharePoint-Tools.net/PrintZen</b></div><style type=\"text/css\"> ." + tmpCssClass + " { text-align: center; font-size: " + new Random().Next(24, 37) + "px; display: none; padding-bottom: 12px; } @media print { div." + tmpCssClass + " { display: block !important; } } </style>"));
                            }
                            if (wpMan == null)
                            {
                                if (!string.IsNullOrEmpty(otherPartID))
                                {
                                    AddOtherWebPart(Request.QueryString ["l"], otherPartID);
                                }
                                else if (itemID > 0)
                                {
                                    AddListFormWebPart(action, itemID);
                                }
                                else if (Guid.Empty.Equals(viewID) && !string.IsNullOrEmpty(viewRawID))
                                {
                                    if (isB)
                                    {
                                        AddPeopleWebPart(action, viewRawID, filters, fht);
                                    }
                                }
                                else
                                {
                                    AddListViewWebPart(action, viewID, filters, fht);
                                }
                            }
                            else
                            {
                                Placeholders = true;
                                foreach (SystemWebPart wp in ProductPage.TryEach <SystemWebPart> (wpMan.WebParts, false, delegate(Exception ex) {
                                    Errors.Add(ex);
                                }, true))
                                {
                                    if ((tbwp = wp as TitleBarWebPart) == null)
                                    {
                                        parts.Add(wp);
                                    }
                                    else
                                    {
                                        PhVals ["TitleBar_Caption"]     = tbwp.HeaderCaption;
                                        PhVals ["TitleBar_Description"] = tbwp.HeaderDescription;
                                        PhVals ["TitleBar_Image"]       = tbwp.Image;
                                        PhVals ["TitleBar_Title"]       = tbwp.HeaderTitle;
                                        if (PrintZenMenuItem.GetBool(action, "st"))
                                        {
                                            parts.Add(tbwp);
                                        }
                                    }
                                }
                                parts.Sort((wp1, wp2) => {
                                    return(wp1.ZoneIndex.CompareTo(wp2.ZoneIndex));
                                });
                                foreach (SystemWebPart wp in parts)
                                {
                                    if (("PRINTZEN_LIST_VIEW".Equals(wp.Title.Trim(), StringComparison.InvariantCultureIgnoreCase)) || ("PRINTZEN_TARGET".Equals(wp.Title.Trim(), StringComparison.InvariantCultureIgnoreCase)))
                                    {
                                        if (!string.IsNullOrEmpty(otherPartID))
                                        {
                                            AddOtherWebPart(Request.QueryString ["l"], otherPartID);
                                        }
                                        else if (itemID > 0)
                                        {
                                            AddListFormWebPart(action, itemID);
                                        }
                                        else if (Guid.Empty.Equals(viewID) && !string.IsNullOrEmpty(viewRawID))
                                        {
                                            if (isB)
                                            {
                                                AddPeopleWebPart(action, viewRawID, filters, fht);
                                            }
                                        }
                                        else
                                        {
                                            AddListViewWebPart(action, viewID, filters, fht);
                                        }
                                        panel = FooterWebParts;
                                    }
                                    else
                                    {
                                        try {
                                            InitWebPart(wp);
                                            panel.Controls.Add(wp);
                                        } catch (Exception ex) {
                                            Errors.Add(ex);
                                        }
                                    }
                                }
                                foreach (Panel p in new Panel [] { HeaderWebParts, MainWebPart, FooterWebParts })
                                {
                                    foreach (Control ctl in p.Controls)
                                    {
                                        if ((pwp = ctl as SystemWebPart) != null)
                                        {
                                            foreach (PropertyInfo propInfo in pwp.GetType().GetProperties())
                                            {
                                                if (propInfo.CanRead && propInfo.CanWrite)
                                                {
                                                    if (propInfo.PropertyType == typeof(string))
                                                    {
                                                        try {
                                                            propVal = propInfo.GetValue(pwp, null) as string;
                                                        } catch {
                                                            propVal = null;
                                                        }
                                                        if ((!string.IsNullOrEmpty(propVal)) && (propVal != (nuPropVal = Replace(propVal))))
                                                        {
                                                            propInfo.SetValue(pwp, nuPropVal, null);
                                                        }
                                                    }
                                                    else if (propInfo.PropertyType == typeof(XmlElement))
                                                    {
                                                        try {
                                                            elem = propInfo.GetValue(pwp, null) as XmlElement;
                                                        } catch {
                                                            elem = null;
                                                        }
                                                        if ((elem != null) && Replace(elem))
                                                        {
                                                            try {
                                                                propInfo.SetValue(pwp, elem, null);
                                                            } catch {
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                        } catch (Exception ex) {
                            Errors.Add(ex);
                            break;
                        }
                    }
                }
        public static IDictionary GetControls(HttpContext context, Page page, string ownerID, string check, string siteUrl, Control parent)
        {
            string thisID, clickScript, fj = string.Empty;
            bool   isSep1, isSep2, hasSep1, hasSep2, includeFilters = false, isPeop, origPage, doZones;
            int    zoneCount;
            List <KeyValuePair <string, KeyValuePair <List <KeyValuePair <string, CamlOperator> >, bool> > > effectiveFilters = null;

            Type []           types = new Type [] { typeof(WebPartVerb) }, rollTypes = new Type [] { typeof(IDictionary) };
            Type              wpType;
            OrderedDictionary dict = new OrderedDictionary(), ctl, items = null, actionItem, actionItems = null;
            KeyValuePair <JsonSchemaManager, JsonSchemaManager> jsonMans;

            JsonSchemaManager.Schema ctlSchema, actSchema;
            WebPartManager           wpMan = WebPartManager.GetCurrentWebPartManager(page);
            Reflector                   refl;
            SPList                      list;
            List <SystemWebPart>        parts;
            IEnumerable <SystemWebPart> partsEnum;
            WebPartVerb                 wpVerb;

            using (ProductPage ppage = new ProductPage()) {
                jsonMans = JsonSchemaManager.TryGet(ppage, null, true, true, null);
                foreach (JsonSchemaManager jman in new JsonSchemaManager [] { jsonMans.Key, jsonMans.Value })
                {
                    if (jman != null)
                    {
                        if (((ctlSchema = jman.AllSchemas ["PrintControls"]) != null) && ((actSchema = jman.AllSchemas ["PrintActions"]) != null))
                        {
                            foreach (IDictionary launcher in ctlSchema.Instances)
                            {
                                if (launcher != null)
                                {
                                    if (JsonSchemaManager.Bool(launcher [check], true))
                                    {
                                        ctl = MakeSubControl(ownerID + "_" + launcher ["id"], JsonSchemaManager.GetDisplayName(launcher, ctlSchema.Name, false), ctlSchema.GetInstanceDescription(launcher), string.Empty, siteUrl + "/_layouts/images/roxority_PrintZen/printer32.png", items = new OrderedDictionary());
                                        foreach (IDictionary action in actSchema.Instances)
                                        {
                                            if (action != null)
                                            {
                                                items [thisID = (ctl ["id"] + "_" + action ["id"])] = actionItem = MakeSubControl(thisID, JsonSchemaManager.GetDisplayName(action, "PrintActions", false), ctlSchema.GetInstanceDescription(action), string.Empty, siteUrl + "/_layouts/images/lg_icxps.gif", actionItems = new OrderedDictionary());
                                                hasSep1   = hasSep2 = isSep1 = isSep2 = false;
                                                zoneCount = -1;
                                                if (wpMan != null)
                                                {
                                                    if (hasSep2 = hasSep1 = (JsonSchemaManager.Bool(launcher ["pp"], true) && !"n".Equals(action ["mpp"])))
                                                    {
                                                        actionItems [thisID + "_pp"] = MakeSubControl(thisID + "_pp", ProductPage.GetProductResource("PrintPageContent"), ProductPage.GetProductResource("PrintPageContentDesc"), clickScript = PrintZenMenuItem.GetClickScript(context, ownerID, siteUrl, string.Empty, action, SPContext.Current.Web, false, false, null, null, true, false, null, null, Guid.Empty, null, page, false), siteUrl + "/_layouts/images/lg_icgen.gif", null);
                                                    }
                                                    if (JsonSchemaManager.Bool(launcher ["pw"], true) && ((partsEnum = ProductPage.TryEach <SystemWebPart> (wpMan.WebParts)) != null))
                                                    {
                                                        parts = new List <SystemWebPart> (partsEnum);
                                                        parts.Sort((wp1, wp2) => {
                                                            WebPartZoneBase zone1, zone2;
                                                            if ((wp1 == null) && (wp2 == null))
                                                            {
                                                                return(0);
                                                            }
                                                            if (wp1 == null)
                                                            {
                                                                return(-1);
                                                            }
                                                            if (wp2 == null)
                                                            {
                                                                return(1);
                                                            }
                                                            if (((zone1 = wp1.Zone) == null) || ((zone2 = wp2.Zone) == null))
                                                            {
                                                                return((wp1.ZoneIndex == wp2.ZoneIndex) ? wp1.TabIndex.CompareTo(wp2.TabIndex) : wp1.ZoneIndex.CompareTo(wp2.ZoneIndex));
                                                            }
                                                            return((zone1.TabIndex == zone2.TabIndex) ? wp1.ZoneIndex.CompareTo(wp2.ZoneIndex) : zone1.TabIndex.CompareTo(zone2.TabIndex));
                                                        });
                                                        foreach (SystemWebPart wp in parts)
                                                        {
                                                            refl   = new Reflector((wpType = wp.GetType()).Assembly);
                                                            list   = (("Microsoft.SharePoint.WebPartPages.XsltListViewWebPart".Equals(wpType.FullName) || (wp is ListViewWebPart)) ? ((wp is ListViewWebPart) ? (refl.Get(wp, "List") as SPList) : ((SPView)refl.Get(wp, "ContextView")).ParentList) : null);
                                                            isPeop = ((wpType.FullName == "roxority_RollupZen.RollupWebPart") || (wpType.FullName == "roxority_PeopleZen.roxority_UserListWebPart"));
                                                            if (IsPartSupported(action, wp, isPeop, list, out origPage))
                                                            {
                                                                if (hasSep1 && !isSep1)
                                                                {
                                                                    isSep1 = true;
                                                                    actionItems [thisID + "_sep1"] = null;
                                                                }
                                                                hasSep2 = true;
                                                                if (isPeop && (!origPage) && ((wpVerb = refl.Call(wp, "GetPrintVerb", rollTypes, new object [] { action }) as WebPartVerb) != null))
                                                                {
                                                                    clickScript = wpVerb.ClientClickHandler + string.Empty;
                                                                }
                                                                else if ((list != null) && !origPage)
                                                                {
                                                                    clickScript = string.Empty;
                                                                    PrintZenMenuItem.GetFilterInfo(action, "PrintActions", ref clickScript, wp, page, ref includeFilters, ref fj, ref effectiveFilters);
                                                                    if (string.IsNullOrEmpty(clickScript))
                                                                    {
                                                                        clickScript = PrintZenMenuItem.GetClickScript(context, ownerID, siteUrl, string.Empty, action, SPContext.Current.Web, JsonSchemaManager.Bool(action ["view"], true), includeFilters, effectiveFilters, fj, true, false, list, null, ProductPage.GetGuid(refl.Get(wp, "ViewGuid") + string.Empty), PrintZenMenuItem.GetAllPageParams(context, true, null), parent, origPage);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    clickScript = PrintZenMenuItem.GetClickScript(context, ownerID, siteUrl, string.Empty, action, SPContext.Current.Web, false, false, null, null, true, false, null, null, ProductPage.GetGuid(wp.ID.Substring(2).Replace('_', '-')), PrintZenMenuItem.GetAllPageParams(context, true, null), parent, origPage);
                                                                }
                                                                actionItems [thisID + "_" + wp.ID] = MakeSubControl(thisID + "_" + wp.ID, wp.DisplayTitle, GetPartDesc(wp, refl), clickScript, siteUrl + "/_layouts/roxority_PrintZen/mash.tl.aspx?op=imgoverlay&backimg=" + HttpUtility.UrlEncode("/_layouts/images/roxority_PrintZen/printer32.png") + "&overlay=" + HttpUtility.UrlEncode(string.IsNullOrEmpty(wp.TitleIconImageUrl) ? (string.IsNullOrEmpty(wp.CatalogIconImageUrl) ? "/_layouts/images/itobject.gif" : wp.CatalogIconImageUrl) : wp.TitleIconImageUrl) + "&r=" + ppage.Rnd.Next(), null);
                                                            }
                                                        }
                                                    }
                                                    if (doZones = (JsonSchemaManager.Bool(launcher ["pz"], true) && (!"n".Equals(action ["mwz"])) && ((!JsonSchemaManager.Bool(launcher ["pp"], true)) || (((zoneCount = wpMan.Zones.Count) > 1)))))
                                                    {
                                                        if (zoneCount > 0)
                                                        {
                                                            zoneCount = 0;
                                                            foreach (WebPartZoneBase zone in ProductPage.TryEach <WebPartZoneBase> (wpMan.Zones))
                                                            {
                                                                if (zone.WebParts.Count > (JsonSchemaManager.Bool(launcher ["pw"], true) ? 1 : 0))
                                                                {
                                                                    zoneCount++;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    if (doZones && ((zoneCount < 0) || (zoneCount > 1)))
                                                    {
                                                        foreach (WebPartZoneBase zone in ProductPage.TryEach <WebPartZoneBase> (wpMan.Zones))
                                                        {
                                                            if (zone.WebParts.Count > (JsonSchemaManager.Bool(launcher ["pw"], true) ? 1 : 0))
                                                            {
                                                                if (hasSep2 && !isSep2)
                                                                {
                                                                    isSep2 = true;
                                                                    actionItems [thisID + "_sep2"] = null;
                                                                }
                                                                clickScript = PrintZenMenuItem.GetClickScript(context, ownerID, siteUrl, string.Empty, action, SPContext.Current.Web, false, false, null, null, true, false, null, null, Guid.Empty, null, zone, false);
                                                                actionItems [thisID + "_" + zone.ID] = MakeSubControl(thisID + "_" + zone.ID, ProductPage.GetProductResource("WebPartZone", zone.DisplayTitle), GetZoneDesc(zone), clickScript, siteUrl + "/_layouts/images/lg_icgen.gif", null);
                                                            }
                                                        }
                                                    }
                                                }
                                                if (actionItems.Count == 0)
                                                {
                                                    items.Remove(thisID);
                                                }
                                            }
                                        }
                                        if (items.Count > 0)
                                        {
                                            dict [launcher ["id"]] = ctl;
                                        }
                                    }
                                    if ((items != null) && (items.Count == 1))
                                    {
                                        foreach (DictionaryEntry entry in actionItems)
                                        {
                                            items [entry.Key] = entry.Value;
                                        }
                                        items.RemoveAt(0);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(dict);
        }
예제 #3
0
        internal void AddListViewWebPart(IDictionary action, Guid viewID, ArrayList filters, Hashtable fht)
        {
            string       viewXml, paging, sortProp = string.Empty, sortOrder = string.Empty;
            bool         expGrps = false;
            int          itemID;
            SPList       list;
            SPView       view = null;
            SPQuery      query;
            SPListItem   item;
            SPField      sortField;
            XmlNode      node;
            XmlDocument  doc = new XmlDocument();
            XmlAttribute att;
            SPFolder     folder = null;
            Dictionary <string, string> viewAtts = new Dictionary <string, string> ();
            ViewToolBar     viewToolBar;
            ListViewWebPart lvwp;

            try {
                list = web.Lists [new Guid(Request.QueryString ["l"])];
                PhVals ["List_Title"] = list.Title;
                if (string.IsNullOrEmpty(Title))
                {
                    Title = list.Title;
                }
                try {
                    view = list.Views [viewID];
                } catch {
                }
                if (view == null)
                {
                    view = list.DefaultView;
                }
                PhVals ["View_Title"]    = view.Title;
                PhVals ["Context_Title"] = list.Title + ((string.IsNullOrEmpty(list.Title) || string.IsNullOrEmpty(view.Title)) ? string.Empty : " - ") + view.Title;
                if ((!string.IsNullOrEmpty(view.Title)) && (view.Title != Title))
                {
                    Title = Title + ((string.IsNullOrEmpty(Title) || string.IsNullOrEmpty(view.Title)) ? string.Empty : " - ") + view.Title;
                }
                if ((filters != null) && (filters.Count == 0))
                {
                    filters = null;
                }
                if (ProductPage.Is14)
                {
                    reflector.Set(view, "InlineEdit", "false");
                    reflector.Set(view, "TabularView", false);
                }
                viewAtts ["FailIfEmpty"] = "FALSE";
                viewAtts ["PageType"]    = "DIALOGVIEW";
                viewAtts ["RequiresClientIntegration"] = "FALSE";
                viewAtts ["Threaded"] = "FALSE";
                viewAtts ["Scope"]    = action ["f"] + string.Empty;
                query = BuildQuery(view, viewAtts, view.ViewFields);
                if (!string.IsNullOrEmpty(Request.QueryString ["RootFolder"]))
                {
                    try {
                        folder = list.RootFolder.SubFolders [Request.QueryString ["RootFolder"]];
                    } catch {
                    }
                }
                query.Folder = ((folder == null) ? list.RootFolder : folder);
                sortProp     = Request.QueryString ["SortField"] + string.Empty;
                sortOrder    = Request.QueryString ["SortDir"] + string.Empty;
                if (!string.IsNullOrEmpty(sortProp))
                {
                    doc.LoadXml("<Query>" + query.Query + "</Query>");
                    if ((node = doc.DocumentElement.SelectSingleNode("OrderBy")) == null)
                    {
                        node = doc.DocumentElement.AppendChild(doc.CreateElement("OrderBy"));
                    }
                    node.InnerXml = "<FieldRef Ascending=\"" + ("desc".Equals(sortOrder, StringComparison.InvariantCultureIgnoreCase) ? "FALSE" : "TRUE") + "\" Name=\"" + sortProp + "\"/>";
                    query.Query   = doc.DocumentElement.InnerXml;
                }
                if ((string.IsNullOrEmpty(sortProp) || string.IsNullOrEmpty(sortOrder)) && !string.IsNullOrEmpty(query.Query))
                {
                    doc.LoadXml("<Query>" + query.Query + "</Query>");
                    if ((node = doc.SelectSingleNode("/Query/OrderBy/FieldRef")) != null)
                    {
                        if (string.IsNullOrEmpty(sortProp) && ((att = node.Attributes.GetNamedItem("Name") as XmlAttribute) != null))
                        {
                            sortProp = att.Value;
                        }
                        if (string.IsNullOrEmpty(sortOrder) && ((att = node.Attributes.GetNamedItem("Ascending") as XmlAttribute) != null))
                        {
                            sortProp = ("true".Equals(att.Value, StringComparison.InvariantCultureIgnoreCase) ? "asc" : "desc");
                        }
                    }
                }
                if (string.IsNullOrEmpty(sortProp))
                {
                    sortProp = "Order";
                }
                if (string.IsNullOrEmpty(sortOrder))
                {
                    sortOrder = "asc";
                }
                sortField = ProductPage.GetField(list, sortProp);
                if (PrintZenMenuItem.GetBool(action, "p") && !string.IsNullOrEmpty(paging = string.Join("&", new List <string> (PrintZenMenuItem.GetAllPageParams(Context, true, "p_" + sortProp)).ConvertAll <string> ((pname) => {
                    try {
                        if (pname.Equals("p_" + sortProp, StringComparison.InvariantCultureIgnoreCase) && string.IsNullOrEmpty(Request.QueryString [pname]) && (sortField != null) && int.TryParse(Request.QueryString ["p_ID"], out itemID) && ((item = list.GetItemById(itemID)) != null))
                        {
                            return(pname + "=" + HttpUtility.UrlEncode(item [sortField.Id] + string.Empty));
                        }
                    } catch {
                    }
                    return(pname + "=" + HttpUtility.UrlEncode(Request.QueryString [pname]));
                }).ToArray()).Trim()))
                {
                    query.RowLimit = view.RowLimit;
                    query.ListItemCollectionPosition = new SPListItemCollectionPosition(paging);
                }
                else
                {
                    query.RowLimit = 0;
                }
                if (filters != null)
                {
                    doc.LoadXml(viewXml = view.SchemaXml);
                    if (!string.IsNullOrEmpty(viewXml = ProductPage.ApplyCore(list, viewXml, doc, filters, ref expGrps, false, fht, null)))
                    {
                        doc.LoadXml(viewXml);
                        if ((node = doc.DocumentElement.SelectSingleNode("Query")) != null)
                        {
                            query.Query = node.InnerXml;
                        }
                    }
                }
                if (ProductPage.Is14)
                {
                    reflector.Set(query, "ViewFieldsOnly", true);
                }
                InitWebPart(lvwp = new ListViewWebPart());
                lvwp.ID          = "ListViewWebPart";
                lvwp.WebId       = web.ID;
                reflector.Set(lvwp, "web", web);
                lvwp.ListName = ProductPage.GuidBracedUpper(list.ID);
                reflector.Set(lvwp, "list", list);
                lvwp.ViewFlag          = 9;
                lvwp.ViewContentTypeId = view.ContentTypeId.ToString();
                lvwp.ViewType          = (ViewType)Enum.Parse(typeof(ViewType), view.Type, true);
                lvwp.ViewGuid          = ProductPage.GuidBracedUpper(view.ID);
                reflector.Set(lvwp, "view", view);
                lvwp.ListViewXml = query.ViewXml;
                if (!string.IsNullOrEmpty(Request.QueryString ["RootFolder"]))
                {
                    reflector.Set(lvwp, "rootFolder", Request.QueryString ["RootFolder"]);
                }
                if (!string.IsNullOrEmpty(Request.QueryString ["FolderCTID"]))
                {
                    reflector.Set(lvwp, "folderCtId", Request.QueryString ["FolderCTID"]);
                }
                MainWebPart.Controls.Add(lvwp);
                PhVals ["WebPart_Title"] = lvwp.DisplayTitle;
                if ((viewToolBar = reflector.Get(lvwp, "ToolbarControl") as ViewToolBar) != null)
                {
                    viewToolBar.Visible = false;
                }
            } catch {
            }
        }