Ejemplo n.º 1
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (!Page.IsPostBack)
            {
                Session["EkDavSessionVal"] = null;
            }
            m_refMsg = m_refContApi.EkMsgRef;
            Utilities.ValidateUserLogin();
            RegisterResources();
            aHelp.HRef = "#Help";
            aHelp.Attributes.Add("onclick", "window.open('" + m_refContApi.fetchhelpLink("add_assets") + "', '', 'width=800,height=500,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no');return false;");
            setLocalizedStrings();
            if (Request.QueryString["folderiD"] != null)
            {
                _folderID = Convert.ToInt64(Request.QueryString["folderID"]);
                jsFolderID.Text = _folderID.ToString();

            }

            if (Request.QueryString["TaxonomyId"] != null)
            {
                _taxonomyID = Convert.ToInt64(Request.QueryString["TaxonomyId"]);
                jsTaxonomyId.Text = _taxonomyID.ToString();
                jsTaxonomyIdReloadFrame.Text = _taxonomyID.ToString();
                jsTaxID.Text = _taxonomyID.ToString();
                isMetadataOrTaxonomyRequired = true;
            }

            if (Request.QueryString["LangType"] != null)
            {
                _contentLanguage = Convert.ToInt32(Request.QueryString["LangType"]);
                jsLanguageID.Text = _contentLanguage.ToString();
            }

            if (m_refContApi.EkContentRef.DoesFolderRequireMetadataOrTaxonomy(_folderID, _contentLanguage))
            {
                isMetadataOrTaxonomyRequired = true;
            }

            ExplorerDragDrop dragDrop = new ExplorerDragDrop();

            bool _useSSL = Ektron.Cms.Common.EkFunctions.GetConfigBoolean("ek_UseOffloadingSSL", false);
            string _scheme = string.Empty;
            if (_useSSL)
            {
                _scheme = "https";
            }
            else
            {
                _scheme = Page.Request.Url.Scheme;
            }

            destination.Value = Convert.ToString(_scheme + Uri.SchemeDelimiter + this.Page.Request.Url.Authority + m_refContApi.ApplicationPath) + "processMultiupload.aspx?close=true";
            PostURL.Value = Convert.ToString(_scheme + Uri.SchemeDelimiter + this.Page.Request.Url.Authority + m_refContApi.ApplicationPath) + "processMultiupload.aspx?close=true";
            NextUsing.Value = Convert.ToString(_scheme + Uri.SchemeDelimiter + Page.Request.Url.Authority + m_refContApi.ApplicationPath + "content.aspx");
            content_id.Value = "-1";
            content_folder.Value = _folderID.ToString();
            content_language.Value = _contentLanguage.ToString();
            requireMetaTaxonomy.Value = isMetadataOrTaxonomyRequired.ToString();
            taxonomyselectedtree.Value = _taxonomyID.ToString();
            content_teaser.Value = "";
            HtmlGenericControl linebreak = new HtmlGenericControl("div");
            linebreak.InnerHtml += "<div id=\'divFileTypes\' style=\'display:none;float:left;\'> " + m_refMsg.GetMessage("lbl valid file types") + "<p class=\'dmsSupportedFileTypes\' style=\'font-size:11px;\'>" + DocumentManagerData.Instance.FileTypes + "</p></div>";
            linebreak.InnerHtml += "<br />";
            linebreak.InnerHtml += "<div id=idMultipleView style=\'display:inline\'>";
            linebreak.InnerHtml += (string) ("<script type=\"text/javascript\">" + Environment.NewLine);
            linebreak.InnerHtml += (string) (" AC_AX_RunContent(\'id\',\'idUploadCtl\',\'name\',\'idUploadCtl\',\'classid\',\'CLSID:07B06095-5687-4d13-9E32-12B4259C9813\',\'width\',\'100%\',\'height\',\'350px\');" + Environment.NewLine);
            linebreak.InnerHtml += Environment.NewLine + " </script> </div> " + Environment.NewLine;
            linebreak.InnerHtml += "<br /><br />";
            //tabMultipleDMS.Controls.Add(linebreak);
            if (Request.Cookies[DMSCookieName] != null && !string.IsNullOrEmpty(Request.Cookies[DMSCookieName].Value))
            {
                pnl_versionToggle.Visible = pnl_DMSMultiUpload.Visible = true;
                pnl_OfficeVerSelector.Visible = false;

                if (Request.Cookies[DMSCookieName].Value == "2010")
                {
                    ExplorerDragDrop edd = new ExplorerDragDrop();
                    string ekdavurl=edd.GetFolderPath(_folderID).Replace(Page.Request.Url.GetLeftPart(UriPartial.Authority), "");
                    try
                    {
                        string[] urlparts = ekdavurl.Split('_');
                        urlparts[4] = _taxonomyID.ToString();
                        ekdavurl = string.Join("_", urlparts);
                    }
                    catch
                    { }
                    destination.Value = ekdavurl;//edd.GetFolderPath(_folderID).Replace(Page.Request.Url.GetLeftPart(UriPartial.Authority), "");
                    putopts.Value = "false";
                    Upload.OnClientClick = "return MultipleDocumentUpload(0);";
                    lbtn_toggleVersion.Attributes.Add("onclick", string.Format(m_refMsg.GetMessage("js office version toggle confirm format"), m_refMsg.GetMessage("li text office 2010 name")));
                    lbtn_toggleVersion.Text = m_refMsg.GetMessage("lbtn dms switch office version") + "(Office 2010 selected)";
                }
                else
                {
                    destination.Value = _scheme + Uri.SchemeDelimiter + this.Page.Request.Url.Authority + m_refContApi.ApplicationPath + "processMultiupload.aspx?close=true";
                    PostURL.Value = _scheme + Uri.SchemeDelimiter + this.Page.Request.Url.Authority + m_refContApi.ApplicationPath + "processMultiupload.aspx?close=true";
                    putopts.Value = "true";
                    Upload.OnClientClick = "MultipleDocumentUpload(1);";
                    lbtn_toggleVersion.Attributes.Add("onclick", string.Format(m_refMsg.GetMessage("js office version toggle confirm format"), m_refMsg.GetMessage("li text other office ver name")));
                    lbtn_toggleVersion.Text = m_refMsg.GetMessage("lbtn dms switch office version") + "(Office 2003/2007 selected)";

                }
                tabMultipleDMS.Controls.Add(linebreak);
            }
            else
            {
                pnl_versionToggle.Visible = pnl_DMSMultiUpload.Visible = false;
                pnl_OfficeVerSelector.Visible = true;
            }

            if (Request.QueryString["showtab"] != null && Request.QueryString["showtab"] == "multiple")
            {
                ltrNoUpload.Text = m_refMsg.GetMessage("lbl upload file");
                ClientScript.RegisterStartupScript(this.GetType(), "selectTab", "var ddTabs = $ektron('#DMStabs').tabs({select: function(event, ui){ResizeDocumentContainer(ui);}}); ddTabs.tabs('select', 1);", true);
            }

            if (! Page.IsPostBack)
            {

                dragDrop.FolderID = _folderID;
                dragDrop.TaxonomyId = _taxonomyID;

                if (_contentLanguage != -1)
                {
                    dragDrop.ContentLanguage = _contentLanguage;
                }

                HelpMessage.Text = "Fill out the description and then click next to upload image(s)."; //m_refMsg.GetMessage("lbl fill out the description and then click next to drag and drop image(s)")
                btnNext.Text = m_refMsg.GetMessage("next") + ">>";
                ImagegalleryTitleLbl = m_refMsg.GetMessage("generic title label");
                ImagegalleryImageWidthLbl = m_refMsg.GetMessage("lbl maximum width");
                ImagegalleryAddressLbl = m_refMsg.GetMessage("lbl image mapaddress");
                ImagegalleryDescriptionLbl = m_refMsg.GetMessage("description label");
                HeaderLabel.Text = m_refMsg.GetMessage("lbl photo data");
                btnNext.Attributes.Add("onclick", "ResizeContainer();");

                if ((Request.QueryString["prop"] != null)&& Request.QueryString["prop"] != "" && (Request.QueryString["type"] == "update") || (Request.QueryString["prop"] == "image"))
                {
                    // Content Designer
                    ctlEditor.FolderId = _folderID;
                    ctlEditor.AllowFonts = true;

                    if (Request.QueryString["prop"] == "image")
                    {
                        dragDrop.IsImage = 1;
                    }

                    this.panelImageProperties.Visible = true;
                    this.panelDragDrop.Visible = false;
                    if ((Request.QueryString["type"] != null)&& Request.QueryString["type"] == "update")
                    {
                        HelpMessage.Text = m_refMsg.GetMessage("lbl fill out the description and then click save");
                        btnNext.Attributes.Add("onclick", "return HideContainer(this);");
                        long id = 0;
                        if (Request.QueryString["id"] != null)
                        {
                            id = Convert.ToInt64(Request.QueryString["id"]);
                        }
                        ekImagegalleryImageWidthLbl.Visible = false;
                        ekImagegalleryImageWidth.Visible = false;
                        if (id > 0)
                        {
                            Ektron.Cms.ContentData data;
                            Ektron.Cms.ContentAPI api = new Ektron.Cms.ContentAPI();
                            data = api.GetContentById(id, 0);
                            this.ekImagegalleryTitle.Value = Server.HtmlDecode(data.Title);
                            ctlEditor.Content = data.Teaser;
                            if (Request.QueryString["prop"] == "image")
                            {
                                this.HeaderLabel.Text = "Image Properties";
                                foreach (Ektron.Cms.ContentMetaData item in data.MetaData)
                                {
                                    if (item.TypeName.ToLower() == "mapaddress")
                                    {
                                        this.ekImagegalleryAddress.Value = item.Text;
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                this.HeaderLabel.Text = "Document Properties";
                                this.ekImagegalleryAddress.Visible = false;
                                this.ekImagegalleryAddressLbl.Visible = false;
                            }
                            btnNext.Text = "Save";
                        }
                    }
                    else
                    {
                        ekImagegalleryTitleLbl.Visible = false;
                        ekImagegalleryTitle.Visible = false;
                    }
                }
                else
                {
                    this.panelImageProperties.Visible = false;
                    this.panelDragDrop.Visible = true;
                }
            }
            else
            {
                Ektron.Cms.CommonApi api = new Ektron.Cms.CommonApi();
                string desc = "";
                int width = 800;
                string address = "";
                desc = (string) ctlEditor.Content;
                if (Request.Form["ekImagegalleryImageWidth"] != null)
                {
                    width = System.Convert.ToInt32(Request.Form["ekImagegalleryImageWidth"].ToString());
                }
                if (Request.Form["ekImagegalleryAddress"] != null)
                {
                    address = (string) (Request.Form["ekImagegalleryAddress"].ToString());
                }

                string[] imageProp = new string[4];
                imageProp[0] = width.ToString(); //width
                imageProp[1] = "-1"; //height
                imageProp[2] = address; //mapaddress
                imageProp[3] = desc; //Descriptions

                if (Request.QueryString["type"] != "update")
                {
                    Ektron.ASM.EkDavProtocol.Constants.GetCustomCacheManger().Remove(api.UserId.ToString() + "_" + api.UniqueId.ToString() + "_MapMeta");
                    Ektron.ASM.EkDavProtocol.Constants.GetCustomCacheManger().Add(api.UserId.ToString() + "_" + api.UniqueId.ToString() + "_MapMeta", imageProp);
                }
            }

            if (Request.Browser.Type.IndexOf("Firefox") != -1)
            {
                liDragDrop.Visible = true;
                tabDragDrop.Visible = true;
                tabDragDrop.Controls.Add(dragDrop);
            }

            literal_wait.Text = m_refMsg.GetMessage("one moment msg");
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        try
            {
                Ektron.Cms.ContentAPI content_api = new Ektron.Cms.ContentAPI();
                Ektron.Cms.Content.EkContent m_refContent = content_api.EkContentRef;
                Ektron.Cms.ContentData content_data = null;
                long content_id = 0;
                bool valid_attempt = false;
                int ContentLanguage;
                CommonApi AppUI = new CommonApi();

                if (! (Request.QueryString["id"] == null))
                {
                    content_id = Convert.ToInt64(Request.QueryString["id"]);

                    if ((!(Request.QueryString["content_language"] == null)) && (int.TryParse(Request.QueryString["content_language"], out ContentLanguage)) && (ContentLanguage > 0))
                    {
                        if (ContentLanguage == Ektron.Cms.Common.EkConstants.CONTENT_LANGUAGES_UNDEFINED || ContentLanguage == Ektron.Cms.Common.EkConstants.ALL_CONTENT_LANGUAGES)
                        {
                            ContentLanguage = AppUI.DefaultContentLanguage;
                        }
                        AppUI.ContentLanguage = ContentLanguage;
                        content_api.ContentLanguage = ContentLanguage;
                    }
                    else
                    {
                        ContentLanguage = AppUI.DefaultContentLanguage;
                    }

                    //if checkout was clicked
                    bool checkOutAsset;
                    if ((! (Request.QueryString["checkout"] == null)) && (bool.TryParse(Request.QueryString["checkout"], out checkOutAsset)) && (checkOutAsset))
                    {
                        ContentData contData = content_api.GetContentById(content_id, ContentAPI.ContentResultType.Staged);
                        //If checkout and save was clicked on a content in the "S" state, checkout will throw an exception
                        //Take ownership of content before checkout
                        if ((contData != null) && (contData.UserId != content_api.RequestInformationRef.UserId) && (contData.Status == "S"))
                        {
                            content_api.EkContentRef.TakeOwnership(content_id);
                        }
                        content_api.EkContentRef.CheckContentOutv2_0(content_id);
                    }
                    //
                    if (content_id > 0)
                    {
                        content_data = content_api.GetContentById(content_id, 0);
                    }
                    if ((content_data != null) && (content_data.AssetData != null) && (content_data.AssetData.Version.Length > 0))
                    {
                        //GetContentById returns content in default language if no content exists for ContentLanguage
                        if (content_data.LanguageId == ContentLanguage)
                        {
                            AssetManagement.AssetManagementService objAssetMgtService;
                            objAssetMgtService = new AssetManagement.AssetManagementService();
                            string filepath = objAssetMgtService.GetViewUI(content_data.AssetData.Id, Ektron.ASM.AssetConfig.InstanceType.current, content_data.AssetData.Version,Ektron.ASM.AssetConfig.UIType.url);
                            if ((Request.QueryString["originalimage"] != null)&& Request.QueryString["originalimage"] == "true")
                            {
                                string _path = (string) (content_api.EkContentRef.GetViewUrl(Convert.ToInt32(content_data.Type), content_data.AssetData.Id).Replace(Page.Request.Url.Scheme + "://" + Page.Request.Url.Host, ""));
                                if (_path.StartsWith(":")) //If https the assetmanagementservice tends to send the port number too
                                {
                                    _path = _path.Substring(_path.IndexOf("/"));
                                }
                                filepath = Page.Server.MapPath(_path);
                                //filepath = filepath.Replace(content_data.AssetData.Id, (string) ("orig_" + content_data.AssetData.Id));
                                if (filepath != null)
                                {
                                    if (File.Exists(filepath))
                                    {
                                        valid_attempt = true;
                                        AssetManagement.AssetManagementService assetmanagementService = new AssetManagement.AssetManagementService();
                                        Ektron.ASM.AssetConfig.AssetData assetData = assetmanagementService.GetAssetData(content_data.AssetData.Id);
                                        Response.Clear();
                                        //Response.ContentType = "application/octet-stream"
                                        Response.ContentType = content_data.AssetData.MimeType;
                                        Response.AddHeader("Content-Disposition", "attachment; filename=\"" + HttpUtility.UrlPathEncode(assetData.Handle) + "\"");
                                        Response.WriteFile(filepath);
                                        Response.Flush();
                                        try
                                        {
                                            Response.End();
                                        }
                                        catch
                                        {

                                        }
                                        return;
                                    }
                                }
                            }

                            if (filepath.IndexOf("?") >= 0)
                            {
                                filepath = filepath + "&mimeType=octet";
                            }
                            else
                            {
                                filepath = filepath + "?mimeType=octet";
                            }
                            Response.Redirect(filepath);
                        }
                    }

                    if (! valid_attempt)
                    {
                        notification_message.Text = "File does not exist or you do not have permission to view this file";
                    }
                }

            }
            catch (System.Threading.ThreadAbortException)
            {
                notification_message.Text = "";
            }
            catch (Exception)
            {
                notification_message.Text = "File does not exist or you do not have permission to view this file";
            }
    }
Ejemplo n.º 3
0
 public static string GetAssetDownloadLink(long content_id)
 {
     Ektron.Cms.ContentAPI content_api = null;
     ContentData content_data = null;
     try
     {
         content_api = new Ektron.Cms.ContentAPI();
         content_data = content_api.GetContentById(content_id, 0);
         if (content_data.AssetData == null || content_data.AssetData.Id.Trim().Length == 0)
         {
             return string.Empty;
         }
         return content_api.RequestInformationRef.ApplicationPath + "/DownloadAsset.aspx?id=" + content_id;
     }
     catch (Exception)
     {
         return string.Empty;
     }
 }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        Ektron.Cms.ContentAPI content_api = new Ektron.Cms.ContentAPI();
            try
            {
                Ektron.Cms.ContentData content_data = null;
                long asset_id = 0;
                bool valid_attempt = false;
                int LangbackUp = 0;
                if (! (Request.QueryString["id"] == null))
                {
                    asset_id = Convert.ToInt64(Request.QueryString["id"]);
                }
                LangbackUp = content_api.ContentLanguage;
                if (Request.QueryString["LangType"] != null && content_api.ContentLanguage == -1)
                {
                    content_api.ContentLanguage = Convert.ToInt32(Request.QueryString["LangType"]);
                }
                if (content_api.ContentLanguage == -1)
                {
                    content_api.ContentLanguage = int.Parse(content_api.GetCookieValue("SiteLanguage"));
                }
                long iTmpCaller = content_api.RequestInformationRef.CallerId;
                if (asset_id > 0)
                {
                    content_api.RequestInformationRef.CallerId = Ektron.Cms.Common.EkConstants.InternalAdmin;
                    content_api.RequestInformationRef.UserId = Ektron.Cms.Common.EkConstants.InternalAdmin;
                    try
                    {
                        content_data = content_api.GetContentById(asset_id, 0);
                    }
                    catch
                    {
                    }
                    finally
                    {
                        content_api.RequestInformationRef.CallerId = iTmpCaller;
                        content_api.RequestInformationRef.UserId = iTmpCaller;
                    }
                    if (content_data != null)
                    {
                        content_api.ContentLanguage = content_data.LanguageId;
                        content_data = null;
                    }
                    content_data = content_api.ShowContentById(asset_id, content_api.CmsPreview, System.Convert.ToBoolean(! content_api.CmsPreview));
                    content_api.ContentLanguage = LangbackUp;
                }
                if ((content_data != null) && (content_data.AssetData != null) && (content_data.AssetData.Version.Length > 0))
                {
                    string filepath = Page.Server.MapPath((string) (content_api.EkContentRef.GetViewUrl(Convert.ToInt32(content_data.Type), content_data.AssetData.Id).Replace(Page.Request.Url.Scheme + "://" + Page.Request.Url.Authority, "").Replace(":443", "").Replace(":80", "")));
                    if (filepath != null)
                    {
                        if (File.Exists(filepath))
                        {
                            valid_attempt = true;
                            string filename = Path.GetFileName(filepath);
                            string ext = "";
                            ext = Path.GetExtension(filepath);
                            AssetData _assetData = new AssetData();
                            _assetData.AssetDataFromAssetID(content_data.AssetData.Id);
                            if (ext.Contains("pdf") || ext.Contains("pps"))
                            {
                                WebClient client = new WebClient();
                                byte[] Buffer = client.DownloadData(Convert.ToString(filepath));
                                if (Buffer.Length > 0)
                                {
                                    valid_attempt = true;
                                    Response.Clear();
                                    Response.ContentType = (string) ((ext.Contains("pdf")) ? "application/pdf" : "application/vnd.ms-powerpoint");
                                    Response.AddHeader("Content-Disposition", "attachment; filename=\"" + (Request.Browser.Browser == "IE" ? (Server.UrlPathEncode(System.IO.Path.GetFileNameWithoutExtension(_assetData.Handle))) : (System.IO.Path.GetFileNameWithoutExtension(_assetData.Handle))) + ext + "\"");
                                    Response.AddHeader("Content-Length", Buffer.Length.ToString());
                                    Response.BinaryWrite(Buffer);
                                }
                            }
                            else
                            {
                                //if (ext.Contains("txt") || ext.Contains("nxb"))
                                //{
                                //    filepath = DocumentManagerData.Instance.StorageLocation + _assetData.Storage + ConfigManager.pathChar + _assetData.Name;
                                //}
                                Response.Clear();
                                Response.ContentType = content_data.AssetData.MimeType;
                                Response.AddHeader("Content-Disposition", "attachment; filename=\"" + (Request.Browser.Browser == "IE" ? (Server.UrlPathEncode(_assetData.Handle)) : _assetData.Handle) + "\"");
                                try
                                {
                                    FileInfo fi = new FileInfo(filepath);
                                    Response.AddHeader("Content-Length", fi.Length.ToString());
                                }
                                catch { }
                                Response.WriteFile(filepath);
                            }
                            Response.Flush();
                            try
                            {
                                Response.End();
                            }
                            catch
                            {
                            }
                        }
                    }
                }
                if (! valid_attempt)
                {
                    notification_message.Text = "File does not exist or you do not have permission to view this file";
                    notification_message.ToolTip = "Error Message - " + notification_message.Text;
                    // Register CSS
                    Ektron.Cms.API.Css.RegisterCss(this, Ektron.Cms.API.Css.ManagedStyleSheet.EktronWorkareaCss);
                    Ektron.Cms.API.Css.RegisterCss(this, Ektron.Cms.API.Css.ManagedStyleSheet.EktronWorkareaIeCss, Ektron.Cms.API.Css.BrowserTarget.AllIE);
                    Login.Visible = System.Convert.ToBoolean(!content_api.IsLoggedIn);
                    content_api.RequestInformationRef.RedirectFromLoginKeyName = Request.Url.PathAndQuery.ToString();
                    Login.RedirectFromLoginPage();
                    Login.Fill();
                }

            }
            catch (Exception)
            {
                notification_message.Text = "File does not exist or you do not have permission to view this file";
                // Register CSS
                Ektron.Cms.API.Css.RegisterCss(this, Ektron.Cms.API.Css.ManagedStyleSheet.EktronWorkareaCss);
                Ektron.Cms.API.Css.RegisterCss(this, Ektron.Cms.API.Css.ManagedStyleSheet.EktronWorkareaIeCss, Ektron.Cms.API.Css.BrowserTarget.AllIE);
                Login.Visible = System.Convert.ToBoolean(!content_api.IsLoggedIn);
                content_api.RequestInformationRef.RedirectFromLoginKeyName = Request.Url.PathAndQuery.ToString();
                Login.RedirectFromLoginPage();
                Login.Fill();
            }
    }