protected override void RenderContents(HtmlTextWriter output)
        {
            var link = GetLink();

            output.Write(BundleHelper.HtmlScript(VirtualPathUtility.ToAbsolute(link), false, false));
        }
Example #2
0
 public static String GetPhysicalPathOfImg(String pVirtualPath)
 {
     return(System.Web.HttpContext.Current.Server.MapPath(VirtualPathUtility.ToAbsolute(pVirtualPath)));
 }
Example #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.Clear();
            context.Response.ContentType = "text/plain";
            Minifier minifier = new Minifier();

            if (JSType == API.JSType.HAP)
            {
                string       s  = "";
                StreamReader sr = File.OpenText(context.Server.MapPath("~/Scripts/hap.web.js.js"));
                while (!sr.EndOfStream)
                {
                    s += sr.ReadLine();
                }
                sr.Close();
                s = s.Replace("root: \"/hap/\",", "root: \"" + VirtualPathUtility.ToAbsolute("~/") + "\",");
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    s = s.Replace("user: \"\",", "user: \"" + ((HAP.AD.User)Membership.GetUser()).UserName + "\",");
                    s = s.Replace("admin: false,", "admin: " + HttpContext.Current.User.IsInRole("Domain Admins").ToString().ToLower() + ",");
                    s = s.Replace("bsadmin: false,", "bsadmin: " + isBSAdmin.ToString().ToLower() + ",");
                    s = s.Replace("hdadmin: false,", "hdadmin: " + isHDAdmin.ToString().ToLower() + ",");
                }
                s = s.Replace("localization: []", "localization: [" + string.Join(", ", BuildLocalization(_locals.SelectSingleNode("/hapStrings"), "")) + "]");
#if !DEBUG
                s = minifier.MinifyJavaScript(s);
#endif
                context.Response.Write(s);
            }
            else
            {
                if (JSType == API.JSType.CSS)
                {
                    context.Response.ContentType = "text/css";
                }
                RegistrationPath[] paths = GetPaths(context.Request.QueryString.Keys[0]);
                int status = 200;
                if (paths.Length > 0)
                {
                    DateTime lastModified = File.GetLastWriteTimeUtc(context.Server.MapPath(paths[0].Path));

                    foreach (RegistrationPath s in paths)
                    {
                        DateTime l = File.GetLastWriteTimeUtc(context.Server.MapPath(s.Path));
                        if (lastModified == null || lastModified < l)
                        {
                            lastModified = l;
                        }
                        context.Response.AddFileDependency(context.Server.MapPath(s.Path));
                    }
                    lastModified = new DateTime(lastModified.Year, lastModified.Month, lastModified.Day, lastModified.Hour, lastModified.Minute, lastModified.Second, 0, DateTimeKind.Utc);

                    context.Response.Cache.SetETagFromFileDependencies();
                    context.Response.Cache.SetLastModifiedFromFileDependencies();
                    context.Response.Cache.SetCacheability(HttpCacheability.Public);


                    if (context.Request.Headers["If-Modified-Since"] != null)
                    {
                        status = 304;
                        DateTime modifiedSinceDate = DateTime.UtcNow;
                        if (DateTime.TryParse(context.Request.Headers["If-Modified-Since"], out modifiedSinceDate))
                        {
                            if (lastModified != modifiedSinceDate)
                            {
                                status = 200;
                            }
                        }
                    }
                }
                context.Response.StatusCode = status;
                if (status == 200)
                {
                    foreach (RegistrationPath s in paths)
                    {
                        //context.Response.Write("\n/* " + s.Path + " */\n\n");
                        StreamReader sr = File.OpenText(context.Server.MapPath(s.Path));
                        string       f  = sr.ReadToEnd();
#if !DEBUG
                        if (s.Minify)
                        {
                            if (JSType != API.JSType.CSS)
                            {
                                f = minifier.MinifyJavaScript(f);
                            }
                            else
                            {
                                f = minifier.MinifyStyleSheet(f);
                            }
                        }
#endif
                        sr.Close();
                        context.Response.Write(f);
                    }
                }
            }
        }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        configManager = new Config(Server.MapPath(VirtualPathUtility.GetDirectory(Request.Path)));

        if (Request["step"] != null)
        {
            step = int.Parse(Request["step"]);
        }

        if (!pdf2swfEnabled(path_to_pdf2swf + pdf2swf_exec))
        {
            path_to_pdf2swf = @"C:\Program Files (x86)\SWFTools\";
        }

        if (!pdf2jsonEnabled(path_to_pdf2json + pdf2json_exec))
        {
            path_to_pdf2json = @"C:\Program Files (x86)\PDF2JSON\";
        }

        if (configManager.getConfig("admin.password") != null)
        {
            Response.Redirect("Default.aspx");
        }

        /* PDF2SWF PATH */
        /* -------------------------------------------- */
        if (Request["PDF2SWF_PATH"] != null)
        {
            path_to_pdf2swf         = Request["PDF2SWF_PATH"];
            Session["PDF2SWF_PATH"] = path_to_pdf2swf;
        }

        if (Session["PDF2SWF_PATH"] != null)
        {
            path_to_pdf2swf = Session["PDF2SWF_PATH"].ToString();
        }
        /* -------------------------------------------- */

        /* PDF2JSON PATH */
        /* -------------------------------------------- */
        if (Request["PDF2JSON_PATH"] != null)
        {
            path_to_pdf2json         = Request["PDF2JSON_PATH"];
            Session["PDF2JSON_PATH"] = path_to_pdf2json;
        }

        if (Session["PDF2JSON_PATH"] != null)
        {
            path_to_pdf2json = Session["PDF2JSON_PATH"].ToString();
        }
        /* -------------------------------------------- */

        if (step == 4) // Save configuration
        {
            String path_pdf            = Request["PDF_DIR"];
            String path_pdf_workingdir = Request["PUBLISHED_PDF_DIR"];

            // check for trailing slash
            if (!path_pdf.EndsWith("\\"))
            {
                path_pdf += "\\";
            }

            if (!path_pdf_workingdir.EndsWith("\\"))
            {
                path_pdf_workingdir += "\\";
            }

            configManager.setConfig("path.pdf", path_pdf);
            configManager.setConfig("path.swf", path_pdf_workingdir);
            configManager.setConfig("pdf2swf", pdf2swfEnabled(path_to_pdf2swf + pdf2swf_exec).ToString());
            configManager.setConfig("admin.username", Request["ADMIN_USERNAME"]);
            configManager.setConfig("admin.password", Request["ADMIN_PASSWORD"]);
            configManager.setConfig("licensekey", Request["LICENSEKEY"]);

            if (configManager.getConfig("test_pdf2json") == "true")
            {
                configManager.setConfig("renderingorder.primary", Request["RenderingOrder_PRIM"]);
                configManager.setConfig("renderingorder.secondary", Request["RenderingOrder_SEC"]);
            }

            configManager.setConfig("cmd.conversion.singledoc", configManager.getConfig("cmd.conversion.singledoc").Replace("pdf2swf.exe", "\"" + path_to_pdf2swf + "pdf2swf.exe" + "\""));
            configManager.setConfig("cmd.conversion.splitpages", configManager.getConfig("cmd.conversion.splitpages").Replace("pdf2swf.exe", "\"" + path_to_pdf2swf + "pdf2swf.exe" + "\""));
            configManager.setConfig("cmd.conversion.renderpage", configManager.getConfig("cmd.conversion.renderpage").Replace("swfrender.exe", "\"" + path_to_pdf2swf + "swfrender.exe" + "\""));
            configManager.setConfig("cmd.conversion.rendersplitpage", configManager.getConfig("cmd.conversion.rendersplitpage").Replace("swfrender.exe", "\"" + path_to_pdf2swf + "swfrender.exe" + "\""));
            configManager.setConfig("cmd.conversion.jsonfile", configManager.getConfig("cmd.conversion.jsonfile").Replace("pdf2json.exe", "\"" + path_to_pdf2json + "pdf2json.exe" + "\""));
            configManager.setConfig("cmd.searching.extracttext", configManager.getConfig("cmd.searching.extracttext").Replace("swfstrings.exe", "\"" + path_to_pdf2swf + "swfstrings.exe" + "\""));

            configManager.SaveConfig(Server.MapPath(VirtualPathUtility.GetDirectory(Request.Path)));

            Response.Redirect("Default.aspx");
        }
    }
Example #5
0
        /// <summary>
        /// Reads a template from cache if available. If not, reads it frm disk.
        /// Substitutes the template fields such as {basefolder}, before caching the result
        /// </summary>
        /// <param name="filePath">Path to the template</param>
        /// <param name="ctx">The current request context (needed in in order to transform virtual paths)</param>
        /// <param name="isInclude">true to indicate that the current template is a fragment of other template, so that is excludes content and other fragments from processing</param>
        /// <returns>The text contents of the template</returns>
        /// <exception cref="System.Security.SecurityException">Thrown if the app has no read access to the requested file</exception>
        /// <exception cref="System.IO.FileNotFoundException">Thrown when the requested file does not exist</exception>
        private static string ReadTemplate(string templateVirtualPath, HttpContext ctx, List <string> cacheDependencies, List <string> graph = null, bool isInclude = false)
        {
            string templatePath  = ctx.Server.MapPath(templateVirtualPath);
            string cachedContent = HttpRuntime.Cache[templatePath] as string;   //Templates are always cached for performance reasons (no switch/parameter to disable it)

            if (string.IsNullOrEmpty(cachedContent))
            {
                //Check for circular references
                if (graph != null)
                {
                    //Check if current file is already on the graph
                    //if it is, then we have a circular reference
                    if (graph.Contains(templatePath))
                    {
                        throw new CircularReferenceException(String.Format("Template not valid!\nThe file '{0}' is a circular reference: {1}", templateVirtualPath, String.Join(" >\n ", graph.ToArray())));
                    }
                    graph.Add(templatePath);    //Add current include to the graph to track circular references
                }

                var templateContents = IOHelper.ReadTextFromFile(templatePath);  //Read template contents from disk

                //Add current file as cache dependency (the read process will add the fragments if needed)
                if (!cacheDependencies.Contains(templatePath))
                {
                    cacheDependencies.Add(templatePath);
                }

                string phValue = string.Empty;    //The value to substitute the placeholder

                ////////////////////////////////////////////
                //Search for includes in the current file and substitute them, before substituting any other placeholder
                ////////////////////////////////////////////
                string[] includes = TemplatingHelper.GetAllPlaceHolderNames(templateContents, "", FILE_INCLUDES_PREFIX);

                //Substitute includes with their contents
                foreach (string include in includes)
                {
                    string includeFileName = VirtualPathUtility.RemoveTrailingSlash(VirtualPathUtility.GetDirectory(templateVirtualPath)) + "/" + include.Substring(FILE_INCLUDES_PREFIX.Length);  //The current template file folder + the include filename
                    try
                    {
                        //Initialize graph to detect circular references
                        List <string> newGraph;
                        if (graph == null)
                        {
                            newGraph = new List <string>()
                            {
                                templatePath
                            };
                        }
                        else
                        {
                            newGraph = graph;
                        }
                        phValue = ReadTemplate(includeFileName, ctx, cacheDependencies, newGraph, true);    //Insert the raw contents of the include (no processing!)
                    }
                    catch (CircularReferenceException crex)
                    {
                        throw crex;
                    }
                    catch   //If it fails, simply do nothing
                    {
                        //TODO: log in the system log
                        phValue = String.Format("<!-- Include file '{0}' not found  -->", includeFileName);
                    }
                    templateContents = TemplatingHelper.ReplacePlaceHolder(templateContents, include, phValue);
                }


                if (!isInclude)
                {
                    //After inserting all the "includes", check if there's a content placeholder present (mandatory)
                    if (!TemplatingHelper.IsPlaceHolderPresent(templateContents, "content"))
                    {
                        throw new Exception("Invalid template: The " + TemplatingHelper.GetPlaceholderName("content") + " placeholder must be present!");
                    }

                    //////////////////////////////
                    //Replace template-specific fields
                    //////////////////////////////
                    //Legacy "basefolder" placeholder (now "~/" it's recommended)
                    templateContents = TemplatingHelper.ReplacePlaceHolder(templateContents, "basefolder", "~/");
                    //Template base folder
                    templateContents = TemplatingHelper.ReplacePlaceHolder(templateContents, "templatebasefolder",
                                                                           VirtualPathUtility.RemoveTrailingSlash(VirtualPathUtility.GetDirectory(VirtualPathUtility.ToAbsolute(templateVirtualPath))));

                    //Transform virtual paths into absolute to the root paths (This is done only once per file if cached)
                    templateContents = WebHelper.TransformVirtualPaths(templateContents);

                    //If it's the main file, add result to cache with dependency on the file(s)
                    //Templates are cached ALWAYS, and this is not dependent on the UseMDcaching parameter (that one is only for MarkDown or MDH files)
                    HttpRuntime.Cache.Insert(templatePath, templateContents, new CacheDependency(cacheDependencies.ToArray()));
                    //Keep a list of template's dependencies to reuse when not reading from cache
                    ctx.Application[templatePath] = cacheDependencies;
                }

                return(templateContents); //Return content
            }
            else
            {
                //Get dependencies for this template
                cacheDependencies.AddRange(ctx.Application[templatePath] as List <string>);
                return(cachedContent);   //Return directly from cache
            }
        }
Example #6
0
 public string Content(string url)
 {
     return(VirtualPathUtility.ToAbsolute(url));
 }
Example #7
0
        private static bool IsApiRequest(IOwinRequest request)
        {
            string apiPath = VirtualPathUtility.ToAbsolute("~/api/");

            return(request.Uri.LocalPath.StartsWith(apiPath));
        }
 private void LoadScripts()
 {
     Page.RegisterStyleControl(LoadControl(VirtualPathUtility.ToAbsolute("~/products/files/masters/styles.ascx")));
     Page.RegisterBodyScripts(LoadControl(VirtualPathUtility.ToAbsolute("~/products/files/masters/FilesScripts.ascx")));
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            _settings     = Community.Forum.ForumManager.Settings;
            _forumManager = _settings.ForumManager;
            PostPageSize  = string.IsNullOrEmpty(Request["size"]) ? 20 : Convert.ToInt32(Request["size"]);

            if (Topic == null)
            {
                Response.Redirect(_settings.StartPageAbsolutePath);
            }

            if ((new Thread {
                ID = Topic.ThreadID
            }).Visible == false)
            {
                Response.Redirect(_settings.StartPageAbsolutePath);
            }


            int currentPageNumber = 0;

            if (!String.IsNullOrEmpty(Request["p"]))
            {
                try
                {
                    currentPageNumber = Convert.ToInt32(Request["p"]);
                }
                catch { currentPageNumber = 0; }
            }
            if (currentPageNumber <= 0)
            {
                currentPageNumber = 1;
            }

            int postCountInTopic;
            var posts = ForumDataProvider.GetPosts(TenantProvider.CurrentTenantID, Topic.ID, currentPageNumber, PostPageSize, out postCountInTopic);

            var postId = 0;

            if (!string.IsNullOrEmpty(Request["post"]))
            {
                try
                {
                    postId = Convert.ToInt32(Request["post"]);
                }
                catch { postId = 0; }
            }

            if (postId != 0)
            {
                var allposts = ForumDataProvider.GetPostIDs(TenantProvider.CurrentTenantID, Topic.ID);
                var idx      = -1;
                for (var j = 0; j < allposts.Count; j++)
                {
                    if (allposts[j] != postId)
                    {
                        continue;
                    }

                    idx = j;
                    break;
                }
                if (idx != -1)
                {
                    var page = idx / 20 + 1;
                    Response.Redirect("posts.aspx?t=" + Topic.ID + "&size=20&p=" + page + "#" + postId);
                }
            }

            PostPagesCount = postCountInTopic;
            var pageSize      = PostPageSize;
            var pageNavigator = new PageNavigator
            {
                PageUrl = string.Format(
                    CultureInfo.CurrentCulture,
                    "{0}?&t={1}&size={2}",
                    VirtualPathUtility.ToAbsolute("~/Products/Community/Modules/Forum/Posts.aspx"),
                    Topic.ID,
                    pageSize
                    ),
                //_settings.LinkProvider.PostList(Topic.ID),
                CurrentPageNumber = currentPageNumber,
                EntryCountOnPage  = pageSize,
                VisiblePageCount  = 5,
                EntryCount        = postCountInTopic
            };


            bottomPageNavigatorHolder.Controls.Add(pageNavigator);

            var i = 0;

            foreach (var post in posts)
            {
                var postControl = (PostControl)LoadControl(_settings.UserControlsVirtualPath + "/PostControl.ascx");
                postControl.Post              = post;
                postControl.IsEven            = (i % 2 == 0);
                postControl.SettingsID        = SettingsID;
                postControl.CurrentPageNumber = currentPageNumber;
                postControl.PostsCount        = Topic.PostCount;
                postListHolder.Controls.Add(postControl);
                i++;
            }

            ForumDataProvider.SetTopicVisit(Topic);
            InitScripts();
            if (Topic.Type != TopicType.Poll)
            {
                return;
            }

            var q = ForumDataProvider.GetPollByID(TenantProvider.CurrentTenantID, Topic.QuestionID);

            if (q == null)
            {
                return;
            }

            var isVote = ForumDataProvider.IsUserVote(TenantProvider.CurrentTenantID, q.ID, SecurityContext.CurrentAccount.ID);

            var pollForm = new PollForm
            {
                VoteHandlerType  = typeof(PollVoteHandler),
                Answered         = isVote || Topic.Closed || !_forumManager.ValidateAccessSecurityAction(ForumAction.PollVote, q),
                Name             = q.Name,
                PollID           = q.ID.ToString(),
                Singleton        = (q.Type == QuestionType.OneAnswer),
                AdditionalParams = _settings.ID.ToString() + "," + q.ID.ToString()
            };


            foreach (var variant in q.AnswerVariants)
            {
                pollForm.AnswerVariants.Add(new PollForm.AnswerViarint
                {
                    ID        = variant.ID.ToString(),
                    Name      = variant.Name,
                    VoteCount = variant.AnswerCount
                });
            }


            pollHolder.Controls.Add(new Literal {
                Text = "<div style='position:relative; padding-left:20px; margin-bottom:15px;'>"
            });
            pollHolder.Controls.Add(pollForm);
            pollHolder.Controls.Add(new Literal {
                Text = "</div>"
            });
        }
Example #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.ReportViewer1.ReportServiceUrl = VirtualPathUtility.ToAbsolute("~/api/RDLCReport");
 }
Example #11
0
    protected void viewer_ReportCreated(object sender, EventArgs e)
    {
        object passed = PXContext.Session.PageInfo[VirtualPathUtility.ToAbsolute(this.Page.Request.Path)];

        if (passed == null)
        {
            object passedByRawUrl = PXContext.Session.PageInfo[VirtualPathUtility.ToAbsolute(this.Page.Request.RawUrl)];
            var    pars           = passedByRawUrl as Dictionary <string, string>;
            if (pars != null)
            {
                string autoexport;
                if (pars.TryGetValue(ReportLauncherHelper._AUTO_EXPORT_PDF, out autoexport) &&
                    autoexport == "true")
                {
                    viewer.AutoExportPDF = true;
                    pars.Remove(ReportLauncherHelper._AUTO_EXPORT_PDF);
                }
                passed = new Dictionary <string, string>(pars);
            }
            else
            {
                passed = passedByRawUrl;
            }
        }
        PXReportsRedirectList reports = passed as PXReportsRedirectList;

        sessionReportParams.Add(reports == null ? passed : reports[0].Value);

        PXSiteMapProvider provider = SiteMap.Provider as PXSiteMapProvider;

        if (provider != null && reports != null)
        {
            if (reports.SeparateWindows)
            {
                if (reports.Count > 1)
                {
                    KeyValuePair <String, Object> pair;
                    do
                    {
                        reports.RemoveAt(0);
                        pair = reports.First();
                    } while (reports.Count > 1 && String.IsNullOrEmpty(pair.Key));

                    string reportID = pair.Key;
                    if (String.IsNullOrEmpty(reportID))
                    {
                        return;
                    }
                    string url = PXBaseDataSource.getScreenUrl(reportID);
                    if (!String.IsNullOrEmpty(url))
                    {
                        url = PXUrl.ToAbsoluteUrl(url) + "&preserveSession=true";

                        NextReport           = new KeyValuePair <String, Object>(url, reports);
                        viewer.NextReportUrl = url;
                    }
                }
            }
            else
            {
                foreach (KeyValuePair <string, object> t in reports)
                {
                    string reportID = t.Key;
                    if (string.IsNullOrEmpty(reportID))
                    {
                        continue;
                    }
                    PXSiteMapNode reportNode = provider.FindSiteMapNodeByScreenID(reportID);
                    string        reportName;
                    if (reportNode != null && !string.IsNullOrEmpty(reportName = PXUrl.GetParameter(reportNode.Url, "ID")))
                    {
                        Report report = new Report();
                        report.ReportName = reportName;
                        viewer.Report.SiblingReports.Add(report);
                        sessionReportParams.Add(t.Value);
                    }
                }
            }
        }
    }
Example #12
0
        static public string GetIconUrl(string code)
        {
            string url = VirtualPathUtility.ToAbsolute("~/Content/Image/");

            if (AppSetting.IsPOSTAR)
            {
                switch (code)
                {
                case "Banner":
                    url += "wallmountedbannee.png";
                    break;

                case "Billboard":
                    url += "billboard.png"; break;

                case "Bus Shelter":
                    url += "busshelter.png"; break;

                case "Large LED":
                    url += "britelite.png"; break;

                case "Rooftop":
                    url += "covermarket.png"; break;

                case "Wall":
                    url += "elevator.png"; break;
                }
            }
            else
            {
                switch (code)
                {
                case "WMB":
                    url += "wallmountedbannee.png";
                    break;

                case "BRL":
                    url += "britelite.png";
                    break;

                case "BSH":
                    url += "busshelter.png";
                    break;

                case "CMR":
                    url += "covermarket.png";
                    break;

                case "ELV":
                    url += "elevator.png";
                    break;

                case "ITK":
                    url += "itkiosk.png";
                    break;

                case "Billboard":
                    url += "billboard.png";
                    break;

                case "BillboardPole":
                    url += "billboardpole.png";
                    break;

                case "Other":
                    url += "other.png";
                    break;
                }
            }

            return(url);
        }
Example #13
0
        private static bool IsEmbeddedResourcePath(string virtualPath)
        {
            var path = VirtualPathUtility.ToAppRelative(virtualPath);

            return(path.StartsWith("~/PageTypeTreeFilterResource/", StringComparison.InvariantCultureIgnoreCase));
        }
        public HttpResponseMessage ListPages(string parent)
        {
            var apiResponse = new DTO.ApiResponse <List <DTO.GenericListImageItem> >();

            try
            {
                var pageId   = -2;
                var portalId = PortalSettings.PortalId;

                switch (parent.ToLower())
                {
                case "admin":
                    pageId = PortalSettings.AdminTabId;
                    break;

                case "host":
                    pageId   = PortalSettings.SuperTabId;
                    portalId = -1;
                    break;

                case "all":
                    pageId = -1;
                    break;

                default:
                    //todo, parse for int and get by parent id
                    break;
                }
                if (pageId > -2)
                {
                    var listOfPages = DotNetNuke.Entities.Tabs.TabController.GetTabsByParent(pageId, portalId);
                    apiResponse.CustomObject = new List <DTO.GenericListImageItem>();

                    foreach (var page in listOfPages.Where(i => i.IsDeleted == false).OrderBy(i => i.TabOrder))
                    {
                        var newItem = new DTO.GenericListImageItem()
                        {
                            Value = page.TabID.ToString(), Name = page.TabName
                        };

                        if (string.IsNullOrWhiteSpace(page.IconFileLarge) == false)
                        {
                            newItem.Image = VirtualPathUtility.ToAbsolute(page.IconFileLarge);
                        }
                        else
                        {
                            newItem.Image = string.Empty;
                        }

                        apiResponse.CustomObject.Add(newItem);
                    }

                    apiResponse.Success = true;

                    return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
                }
            }
            catch (Exception err)
            {
                apiResponse.Success = false;
                apiResponse.Message = err.Message;

                Exceptions.LogException(err);
            }

            return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
        }
Example #15
0
 public static void ShowProjectSettings()
 {
     OpenFileAsDocument(VirtualPathUtility.GetRealPathByVirtual(ProjectSettings.FileName), true, true, true, "ProjectSettingsUserMode");
 }
Example #16
0
 protected string RenderMailLinkAttribute()
 {
     return(CoreContext.Configuration.Personal || WebItemManager.Instance[WebItemManager.MailProductID].IsDisabled()
                ? "href=\"mailto:" + User.Email.HtmlEncode() + "\""
                : "target=\"_blank\" href=\"" + VirtualPathUtility.ToAbsolute("~/addons/mail/#composeto/email=" + HttpUtility.UrlEncode(User.Email)) + "\"");
 }
Example #17
0
        public static DocumentWindow OpenDocumentWindowForObject(DocumentInstance document, object obj)          //, bool canUseAlreadyOpened )
        {
            if (!IsDocumentObjectSupport(obj))
            {
                return(null);
            }

            //another document or no document
            {
                var objectToDocument = GetDocumentByObject(obj);
                if (objectToDocument == null || objectToDocument != document)
                {
                    var component = obj as Component;
                    if (component != null)
                    {
                        var fileName = ComponentUtility.GetOwnedFileNameOfComponent(component);
                        if (!string.IsNullOrEmpty(fileName))
                        {
                            var realFileName = VirtualPathUtility.GetRealPathByVirtual(fileName);

                            if (IsDocumentFileSupport(realFileName))
                            {
                                var documentWindow = OpenFileAsDocument(realFileName, true, true) as DocumentWindow;
                                if (documentWindow != null)
                                {
                                    var newDocument = documentWindow.Document;
                                    var newObject   = newDocument.ResultComponent.Components[component.GetPathFromRoot()];
                                    if (newObject != null)
                                    {
                                        return(OpenDocumentWindowForObject(newDocument, newObject));
                                    }
                                }

                                return(null);
                            }
                        }
                    }

                    return(null);
                }
            }

            //check for already opened
            var canUseAlreadyOpened = !EditorForm.ModifierKeys.HasFlag(Keys.Shift);

            if (canUseAlreadyOpened)
            {
                var openedWindow = EditorForm.Instance.WorkspaceController.FindWindowRecursive(document, obj);
                if (openedWindow != null)
                {
                    EditorForm.Instance.WorkspaceController.SelectDockWindow(openedWindow);
                    return(openedWindow);
                }
            }

            //create document window
            var window = CreateWindowImpl(document, obj, false);

            //!!!!
            bool floatingWindow = false;
            bool select         = true;

            EditorForm.Instance.WorkspaceController.AddDockWindow(window, floatingWindow, select);

            return(window);
        }
Example #18
0
 internal virtual string GetDirectory(string virtualPath)
 {
     return(VirtualPathUtility.GetDirectory(virtualPath));
 }
Example #19
0
 /// <summary>
 /// Returns the url of a themed asset
 /// </summary>
 /// <param name="url"></param>
 /// <param name="model"></param>
 /// <param name="relativeAssetPath"></param>
 /// <returns></returns>
 public static string ThemedAsset(this UrlHelper url, IMasterModel model, string relativeAssetPath)
 {
     return(VirtualPathUtility.ToAbsolute(PathHelper.GetThemePath(model)).EnsureEndsWith('/') + "assets/" + relativeAssetPath);
 }
Example #20
0
 public virtual string NormalizePath(string path)
 {
     // If it's relative, resolve it
     return(VirtualPathUtility.Combine(VirtualPath, path));
 }
Example #21
0
        public static void SendPings(Post post, string pingUrls)
        {
            // Split ping urls into string array
            string[] pingUrlsArray = pingUrls.Split('\n');

            // Gather information to pass to ping service(s)
            string name    = SiteSettings.Get().Title;
            string url     = post.Category.IsUncategorized ? new Macros().FullUrl(new Urls().Home) : new Macros().FullUrl(post.Category.Url);
            string feedUrl = SiteSettings.Get().ExternalFeedUrl ?? new Macros().FullUrl(VirtualPathUtility.ToAbsolute("~/feed/"));

            XmlRpcPings pinger = new XmlRpcPings(name, url, feedUrl, pingUrlsArray);

            ManagedThreadPool.QueueUserWorkItem(new WaitCallback(pinger.SendPings));
        }
 public string ToAbsolute(string virtualPath)
 {
     return(VirtualPathUtility.ToAbsolute(virtualPath));
 }
Example #23
0
        private void RegisterClientScripts()
        {
            Page.RegisterBodyScripts(VirtualPathUtility.ToAbsolute("~/usercontrols/common/ckeditor/ckeditor.js"));
            Page.RegisterBodyScripts(VirtualPathUtility.ToAbsolute("~/usercontrols/common/ckeditor/adapters/jquery.js"));
            Page.RegisterBodyScripts(ResolveUrl("~/js/uploader/ajaxupload.js"));
            Page.RegisterBodyScripts(ResolveUrl("~/usercontrols/common/comments/js/comments.js"));

            var uploadPath = string.Format("{0}://{1}:{2}{3}", Page.Request.GetUrlRewriter().Scheme, Page.Request.GetUrlRewriter().Host, Page.Request.GetUrlRewriter().Port, VirtualPathUtility.ToAbsolute("~/") + "fckuploader.ashx?newEditor=true");

            uploadPath += "&esid=" + FckDomainName;

            var paramsScript = string.Format(@"
                    CommentsManagerObj.javaScriptAddCommentFunctionName = '{0}';
                    CommentsManagerObj.javaScriptLoadBBcodeCommentFunctionName = '{1}';
                    CommentsManagerObj.javaScriptUpdateCommentFunctionName = '{2}';
                    CommentsManagerObj.javaScriptCallBackAddComment = '{3}';
                    CommentsManagerObj.javaScriptPreviewCommentFunctionName = '{4}';
                    CommentsManagerObj.isSimple = {5};                    
                    CommentsManagerObj._jsObjName = '{6}';
                    CommentsManagerObj.PID = '{7}';                    
                    CommentsManagerObj.isDisableCtrlEnter = {8};
                    CommentsManagerObj.inactiveMessage = '{9}';
                    CommentsManagerObj.EnableAttachmets = {10};
                    CommentsManagerObj.RemoveAttachButton = '{11}';
                    CommentsManagerObj.FckUploadHandlerPath = '{12}';
                    CommentsManagerObj.maxLevel = {13};
                    ",
                                             _javaScriptAddCommentFunctionName, _javaScriptLoadBBcodeCommentFunctionName,
                                             _javaScriptUpdateCommentFunctionName, _javaScriptCallBackAddComment,
                                             _javaScriptPreviewCommentFunctionName, _simple.ToString().ToLower(), JsObjName,
                                             PID, DisableCtrlEnter.ToString().ToLower(), _inactiveMessage, EnableAttachmets.ToString().ToLower(),
                                             RemoveAttachButton, uploadPath, MaxDepthLevel);

            paramsScript += string.Format(@"
                    CommentsManagerObj.OnEditedCommentJS = '{0}';
                    CommentsManagerObj.OnRemovedCommentJS = '{1}';
                    CommentsManagerObj.OnCanceledCommentJS = '{2}';
                    CommentsManagerObj.FckDomainName = '{3}';",
                                          OnEditedCommentJS, OnRemovedCommentJS, OnCanceledCommentJS, FckDomainName);

            paramsScript +=
                "\n" +
                "if(jq('#comments_Uploader').length>0 && '" + HandlerTypeName + "' != '')\n" +
                "{\n" +
                "new AjaxUpload('comments_Uploader', {\n" +
                "action: 'ajaxupload.ashx?type=" + HandlerTypeName + "',\n" +
                "onComplete: CommentsManagerObj.UploadCallBack\n" +
                "});\n}\n";

            if (!Simple)
            {
                paramsScript += string.Format(@"
                        CommentsManagerObj.InitEditor('{1}', '{2}', '{3}', '{4}', '{5}');", "{", FCKBasePath, FCKToolbar, FCKHeight, FCKWidth, FCKEditorAreaCss, "}");
            }

            Page.RegisterInlineScript(paramsScript);

            if (Simple && !DisableCtrlEnter)
            {
                Page.RegisterBodyScripts(ResolveUrl("~/usercontrols/common/comments/js/onReady.js"));
            }
        }
 public string CombinePaths(string basePath, string relativePath)
 {
     return(VirtualPathUtility.Combine(VirtualPathUtility.AppendTrailingSlash(basePath), relativePath));
 }
Example #25
0
 public CustomVirtualFile(string virtualPath) : base(virtualPath)
 {
     path = VirtualPathUtility.ToAppRelative(virtualPath);
 }
Example #26
0
    protected void viewer_ReportLoaded(object sender, EventArgs e)
    {
        bool renderName        = (Request.QueryString["RenderNames"] != null);
        int  systemParamsCount = renderName ? 2 : 1;

        if ((Request.QueryString[PXUrl.HideScriptParameter] != null))
        {
            systemParamsCount++;
        }
        if ((Request.QueryString[PXUrl.PopupParameter] != null))
        {
            systemParamsCount++;
        }
        if ((Request.QueryString[PXPageCache.TimeStamp] != null))
        {
            systemParamsCount++;
        }
        if ((Request.QueryString[PXUrl.UNum] != null))
        {
            systemParamsCount++;
        }
        if ((Request.QueryString[PXUrl.CompanyID] != null))
        {
            systemParamsCount++;
        }
        if ((Request.QueryString["_" + PXUrl.CompanyID] != null))
        {
            systemParamsCount++;
        }

        if (Request.QueryString[PX.Reports.Messages.Max] != null)
        {
            viewer.Report.TopCount = Convert.ToInt32(Request.QueryString[PX.Reports.Messages.Max].ToString());
        }

        object passed = sessionReportParams.Count > 0 ? sessionReportParams[0] : null;

        if (passed == null && PXSiteMap.IsPortal && this.Request.QueryString["PortalAccessAllowed"] == null)
        {
            throw new PXException(ErrorMessages.NotEnoughRights, viewer.Report.ReportName);
        }
        Dictionary <string, string> pars = passed as Dictionary <string, string>;

        if (pars == null && Request.QueryString.Count > systemParamsCount && !(Request.AppRelativeCurrentExecutionFilePath ?? "").StartsWith("~/rest/"))
        {
            foreach (string key in Request.QueryString.AllKeys)
            {
                if (String.Compare(key, "ID", StringComparison.OrdinalIgnoreCase) == 0 ||
                    String.Compare(key, "RenderNames", StringComparison.OrdinalIgnoreCase) == 0 ||
                    String.Compare(key, PXUrl.CompanyID, StringComparison.OrdinalIgnoreCase) == 0 ||
                    String.Compare(key, "_CompanyID", StringComparison.OrdinalIgnoreCase) == 0 || PXUrl.SystemParams.Contains(key))
                {
                    continue;
                }
                if (pars == null)
                {
                    pars = new System.Collections.Generic.Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                }
                pars[key] = Request.QueryString[key];
            }
        }

        viewer.Report.RenderNames = renderName;
        viewer.Report.Title       = this.Title;
        // reportid from params
        string reportIdParamValue = pars != null && pars.ContainsKey(ReportLauncherHelper._REPORTID_PARAM_KEY) ? pars[ReportLauncherHelper._REPORTID_PARAM_KEY] : string.Empty;

        if (string.IsNullOrEmpty(reportIdParamValue))
        {
            var id = Page.Request.Params["id"];
            reportIdParamValue = id != null?id.Replace(".rpx", string.Empty) : null;
        }
        // true if params are intended for the current report
        bool isCurrReportParams = passed == null ||
                                  String.Equals(_screenID, reportIdParamValue, StringComparison.OrdinalIgnoreCase);

        // clear params if they are not for the current report
        if (!isCurrReportParams && pars != null)
        {
            pars = null;
            PXContext.Session.PageInfo[VirtualPathUtility.ToAbsolute(this.Page.Request.Path)] = null;
        }

        if (!viewer.HideParameters)
        {
            viewer.Report.RequestParams = !(passed is IPXResultset) && (!isCurrReportParams || pars == null);
        }

        if (isCurrReportParams)
        {
            for (int i = 0; i < sessionReportParams.Count; i++)
            {
                try
                {
                    if (i == 0)
                    {
                        ReportLauncherHelper.LoadParameters(viewer.Report, pars, (SoapNavigator)((PXReportViewer)sender).GetNavigator());
                        // Clear report data from session after report has been loaded when there is only one report
                        if (sessionReportParams.Count == 1 && (pars == null || pars.Count == 1 && pars.ContainsKey(ReportLauncherHelper._REPORTID_PARAM_KEY)))
                        {
                            PXContext.Session.PageInfo[VirtualPathUtility.ToAbsolute(this.Page.Request.Path)] = null;
                        }
                    }
                    else
                    {
                        ReportLauncherHelper.LoadParameters(viewer.Report.SiblingReports[i - 1], sessionReportParams[i], (SoapNavigator)((PXReportViewer)sender).GetNavigator());
                    }
                }
                catch
                {
                    PXContext.Session.PageInfo[VirtualPathUtility.ToAbsolute(this.Page.Request.Path)] = null;
                    throw;
                }
            }
        }
    }
Example #27
0
 private static string GetBundlePath(Bundle bundle)
 {
     return(!string.IsNullOrEmpty(bundle.CdnPath)
                ? bundle.CdnPath
                : VirtualPathUtility.ToAbsolute(bundle.Path));
 }
Example #28
0
        //!!!!new

        public static (Metadata.TypeInfo objectType, string referenceToObject) GetObjectToCreateByContentBrowserItem(ContentBrowser.Item item)
        {
            Metadata.TypeInfo objectType        = null;
            string            referenceToObject = "";
            //string memberFullSignature = "";
            //Component createNodeWithComponent = null;

            //!!!!не все итемы можно создать.

            //_Type
            var typeItem = item as ContentBrowserItem_Type;

            if (typeItem != null)
            {
                var type = typeItem.Type;

                //!!!!генериковому нужно указать типы

                if (MetadataManager.GetTypeOfNetType(typeof(Component)).IsAssignableFrom(type) && !type.Abstract)
                {
                    objectType = type;
                    //referenceToObject = objectType.Name;
                }
            }

            //!!!!
            //var memberItem = item as ContentBrowserItem_Member;
            //if( memberItem != null )
            //{
            //	var member = memberItem.Member;

            //	var type = member.Creator as Metadata.TypeInfo;
            //	if( type != null )
            //		memberFullSignature = string.Format( "{0}|{1}", type.Name, member.Signature );
            //}

            //_File
            var fileItem = item as ContentBrowserItem_File;

            if (fileItem != null && !fileItem.IsDirectory)
            {
                //!!!!не делать предпросмотр для сцены, т.к. долго. что еще?
                var ext = Path.GetExtension(fileItem.FullPath);
                if (ResourceManager.GetTypeByFileExtension(ext) != null)
                {
                    var res  = ResourceManager.GetByName(VirtualPathUtility.GetVirtualPathByReal(fileItem.FullPath));
                    var type = res?.PrimaryInstance?.ResultComponent?.GetProvidedType();
                    if (type != null)
                    {
                        objectType        = type;
                        referenceToObject = res.Name;
                    }
                }
            }

            //_Component
            var componentItem = item as ContentBrowserItem_Component;

            if (componentItem != null)
            {
                var component = componentItem.Component;

                if (component.ParentRoot.HierarchyController != null &&
                    component.ParentRoot.HierarchyController.CreatedByResource.InstanceType == Resource.InstanceType.Resource)
                {
                    objectType = component.GetProvidedType();
                    if (objectType != null)
                    {
                        referenceToObject = objectType.Name;
                    }
                }
                //else
                //{
                //if( Scene.ParentRoot == component.ParentRoot )
                //{
                //!!!!

                ////add node with component
                //createNodeWithComponent = component;
                //}
                //}
            }

            return(objectType, referenceToObject);
        }
        public ActionResult Performance(string lblRows, string lblColumns, string SaveOption)
        {
            if (SaveOption == null)
            {
                return(View());
            }

            int rowCount = Convert.ToInt32(lblRows);
            int colCount = Convert.ToInt32(lblColumns);

            if (SaveOption == "Xls")
            {
                if (colCount > 256)
                {
                    Response.Write("<script LANGUAGE='JavaScript' >alert('Column count must be less than or equal to 256 for Excel 2003 format.');document.location='" + VirtualPathUtility.ToAbsolute("~/XlsIO/Performance") + "';</script>");
                    return(View());
                }
                if (rowCount > 65536)
                {
                    Response.Write("<script LANGUAGE='JavaScript' >alert('Row count must be less than or equal to 65,536 for Excel 2003 format.');document.location='" + VirtualPathUtility.ToAbsolute("~/XlsIO/Performance") + "';</script>");
                    return(View());
                }
            }
            if (SaveOption == "Xlsx")
            {
                if (rowCount > 100001)
                {
                    Response.Write("<script LANGUAGE='JavaScript' >alert('Row count must be less than or equal to 100,000.');document.location='" + VirtualPathUtility.ToAbsolute("~/XlsIO/Performance") + "';</script>");
                    return(View());
                }
                if (colCount > 151)
                {
                    Response.Write("<script LANGUAGE='JavaScript' >alert('Column count must be less than or equal to 151.');document.location='" + VirtualPathUtility.ToAbsolute("~/XlsIO/Performance") + "';</script>");
                    return(View());
                }
            }
            //New instance of XlsIO is created.[Equivalent to launching Microsoft Excel with no workbooks open].
            //The instantiation process consists of two steps.

            //Step 1 : Instantiate the spreadsheet creation engine.
            ExcelEngine excelEngine = new ExcelEngine();

            //Step 2 : Instantiate the excel application object.
            IApplication application = excelEngine.Excel;
            IWorkbook    workbook;

            if (SaveOption == "Xlsx")
            {
                application.DefaultVersion = ExcelVersion.Excel2016;
            }
            else
            {
                application.DefaultVersion = ExcelVersion.Excel97to2003;
            }

            workbook = application.Workbooks.Create(1);

            IWorksheet sheet = workbook.Worksheets[0];

            IMigrantRange migrantRange = sheet.MigrantRange;

            for (int column = 1; column <= colCount; column++)
            {
                migrantRange.ResetRowColumn(1, column);
                migrantRange.SetValue("Column: " + column.ToString());
            }

            //Writing Data using normal interface
            for (int row = 2; row <= rowCount; row++)
            {
                //double columnSum = 0.0;
                for (int column = 1; column <= colCount; column++)
                {
                    //Writing number
                    migrantRange.ResetRowColumn(row, column);
                    migrantRange.SetValue(row * column);
                }
            }

            try
            {
                if (SaveOption == "Xls")
                {
                    return(excelEngine.SaveAsActionResult(workbook, "Performance.xls", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel97));
                }
                else
                {
                    return(excelEngine.SaveAsActionResult(workbook, "Performance.xlsx", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2016));
                }
            }
            catch (Exception)
            {
            }

            //Close the workbook.
            workbook.Close();
            excelEngine.Dispose();
            return(View());
        }
 private string GetLoginUrl(ContentReference returnToContentLink)
 {
     return(string.Format(
                "{0}?ReturnUrl={1}",
                (FormsAuthentication.IsEnabled ? FormsAuthentication.LoginUrl : VirtualPathUtility.ToAbsolute(Global.AppRelativeLoginPath)),
                _urlResolver.GetUrl(returnToContentLink)));
 }