protected override void Page_Load(object sender, System.EventArgs e) { base.Page_Load(sender, e); Utilities.ValidateUserLogin(); m_SelectedEditControl = Utilities.GetEditorPreference(Request); objCookieObject = Ektron.Cms.CommonApi.GetEcmCookie(); if (objCookieObject != null && !(objCookieObject.Values["editoroptions"] == null)) { m_SelectedEditControl = objCookieObject.Values["editoroptions"].ToLower(); } if (m_SelectedEditControl.ToLower() == "jseditor") { cdContent_teaser.Visible = false; } bool bPermissions = true; m_refContentApi = new Ektron.Cms.ContentAPI(); iNewLang = m_refContentApi.ContentLanguage; if (!String.IsNullOrEmpty(Request.QueryString["dynamicbox"])) { bDynamicBox = Convert.ToBoolean(Request.QueryString["dynamicbox"]); } if (!String.IsNullOrEmpty(Request.QueryString["forum"])) { try { IsForum = Convert.ToBoolean(Convert.ToInt32(Request.QueryString["forum"])); } catch (Exception) { IsForum = false; } } setlabels(); if (!IsForum && m_SelectedEditControl.ToLower() == "jseditor") { AddEkDoPostBack(); } this.dialog_publish.Attributes.Add("onclick", "return publish_handler();"); this.dialog_publish_top.Attributes.Add("onclick", "return publish_handler();"); this.dialog_publish_asset.Attributes.Add("onclick", "return publish_handler();"); if (!String.IsNullOrEmpty(Request.QueryString["mode"])) { if (Request.QueryString["mode"].Trim().ToLower() == "edit") { Mode = CurrentMode.Edit; } else if (Request.QueryString["mode"].Trim().ToLower() == "addlang") { Mode = CurrentMode.Edit; bWithLang = true; if (!String.IsNullOrEmpty(Request.QueryString["Lang"])) iOrigLang = Convert.ToInt32(Request.QueryString["Lang"]); } else { Mode = CurrentMode.Add; } } SetCSS(); if (!String.IsNullOrEmpty(Request.QueryString["mode_id"])) { try { ModeID = Convert.ToInt64(Request.QueryString["mode_id"]); } catch (Exception) { ModeID = 0; } } if (!String.IsNullOrEmpty(Request.QueryString["lang_id"])) { try { LangID = Convert.ToInt32(Request.QueryString["lang_id"]); } catch (Exception) { LangID = m_refContentApi.RequestInformationRef.DefaultContentLanguage; } } if (!String.IsNullOrEmpty(Request.QueryString["langtype"])) { try { LangID = Convert.ToInt32(Request.QueryString["langtype"]); } catch (Exception) { LangID = m_refContentApi.RequestInformationRef.DefaultContentLanguage; } } if (LangID == -1 || LangID == 0) { LangID = m_refContentApi.RequestInformationRef.DefaultContentLanguage; } m_refContentApi.RequestInformationRef.ContentLanguage = LangID; m_refContentApi.ContentLanguage = LangID; if (!Page.IsPostBack) { if (m_refContentApi.IsARoleMember(Ektron.Cms.Common.EkEnumeration.CmsRoleIds.TaxonomyAdministrator, m_refContentApi.RequestInformationRef.UserId, false)) { TaxonomyRoleExists = true; } switch (Mode) { case CurrentMode.Add: auto_generate_summary.Visible = false; content_id.Value = "0"; security_data = m_refContentApi.LoadPermissions(ModeID, "folder", 0); if (!security_data.CanAdd) { title_label.Text = "You do not have rights to add content in FolderID=" + ModeID; bPermissions = false; } else { Ektron.Cms.API.Folder folderApi = new Ektron.Cms.API.Folder(); folder_data = folderApi.GetFolder(ModeID); if (folder_data != null) { if (cssFilesPath == "") //apply stylesheet from folderdata { cssFilesPath = this.m_refContentApi.RequestInformationRef.SitePath + folder_data.StyleSheet; } if (cssFilesPath.Length > 0) { cdContent_teaser.Stylesheet = cssFilesPath; } } cdContent_teaser.FolderId = ModeID; if (!IsForum && m_SelectedEditControl.ToLower() == "jseditor") { InnerEditor.ToolbarLayout = SetToolbar(); ftb_control.Text = InnerEditor.ToString(); ftb_control.Visible = true; cdContent_teaser.Visible = false; } else if (!IsForum) { ftb_control.Visible = false; cdContent_teaser.Visible = true; } SetTaxonomy(0, ModeID); } break; case CurrentMode.Edit: auto_generate_summary.Visible = true; content_id.Value = ModeID.ToString(); if (!String.IsNullOrEmpty(Request.QueryString["mode"]) && Request.QueryString["mode"].Trim().ToLower() == "addlang") { long folderid = 0; if (!String.IsNullOrEmpty(Request.QueryString["folder"])) { long.TryParse(Request.QueryString["folder"], out folderid); } security_data = m_refContentApi.LoadPermissions(folderid, "folder", 0); if (!security_data.CanAdd) { title_label.Text = "You do not have rights to add language content block ID=" + ModeID; bPermissions = false; } } else { security_data = m_refContentApi.LoadPermissions(ModeID, "content", 0); if (!security_data.CanEdit && !IsForum) { title_label.Text = "You do not have rights to edit content block ID=" + ModeID; bPermissions = false; } else { Ektron.Cms.API.Folder folderApi = new Ektron.Cms.API.Folder(); folder_data = folderApi.GetFolder(ModeID); if (folder_data != null) { if (cssFilesPath == "") //apply stylesheet from folderdata { cssFilesPath = this.m_refContentApi.RequestInformationRef.SitePath + folder_data.StyleSheet; } if (cssFilesPath.Length > 0) { cdContent_teaser.Stylesheet = cssFilesPath; } } } } if (bPermissions) { if (Request.QueryString["ctlupdateid"] != "") { commparams = (string)("&ctlupdateid=" + Request.QueryString["ctlupdateid"] + "&ctlmarkup=" + Request.QueryString["ctlmarkup"] + "&cltid=" + Request.QueryString["cltid"] + "&ctltype=" + Request.QueryString["ctltype"]); updateFieldId = Request.QueryString["ctlupdateid"]; Page.ClientScript.RegisterHiddenField("ctlupdateid", updateFieldId); } if (Request.QueryString["ctlmarkup"] != "") { Page.ClientScript.RegisterHiddenField("ctlmarkup", Request.QueryString["ctlmarkup"]); } if (Request.QueryString["ctltype"] != "") { Page.ClientScript.RegisterHiddenField("ctltype", Request.QueryString["ctltype"]); } if (Request.QueryString["cltid"] != "") { Page.ClientScript.RegisterHiddenField("cltid", Request.QueryString["cltid"]); } SetContentBlock(); } break; } if (!bPermissions) { ftb_control.Visible = false; title_value.Visible = false; dialog_publish.Visible = false; dialog_publish_top.Visible = false; dialog_publish_asset.Visible = false; cdContent_teaser.Visible = false; return; } ltr_js.Text = this.EditorJS(); if (m_SelectedEditControl.ToLower() != "jseditor") { ftb_control.Visible = false; //set the equavalent SetToolbar() to contentdesigner if (cdContent_teaser != null) { string ToolsOption = ""; if (security_data.CanAdd) { ToolsOption = "Wiki=1"; } bool bLibraryAllowed = false; if (security_data.IsReadOnlyLib) { bLibraryAllowed = true; } ToolsOption = ToolsOption + ("&LibraryAllowed=" + bLibraryAllowed.ToString()); bool bCanModifyImg = false; if (security_data.CanAddToImageLib) { bCanModifyImg = true; } ToolsOption = ToolsOption + ("&CanModifyImg=" + bCanModifyImg.ToString()); if (ToolsOption.Length > 0) { ToolsOption = (string)("?" + ToolsOption); } cdContent_teaser.SetPermissions(security_data); cdContent_teaser.ToolsFile = this.m_refContentApi.RequestInformationRef.ApplicationPath + "ContentDesigner/configurations/InterfaceBlog.aspx" + ToolsOption; if (!(Request.QueryString["editorVisible"] == null)) { //To avoid the editor's onbeforeunload checks being called cdContent_teaser.Visible = System.Convert.ToBoolean(Request.QueryString["editorVisible"]); } } } } if (dialog_publish.Visible == true) { tr_pub.Visible = true; tr_asset.Visible = false; } else { tr_pub.Visible = false; tr_asset.Visible = true; } string _helpUrl = string.Empty; if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["ek_helpDomainPrefix"])) { string helpDomain = ConfigurationManager.AppSettings["ek_helpDomainPrefix"]; Uri _uri = new Uri(helpDomain); if (_uri != null && !_uri.IsFile) { if ((helpDomain.IndexOf("[ek_cmsversion]") > 1)) { //defect # 64951 - This help file (It had been its own help project in previous releases as well). _helpUrl = " http://documentation.ektron.com/current/memberhelp/wwhelp/wwhimpl/js/html/wwhelp.htm"; } } else { _helpUrl = this.m_refContentApi.RequestInformationRef.ApplicationPath + "/helpmessage.aspx?error=isfile"; } } else { _helpUrl = this.m_refContentApi.RequestInformationRef.ApplicationPath + "/help/memberhelp/index.html"; } help_button.Text = "<a href=\"#\"><img id=\"DeskTopHelp\" title=\"" + this.m_refMsg.GetMessage("alt help button text") + "\" border=\"0\" src=\"" + this.m_refContentApi.RequestInformationRef.ApplicationPath + "/images/application/menu/help.gif\" onclick=\"javascript:PopUpWindow(\'" + _helpUrl + "\', \'SitePreview\', 600, 500, 1, 1);return false;\"></a>"; if (IsForum) { SetForumMode(); } }
protected void click_handler() { string strContent = ""; string strSearchText = ""; string strContentTeaser = ""; bool bUpdateField = false; //If (Request.QueryString("TaxonomyId") IsNot Nothing AndAlso Request.QueryString("TaxonomyId") <> "") Then // TaxonomyOverrideId = Convert.ToInt32(Request.QueryString("TaxonomyId")) //End If if ((Request.QueryString["SelTaxonomyId"] != null) && Request.QueryString["SelTaxonomyId"] != "") { TaxonomySelectId = Convert.ToInt64(Request.QueryString["SelTaxonomyId"]); } switch (Mode) { case CurrentMode.Add: try { if (m_SelectedEditControl.ToLower() == "jseditor") { strContent = Page.Server.HtmlDecode((string)(Request.Form["EkInnerEditor"].ToString())); } else { strContent = (string)cdContent_teaser.Content; } strContent = Utilities.WikiQLink(strContent, ModeID); strContentTeaser = Utilities.AutoSummary(strContent); if (strContentTeaser != "") { strContentTeaser = "<p>" + strContentTeaser + "</p>"; } Ektron.Cms.API.Folder folderApi = new Ektron.Cms.API.Folder(); folder_data = folderApi.GetFolder(ModeID); if (folder_data != null) { ModeID = m_refContentApi.AddContent((string)this.title_value.Text, "", strContent, "", strContentTeaser, m_refContentApi.RequestInformationRef.ContentLanguage.ToString(), ModeID, "", "", "", 0, folder_data.TemplateId); } else { ModeID = m_refContentApi.AddContent((string)this.title_value.Text, "", strContent, "", strContentTeaser, m_refContentApi.RequestInformationRef.ContentLanguage.ToString(), ModeID, "", "", ""); } if (TaxonomyOverrideId > 0) { TaxonomyTreeIdList = TaxonomyOverrideId.ToString(); } if ((Request.Form[taxonomyselectedtree.UniqueID] != null) && Request.Form[taxonomyselectedtree.UniqueID] != "") { TaxonomyTreeIdList = Request.Form[taxonomyselectedtree.UniqueID]; if (TaxonomyTreeIdList.Trim().EndsWith(",")) { TaxonomyTreeIdList = TaxonomyTreeIdList.Substring(0, TaxonomyTreeIdList.Length - 1); } } TaxonomyContentRequest cotnent_request = new TaxonomyContentRequest(); cotnent_request.ContentId = ModeID; cotnent_request.TaxonomyList = TaxonomyTreeIdList; m_refContentApi.AddTaxonomyItem(cotnent_request); Mode = CurrentMode.Edit; ftb_control.Visible = false; cdContent_teaser.Visible = false; this.title_value.Visible = false; this.title_label.Text = ""; this.change_notification.Text = "Content Added"; this.change_notification.ToolTip = this.change_notification.Text; if (this.TaxonomySelectId > 0) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "__EkReloadTop", "RefreshPage(\'" + TaxonomySelectId.ToString() + "\', " + bDynamicBox.ToString().ToLower() + ");self.close()", true); } else if (this.TaxonomyOverrideId > 0) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "__EkReloadTop", "RefreshPage(\'" + TaxonomyOverrideId.ToString() + "\', " + bDynamicBox.ToString().ToLower() + ");self.close()", true); } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "__EkReloadTop", "RefreshPage(\'\', " + bDynamicBox.ToString().ToLower() + ");self.close()", true); } } catch (Exception ex) { ftb_control.Visible = false; title_value.Visible = false; cdContent_teaser.Visible = false; if (ex.Message.IndexOf("Invalid License") == 0) { title_label.Text = ex.Message.ToString(); } else { title_label.Text = "You do not have rights to add content in FolderID=" + ModeID; } } break; case CurrentMode.Edit: if (bWithLang == true) { Ektron.Cms.Content.EkContent brContent; Collection page_content_data = new Collection(); m_refContentApi.ContentLanguage = iOrigLang; brContent = m_refContentApi.EkContentRef; page_content_data = brContent.GetContentByIDv2_0(ModeID); m_refContentApi.ContentLanguage = iNewLang; brContent = m_refContentApi.EkContentRef; if (m_SelectedEditControl.ToLower() == "jseditor") { strContent = Page.Server.HtmlDecode((string)(Page.Request.Form["EkInnerEditor"].ToString())); } else { strContent = (string)cdContent_teaser.Content; } strSearchText = Utilities.StripHTML(strContent); page_content_data.Remove("ContentHtml"); strContent = Utilities.WikiQLink(strContent, Convert.ToInt64(page_content_data["FolderID"])); page_content_data.Add(strContent, "ContentHtml", null, null); page_content_data.Remove("ContentLanguage"); page_content_data.Add(iNewLang, "ContentLanguage", null, null); if (page_content_data.Contains("ContentTeaser") && (page_content_data["ContentTeaser"].ToString() == "")) { strContentTeaser = Utilities.AutoSummary(strContent); if (strContentTeaser != "") { strContentTeaser = "<p>" + strContentTeaser + "</p>"; } page_content_data.Remove("ContentTeaser"); page_content_data.Add(strContentTeaser, "ContentTeaser", null, null); } else { if (auto_generate_summary.Checked == true) { // strContentTeaser = Utilities.WikiQLink(strContent, ModeID) strContentTeaser = Utilities.AutoSummary(strContent); if (strContentTeaser != "") { strContentTeaser = "<p>" + strContentTeaser + "</p>"; } page_content_data.Remove("ContentTeaser"); page_content_data.Add(strContentTeaser, "ContentTeaser", null, null); } } if (page_content_data.Contains("SearchText")) { page_content_data.Remove("SearchText"); } page_content_data.Add(strSearchText, "SearchText", null, null); if (page_content_data.Contains("ContentTitle")) { page_content_data.Remove("ContentTitle"); } page_content_data.Add(title_value.Text, "ContentTitle", null, null); if (page_content_data.Contains("IsSearchable")) { page_content_data.Remove("IsSearchable"); } page_content_data.Add(false, "IsSearchable", null, null); page_content_data.Add(true, "AddToQlink", null, null); if (page_content_data.Contains("Taxonomy")) { page_content_data.Remove("Taxonomy"); } if (TaxonomyOverrideId > 0) { TaxonomyTreeIdList = TaxonomyOverrideId.ToString(); } if ((Request.Form[taxonomyselectedtree.UniqueID] != null) && Request.Form[taxonomyselectedtree.UniqueID] != "") { TaxonomyTreeIdList = Request.Form[taxonomyselectedtree.UniqueID]; if (TaxonomyTreeIdList.Trim().EndsWith(",")) { TaxonomyTreeIdList = TaxonomyTreeIdList.Substring(0, TaxonomyTreeIdList.Length - 1); } } page_content_data.Add(TaxonomyTreeIdList, "Taxonomy", null, null); ModeID = brContent.AddNewContentv2_0(page_content_data); brContent.SaveContentv2_0(page_content_data); brContent.CheckIn(ModeID, ""); brContent.SubmitForPublicationv2_0(ModeID, Convert.ToInt64(page_content_data["FolderID"]), ""); Mode = CurrentMode.Edit; ftb_control.Visible = false; cdContent_teaser.Visible = false; this.title_value.Visible = false; this.title_label.Text = ""; this.change_notification.Text = "Content Added"; this.change_notification.ToolTip = this.change_notification.Text; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "__EkReloadTop", "top.opener.location.reload();self.close()", true); } else { ContentData cData = m_refContentApi.GetContentById(ModeID, ContentAPI.ContentResultType.Published); Collection page_content_data; bool bError = false; if ((cData != null) && (cData.Status != "O")) { try { m_refContentApi.CheckOutContentById(ModeID); ContentEditData data = m_refContentApi.GetContentForEditing(ModeID); if (m_SelectedEditControl.ToLower() == "jseditor") { data.Html = Page.Server.HtmlDecode((string)(Page.Request.Form["EkInnerEditor"].ToString())); } else { data.Html = (string)cdContent_teaser.Content; } data.Html = Utilities.WikiQLink(data.Html, data.FolderId); data.Title = (string)title_value.Text; if (data.Teaser == "" || data.Teaser.ToLower() == "<br /><!-- wiki summary -->") { //data.Teaser = Utilities.WikiQLink(data.Html, ModeID) data.Teaser = Utilities.AutoSummary(data.Html); if (data.Teaser != "") { data.Teaser = "<p>" + data.Teaser + "</p>"; } } else { if (auto_generate_summary.Checked == true) { //data.Teaser = Utilities.WikiQLink(data.Html, ModeID) data.Teaser = Utilities.AutoSummary(data.Html); if (data.Teaser != "") { data.Teaser = "<p>" + data.Teaser + "</p>"; } } } page_content_data = StepConvert(data, cData); if (TaxonomyOverrideId > 0) { TaxonomyTreeIdList = TaxonomyOverrideId.ToString(); } if ((Request.Form[taxonomyselectedtree.UniqueID] != null) && Request.Form[taxonomyselectedtree.UniqueID] != "") { TaxonomyTreeIdList = Request.Form[taxonomyselectedtree.UniqueID]; if (TaxonomyTreeIdList.Trim().EndsWith(",")) { TaxonomyTreeIdList = TaxonomyTreeIdList.Substring(0, TaxonomyTreeIdList.Length - 1); } } page_content_data.Add(TaxonomyTreeIdList, "Taxonomy", null, null); // m_refContentApi.SaveContent(data) m_refContentApi.EkContentRef.SaveContentv2_0(page_content_data); m_refContentApi.PublishContentById(ModeID, data.FolderId, data.LanguageId, "", m_refContentApi.UserId, ""); string markupPath = ""; string updateContent = ""; markupPath = Request.Form["ctlmarkup"]; if ((markupPath != null) && markupPath.Length > 0) { markupPath = Request.PhysicalApplicationPath + markupPath; } object ekml = null; if ((markupPath != null) && (HttpContext.Current.Cache[markupPath] != null)) { ekml = HttpContext.Current.Cache[markupPath]; ContentBase results = m_refContentApi.EkContentRef.LoadContent(ModeID, false); updateContent = this.m_refContentApi.FormatOutput((string)ekml.GetType().GetProperty("ContentFormat").GetValue(ekml, null), Request.Form["ctltype"], results); updateContent = this.m_refContentApi.WrapAjaxToolBar(updateContent, results, commparams); } else { updateContent = data.Html; } if ((Request.Form["ctlupdateid"] != null) && Request.Form["ctlupdateid"] != "") { Page.ClientScript.RegisterHiddenField("updatefieldcontent", updateContent); StringBuilder strJs = new StringBuilder(); strJs.Append("<script language=\"JavaScript1.2\" type=\"text/javascript\"> ").Append("\r\n"); strJs.Append(" if (top.opener != null) { ").Append("\r\n"); strJs.Append(" var objUpdateField = top.opener.document.getElementById(\'" + Request.Form["ctlupdateid"] + "\');").Append("\r\n"); strJs.Append(" if (objUpdateField != null) { objUpdateField.innerHTML = document.getElementById(\"updatefieldcontent\").value; }").Append("\r\n"); strJs.Append(" }").Append("\r\n"); strJs.Append("self.close();").Append("\r\n"); strJs.Append("</script>").Append("\r\n"); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "objUpdateField", strJs.ToString(), false); bUpdateField = true; } this.change_notification.Text = "Changes Published"; this.change_notification.ToolTip = this.change_notification.Text; } catch { this.change_notification.Text = "Another user is editing this content - Your changes could not be saved."; this.change_notification.ToolTip = this.change_notification.Text; bError = true; } } else { this.change_notification.Text = "Content is checked out - no changes made."; this.change_notification.ToolTip = this.change_notification.Text; } if (!bUpdateField) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "__EkReloadTop", (string)((bError ? "alert(\'" + this.change_notification.Text + "\');" : "") + "RefreshPage(\'\', " + bDynamicBox.ToString().ToLower() + ");self.close()"), true); } SetContentBlock(); } break; } }
private void Display_ViewLibraryByCategory() { FolderData folder_data; PermissionData security_data; LibraryData[] library_data; librarytoolbar m_libraryToolBar; int i = 0; string strOldDesLoc; System.IO.FileInfo fs2; string strTeaser = ""; //allow navigation away from Library jsDisableNav.Text = "false"; _CurrentPageNumber = System.Convert.ToInt32(this.uxPaging.SelectedPage); if (!string.IsNullOrEmpty(Request.QueryString["id"])) { _FolderId = Convert.ToInt64(Request.QueryString["id"]); } else { _FolderId = Convert.ToInt64(Request.QueryString["amp;id"]); } if (_ContentLanguage == Ektron.Cms.Common.EkConstants.CONTENT_LANGUAGES_UNDEFINED) { m_refcontentapi.ContentLanguage = Ektron.Cms.Common.EkConstants.ALL_CONTENT_LANGUAGES; } else { m_refcontentapi.ContentLanguage = _ContentLanguage; } folder_data = m_refcontentapi.GetFolderById(_FolderId); if (folder_data == null) { Response.Redirect((string)("notify_user.aspx?Tree=LibraryTree&folder_id=" + Convert.ToInt64(_FolderId)), false); return; //Not required } security_data = m_refcontentapi.LoadPermissions(_FolderId, "folder", 0); library_data = m_refcontentapi.GetAllChildLibItemsByType(_Type, _FolderId, _OrderBy, System.Convert.ToInt32(_CurrentPageNumber + 1), m_refcontentapi.RequestInformationRef.PagingSize, ref _TotalPagesNumber); //Fix for Assets in a multisite enviroment [workarea/library.aspx.vb] Microsoft.VisualBasic.Collection fCol = new Microsoft.VisualBasic.Collection(); Ektron.Cms.API.Folder fapi = new Ektron.Cms.API.Folder(); Ektron.Cms.FolderData[] fdata; Ektron.Cms.Content.EkContent m_refContent; m_refContent = m_refcontentapi.EkContentRef; fdata = m_refcontentapi.GetChildFolders(0, false, EkEnumeration.FolderOrderBy.Name); if (fdata != null) { foreach (FolderData thisfdata in fdata) { if (thisfdata.FolderType == 2) { fCol = m_refContent.GetFolderInfov2_0(thisfdata.Id); foreach (LibraryData thisresult in library_data) { string domain_Prod = (string)("http://" + fCol["DomainProduction"]); if ((_Type == "quicklinks" || _Type == "forms") &&(! string.IsNullOrEmpty(fCol["DomainProduction"].ToString())) && thisresult.FileName.IndexOf((String)fCol["DomainProduction"]) != -1 && !thisresult.FileName.Substring(System.Convert.ToInt32(thisresult.FileName.IndexOf(domain_Prod) + domain_Prod.Length)).StartsWith("/")) { thisresult.FileName = thisresult.FileName.Replace("http://" + fCol["DomainProduction"], "http://" + fCol["DomainProduction"] + "/"); } thisresult.FileName = Regex.Replace(thisresult.FileName, "http://" + fCol["DomainProduction"] + "javascript", "javascript"); } } } } //End fix for multisite and Assets m_libraryToolBar = (librarytoolbar)(LoadControl("controls/library/librarytoolbar.ascx")); ToolBarHolder.Controls.Add(m_libraryToolBar); m_libraryToolBar.AppImgPath = _AppImgPath; m_libraryToolBar.PageAction = _PageAction; m_libraryToolBar.FolderInfo = folder_data; m_libraryToolBar.FolderId = _FolderId; m_libraryToolBar.LibType = _Type; m_libraryToolBar.SecurityInfo = security_data; m_libraryToolBar.ContentLanguage = _ContentLanguage; ViewLibraryCategoryPanel.Visible = true; System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "TITLE"; colBound.HeaderText = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryByCategory&orderby=LibraryTitle&id=" + _FolderId + "&type=" + _Type + "\" title=\"" + _MessageHelper.GetMessage("click to sort msg") + "\">" + _MessageHelper.GetMessage("generic Title") + "</a>"; colBound.ItemStyle.Wrap = false; colBound.ItemStyle.VerticalAlign = VerticalAlign.Top; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left; colBound.HeaderStyle.CssClass = "title-header"; ViewLibraryCategoryGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "ID"; colBound.HeaderText = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryByCategory&orderby=LibraryID&id=" + _FolderId + "&type=" + _Type + "\" title=\"" + _MessageHelper.GetMessage("click to sort msg") + "\">" + _MessageHelper.GetMessage("generic ID") + "</a>"; colBound.ItemStyle.Wrap = false; colBound.ItemStyle.VerticalAlign = VerticalAlign.Top; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left; colBound.HeaderStyle.CssClass = "title-header"; ViewLibraryCategoryGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "DATEMODIFIED"; colBound.HeaderText = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryByCategory&orderby=date&id=" + _FolderId + "&type=" + _Type + "\" title=\"" + _MessageHelper.GetMessage("click to sort msg") + "\">" + _MessageHelper.GetMessage("generic Date Modified") + "</a>"; colBound.ItemStyle.Wrap = false; colBound.ItemStyle.VerticalAlign = VerticalAlign.Top; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left; colBound.HeaderStyle.CssClass = "title-header"; ViewLibraryCategoryGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "FILENAME"; if ((_Type == "files") || (_Type == "images")) { colBound.HeaderText = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryByCategory&orderby=LibraryFilename&id=" + _FolderId + "&type=" + _Type + "\" title=\"" + _MessageHelper.GetMessage("click to sort msg") + "\">" + _MessageHelper.GetMessage("generic Filename") + "</a>"; } else { colBound.HeaderText = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryByCategory&orderby=LibraryFilename&id=" + _FolderId + "&type=" + _Type + "\" title=\"" + _MessageHelper.GetMessage("click to sort msg") + "\">" + _MessageHelper.GetMessage("generic URL Link") + "</a>"; } colBound.ItemStyle.Wrap = false; colBound.ItemStyle.VerticalAlign = VerticalAlign.Top; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left; colBound.HeaderStyle.CssClass = "title-header"; ViewLibraryCategoryGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "CONTENTID"; if (_Type == "quicklinks") { colBound.HeaderText = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryByCategory&orderby=ContentID&id=" + _FolderId + "&type=" + _Type + "\" title=\"" + _MessageHelper.GetMessage("click to sort msg") + "\">" + _MessageHelper.GetMessage("generic Content ID") + "</a>"; } else { colBound.HeaderText = ""; colBound.Visible = false; } colBound.ItemStyle.Wrap = false; colBound.ItemStyle.VerticalAlign = VerticalAlign.Top; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left; colBound.HeaderStyle.CssClass = "title-header"; ViewLibraryCategoryGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "LANGUAGE"; if ((_Type == "forms") || (_Type == "quicklinks")) { colBound.HeaderText = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryByCategory&orderby=contentlanguage&id=" + _FolderId + "\" title=\"" + _MessageHelper.GetMessage("click to sort msg") + "\">" + "Language" + "</a>"; } else { colBound.HeaderText = ""; colBound.Visible = false; } colBound.ItemStyle.Wrap = false; colBound.ItemStyle.VerticalAlign = VerticalAlign.Top; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left; colBound.HeaderStyle.CssClass = "title-header"; ViewLibraryCategoryGrid.Columns.Add(colBound); ViewLibraryCategoryGrid.BorderColor = System.Drawing.Color.White; DataTable dt = new DataTable(); DataRow dr; int intItemLanguage = -1; dt.Columns.Add(new DataColumn("TITLE", typeof(string))); dt.Columns.Add(new DataColumn("ID", typeof(string))); dt.Columns.Add(new DataColumn("DATEMODIFIED", typeof(string))); dt.Columns.Add(new DataColumn("FILENAME", typeof(string))); dt.Columns.Add(new DataColumn("CONTENTID", typeof(string))); dt.Columns.Add(new DataColumn("LANGUAGE", typeof(string))); if (!(library_data == null)) { FileInfo fs = null; string strDesLoc = ""; string myImageFile = ""; string myNewImageFile = ""; string sExt = ""; string[] myfilePathArray; for (i = 0; i <= library_data.Length - 1; i++) { if (library_data[i].StagingFileName == "") { library_data[i].StagingFileName = library_data[i].FileName; } if ((_Type == "forms") || (_Type == "quicklinks")) { intItemLanguage = library_data[i].LanguageId; } else { intItemLanguage = _ContentLanguage; } dr = dt.NewRow(); dr[0] = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryItem&id=" + library_data[i].Id + "&parent_id=" + _FolderId + "\" title=\'" + _MessageHelper.GetMessage("generic View") + " \"" + Strings.Replace(library_data[i].Title, "\'", "`", 1, -1, 0) + "\"" + "\'>" + library_data[i].Title + "</a>"; dr[1] = library_data[i].Id; dr[2] = library_data[i].DisplayLastEditDate; dr[3] = library_data[i].FileName; if (_Type == "quicklinks") { dr[4] = library_data[i].ContentId; } else { dr[4] = ""; } if ((_Type == "forms") || (_Type == "quicklinks")) { dr[5] = library_data[i].LanguageId; } else { dr[5] = ""; } dt.Rows.Add(dr); if (_Type == "images") { strDesLoc = library_data[i].StagingFileName; myfilePathArray = strDesLoc.Split('/'); myImageFile = myfilePathArray[myfilePathArray.Length - 1]; sExt = (string)(myImageFile.Substring(myImageFile.Length - 3, 3).ToLower()); if ("gif" == sExt) { sExt = "png"; myNewImageFile = "thumb_" + myImageFile.Substring(0, myImageFile.Length - 3) + "png"; } else { myNewImageFile = (string)("thumb_" + myImageFile); } try { strOldDesLoc = strDesLoc; strDesLoc = strDesLoc.Replace(myImageFile, myNewImageFile); if (!folder_data.IsDomainFolder && folder_data.DomainProduction == "") { fs = new FileInfo(Server.MapPath(strDesLoc)); if (!fs.Exists) { if (strDesLoc.ToLower().Contains("/assets/")) { fs2 = new FileInfo(Server.MapPath(strOldDesLoc)); if (fs2.Exists) { Utilities.ProcessThumbnail(Server.MapPath(strDesLoc.Substring(0, Strings.InStrRev(strDesLoc, "/", -1, 0))), myImageFile); } } fs = new FileInfo(Server.MapPath(strDesLoc)); } } if (fs == null || fs.Exists) { Random r = new Random(System.DateTime.Now.Millisecond); //dr = dt.NewRow dr[0] += "<br /><a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryItem&id=" + library_data[i].Id + "&parent_id=" + _FolderId + "\" title=\'" + _MessageHelper.GetMessage("generic View") + " \"" + Strings.Replace(library_data[i].Title, "\'", "`", 1, -1, 0) + "\"" + "\'>" + "<img src=\"" + strDesLoc + "?n=" + r.Next(1, 5000) + "\"></a>"; if (library_data[i].ContentId >0) { strTeaser = m_refcontentapi.GetJustTeaserByContentId(library_data[i].ContentId, library_data[i].LanguageId); strTeaser = strTeaser.Replace("<p> </p>", string.Empty); if (strTeaser != "") { dr[1] += "<table width=\'89%\'><tr><td style=\'white-space: normal;\' nowrap=\'true\'><div>" + strTeaser + "</div></td></tr></table>"; } } } } catch (Exception) { // } } } } DataView dv = new DataView(dt); this.ViewLibraryCategoryGrid.PageSize = _CommonApi.RequestInformationRef.PagingSize; this.ViewLibraryCategoryGrid.DataSource = dv; this.ViewLibraryCategoryGrid.CurrentPageIndex = _CurrentPageNumber; this.ViewLibraryCategoryGrid.DataBind(); if (_TotalPagesNumber > 1) { this.uxPaging.TotalPages = _TotalPagesNumber; this.uxPaging.CurrentPageIndex = _CurrentPageNumber; } else { this.uxPaging.Visible = false; } }
private void Display_UpdateQlinkTemplateByCategory() { hdnIsPostBack.Value = "false"; //FormAction = "LangType=" & m_intContentLanguage & "&action=DoUpdateQlinkTemplateByCategory" //SetPostBackPage() FolderData folder_data; PermissionData security_data; LibraryData[] library_data; librarytoolbar m_libraryToolBar; int i = 0; _FolderId = Convert.ToInt64(Request.QueryString["id"]); folder_data = _ContentApi.GetFolderById(_FolderId); security_data = _ContentApi.LoadPermissions(_FolderId, "folder", 0); _CurrentPageNumber = System.Convert.ToInt32(this.uxPagingUpdateLink.SelectedPage); library_data = _ContentApi.GetAllChildLibItemsByType(_Type, _FolderId, _OrderBy, System.Convert.ToInt32(_CurrentPageNumber + 1), m_refcontentapi.RequestInformationRef.PagingSize, ref _TotalPagesNumber); //Fix for Assets in a multisite enviroment [workarea/library.aspx.vb] Microsoft.VisualBasic.Collection fCol = new Microsoft.VisualBasic.Collection(); Ektron.Cms.API.Folder fapi = new Ektron.Cms.API.Folder(); Ektron.Cms.FolderData[] fdata; Ektron.Cms.Content.EkContent m_refContent; ContentAPI m_refContentApi = new ContentAPI(); m_refContent = m_refContentApi.EkContentRef; fdata = m_refContentApi.GetChildFolders(0, false, EkEnumeration.FolderOrderBy.Name); if (fdata != null) { foreach (FolderData thisfdata in fdata) { if (thisfdata.FolderType == 2) { fCol = m_refContent.GetFolderInfov2_0(thisfdata.Id); foreach (LibraryData thisresult in library_data) { thisresult.FileName = Regex.Replace(thisresult.FileName, "http://" + fCol["DomainProduction"] + "javascript", "javascript"); } } } } //End fix for multisite and Assets m_libraryToolBar = (librarytoolbar)(LoadControl("controls/library/librarytoolbar.ascx")); ToolBarHolder.Controls.Add(m_libraryToolBar); m_libraryToolBar.AppImgPath = _AppImgPath; m_libraryToolBar.PageAction = _PageAction; m_libraryToolBar.FolderInfo = folder_data; m_libraryToolBar.SecurityInfo = security_data; m_libraryToolBar.FolderId = _FolderId; m_libraryToolBar.ContentLanguage = _ContentLanguage; m_libraryToolBar.LibType = _Type; UpdateQlinkTemplateByCategoryPanel.Visible = true; qlinkfrom.InnerHtml = _SitePath + "<input type=\"textbox\" size=\"50\" maxlength=\"255\" value=\"" + folder_data.TemplateFileName + "\" name=\"template_from\"/>"; qlinkto.InnerHtml = _SitePath + "<input type=\"textbox\" size=\"50\" maxlength=\"255\" value=\"" + folder_data.TemplateFileName + "\" name=\"template_to\"/>"; System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "CHECK"; colBound.HeaderText = "<input type=\"checkbox\" name=\"all\" onclick=\"javascript:checkAll(document.forms[0].all.checked);\"/>"; colBound.ItemStyle.Wrap = false; colBound.ItemStyle.VerticalAlign = VerticalAlign.Top; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left; colBound.HeaderStyle.CssClass = "title-header"; QlinkTemplateByCategoryGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "TITLE"; colBound.HeaderText = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryByCategory&orderby=LibraryTitle&id=" + _FolderId + "&type=" + _Type + "\" title=\"" + _MessageHelper.GetMessage("click to sort msg") + "\">" + _MessageHelper.GetMessage("generic Title") + "</a>"; colBound.ItemStyle.Wrap = false; colBound.ItemStyle.VerticalAlign = VerticalAlign.Top; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left; colBound.HeaderStyle.CssClass = "title-header"; QlinkTemplateByCategoryGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "ID"; colBound.HeaderText = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryByCategory&orderby=LibraryID&id=" + _FolderId + "&type=" + _Type + "\" title=\"" + _MessageHelper.GetMessage("click to sort msg") + "\">" + _MessageHelper.GetMessage("generic ID") + "</a>"; colBound.ItemStyle.Wrap = false; colBound.ItemStyle.VerticalAlign = VerticalAlign.Top; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left; colBound.HeaderStyle.CssClass = "title-header"; QlinkTemplateByCategoryGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "DATEMODIFIED"; colBound.HeaderText = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryByCategory&orderby=date&id=" + _FolderId + "&type=" + _Type + "\" title=\"" + _MessageHelper.GetMessage("click to sort msg") + "\">" + _MessageHelper.GetMessage("generic Date Modified") + "</a>"; colBound.ItemStyle.Wrap = false; colBound.ItemStyle.VerticalAlign = VerticalAlign.Top; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left; colBound.HeaderStyle.CssClass = "title-header"; QlinkTemplateByCategoryGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "FILENAME"; colBound.HeaderText = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryByCategory&orderby=LibraryFilename&id=" + _FolderId + "&type=" + _Type + "\" title=\"" + _MessageHelper.GetMessage("click to sort msg") + "\">" + _MessageHelper.GetMessage("generic URL Link") + "</a>"; colBound.ItemStyle.Wrap = false; colBound.ItemStyle.VerticalAlign = VerticalAlign.Top; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left; colBound.HeaderStyle.CssClass = "title-header"; QlinkTemplateByCategoryGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "CONTENTID"; colBound.HeaderText = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryByCategory&orderby=ContentID&id=" + _FolderId + "\" title=\"" + _MessageHelper.GetMessage("click to sort msg") + "\">" + _MessageHelper.GetMessage("generic Content ID") + "</a>"; colBound.ItemStyle.Wrap = false; colBound.ItemStyle.VerticalAlign = VerticalAlign.Top; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left; colBound.HeaderStyle.CssClass = "title-header"; QlinkTemplateByCategoryGrid.Columns.Add(colBound); QlinkTemplateByCategoryGrid.BorderColor = System.Drawing.Color.White; DataTable dt = new DataTable(); DataRow dr; //int intItemLanguage = -1; dt.Columns.Add(new DataColumn("CHECK", typeof(string))); dt.Columns.Add(new DataColumn("TITLE", typeof(string))); dt.Columns.Add(new DataColumn("ID", typeof(string))); dt.Columns.Add(new DataColumn("DATEMODIFIED", typeof(string))); dt.Columns.Add(new DataColumn("FILENAME", typeof(string))); dt.Columns.Add(new DataColumn("CONTENTID", typeof(string))); if (!(library_data == null)) { string strLibIds = ""; for (i = 0; i <= library_data.Length - 1; i++) { strLibIds = strLibIds + library_data[i].Id + ","; dr = dt.NewRow(); dr[0] = "<input type=\"checkbox\" name=\"id_" + library_data[i].Id + "\"/>"; dr[1] = "<a href=\"library.aspx?LangType=" + _ContentLanguage + "&action=ViewLibraryItem&id=" + library_data[i].Id + "&parent_id=" + _FolderId + "\" title=\'" + _MessageHelper.GetMessage("generic View") + " \"" + Strings.Replace(library_data[i].Title, "\'", "`", 1, -1, 0) + "\"" + "\'>" + library_data[i].Title + "</a>"; dr[2] = library_data[i].Id; dr[3] = library_data[i].DisplayLastEditDate; dr[4] = library_data[i].FileName; dr[5] = library_data[i].ContentId; dt.Rows.Add(dr); } if (strLibIds != "") { strLibIds = strLibIds.Substring(0, strLibIds.Length - 1); } libids.Value = strLibIds; } folder_id.Value = Convert.ToString(_FolderId); DataView dv = new DataView(dt); QlinkTemplateByCategoryGrid.DataSource = dv; QlinkTemplateByCategoryGrid.DataBind(); if (_TotalPagesNumber > 1) { this.uxPagingUpdateLink.TotalPages = _TotalPagesNumber; this.uxPagingUpdateLink.CurrentPageIndex = _CurrentPageNumber; } else { this.uxPagingUpdateLink.Visible = false; } }
protected void cmd_attach_Click(object sender, System.EventArgs e) { try { if (!(ul_file.PostedFile == null)) { long iFolder = iforumid; Ektron.Cms.LibraryConfigData lib_settings_data; lib_settings_data = this.m_refContentApi.GetLibrarySettings(iFolder); // file was sent HttpPostedFile myFile = ul_file.PostedFile; string sFileExt = ""; // Get and check size of uploaded file int nFileLen = myFile.ContentLength; if (nFileLen > _board.MaxFileSize) { throw (new Exception("File is too large. There is a " + _board.MaxFileSize.ToString() + " byte limit.")); } //get and check name and extension string sFileName = myFile.FileName; string sShortName = ""; if (myFile.FileName.IndexOf("\\") > -1) { string[] aFilename = myFile.FileName.Split('\\'); // take the very last one if (aFilename.Length > 0) { sFileName = aFilename[aFilename.Length - 1]; } } sFileName = sFileName.Replace("\'", "").Replace("#", "_"); // make safe string[] aFileExt = sFileName.Split('.'); if (aFileExt.Length > 1) { sFileExt = (string)(aFileExt[(aFileExt.Length - 1)].Trim().ToLower()); //use the LAASSTT one. sShortName = sFileName.Substring(0, System.Convert.ToInt32(sFileName.Length - (sFileExt.Length + 1))); } else { throw (new Exception("The extension \"" + sFileExt + "\" is not allowed.")); } aFileExt = _board.AcceptedExtensions.Split(','); if (aFileExt.Length > 0) { bool bGo = false; for (int i = 0; i <= (aFileExt.Length - 1); i++) { if (sFileExt == aFileExt[i].Trim().ToLower()) { bGo = true; break; } } if (bGo == false) { throw (new Exception("The extension \"" + sFileExt + "\" is not allowed.")); } } else { throw (new Exception("The extension \"" + sFileExt + "\" is not allowed.")); } // Allocate a buffer for reading of the file byte[] myData = new byte[nFileLen - 1 + 1]; // Read uploaded file from the Stream myFile.InputStream.Read(myData, 0, nFileLen); //check for existence of file. FileInfo CheckFile; int iUnqueNameIdentifier = 0; string sWebPath = lib_settings_data.FileDirectory; if (Ektron.Cms.Common.EkFunctions.IsImage(System.IO.Path.GetExtension(sFileName))) { sWebPath = lib_settings_data.ImageDirectory; } string sPhysicalPath = Server.MapPath(sWebPath); if (!System.IO.Directory.Exists(sPhysicalPath)) { Ektron.Cms.API.Folder folderApi = new Ektron.Cms.API.Folder(); folderApi.CreateFolder(sPhysicalPath); } CheckFile = new FileInfo(sPhysicalPath + sFileName); if (CheckFile.Exists) { while (CheckFile.Exists) { iUnqueNameIdentifier++; sFileName = sShortName + "(" + iUnqueNameIdentifier + ")." + sFileExt; CheckFile = new FileInfo(sPhysicalPath + sFileName); } } //write WriteToFile(sPhysicalPath + sFileName, myData); //----------------- Load Balance ------------------------------------------------------ LoadBalanceData[] loadbalance_data; loadbalance_data = base.m_refContentApi.GetAllLoadBalancePathsExtn(iFolder, "files"); if (!(loadbalance_data == null)) { for (int j = 0; j <= loadbalance_data.Length - 1; j++) { sPhysicalPath = Server.MapPath(loadbalance_data[j].Path); if ((sPhysicalPath.Substring(sPhysicalPath.Length - 1, 1) != "\\")) { sPhysicalPath = sPhysicalPath + "\\"; } WriteToFile(sPhysicalPath + sFileName, myData); } } //record to db Ektron.Cms.FileAttachment faAttach = new Ektron.Cms.FileAttachment(); faAttach.DoesExist = true; faAttach.Filename = sFileName; faAttach.Filepath = sWebPath + sFileName; faAttach.FileSize = int.Parse(myFile.ContentLength.ToString()); faAttach.MimeType = myFile.ContentType; if (this.m_iID > 0) { faAttach.ReplyID = this.m_iID; } faAttach = m_refContentApi.EkContentRef.AddFileAttachment(faAttach); ltr_filelist.Text += "<div id=\"ekfile_" + faAttach.ID.ToString() + "\" onMouseOver=\"doselect(this,\'over\',\'" + lib_settings_data.FileDirectory + faAttach.Filename + "\');\" onMouseOut=\"doselect(this,\'out\',\'" + lib_settings_data.FileDirectory + faAttach.Filename + "\');\" onClick=\"doselect(this,\'toggle\',\'" + lib_settings_data.FileDirectory + faAttach.Filename + ("\');\"><img alt=\"Attachment\" src=\"" + this.AppImgPath + "doc.gif\" border=\"0\"> ") + Path.GetFileName(sFileName) + " (" + myFile.ContentLength.ToString() + " bytes) <input type=\"hidden\" name=\"ek_attachedfile_id_" + faAttach.ID.ToString() + "\" id=\"ek_attachedfile_id_" + faAttach.ID.ToString() + "\" value=\"" + faAttach.ID.ToString() + "\" /></div>"; ReUpParent(); } else { throw (new Exception("No File")); } } catch (Exception ex) { ltr_error.Text = ex.Message; //ltr_bottomjs.Text &= "<script language=""javaScript"" type=""text/javascript"">" & Environment.NewLine ltr_bottomjs.Text += " justtoggle(document.getElementById(\'dvErrorMessage\'), true);" + Environment.NewLine; //ltr_bottomjs.Text &= "</script>" & Environment.NewLine bError = true; //Utilities.ShowError(ex.Message) } }
private void Display_ViewLibraryByCategory() { LibraryData[] result; Ektron.Cms.Content.EkContent m_refcontent; Collection cTmp = new Collection(); DataTable dt = new DataTable(); DataRow dr; int i = 0; string QLinkDisplayName; string TdName = ""; string strLibraryFileName = ""; string sDesLoc; string[] myfilePathArray; string myImagefile; string myNewImagefile; string sExt; string originalfile; System.IO.FileInfo fs = null; bool isQuicklinks; bool isForms; bool isFiles; bool isHyperlinks; string strEnhancedmetaselect = string.Empty; m_refcontent = m_refContentApi.EkContentRef; isQuicklinks = System.Convert.ToBoolean("quicklinks" == LibType); isForms = System.Convert.ToBoolean("forms" == LibType); isFiles = System.Convert.ToBoolean("files" == LibType); isHyperlinks = System.Convert.ToBoolean("hyperlinks" == LibType); if (autoNavFolder == 0) { if (IsRootFolder) { Session["AutoNavFolder" + "_" + folder] = null; } else { Session["AutoNavFolder" + "_" + folder] = folder; } } else { Session["AutoNavFolder" + "_" + folder] = autoNavFolder; } result = m_refLib.GetAllChildLibItemsByTypev5_0(LibType, folder, Request.QueryString["orderby"], _currentPageNumber, m_refContentApi.RequestInformationRef.PagingSize, true, ref TotalPagesNumber); //Fix for Assets in a multisite enviroment [mediainsert.aspx.vb] Microsoft.VisualBasic.Collection fCol = new Microsoft.VisualBasic.Collection(); Ektron.Cms.API.Folder fapi = new Ektron.Cms.API.Folder(); Ektron.Cms.FolderData[] fdata; fdata = m_refContentApi.GetChildFolders(0, false, EkEnumeration.FolderOrderBy.Name); if (fdata != null) { foreach (FolderData thisfdata in fdata) { if (thisfdata.FolderType == 2) { fCol = m_refcontent.GetFolderInfov2_0(thisfdata.Id); foreach (LibraryData thisresult in result) { if (fCol["DomainProduction"].ToString() != "" && thisresult.FileName.IndexOf(fCol["DomainProduction"].ToString()) != -1) { string slashCheck = thisresult.FileName.Replace((string)("http://" + fCol["DomainProduction"]), ""); if (slashCheck != "" && slashCheck.Substring(0, 1) != "/") { thisresult.FileName = thisresult.FileName.Replace("http://" + fCol["DomainProduction"], "http://" + fCol["DomainProduction"] + "/"); } else { thisresult.FileName = slashCheck; } } thisresult.FileName = Regex.Replace(thisresult.FileName, "http://" + fCol["DomainProduction"] + "javascript", "javascript"); } } } } //End fix for multisite and Assets if (TotalPagesNumber <= 1) { TotalPages.Visible = false; CurrentPage.Visible = false; lnkBtnPreviousPage.Visible = false; NextPage.Visible = false; LastPage.Visible = false; FirstPage.Visible = false; PageLabel.Visible = false; OfLabel.Visible = false; } else { TotalPages.Visible = true; CurrentPage.Visible = true; lnkBtnPreviousPage.Visible = true; NextPage.Visible = true; LastPage.Visible = true; FirstPage.Visible = true; PageLabel.Visible = true; OfLabel.Visible = true; TotalPages.Text = (System.Math.Ceiling(Convert.ToDecimal(TotalPagesNumber))).ToString(); TotalPages.ToolTip = TotalPages.Text; CurrentPage.Text = _currentPageNumber.ToString(); CurrentPage.ToolTip = CurrentPage.Text; if (_currentPageNumber == 1) { lnkBtnPreviousPage.Enabled = false; if (TotalPagesNumber > 1) { NextPage.Enabled = true; } else { NextPage.Enabled = false; } } else { lnkBtnPreviousPage.Enabled = true; if (_currentPageNumber == TotalPagesNumber) { NextPage.Enabled = false; } else { NextPage.Enabled = true; } } } TypeCounts = m_refcontent.GetLibraryTypeCount(folder); cFolder = m_refContentApi.GetFolderById(folder); cPerms = m_refContentApi.LoadPermissions(folder, "folder", 0); ViewLibraryByCategoryToolBar(); strEnhancedmetaselect = Request.QueryString["enhancedmetaselect"]; // Title: System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "ITEM1"; if (!((Request.QueryString["enhancedmetaselect"] == null)) && strEnhancedmetaselect.Length != 0) { colBound.HeaderText = "<a href=\"mediainsert.aspx?EditorName=" + sEditor + "&enhancedmetaselect=1" + "&scope=" + Request.QueryString["scope"].ToString() + "&action=ViewLibraryByCategory" + "&dentrylink=" + DEntryLink + "&fullscreen=off&orderby=LibraryTitle&id=" + folder + "&type=" + LibType + "\" title=\"" + m_refMsg.GetMessage("click to sort msg") + "\">" + m_refMsg.GetMessage("generic Title") + "</a>"; } else { colBound.HeaderText = "<a href=\"mediainsert.aspx?EditorName=" + sEditor + "&action=ViewLibraryByCategory" + "&scope=" + Request.QueryString["scope"].ToString() + "&dentrylink=" + DEntryLink + "&fullscreen=off&orderby=LibraryTitle&id=" + folder + "&type=" + LibType + "\" title=\"" + m_refMsg.GetMessage("click to sort msg") + "\">" + m_refMsg.GetMessage("generic Title") + "</a>"; } colBound.ItemStyle.Wrap = false; colBound.HeaderStyle.CssClass = "title-header"; MediaListGrid.Columns.Add(colBound); dt.Columns.Add(new DataColumn("ITEM1", typeof(string))); // ID: if (!(isQuicklinks || isForms)) { colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "ITEM2"; colBound.HeaderText = "<a href=\"mediainsert.aspx?EditorName=" + sEditor + "&action=ViewLibraryByCategory" + "&scope=" + Request.QueryString["scope"].ToString() + "&dentrylink=" + DEntryLink + "&fullscreen=off&orderby=LibraryID&&id=" + folder + "&type=" + LibType + "\" title=\"" + m_refMsg.GetMessage("click to sort msg") + "\">" + m_refMsg.GetMessage("generic ID") + "</a>"; colBound.ItemStyle.Wrap = false; colBound.HeaderStyle.CssClass = "title-header"; MediaListGrid.Columns.Add(colBound); dt.Columns.Add(new DataColumn("ITEM2", typeof(string))); } // Language: if (isQuicklinks || isForms) { colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "ITEM3"; if (!((Request.QueryString["enhancedmetaselect"] == null)) && strEnhancedmetaselect.Length != 0) { colBound.HeaderText = "<a href=\"mediainsert.aspx?EditorName=" + sEditor + "&enhancedmetaselect=1" + "&action=ViewLibraryByCategory" + "&scope=" + Request.QueryString["scope"].ToString() + "&dentrylink=" + DEntryLink + "&fullscreen=off&orderby=ContentLanguage&&id=" + folder + "&type=" + LibType + "\" title=\"" + m_refMsg.GetMessage("click to sort msg") + "\">" + "Language" + "</a>"; } else { colBound.HeaderText = "<a href=\"mediainsert.aspx?EditorName=" + sEditor + "&action=ViewLibraryByCategory" + "&scope=" + Request.QueryString["scope"].ToString() + "&dentrylink=" + DEntryLink + "&fullscreen=off&orderby=ContentLanguage&&id=" + folder + "&type=" + LibType + "\" title=\"" + m_refMsg.GetMessage("click to sort msg") + "\">" + "Language" + "</a>"; } colBound.ItemStyle.Wrap = false; colBound.HeaderStyle.CssClass = "title-header"; MediaListGrid.Columns.Add(colBound); dt.Columns.Add(new DataColumn("ITEM3", typeof(string))); } // Date modified: colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "ITEM4"; if (!((Request.QueryString["enhancedmetaselect"] == null)) && strEnhancedmetaselect.Length != 0) { colBound.HeaderText = "<a href=\"mediainsert.aspx?EditorName=" + sEditor + "&enhancedmetaselect=1" + "&action=ViewLibraryByCategory" + "&scope=" + Request.QueryString["scope"].ToString() + "&dentrylink=" + DEntryLink + "&fullscreen=off&orderby=date&&id=" + folder + "&type=" + LibType + "\" title=\"" + m_refMsg.GetMessage("click to sort msg") + "\">" + "Date modified" + "</a>"; } else { colBound.HeaderText = "<a href=\"mediainsert.aspx?EditorName=" + sEditor + "&action=ViewLibraryByCategory" + "&scope=" + Request.QueryString["scope"].ToString() + "&dentrylink=" + DEntryLink + "&fullscreen=off&orderby=date&&id=" + folder + "&type=" + LibType + "\" title=\"" + m_refMsg.GetMessage("click to sort msg") + "\">" + "Date modified" + "</a>"; } colBound.ItemStyle.Wrap = false; colBound.HeaderStyle.CssClass = "title-header"; MediaListGrid.Columns.Add(colBound); dt.Columns.Add(new DataColumn("ITEM4", typeof(string))); foreach (LibraryData myLibrary in result) { bool IsAsset = EkConstants.IsAssetContentType(myLibrary.ContentType, true); if (!(IsMac && IsAsset)) { string FileExtension = System.IO.Path.GetExtension(myLibrary.FileName); Array.Resize(ref arr_TdName, i + 1); TdName = (string)("cell" + myLibrary.Id); QLinkDisplayName = myLibrary.Title; dr = dt.NewRow(); strLibraryFileName = (string)(Convert.ToString(Server.HtmlDecode(myLibrary.FileName))); if (strLibraryFileName.StartsWith("/")) { if (!myLibrary.FileName.ToLower().Contains(SitePath.ToLower())) { strLibraryFileName = strLibraryFileName.Substring(1); strLibraryFileName = SitePath + strLibraryFileName; } } if (isQuicklinks || isForms) { // see if content is in a domain folder which always use linkit.aspx //Dim domain As String = m_refContentApi.GetDomainByContentId(myLibrary.ContentId) if (UseLinkItPage) { // if content is in a domain folder, linkit.aspx will redirect to the proper domain if (isForms) { if (1 == DEntryLink) { //workaround for any form filelink added to the redirection post message from the library //this would allow the application to add the AppPath when the form is redirected. strLibraryFileName = (string)("linkit.aspx?LinkIdentifier=ekfrm&ItemID=" + myLibrary.ContentId); } else { strLibraryFileName = m_refContentApi.AppPath + "linkit.aspx?LinkIdentifier=ekfrm&ItemID=" + myLibrary.ContentId; } } else { strLibraryFileName = m_refContentApi.AppPath + "linkit.aspx?LinkIdentifier=id&ItemID=" + myLibrary.ContentId; } } } else if (Request.QueryString["scope"] == "" && !(isQuicklinks || isForms)) { strLibraryFileName = myLibrary.ContentId.ToString() ; } string thumbName=string.Empty; string strRelativeFilename; strRelativeFilename = myLibrary.FileName; if (strRelativeFilename == null) { strRelativeFilename = ""; } else if (strRelativeFilename.StartsWith(SitePath)) { strRelativeFilename = strRelativeFilename.Substring(SitePath.Length); } myLibrary.Title = Server.HtmlDecode(myLibrary.Title); arr_TdName[i] = TdName; if (isQuicklinks || isForms || isFiles || isHyperlinks) { dr["ITEM1"] += "<a href=\"#\" title=\"double click to insert msg\" onclick=\"Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + Convert.ToString(myLibrary.Title).Replace("\'", "\\\'") + "\', \'" + MakeStringJSSafe(strLibraryFileName) + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');Blink(\'" + TdName + "\', \'yellow\');return false;\"ondblclick=\"Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + Convert.ToString(myLibrary.Title).Replace("\'", "\\\'") + "\', \'" + MakeStringJSSafe(strLibraryFileName) + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');SubmitInsert();\"" + " >" + "\r\n"; dr["ITEM1"] += QLinkDisplayName + "</a>" + "\r\n"; dr["ITEM1"] += "<br /> " + "\r\n"; dr["ITEM1"] += strRelativeFilename; } else { if (IsAsset && Request.QueryString["scope"] != "") { strRelativeFilename = strLibraryFileName; thumbName = strLibraryFileName; } else { thumbName = MakeStringJSSafe(EkFunctions.GetThumbnailForContent(strLibraryFileName)); } if (thumbName.StartsWith("/")) { if (!thumbName.ToLower().Contains(SitePath.ToLower())) { thumbName = thumbName.Substring(1); thumbName = SitePath + thumbName; } } dr["ITEM1"] += "<a href=\"#\" title=\"double click to insert msg\" onclick=\"ThumbnailForContentImage(\'" + thumbName + "\');Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + Convert.ToString(myLibrary.Title).Replace("\'", "\\\'") + "\', \'" + MakeStringJSSafe(strLibraryFileName) + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');Blink(\'" + TdName + "\', \'yellow\');return false;\" ondblclick=\"Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + Convert.ToString(myLibrary.Title).Replace("\'", "\\\'") + "\', \'" + MakeStringJSSafe(strLibraryFileName) + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');SubmitInsert();\"" + " >" + "\r\n"; dr["ITEM1"] += QLinkDisplayName + " [" + strRelativeFilename + "]"; dr["ITEM1"] += "</a>" + "\r\n"; } if (!(isQuicklinks || isForms)) { dr["ITEM2"] += "<a href=\"#\" title=\"double click to insert msg\" onclick=\"ThumbnailForContentImage(\'" + thumbName + "\');Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + Convert.ToString(myLibrary.Title).Replace("\'", "\\\'") + "\', \'" + MakeStringJSSafe(strLibraryFileName) + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');Blink(\'" + TdName + "\', \'yellow\');return false;\" ondblclick=\"Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + Convert.ToString(myLibrary.Title).Replace("\'", "\\\'") + "\', \'" + MakeStringJSSafe(strLibraryFileName) + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');SubmitInsert();\"" + " >" + "\r\n"; dr["ITEM2"] += Convert.ToString(myLibrary.Id) + "\r\n"; dr["ITEM2"] += "</a>" + "\r\n"; } if (isQuicklinks || isForms) { dr["ITEM3"] += "<a href=\"#\" title=\"double click to insert msg\" onclick=\"Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + Convert.ToString(myLibrary.Title).Replace("\'", "\\\'") + "\', \'" + MakeStringJSSafe(strLibraryFileName) + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');Blink(\'" + TdName + "\', \'yellow\');return false;\" ondblclick=\"Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + Convert.ToString(myLibrary.Title).Replace("\'", "\\\'") + "\', \'" + MakeStringJSSafe(strLibraryFileName) + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');SubmitInsert();\"" + " ></a>" + "\r\n"; dr["ITEM3"] += " <img style=\'vertical-align:middle;\' src=\'" + objLocalizationApi.GetFlagUrlByLanguageID(myLibrary.LanguageId) + "\' />" + "\r\n"; } if (!(isQuicklinks || isForms)) { dr["ITEM4"] += "<a href=\"#\" title=\"double click to insert msg\" onclick=\"ThumbnailForContentImage(\'" + thumbName + "\');Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + Convert.ToString(myLibrary.Title).Replace("\'", "\\\'") + "\', \'" + MakeStringJSSafe(strLibraryFileName) + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');;Blink(\'" + TdName + "\', \'yellow\');return false;\" ondblclick=\"Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + Convert.ToString(myLibrary.Title).Replace("\'", "\\\'") + "\', \'" + MakeStringJSSafe(strLibraryFileName) + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');SubmitInsert();\"" + " >" + "\r\n"; dr["ITEM4"] += myLibrary.DisplayLastEditDate + "\r\n"; dr["ITEM4"] += "</a>" + "\r\n"; } dt.Rows.Add(dr); if (LibType == "images") { sDesLoc = myLibrary.StagingFileName; if (sDesLoc == "") { sDesLoc = myLibrary.FileName; } originalfile = myLibrary.FileName; myfilePathArray = sDesLoc.Split('/'); myImagefile = myfilePathArray[(myfilePathArray.Length - 1)]; sExt = myImagefile.Substring(myImagefile.Length - 3, 3); if ("gif" == sExt || "GIF" == sExt) { sExt = "png"; myNewImagefile = "thumb_" + myImagefile.Substring(0, myImagefile.Length - 3) + "png"; } else { myNewImagefile = (string)("thumb_" + myImagefile); } try { sDesLoc = sDesLoc.Replace(myImagefile, myNewImagefile); FolderData folder_data = this.m_refContentApi.GetFolderById(this.folder); if (folder_data.IsDomainFolder) { fs = null; } else if (folder_data.DomainProduction == "") { fs = new FileInfo(Server.MapPath(sDesLoc)); } if (fs == null || fs.Exists || IsAsset) { if (sDesLoc.StartsWith("/")) { if (!sDesLoc.ToLower().Contains(SitePath.ToLower())) { sDesLoc = sDesLoc.Substring(1); sDesLoc = m_refContentApi.SitePath + sDesLoc; } } dr = dt.NewRow(); string libFileName; if (Request.QueryString["scope"] == "") { libFileName = myLibrary.ContentId.ToString(); } else { if (IsAsset) { libFileName = strLibraryFileName; originalfile = libFileName; } else { libFileName = myLibrary.FileName.Replace("\'", "\\\'"); if (libFileName.StartsWith("/")) { if (!myLibrary.FileName.ToLower().Contains(SitePath.ToLower())) { libFileName = libFileName.Substring(1); libFileName = SitePath + libFileName; } } } System.Random rand = new System.Random(); if ("image" == LibType) { libFileName += "?n=" + rand.Next(0, 1000); } } if (originalfile.StartsWith("/")) { if (!originalfile.ToLower().Contains(SitePath.ToLower())) { originalfile = originalfile.Substring(1); originalfile = SitePath + originalfile; } } if ((m_strEnhancedMetaSelect.Length == 0) && DEntryLink == 0 && sEditor != "JSEditor") { dr["ITEM1"] = "<a href=\"#\" title=\"" + m_refMsg.GetMessage("double click to insert msg") + "\" onclick=\"Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + myLibrary.Title.Replace("\'", "\\\'") + "\', \'" + libFileName + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');Blink(\'" + TdName + "\', \'yellow\');ThumbnailForContentImage(\'" + thumbName + "\');return false;\" ondblclick=\"Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + myLibrary.Title.Replace("\'", "\\\'") + "\', \'" + libFileName + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');ThumbnailForContentImage(\'" + thumbName + "\');SubmitInsert();\"><img src=\"" + sDesLoc + "\" border=\"0\" /></a> " + (showThumbnail ? ("<a href=\"#\" onclick=\"Insert_thumb(\'" + myLibrary.Title.Replace("\'", "\\\'") + "\', \'" + originalfile.Replace("\'", "\\\'") + "\',\'" + sDesLoc.Replace("\'", "\\\'") + "\')\"><img src=\"images/application/thumbnail.gif\" border=\"0\" alt=\"Insert thumb nail and pop up larger image\" /></a>") : ""); } else { dr["ITEM1"] = "<a href=\"#\" title=\"" + m_refMsg.GetMessage("double click to insert msg") + "\" onclick=\"Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + myLibrary.Title.Replace("\'", "\\\'") + "\', \'" + libFileName + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');Blink(\'" + TdName + "\', \'yellow\');ThumbnailForContentImage(\'" + thumbName + "\');return false;\" ondblclick=\"Insert(\'" + myLibrary.Id + "\', \'" + folder + "\', \'" + myLibrary.Title.Replace("\'", "\\\'") + "\', \'" + libFileName + "\', \'" + LibType + "\', \'" + myLibrary.ContentId + "\');ThumbnailForContentImage(\'" + thumbName + "\');SubmitInsert();\"><img src=\"" + sDesLoc + "\" border=\"0\" /></a> <hr />"; } dr["ITEM2"] = "REMOVE_ITEM"; if (isQuicklinks || isForms) { dr["ITEM3"] = "REMOVE_ITEM"; } dr["ITEM4"] = "REMOVE_ITEM"; dt.Rows.Add(dr); } } catch (Exception) { } } i++; } } DataView dv = new DataView(dt); MediaListGrid.DataSource = dv; MediaListGrid.DataBind(); }