コード例 #1
0
        private void CreateEmptyPanel()
        {
            var buttons = "<a id='uploadFirstFile' class='baseLinkAction'>" + MenuUploadFile + "</a><br/>" +
                          "<a id='createFirstDocument' class='baseLinkAction'>" + MenuNewDocument + "</a>" +
                          "<span class='sort-down-black newDocComb'></span>";

            if (ModuleName != "crm")
            {
                buttons += "<br/><a id='attachProjDocuments' class='baseLinkAction'>" + MenuProjectDocuments + "</a>";
            }

            var emptyParticipantScreenControl = new EmptyScreenControl
            {
                ImgSrc   = VirtualPathUtility.ToAbsolute("~/UserControls/Common/Attachments/Images/documents-logo.png"),
                Header   = UserControlsCommonResource.EmptyListDocumentsHead,
                Describe =
                    MobileDetector.IsRequestMatchesMobile(Context)
                            ? UserControlsCommonResource.EmptyListDocumentsDescrMobile
                            : String.Format(UserControlsCommonResource.EmptyListDocumentsDescr,
                                            //create
                                            "<span class='hintCreate baseLinkAction' >", "</span>",
                                            //upload
                                            "<span class='hintUpload baseLinkAction' >", "</span>",
                                            //open
                                            "<span class='hintOpen baseLinkAction' >", "</span>",
                                            //edit
                                            "<span class='hintEdit baseLinkAction' >", "</span>"),
                ButtonHTML = buttons
            };

            _phEmptyDocView.Controls.Add(emptyParticipantScreenControl);
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Utility.RegisterTypeForAjax(typeof(TaskDescriptionView), Page);

            _hintPopup.Options.IsPopup           = true;
            _hintPopupTaskRemove.Options.IsPopup = true;
            _newLinkError.Options.IsPopup        = true;

            IsMobile = MobileDetector.IsRequestMatchesMobile(Context);

            CanReadFiles       = ProjectSecurity.CanReadFiles(Task.Project);
            CanEditTask        = ProjectSecurity.CanEdit(Task);
            CanCreateSubtask   = ProjectSecurity.CanCreateSubtask(Task);
            CanCreateTimeSpend = ProjectSecurity.CanCreateTimeSpend(Task);
            CanDeleteTask      = ProjectSecurity.CanDelete(Task);
            SubtasksCount      = Task.SubTasks.Count;

            if (CanReadFiles)
            {
                InitAttachments();
            }

            InitCommentBlock();

            var timeList = Global.EngineFactory.GetTimeTrackingEngine().GetByTask(Task.ID);

            TaskTimeSpend = timeList.Sum(timeSpend => timeSpend.Hours).ToString();
            TaskTimeSpend = TaskTimeSpend.Replace(',', '.');
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Utility.RegisterTypeForAjax(typeof(DiscussionDetails), Page);

            _hintPopup.Options.IsPopup = true;

            LoadCommentsControl();

            BindDiscussionParticipants();
            CanEdit = ProjectSecurity.CanEdit(Discussion);

            if (CanEdit)
            {
                LoadDiscussionParticipantsSelector();
            }

            CanReadFiles = ProjectSecurity.CanReadFiles(Discussion.Project);
            CanEditFiles = ProjectSecurity.IsInTeam(Project);
            IsMobile     = MobileDetector.IsRequestMatchesMobile(Context);

            FilesCount = GetDiscussionFilesCount();

            if (CanReadFiles && (CanEditFiles || FilesCount > 0))
            {
                LoadDiscussionFilesControl();
            }
        }
コード例 #4
0
 protected override void OnLoad(EventArgs e)
 {
     IsMobile = MobileDetector.IsRequestMatchesMobile(Context);
     PageLoad();
     InitScript();
     RenderCustomScript();
 }
コード例 #5
0
        protected override void PageLoad()
        {
            if (!CommunitySecurity.CheckPermissions(Constants.Action_AddPost))
            {
                Response.Redirect(Constants.DefaultPageUrl, true);
            }

            _mobileVer = MobileDetector.IsRequestMatchesMobile(Context);

            //fix for IE 10 && IE11
            var browser = HttpContext.Current.Request.Browser.Browser;

            var userAgent  = Context.Request.Headers["User-Agent"];
            var regExp     = new Regex("MSIE 10.0", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
            var regExpIe11 = new Regex("(?=.*Trident.*rv:11.0).+", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);

            if (browser == "IE" && regExp.Match(userAgent).Success || regExpIe11.Match(userAgent).Success)
            {
                _mobileVer = true;
            }

            //lbtnPost.Text = BlogsResource.PostButton;
            FCKeditor.BasePath      = VirtualPathUtility.ToAbsolute(CommonControlsConfigurer.FCKEditorBasePath);
            FCKeditor.ToolbarSet    = "BlogToolbar";
            FCKeditor.EditorAreaCSS = WebSkin.BaseCSSFileAbsoluteWebPath;
            FCKeditor.Visible       = !_mobileVer;

            if (_mobileVer && Request["mobiletext"] != null)
            {
                _text = Request["mobiletext"];
            }

            if (CheckTitle(txtTitle.Text))
            {
                mainContainer.Options.InfoMessageText = "";
            }

            mainContainer.CurrentPageCaption = BlogsResource.NewPost;
            Title = HeaderStringHelper.GetPageTitle(BlogsResource.NewPost);

            InitPreviewTemplate();

            lbCancel.Attributes["name"] = FCKeditor.ClientID;

            if (IsPostBack)
            {
                var control = FindControl(Request.Params["__EVENTTARGET"]);
                if (lbCancel.Equals(control))
                {
                    Response.Redirect(Constants.DefaultPageUrl);
                }
                else
                {
                    TryPostBlog(GetEngine());
                }
            }

            InitScript();
        }
コード例 #6
0
        protected void PageLoad()
        {
            File file;

            try
            {
                ShareLink = Request[UrlConstant.DocUrlKey] ?? "";
                WithLink  = !string.IsNullOrEmpty(ShareLink);

                var fileId = WithLink ? (object)-1 : Request[UrlConstant.FileId];
                FileNew = !string.IsNullOrEmpty(Request[UrlConstant.New]) && Request[UrlConstant.New] == "true";
                var ver = string.IsNullOrEmpty(Request[UrlConstant.Version]) ? -1 : Convert.ToInt32(Request[UrlConstant.Version]);

                file = DocumentUtils.GetServiceParams(false, fileId, ver, FileNew, ShareLink, out DocParams);
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                return;
                //var urlRedirect = Request.UrlReferrer == null
                //                      ? PathProvider.StartURL
                //                      : Request.UrlReferrer.ToString();

                //Response.Redirect(urlRedirect + "#" + UrlConstant.Error + "/" + HttpUtility.UrlEncode(ex.Message));
            }

            if (!FileUtility.UsingHtml5(file.Title, false))
            {
                Server.Transfer("viewer.aspx", true);
            }

            Title = file.Title;

            DocParams.Type = MobileDetector.IsRequestMatchesMobile(Context) ? "mobile" : "desktop";
            if (MobileDetector.IsRequestMatchesMobile(Context))
            {
                DocParams.FolderUrl = string.Empty;
            }

            DocKeyForTrack = DocumentUtils.GetDocKey(file.ID, -1, DateTime.MinValue);

            Global.DaoFactory.GetTagDao().RemoveTags(Tag.New(SecurityContext.CurrentAccount.ID, file));

            FilesActivityPublisher.OpenEditorFile(file);
        }
コード例 #7
0
        protected void PageLoad()
        {
            var file = new File();

            try
            {
                ShareLink = Request[UrlConstant.DocUrlKey] ?? "";
                WithLink  = !string.IsNullOrEmpty(ShareLink);

                var fileId = WithLink ? (object)-1 : Request[UrlConstant.FileId];
                FileNew = !string.IsNullOrEmpty(Request[UrlConstant.New]) && Request[UrlConstant.New] == "true";

                file = DocumentUtils.GetServiceParams(true, fileId, 0, FileNew, ShareLink, out DocParams);
            }
            catch (Exception ex)
            {
                Response.Redirect(PathProvider.BaseVirtualPath + "docviewer.aspx" + "?" + Request.QueryString + "#" + UrlConstant.Error + "/" + HttpUtility.UrlEncode(ex.Message));
            }

            if (!FileUtility.UsingHtml5(file.Title))
            {
                Server.Transfer("editor.aspx", true);
            }

            Title = file.Title;

            DocParams.Type = MobileDetector.IsRequestMatchesMobile(Context) ? "mobile" : "desktop";

            DocKeyForTrack = DocumentUtils.GetDocKey(file.ID, -1, DateTime.MinValue);

            using (var tagDao = Global.DaoFactory.GetTagDao())
            {
                tagDao.RemoveTags(Tag.New(SecurityContext.CurrentAccount.ID, file));
            }

            FilesActivityPublisher.OpenEditorFile(file);

            FileLocker.Add(file.ID);
        }
コード例 #8
0
        private void PageLoad()
        {
            var editPossible = !RequestEmbedded && !IsMobile;
            var isExtenral   = false;

            File file;
            var  fileUri = string.Empty;

            if (!ItsTry)
            {
                try
                {
                    if (string.IsNullOrEmpty(RequestFileUrl))
                    {
                        _fileNew = (Request["new"] ?? "") == "true";

                        var app = ThirdPartySelector.GetAppByFileId(RequestFileId);
                        if (app == null)
                        {
                            var ver = string.IsNullOrEmpty(Request[FilesLinkUtility.Version]) ? -1 : Convert.ToInt32(Request[FilesLinkUtility.Version]);

                            file = DocumentServiceHelper.GetParams(RequestFileId, ver, RequestShareLinkKey, _fileNew, editPossible, !RequestView, out _docParams);

                            _fileNew = _fileNew && file.Version == 1 && file.ConvertedType != null && file.CreateOn == file.ModifiedOn;
                        }
                        else
                        {
                            isExtenral = true;

                            bool editable;
                            ThirdPartyApp = true;
                            file          = app.GetFile(RequestFileId, out editable);
                            file          = DocumentServiceHelper.GetParams(file, true, true, true, editable, editable, editable, out _docParams);

                            _docParams.FileUri   = app.GetFileStreamUrl(file);
                            _docParams.FolderUrl = string.Empty;
                        }
                    }
                    else
                    {
                        isExtenral = true;

                        fileUri = RequestFileUrl;
                        var fileTitle = Request[FilesLinkUtility.FileTitle];
                        if (string.IsNullOrEmpty(fileTitle))
                        {
                            fileTitle = Path.GetFileName(HttpUtility.UrlDecode(fileUri)) ?? "";
                        }

                        if (CoreContext.Configuration.Standalone)
                        {
                            try
                            {
                                var webRequest = WebRequest.Create(RequestFileUrl);
                                using (var response = webRequest.GetResponse())
                                    using (var responseStream = new ResponseStream(response))
                                    {
                                        var externalFileKey = DocumentServiceConnector.GenerateRevisionId(RequestFileUrl);
                                        fileUri = DocumentServiceConnector.GetExternalUri(responseStream, MimeMapping.GetMimeMapping(fileTitle), externalFileKey);
                                    }
                            }
                            catch (Exception error)
                            {
                                Global.Logger.Error("Cannot receive external url for \"" + RequestFileUrl + "\"", error);
                            }
                        }

                        file = new File
                        {
                            ID    = RequestFileUrl,
                            Title = Global.ReplaceInvalidCharsAndTruncate(fileTitle)
                        };

                        file = DocumentServiceHelper.GetParams(file, true, true, true, false, false, false, out _docParams);
                        _docParams.CanEdit = editPossible && !CoreContext.Configuration.Standalone;
                        _editByUrl         = true;

                        _docParams.FileUri = fileUri;
                    }
                }
                catch (Exception ex)
                {
                    _errorMessage = ex.Message;
                    return;
                }
            }
            else
            {
                FileType tryType;
                try
                {
                    tryType = (FileType)Enum.Parse(typeof(FileType), Request[FilesLinkUtility.TryParam]);
                }
                catch
                {
                    tryType = FileType.Document;
                }

                var path = "demo";
                if (!IsMobile)
                {
                    path = FileConstant.NewDocPath + CultureInfo.CurrentUICulture.TwoLetterISOLanguageName + "/";
                    if (!Global.GetStoreTemplate().IsDirectory(path))
                    {
                        path = FileConstant.NewDocPath + "default/";
                    }

                    path += "new";
                }

                path += FileUtility.InternalExtension[tryType];

                var store = Global.GetStoreTemplate();
                fileUri = store.GetUri("", path).ToString();

                var fileTitle = "Demo" + FileUtility.InternalExtension[tryType];
                file = new File
                {
                    ID    = Guid.NewGuid(),
                    Title = Global.ReplaceInvalidCharsAndTruncate(fileTitle)
                };

                file = DocumentServiceHelper.GetParams(file, true, true, true, editPossible, editPossible, true, out _docParams);

                _docParams.FileUri = CommonLinkUtility.GetFullAbsolutePath(fileUri);
                _editByUrl         = true;
                _docParams.Lang    = CultureInfo.CurrentUICulture.Name;
            }

            if (_docParams.ModeWrite && FileConverter.MustConvert(file))
            {
                try
                {
                    file = FileConverter.ExecDuplicate(file, RequestShareLinkKey);
                }
                catch (Exception e)
                {
                    _docParams    = null;
                    _errorMessage = e.Message;
                    return;
                }

                var comment = "#message/" + HttpUtility.UrlEncode(FilesCommonResource.CopyForEdit);

                Response.Redirect(FilesLinkUtility.GetFileWebEditorUrl(file.ID) + comment);
                return;
            }

            Title = HeaderStringHelper.GetPageTitle(file.Title);

            _newScheme = FileUtility.ExtsNewService.Contains(FileUtility.GetFileExtension(file.Title));
            if (_newScheme)
            {
                DocServiceApiUrl = FilesLinkUtility.DocServiceApiUrlNew;
            }

            if (string.IsNullOrEmpty(_docParams.FolderUrl))
            {
                _docParams.FolderUrl = Request[FilesLinkUtility.FolderUrl] ?? "";
            }
            if (MobileDetector.IsRequestMatchesMobile(true))
            {
                _docParams.FolderUrl = string.Empty;
            }

            if (RequestEmbedded)
            {
                _docParams.Type = DocumentServiceParams.EditorType.Embedded;

                var shareLinkParam = "&" + FilesLinkUtility.DocShareKey + "=" + RequestShareLinkKey;
                _docParams.ViewerUrl   = CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.FilesBaseAbsolutePath + FilesLinkUtility.EditorPage + "?" + FilesLinkUtility.Action + "=view" + shareLinkParam);
                _docParams.DownloadUrl = CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.FileHandlerPath + "?" + FilesLinkUtility.Action + "=download" + shareLinkParam);
                _docParams.EmbeddedUrl = CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.FilesBaseAbsolutePath + FilesLinkUtility.EditorPage + "?" + FilesLinkUtility.Action + "=embedded" + shareLinkParam);
            }
            else
            {
                _docParams.Type = IsMobile ? DocumentServiceParams.EditorType.Mobile : DocumentServiceParams.EditorType.Desktop;

                if (FileSharing.CanSetAccess(file))
                {
                    _docParams.SharingSettingsUrl = CommonLinkUtility.GetFullAbsolutePath(Share.Location + "?" + FilesLinkUtility.FileId + "=" + file.ID);
                }
            }

            if (!isExtenral)
            {
                _docKeyForTrack = DocumentServiceHelper.GetDocKey(file.ID, -1, DateTime.MinValue);

                if (!ItsTry)
                {
                    FileMarker.RemoveMarkAsNew(file);
                }
            }

            if (_docParams.ModeWrite)
            {
                _tabId        = FileTracker.Add(file.ID, _fileNew);
                _fixedVersion = FileTracker.FixedVersion(file.ID);

                if (ItsTry)
                {
                    AppendAuthControl();
                }
            }
            else
            {
                _docParams.LinkToEdit = _editByUrl
                                            ? CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorExternalUrl(fileUri, file.Title))
                                            : FileConverter.MustConvert(_docParams.File) || _newScheme
                                                  ? CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorUrl(file.ID))
                                                  : string.Empty;
            }

            if (CoreContext.Configuration.Personal && IsMobile)
            {
                _docParams.CanEdit = false;
            }
        }
コード例 #9
0
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (MobileDetector.IsRequestMatchesMobile(Context))
            {
                Response.Redirect(CommonLinkUtility.GetFileWebViewerUrl(Request[UrlConstant.FileId]) +
                                  (string.IsNullOrEmpty(Request[UrlConstant.DocUrlKey]) ? "" : "&" + UrlConstant.DocUrlKey + "=" + Request[UrlConstant.DocUrlKey]));
            }

            if (!FileUtility.EnableHtml5)
            {
                Server.Transfer("editor.aspx", true);
            }

            //check if cookie from this portal
            if (SecurityContext.CurrentAccount is IUserAccount &&
                ((IUserAccount)SecurityContext.CurrentAccount).Tenant != CoreContext.TenantManager.GetCurrentTenant().TenantId)
            {
                SecurityContext.Logout();
                Response.Redirect("~/");
            }

            var currentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

            if (currentUser == Constants.LostUser || currentUser.Status != EmployeeStatus.Active)
            {
                SecurityContext.Logout();
                Response.Redirect("~/");
            }

            ProcessSecureFilter();

            if (!SecurityContext.IsAuthenticated &&
                DocumentUtils.ParseShareLink(Request[UrlConstant.DocUrlKey]) == null)
            {
                //for demo
                if (SetupInfo.WorkMode == WorkMode.Promo)
                {
                    if (AutoAuthByPromo())
                    {
                        UserOnlineManager.Instance.RegistryOnlineUser(SecurityContext.CurrentAccount.ID);

                        Response.Redirect("~/");
                        return;
                    }
                }

                var refererURL = Request.GetUrlRewriter().AbsoluteUri;
                if (!ValidateRefererUrl(refererURL))
                {
                    refererURL = (string)Session["refererURL"];
                }

                if (!AutoAuthByCookies() && !CoreContext.TenantManager.GetCurrentTenant().Public)
                {
                    Session["refererURL"] = refererURL;
                    Response.Redirect("~/auth.aspx");
                    return;
                }
            }

            if (SecurityContext.IsAuthenticated)
            {
                UserOnlineManager.Instance.RegistryOnlineUser(SecurityContext.CurrentAccount.ID);
            }

            CurrentSkin = WebSkin.GetUserSkin();
            Theme       = CurrentSkin.ASPTheme;
        }
コード例 #10
0
        private void RegisterClientSideScript()
        {
            var currentCulture = CultureInfo.CurrentCulture.Name;
            var mobileAgentStr = MobileDetector.IsRequestMatchesMobile(Context).ToString().ToLower();

            var sb = new StringBuilder();

            //Skin images
            sb.Append("<script language=\"javascript\" type=\"text/javascript\">");
            sb.Append(JsSkinHash.GetJs());
            sb.Append("</script>");

            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/jquery_full.js") + "\"></script>");

            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/asc.customevents.js") + "\"></script>");
            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/api.factory.js") + "\"></script>");
            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/api.helper.js") + "\"></script>");
            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/api.service.js") + "\"></script>");
            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/asc.teamlab.js") + "\"></script>");
            sb.Append("<script language=\"javascript\" type=\"text/javascript\">");
            sb.AppendFormat("ServiceManager.init('{0}');", SetupInfo.WebApiBaseUrl);
            sb.AppendFormat("ServiceFactory.init({{responses:{{isme:'{0}'}},portaldatetime:{{utcoffsettotalminutes:{1}, displayname:'{2}'}},names:{{months:'{3}',shortmonths:'{4}',days:'{5}',shortdays:'{6}'}},formats:{{datetime:'{7}',time:'{8}',date:'{9}'}},avatars:{{small:'{10}',medium:'{11}',large:'{12}'}},supportedfiles:{{imgs:'{13}',docs:'{14}'}}}});",
                            new Api.ApiServer().GetApiResponse("api/1.0/people/@self.json", "GET"),
                            CoreContext.TenantManager.GetCurrentTenant().TimeZone.GetUtcOffset(DateTime.UtcNow).TotalMinutes,
                            CoreContext.TenantManager.GetCurrentTenant().TimeZone.DisplayName,
                            EscapeJsString(GetMonthNames()),
                            EscapeJsString(GetShortMonthNames()),
                            EscapeJsString(GetDayNames()),
                            EscapeJsString(GetShortDayNames()),
                            EscapeJsString(GetFullDateTimePattern()),
                            EscapeJsString(GetShortTimePattern()),
                            EscapeJsString(GetShortDatePattern()),
                            WebImageSupplier.GetAbsoluteWebPath("default_user_photo_size_32-32.gif"),
                            WebImageSupplier.GetAbsoluteWebPath("default_user_photo_size_48-48.gif"),
                            WebImageSupplier.GetAbsoluteWebPath("default_user_photo_size_82-82.gif"),
                            ConfigurationManager.AppSettings["files.viewed-images"],
                            ConfigurationManager.AppSettings["files.docservice.viewed-docs"]);
            sb.Append("Teamlab.init();");
            sb.Append("</script>");

            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/jquery.cookies.js") + "\"></script>");
            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/fancyzoom.min.js") + "\"></script>");
            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/jquery.helper.js") + "\"></script>");

            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/jquery-datepicker.js") + "\"></script>");
            sb.Append("<script type=\"text/javascript\">");
            sb.AppendFormat("if(jQuery.datepicker)jQuery.datepicker.setDefaults({{prevText:'',nextText:'',firstDay:{0},dateFormat:'{1}',dayNamesMin:'{2}'.split(','),monthNames:'{3}'.split(',')}});",
                            getFirtsDay().ToString(),
                            EscapeJsString(getDatepikerDateFormat(GetShortDatePattern())),
                            EscapeJsString(GetShortDayNames()),
                            EscapeJsString(GetMonthNames()));
            sb.Append("</script>");

            sb.Append("<script language=\"javascript\" type=\"text/javascript\">");
            sb.Append("jQuery.extend(jQuery.browser, {mobile : " + mobileAgentStr + "});");
            sb.Append("</script>");

            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/common.js") + "\"></script>");
            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/profile_info_tooltip.js") + "\"></script>");
            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/management.js") + "\"></script>");
            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/asc.anchorcontroller.js") + "\"></script>");
            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/asc.xsltmanager.js") + "\"></script>");
            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/jquery.datepick.lang.js") + "\"></script>");
            sb.Append("<script language=\"javascript\" type=\"text/javascript\" src=\"" + WebPath.GetPath("js/auto/asc.files.utility.js") + "\"></script>");

            sb.Append("<script language=\"javascript\" type=\"text/javascript\">");

            sb.Append(" jq.datepick.setDefaults(jq.datepick.regional['" + currentCulture + "']); ");
            sb.Append(" StudioManager.LoadingProcessing = \"" + Resources.Resource.LoadingProcessing + "\"; ");
            sb.Append(" StudioManager.LoadingDescription = \"" + Resources.Resource.LoadingDescription + "\"; ");
            sb.Append(" StudioManager.RemoveMessage = \"" + Resources.Resource.DeleteButton + "\"; ");
            sb.Append(" StudioManager.ErrorFileSizeLimit = \"" + FileSizeComment.FileSizeExceptionString + "\"; ");
            sb.Append(" StudioManager.ErrorFileEmpty = \"" + Resources.Resource.ErrorFileEmptyText + "\"; ");
            sb.Append(" StudioManager.ErrorFileTypeText = \"" + Resources.Resource.ErrorFileTypeText + "\"; ");
            sb.Append(" AuthManager.ConfirmMessage = \"" + Resources.Resource.ConfirmMessage + "\"; ");
            sb.Append(" AuthManager.ConfirmRemoveUser = \"" + Core.Users.CustomNamingPeople.Substitute <Resources.Resource>("ConfirmRemoveUser").HtmlEncode() + "\"; ");
            sb.AppendFormat(" function GetMaxImageWidth() {{ return {0}; }};", ConfigurationManager.AppSettings["MaxImageFCKWidth"] ?? "620");
            sb.AppendFormat(" jq(document).ready(function() {{ jq('a.fancyzoom').fancyZoom({{scaleImg: true, closeOnClick: true, directory : '{0}'}}); }});", WebSkin.GetUserSkin().GetCSSFileAbsoluteWebPath("fancyzoom_img"));

            if (SetupInfo.WorkMode == WorkMode.Promo)
            {
                sb.Append(" PromoMode = true; PromoActionURL='" + SetupInfo.PromoActionURL + "'; ");
            }

            sb.Append("</script>");

            sb.Append(FileUtility.GetFileUtilityJScript());

            mainScript.Text = sb.ToString();
        }
コード例 #11
0
        private void PageLoad()
        {
            var editPossible = !RequestEmbedded;
            var isExtenral   = false;

            File file;
            var  fileUri = string.Empty;

            try
            {
                if (string.IsNullOrEmpty(RequestFileUrl))
                {
                    _fileNew = (Request["new"] ?? "") == "true";

                    var app = ThirdPartySelector.GetAppByFileId(RequestFileId);
                    if (app == null)
                    {
                        var ver = string.IsNullOrEmpty(Request[FilesLinkUtility.Version]) ? -1 : Convert.ToInt32(Request[FilesLinkUtility.Version]);

                        file = DocumentServiceHelper.GetParams(RequestFileId, ver, RequestShareLinkKey, _fileNew, editPossible, !RequestView, out _docParams);

                        _fileNew = _fileNew && file.Version == 1 && file.CreateOn == file.ModifiedOn;
                    }
                    else
                    {
                        isExtenral = true;

                        bool editable;
                        _thirdPartyApp = true;
                        file           = app.GetFile(RequestFileId, out editable);
                        file           = DocumentServiceHelper.GetParams(file, true, true, true, editable, editable, editable, editable, out _docParams);

                        _docParams.FileUri   = app.GetFileStreamUrl(file);
                        _docParams.FolderUrl = string.Empty;
                    }
                }
                else
                {
                    isExtenral = true;

                    fileUri = RequestFileUrl;
                    var fileTitle = Request[FilesLinkUtility.FileTitle];
                    if (string.IsNullOrEmpty(fileTitle))
                    {
                        fileTitle = Path.GetFileName(HttpUtility.UrlDecode(fileUri)) ?? "";
                    }

                    if (CoreContext.Configuration.Standalone)
                    {
                        try
                        {
                            var webRequest = (HttpWebRequest)WebRequest.Create(RequestFileUrl);

                            // hack. http://ubuntuforums.org/showthread.php?t=1841740
                            if (WorkContext.IsMono)
                            {
                                ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
                            }

                            using (var response = webRequest.GetResponse())
                                using (var responseStream = new ResponseStream(response))
                                {
                                    var externalFileKey = DocumentServiceConnector.GenerateRevisionId(RequestFileUrl);
                                    fileUri = DocumentServiceConnector.GetExternalUri(responseStream, MimeMapping.GetMimeMapping(fileTitle), externalFileKey);
                                }
                        }
                        catch (Exception error)
                        {
                            Global.Logger.Error("Cannot receive external url for \"" + RequestFileUrl + "\"", error);
                        }
                    }

                    file = new File
                    {
                        ID    = RequestFileUrl,
                        Title = Global.ReplaceInvalidCharsAndTruncate(fileTitle)
                    };

                    file = DocumentServiceHelper.GetParams(file, true, true, true, false, false, false, false, out _docParams);
                    _docParams.CanEdit   = editPossible && !CoreContext.Configuration.Standalone;
                    _docParams.CanReview = _docParams.CanEdit;
                    _editByUrl           = true;

                    _docParams.FileUri = fileUri;
                }
            }
            catch (Exception ex)
            {
                Global.Logger.Error("DocEditor", ex);
                _errorMessage = ex.Message;
                return;
            }

            if (_docParams.ModeWrite && FileConverter.MustConvert(file))
            {
                try
                {
                    file = FileConverter.ExecDuplicate(file, RequestShareLinkKey);
                }
                catch (Exception ex)
                {
                    _docParams = null;
                    Global.Logger.Error("DocEditor", ex);
                    _errorMessage = ex.Message;
                    return;
                }

                var comment = "#message/" + HttpUtility.UrlEncode(FilesCommonResource.CopyForEdit);

                Response.Redirect(FilesLinkUtility.GetFileWebEditorUrl(file.ID) + comment);
                return;
            }

            Title = file.Title;

            if (string.IsNullOrEmpty(_docParams.FolderUrl))
            {
                _docParams.FolderUrl = Request[FilesLinkUtility.FolderUrl] ?? "";
            }
            if (MobileDetector.IsRequestMatchesMobile(true))
            {
                _docParams.FolderUrl = string.Empty;
            }

            if (RequestEmbedded)
            {
                _docParams.Type = DocumentServiceParams.EditorType.Embedded;

                var shareLinkParam = "&" + FilesLinkUtility.DocShareKey + "=" + RequestShareLinkKey;
                _docParams.ViewerUrl   = CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.FilesBaseAbsolutePath + FilesLinkUtility.EditorPage + "?" + FilesLinkUtility.Action + "=view" + shareLinkParam);
                _docParams.DownloadUrl = CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.FileHandlerPath + "?" + FilesLinkUtility.Action + "=download" + shareLinkParam);
                _docParams.EmbeddedUrl = CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.FilesBaseAbsolutePath + FilesLinkUtility.EditorPage + "?" + FilesLinkUtility.Action + "=embedded" + shareLinkParam);
            }
            else
            {
                _docParams.Type = IsMobile ? DocumentServiceParams.EditorType.Mobile : DocumentServiceParams.EditorType.Desktop;

                if (FileSharing.CanSetAccess(file))
                {
                    _docParams.SharingSettingsUrl = CommonLinkUtility.GetFullAbsolutePath(Share.Location + "?" + FilesLinkUtility.FileId + "=" + file.ID);
                }
            }

            if (!isExtenral)
            {
                _docKeyForTrack = DocumentServiceHelper.GetDocKey(file.ID, -1, DateTime.MinValue);

                FileMarker.RemoveMarkAsNew(file);
            }

            if (_docParams.ModeWrite)
            {
                _tabId        = FileTracker.Add(file.ID, _fileNew);
                _fixedVersion = FileTracker.FixedVersion(file.ID);
                if (SecurityContext.IsAuthenticated)
                {
                    _docParams.FileChoiceUrl  = CommonLinkUtility.GetFullAbsolutePath(FileChoice.Location) + "?" + FileChoice.ParamFilterExt + "=xlsx&" + FileChoice.MailMergeParam + "=true";
                    _docParams.MergeFolderUrl = CommonLinkUtility.GetFullAbsolutePath(MailMerge.GetUrl);
                }
            }
            else
            {
                if (!RequestView && FileTracker.IsEditingAlone(file.ID))
                {
                    var editingBy = FileTracker.GetEditingBy(file.ID).FirstOrDefault();
                    _errorMessage = string.Format(FilesCommonResource.ErrorMassage_EditingMobile, Global.GetUserName(editingBy));
                }

                _docParams.LinkToEdit = _editByUrl
                                            ? CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorExternalUrl(fileUri, file.Title))
                                            : CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorUrl(file.ID));

                if (FileConverter.MustConvert(_docParams.File))
                {
                    _editByUrl = true;
                }
            }
        }
コード例 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AjaxPro.Utility.RegisterTypeForAjax(typeof(ActionContainer), this.Page);

            _storage       = StorageFactory.GetStorage();
            _requestHelper = new RequestHelper(Request, _storage);

            var currentModule = UserOnlineManager.Instance.GetCurrentModule() as Module;

            if (currentModule == null)
            {
                return;
            }

            var actionsControl = new SideActions();

            if (CommunitySecurity.CheckPermissions(ASC.PhotoManager.PhotoConst.Action_AddPhoto) && !MobileDetector.IsRequestMatchesMobile(Context))
            {
                actionsControl.Controls.Add(new NavigationItem()
                {
                    Name        = PhotoManagerResource.UploadPhotosLink,
                    Description = PhotoManagerResource.UploadPhotosLinkDescription,
                    URL         = ASC.PhotoManager.PhotoConst.AddPhotoPageUrl
                                  + (_requestHelper.EventId != 0 ? "?" + ASC.PhotoManager.PhotoConst.PARAM_EVENT + "=" + _requestHelper.EventId : ""),
                    IsPromo = (SetupInfo.WorkMode == WorkMode.Promo)
                });
            }

            if (IAmAsRecipient != null)
            {
                actionsControl.Controls.Add(new HtmlMenuItem(RenderSubscriptionOnUploadsLink()));
            }
            if (IAmAsRecipient != null && _requestHelper.EventId != 0)
            {
                actionsControl.Controls.Add(new HtmlMenuItem(RenderSubscriptionOnEventLink(_requestHelper.EventId)));
            }
            if (actionsControl.Controls.Count > 0)
            {
                _actionHolder.Controls.Add(actionsControl);
            }
            if (ActionsPlaceHolder.Controls.Count > 0)
            {
                actionsControl.Controls.Add(ActionsPlaceHolder);
            }
            if (currentModule.Navigations.Any())
            {
                var navigationControl = new SideNavigator();
                foreach (var shortcut in currentModule.Navigations)
                {
                    if (shortcut.ID == new Guid("4367C1B3-9F22-41a9-9CF1-DDCC612AFEE0") && !SecurityContext.IsAuthenticated)
                    {
                        // skip My Photos for guest
                        continue;
                    }
                    navigationControl.Controls.Add(new NavigationItem()
                    {
                        Name        = shortcut.Name,
                        Description = shortcut.Description,
                        URL         = shortcut.StartURL
                    });
                }
                _actionHolder.Controls.Add(navigationControl);
            }
        }
コード例 #13
0
        protected override void PageLoad()
        {
            Utility.RegisterTypeForAjax(typeof(AddBlog));

            if (String.IsNullOrEmpty(BlogId))
            {
                Response.Redirect(Constants.DefaultPageUrl);
            }

            _mobileVer = MobileDetector.IsRequestMatchesMobile(Context);

            //fix for IE 10 && IE11
            var browser = HttpContext.Current.Request.Browser.Browser;

            var userAgent  = Context.Request.Headers["User-Agent"];
            var regExp     = new Regex("MSIE 10.0", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
            var regExpIe11 = new Regex("(?=.*Trident.*rv:11.0).+", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);

            if (browser == "IE" && regExp.Match(userAgent).Success || regExpIe11.Match(userAgent).Success)
            {
                _mobileVer = true;
            }

            var engine = GetEngine();

            Utility.RegisterTypeForAjax(typeof(EditBlog), Page);

            FCKeditor.BasePath      = VirtualPathUtility.ToAbsolute(CommonControlsConfigurer.FCKEditorBasePath);
            FCKeditor.ToolbarSet    = "BlogToolbar";
            FCKeditor.EditorAreaCSS = WebSkin.BaseCSSFileAbsoluteWebPath;

            FCKeditor.Visible = !_mobileVer;

            if (_mobileVer && IsPostBack)
            {
                _text = Request["mobiletext"];
            }

            mainContainer.CurrentPageCaption = BlogsResource.EditPostTitle;
            Title = HeaderStringHelper.GetPageTitle(BlogsResource.EditPostTitle);

            ShowForEdit(engine);

            lbCancel.Attributes["name"] = FCKeditor.ClientID;
            if (IsPostBack)
            {
                var control = FindControl(Request.Params["__EVENTTARGET"]);
                if (lbCancel.Equals(control))
                {
                    Response.Redirect("viewblog.aspx?blogid=" + Request.Params["blogid"]);
                }
                else
                {
                    if (CheckTitle(txtTitle.Text))
                    {
                        var pageEngine = GetEngine();
                        var post       = pageEngine.GetPostById(new Guid(hidBlogID.Value));
                        UpdatePost(post, engine);
                    }
                    else
                    {
                        mainContainer.Options.InfoMessageText = BlogsResource.BlogTitleEmptyMessage;
                        mainContainer.Options.InfoType        = InfoType.Alert;
                    }
                }
            }
            InitScript();
        }
コード例 #14
0
        private void PageLoad()
        {
            var editPossible = !RequestEmbedded && !IsMobile;
            var isExtenral   = false;

            File file;
            var  fileUri = string.Empty;

            if (!ItsTry)
            {
                try
                {
                    if (string.IsNullOrEmpty(RequestFileUrl))
                    {
                        _fileNew = !string.IsNullOrEmpty(Request[UrlConstant.New]) && Request[UrlConstant.New] == "true";

                        var ver = string.IsNullOrEmpty(Request[CommonLinkUtility.Version]) ? -1 : Convert.ToInt32(Request[CommonLinkUtility.Version]);

                        file = DocumentServiceHelper.GetParams(RequestFileId, ver, RequestShareLinkKey, _fileNew, editPossible, !RequestView, out _docParams);

                        _fileNew = file.Version == 1 && file.ConvertedType != null && _fileNew && file.CreateOn == file.ModifiedOn;
                    }
                    else
                    {
                        isExtenral = true;

                        fileUri = RequestFileUrl;
                        var fileTitle = Request[CommonLinkUtility.FileTitle];
                        if (string.IsNullOrEmpty(fileTitle))
                        {
                            fileTitle = Path.GetFileName(HttpUtility.UrlDecode(fileUri)) ?? "";
                        }

                        if (CoreContext.Configuration.Standalone)
                        {
                            try
                            {
                                var webRequest = WebRequest.Create(RequestFileUrl);
                                using (var response = webRequest.GetResponse())
                                    using (var responseStream = new ResponseStream(response))
                                    {
                                        fileUri = DocumentServiceConnector.GetExternalUri(responseStream, MimeMapping.GetMimeMapping(fileTitle), "new");
                                    }
                            }
                            catch (Exception error)
                            {
                                Global.Logger.Error("Cannot receive external url for \"" + RequestFileUrl + "\"", error);
                            }
                        }

                        file = new File
                        {
                            ID    = fileUri.GetHashCode(),
                            Title = Global.ReplaceInvalidCharsAndTruncate(fileTitle)
                        };

                        file = DocumentServiceHelper.GetParams(file, true, true, true, false, false, false, out _docParams);
                        _docParams.CanEdit = editPossible && !CoreContext.Configuration.Standalone;
                        _editByUrl         = true;

                        _docParams.FileUri = fileUri;
                    }
                }
                catch (Exception ex)
                {
                    _errorMessage = ex.Message;
                    return;
                }
            }
            else
            {
                FileType tryType;
                try
                {
                    tryType = (FileType)Enum.Parse(typeof(FileType), Request[CommonLinkUtility.TryParam]);
                }
                catch
                {
                    tryType = FileType.Document;
                }

                var fileTitle = "Demo";
                fileTitle += FileUtility.InternalExtension[tryType];

                var relativeUri = string.Format(CommonLinkUtility.FileHandlerPath + UrlConstant.ParamsDemo, tryType);
                fileUri = new Uri(Request.Url, relativeUri).ToString();

                file = new File
                {
                    ID    = Guid.NewGuid(),
                    Title = Global.ReplaceInvalidCharsAndTruncate(fileTitle)
                };

                file = DocumentServiceHelper.GetParams(file, true, true, true, editPossible, editPossible, true, out _docParams);

                _docParams.FileUri = fileUri;
                _editByUrl         = true;
            }

            if (_docParams.ModeWrite && FileConverter.MustConvert(file))
            {
                try
                {
                    file = FileConverter.ExecDuplicate(file, RequestShareLinkKey);
                }
                catch (Exception e)
                {
                    _docParams    = null;
                    _errorMessage = e.Message;
                    return;
                }

                var comment = "#message/" + HttpUtility.UrlEncode(FilesCommonResource.CopyForEdit);

                Response.Redirect(CommonLinkUtility.GetFileWebEditorUrl(file.ID) + comment);
                return;
            }

            Title = HeaderStringHelper.GetPageTitle(file.Title);

            if (string.IsNullOrEmpty(_docParams.FolderUrl))
            {
                _docParams.FolderUrl = Request[CommonLinkUtility.FolderUrl] ?? "";
            }
            if (MobileDetector.IsRequestMatchesMobile(Context.Request.UserAgent, true))
            {
                _docParams.FolderUrl = string.Empty;
            }

            if (RequestEmbedded)
            {
                _docParams.Type = DocumentServiceParams.EditorType.Embedded;

                var shareLinkParam = "&" + CommonLinkUtility.DocShareKey + "=" + RequestShareLinkKey;
                _docParams.ViewerUrl   = CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.FilesBaseAbsolutePath + CommonLinkUtility.EditorPage + "?" + CommonLinkUtility.Action + "=view" + shareLinkParam);
                _docParams.DownloadUrl = CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.FileHandlerPath + "?" + CommonLinkUtility.Action + "=download" + shareLinkParam);
                _docParams.EmbeddedUrl = CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.FilesBaseAbsolutePath + CommonLinkUtility.EditorPage + "?" + CommonLinkUtility.Action + "=embedded" + shareLinkParam);
            }
            else
            {
                _docParams.Type = IsMobile ? DocumentServiceParams.EditorType.Mobile : DocumentServiceParams.EditorType.Desktop;

                if (FileSharing.CanSetAccess(file))
                {
                    _docParams.SharingSettingsUrl = CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.FilesBaseAbsolutePath + "share.aspx" + "?" + CommonLinkUtility.FileId + "=" + file.ID + "&" + CommonLinkUtility.FileTitle + "=" + HttpUtility.UrlEncode(file.Title));
                }
            }

            if (!isExtenral)
            {
                _docKeyForTrack = DocumentServiceHelper.GetDocKey(file.ID, -1, DateTime.MinValue);

                if (!ItsTry)
                {
                    FileMarker.RemoveMarkAsNew(file);
                }
            }

            if (_docParams.ModeWrite)
            {
                _tabId       = FileLocker.Add(file.ID, _fileNew);
                _lockVersion = FileLocker.LockVersion(file.ID);

                if (ItsTry)
                {
                    AppendAuthControl();
                }
            }
            else
            {
                _docParams.LinkToEdit = _editByUrl
                                            ? CommonLinkUtility.GetFullAbsolutePath(string.Format(CommonLinkUtility.FileWebEditorExternalUrlString, HttpUtility.UrlEncode(fileUri), file.Title))
                                            : FileConverter.MustConvert(_docParams.File)
                                                  ? CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetFileWebEditorUrl(file.ID))
                                                  : string.Empty;
            }

            if (CoreContext.Configuration.YourDocsDemo && IsMobile)
            {
                _docParams.CanEdit = false;
            }
        }
コード例 #15
0
        protected void PageLoad()
        {
            File file;

            try
            {
                ShareLink = Request[UrlConstant.DocUrlKey] ?? "";
                WithLink  = !string.IsNullOrEmpty(ShareLink);

                var fileId  = WithLink ? (object)-1 : Request[UrlConstant.FileId];
                var ver     = string.IsNullOrEmpty(Request[UrlConstant.Version]) ? -1 : Convert.ToInt32(Request[UrlConstant.Version]);
                var fileNew = !string.IsNullOrEmpty(Request[UrlConstant.New]) && Request[UrlConstant.New] == "true";

                file = DocumentUtils.ViewIframeSrc(fileId, fileNew, ver, ShareLink, out SrcIframe);

                if (!MobileDetector.IsRequestMatchesMobile(Context))
                {
                    if (SecurityContext.IsAuthenticated)
                    {
                        var parent = Global.DaoFactory.GetFolderDao().GetFolder(file.FolderID);
                        if (file.RootFolderType == FolderType.USER &&
                            file.RootFolderCreator != SecurityContext.CurrentAccount.ID &&
                            !Global.GetFilesSecurity().CanRead(parent))
                        {
                            FolderUrl = PathProvider.GetFolderUrl(Global.FolderShare, false, null);
                        }
                        else
                        {
                            FolderUrl = PathProvider.GetFolderUrl(parent);

                            if (string.IsNullOrEmpty(FolderUrl))
                            {
                                FolderUrl = Request.UrlReferrer == null
                                                ? VirtualPathUtility.ToAbsolute(PathProvider.StartURL)
                                                : Request.UrlReferrer.ToString();
                            }

                            if (Global.EnableShare)
                            {
                                CommonContainerHolder.Controls.Add(LoadControl(AccessRights.Location));
                            }
                        }
                    }
                }
                else
                {
                    file = null;
                }
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                return;
                //var urlRedirect = Request.UrlReferrer == null
                //                      ? PathProvider.StartURL
                //                      : Request.UrlReferrer.ToString();

                //Response.Redirect(urlRedirect + "#" + UrlConstant.Error + "/" + HttpUtility.UrlEncode(ex.Message));
            }

            if (file == null)
            {
                Response.Redirect(SrcIframe);
            }

            Title       = file.Title;
            FileId      = file.ID;
            FileTitle   = file.Title;
            FileVersion = file.Version;

            using (var tagDao = Global.DaoFactory.GetTagDao())
            {
                tagDao.RemoveTags(Tag.New(SecurityContext.CurrentAccount.ID, file));
            }
        }