protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!String.IsNullOrEmpty(_box_css_name)) { if (_box_css_name.IndexOf("-title-") > 0) { string sBoxTop = String.Format("<div id=\"{0}\"><div class=\"t\"><div class=\"t\"><div class=\"t\"></div></div></div><div class=\"title\">{1}</div><div class=\"m\"><div class=\"clearfix\">", _box_css_name, LegoWebSite.Buslgic.CommonParameters.asign_COMMON_PARAMETER(this.Title)); string sBoxBottom = "</div><div class=\"clr\"></div></div><div class=\"b\"><div class=\"b\"><div class=\"b\"></div></div></div></div>"; this.litBoxTop.Text = sBoxTop; this.litBoxBottom.Text = sBoxBottom; } else { string sBoxTop = String.Format("<div id=\"{0}\"><div class=\"t\"><div class=\"t\"><div class=\"t\"></div></div></div><div class=\"m\"><div class=\"clearfix\">", _box_css_name); string sBoxBottom = "</div><div class=\"clr\"></div></div><div class=\"b\"><div class=\"b\"><div class=\"b\"></div></div></div></div>"; this.litBoxTop.Text = sBoxTop; this.litBoxBottom.Text = sBoxBottom; } } string sliderShowScript = @" <script type='text/javascript'> $(document).ready(function() { //Execute the slideShow slideShow(); }); function slideShow() { //Resize the heigh of the div according to the image heigh $('#gallery').css({height: $('#gallery a').find('img').css('height')}); //Set the opacity of all images to 0 $('#gallery a').css({opacity: 0.0}); //Get the first image and display it (set it to full opacity) $('#gallery a:first').css({opacity: 1.0}); //Set the caption background to semi-transparent $('#gallery .caption').css({opacity: 0.7}); //Resize the width of the caption according to the image width $('#gallery .caption').css({width: $('#gallery a').find('img').css('width')}); //Get the caption of the first image from REL attribute and display it $('#gallery .content').html($('#gallery a:first').find('img').attr('rel')) .animate({opacity: 0.7}, 400); //Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds setInterval('gallery()',6000); } function gallery() { //if no IMGs have the show class, grab the first image var current = ($('#gallery a.show')? $('#gallery a.show') : $('#gallery a:first')); //Get next image, if it reached the end of the slideshow, rotate it back to the first image var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first')); //Get next image caption var caption = next.find('img').attr('rel'); //Set the fade in effect for the next image, show class has higher z-index next.css({opacity: 0.0}) .addClass('show') .animate({opacity: 1.0}, 1000); //Hide the current image current.animate({opacity: 0.0}, 1000) .removeClass('show'); //Set the opacity to 0 and height to 1px $('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 }); //Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect $('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '65px'},500 ); //Display the content $('#gallery .content').html(caption); } </script> "; int contentid = discover_content_id(); if ((contentid <= 0) || (contentid > 0 && !LegoWebSite.Buslgic.MetaContents.is_META_CONTENTS_EXIST(contentid))) { this.litContent.Text = "<H3>No suitable data!</H3>"; return; } CRecord myRec = new CRecord(); string sMetaXml = LegoWebSite.Buslgic.MetaContents.get_META_CONTENT_MARCXML(contentid, 0); myRec.load_Xml(sMetaXml); myRec.Sort(); string sdefaultHeight = myRec.Datafields.Datafield("300").Subfields.Subfield("h").Value; string sdefaultWidth = myRec.Datafields.Datafield("300").Subfields.Subfield("w").Value; CDatafields Dfs = myRec.Datafields; Dfs.Filter("856"); if (Dfs.Count == 0) { this.litContent.Text = "<H3>No image info</H3>"; return; } else { string sSliderHTML = "<div id='gallery'>"; string aFormat = "<a href='{0}' {1}> <img src='{2}' alt='{3}' width='{4}' height='{5}' rel='<h3>{3}</h3>{6}'/></a>"; for (int i = 0; i < Dfs.Count; i++) { CDatafield Df = Dfs.Datafield(i); if (i == 0) { sSliderHTML += String.Format(aFormat, String.IsNullOrEmpty(Df.Subfields.Subfield("l").Value) ? "#" : Df.Subfields.Subfield("l").Value, " class='show'", Df.Subfields.Subfield("u").Value, Df.Subfields.Subfield("3").Value, String.IsNullOrEmpty(Df.Subfields.Subfield("w").Value) == true ? sdefaultWidth : Df.Subfields.Subfield("w").Value, String.IsNullOrEmpty(Df.Subfields.Subfield("h").Value) == true ? sdefaultHeight: Df.Subfields.Subfield("h").Value, Df.Subfields.Subfield("a").Value); } else { sSliderHTML += String.Format(aFormat, String.IsNullOrEmpty(Df.Subfields.Subfield("l").Value) ? "#" : Df.Subfields.Subfield("l").Value, "", Df.Subfields.Subfield("u").Value, Df.Subfields.Subfield("3").Value, String.IsNullOrEmpty(Df.Subfields.Subfield("w").Value) == true ? sdefaultWidth : Df.Subfields.Subfield("w").Value, String.IsNullOrEmpty(Df.Subfields.Subfield("h").Value) == true ? sdefaultHeight: Df.Subfields.Subfield("h").Value, Df.Subfields.Subfield("a").Value); } } sSliderHTML += "<div class='caption'><div class='content'></div></div>"; sSliderHTML += "</div"; this.litContent.Text = sSliderHTML; } Page.RegisterStartupScript("slidershowscript", sliderShowScript); } }
protected void Page_Load(object sender, EventArgs e) { int meta_content_id = 0; int category_id = 0; int menu_id = 0; string sLangCode = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.ToLower(); if (!IsPostBack) { //set round boxs if (!String.IsNullOrEmpty(_navibox_css_name)) { if (_navibox_css_name.IndexOf("-title-") > 0) { string sBoxTop = String.Format("<div id=\"{0}\"><div class=\"t\"><div class=\"t\"><div class=\"t\"></div></div></div><div class=\"title\">{1}</div><div class=\"m\"><div class=\"clearfix\">", _navibox_css_name, LegoWebSite.Buslgic.CommonParameters.asign_COMMON_PARAMETER(_navibox_title)); string sBoxBottom = "</div><div class=\"clr\"></div></div><div class=\"b\"><div class=\"b\"><div class=\"b\"></div></div></div></div>"; this.litCatNaviBoxTop.Text = sBoxTop; this.litCatNaviBoxBottom.Text = sBoxBottom; } else { string sBoxTop = String.Format("<div id=\"{0}\"><div class=\"t\"><div class=\"t\"><div class=\"t\"></div></div></div><div class=\"m\"><div class=\"clearfix\">", _navibox_css_name); string sBoxBottom = "</div><div class=\"clr\"></div></div><div class=\"b\"><div class=\"b\"><div class=\"b\"></div></div></div></div>"; this.litCatNaviBoxTop.Text = sBoxTop; this.litCatNaviBoxBottom.Text = sBoxBottom; } } else { this.litCatNaviBoxTop.Text = "<div>"; this.litCatNaviBoxBottom.Text = "</div>"; } if (!String.IsNullOrEmpty(_contentbox_css_name)) { if (_contentbox_css_name.IndexOf("-title-") > 0) { string sBoxTop = String.Format("<div id=\"{0}\"><div class=\"t\"><div class=\"t\"><div class=\"t\"></div></div></div><div class=\"title\">{1}</div><div class=\"m\"><div class=\"clearfix\">", _contentbox_css_name, LegoWebSite.Buslgic.CommonParameters.asign_COMMON_PARAMETER(_contentbox_title)); string sBoxBottom = "</div><div class=\"clr\"></div></div><div class=\"b\"><div class=\"b\"><div class=\"b\"></div></div></div></div>"; this.litContentBrowserBoxTop.Text = sBoxTop; this.litContentBrowserBoxBottom.Text = sBoxBottom; } else { string sBoxTop = String.Format("<div id=\"{0}\"><div class=\"t\"><div class=\"t\"><div class=\"t\"></div></div></div><div class=\"m\"><div class=\"clearfix\">", _contentbox_css_name); string sBoxBottom = "</div><div class=\"clr\"></div></div><div class=\"b\"><div class=\"b\"><div class=\"b\"></div></div></div></div>"; this.litContentBrowserBoxTop.Text = sBoxTop; this.litContentBrowserBoxBottom.Text = sBoxBottom; } } else { this.litContentBrowserBoxTop.Text = "<div>"; this.litContentBrowserBoxBottom.Text = "</div>"; } if (!String.IsNullOrEmpty(_relatedbox_css_name)) { if (_relatedbox_css_name.IndexOf("-title-") > 0) { string sBoxTop = String.Format("<div id=\"{0}\"><div class=\"t\"><div class=\"t\"><div class=\"t\"></div></div></div><div class=\"title\">{1}</div><div class=\"m\"><div class=\"clearfix\">", _relatedbox_css_name, LegoWebSite.Buslgic.CommonParameters.asign_COMMON_PARAMETER(_relatedbox_title)); string sBoxBottom = "</div><div class=\"clr\"></div></div><div class=\"b\"><div class=\"b\"><div class=\"b\"></div></div></div></div>"; this.litRelatedContentBoxTop.Text = sBoxTop; this.litRelatedContentBoxBottom.Text = sBoxBottom; } else { string sBoxTop = String.Format("<div id=\"{0}\"><div class=\"t\"><div class=\"t\"><div class=\"t\"></div></div></div><div class=\"m\"><div class=\"clearfix\">", _relatedbox_css_name); string sBoxBottom = "</div><div class=\"clr\"></div></div><div class=\"b\"><div class=\"b\"><div class=\"b\"></div></div></div></div>"; this.litRelatedContentBoxTop.Text = sBoxTop; this.litRelatedContentBoxBottom.Text = sBoxBottom; } } else { this.litRelatedContentBoxTop.Text = "<div>"; this.litRelatedContentBoxBottom.Text = "</div>"; } //try to find meta_content_id in order of: meta_content_id; category_id->get top 1 meta_content_id of; menu_id->category_id->get top 1 meta_content_id of if (CommonUtility.GetInitialValue("contentid", null) != null) { meta_content_id = int.Parse(CommonUtility.GetInitialValue("contentid", null).ToString()); } if (CommonUtility.GetInitialValue("catid", null) != null) { category_id = int.Parse(CommonUtility.GetInitialValue("catid", null).ToString()); } if (CommonUtility.GetInitialValue("mnuid", null) != null) { menu_id = int.Parse(CommonUtility.GetInitialValue("mnuid", 0).ToString()); } if (meta_content_id <= 0) { if (category_id > 0) { if (!LegoWebSite.Buslgic.Categories.is_CATEGORY_EXIST(category_id)) { this.litContentBrowserContent.Text = "<H3>" + Resources.strings.DataIsNotAvailable + "</H3>"; return; } else { DataTable top1Data = LegoWebSite.Buslgic.MetaContents.get_TOP_CONTENTS_OF_CATEGORY(category_id, 1, sLangCode); if (top1Data.Rows.Count > 0) { meta_content_id = (int)top1Data.Rows[0]["META_CONTENT_ID"]; category_id = (int)top1Data.Rows[0]["CATEGORY_ID"]; } else { this.litContentBrowserContent.Text = "<H3>" + Resources.strings.DataIsNotAvailable + "</H3>"; return; } } } else if (menu_id > 0) { category_id = LegoWebSite.Buslgic.Categories.get_CATEGORY_ID_BY_MENU_ID(menu_id); if (!LegoWebSite.Buslgic.Categories.is_CATEGORY_EXIST(category_id)) { this.litContentBrowserContent.Text = "<H3>" + Resources.strings.DataIsNotAvailable + "</H3>"; return; } else { DataTable top1Data = LegoWebSite.Buslgic.MetaContents.get_TOP_CONTENTS_OF_CATEGORY(category_id, 1, sLangCode); if (top1Data.Rows.Count > 0) { meta_content_id = (int)top1Data.Rows[0]["META_CONTENT_ID"]; category_id = (int)top1Data.Rows[0]["CATEGORY_ID"];//change to specific content's category } else { this.litContentBrowserContent.Text = "<H3>" + Resources.strings.DataIsNotAvailable + "</H3>"; return; } } } else { this.litContentBrowserContent.Text = "<H3>" + Resources.strings.DataIsNotAvailable + "</H3>"; return; } } if (!LegoWebSite.Buslgic.MetaContents.is_META_CONTENTS_EXIST(meta_content_id)) { litContentBrowserContent.Text = "<H3>meta_content_id is not available!</H3>"; return; } if (category_id == 0) { category_id = LegoWebSite.Buslgic.MetaContents.get_META_CONTENT_CATEGORY_ID(meta_content_id); } //Display Navigator Info this.litCatNaviContent.Text = LegoWebSite.Buslgic.Categories.get_NavigatePath(category_id, (String.IsNullOrEmpty(_default_post_page) == true ? Request.Url.AbsoluteUri:_default_post_page)); #region verify access right //verify access right int iAccessLevel = LegoWebSite.Buslgic.MetaContents.get_ACCESS_LEVEL(meta_content_id); switch (iAccessLevel) { case 1: //need logedin if (!Page.User.Identity.IsAuthenticated) { this.litContentBrowserContent.Text = "<span><b>Only registered users can view details</b></span>"; return; } break; case 2: if (!Page.User.Identity.IsAuthenticated) { this.litContentBrowserContent.Text = "<span><b>Only registered users can view details</b></span>"; return; } else //verify user roles { string[] sAllowAccessRoles = LegoWebSite.Buslgic.MetaContents.get_ACCESS_ROLES(meta_content_id); string[] sUserRoles = Roles.GetRolesForUser(Page.User.Identity.Name); bool bAllowAccess = false; if (sUserRoles != null && sUserRoles.Length > 0 && sAllowAccessRoles != null && sAllowAccessRoles.Length > 0) { for (int x = 0; x < sUserRoles.Length; x++) { for (int y = 0; y < sAllowAccessRoles.Length; y++) { if (sUserRoles[x] == sAllowAccessRoles[y]) { bAllowAccess = true; break; } } if (bAllowAccess) { break; } } } if (!bAllowAccess) { this.litContentBrowserContent.Text = "<span><b>You are not authorized to view details</b></span>"; return; } } break; } #endregion verify access right //auhorized //Display Content Details CRecord myRec = new CRecord(); myRec.load_Xml(LegoWebSite.Buslgic.MetaContents.get_META_CONTENT_MARCXML(meta_content_id, 1)); string sTemplateFileName = LegoWebSite.DataProvider.FileTemplateDataProvider.get_XsltTemplateFile(LegoWebSite.Buslgic.Categories.get_CATEGORY_TEMPLATE_NAME(category_id)); //find linked contents list CDatafields Dfs = myRec.Datafields; Dfs.Filter("780"); int iLinkedCount = Dfs.Count; int[] linkedIDs = new int[iLinkedCount + 1]; UrlQuery linkPost = new UrlQuery(); if (!String.IsNullOrEmpty(_default_post_page)) { linkPost = new UrlQuery(_default_post_page); } for (int i = 0; i < iLinkedCount; i++) { linkedIDs[i] = int.Parse(Dfs.Datafield(i).Subfields.Subfield("w").Value); //change link content id to link url linkPost.Set("contentid", linkedIDs[i].ToString()); Dfs.Datafield(i).Subfields.Subfield("w").Value = linkPost.AbsoluteUri; } this.litContentBrowserContent.Text = myRec.XsltFile_Transform(sTemplateFileName); //increase read count LegoWebSite.Buslgic.MetaContents.increase_READ_COUNT(meta_content_id); //exception ids linkedIDs[iLinkedCount] = meta_content_id;//last id is current meta_content_id DataTable relData = LegoWebSite.Buslgic.MetaContents.get_TOP_RELATED_CONTENTS(category_id, _number_of_record, sLangCode, linkedIDs); if (relData.Rows.Count > 0) { CRecords outRecs = new CRecords(); sTemplateFileName = LegoWebSite.DataProvider.FileTemplateDataProvider.get_XsltTemplateFile(_related_content_template); for (int i = 0; i < relData.Rows.Count; i++) { meta_content_id = (int)relData.Rows[i]["META_CONTENT_ID"]; myRec.load_Xml(LegoWebSite.Buslgic.MetaContents.get_META_CONTENT_MARCXML(meta_content_id, 1)); linkPost.Set("contentid", meta_content_id.ToString()); myRec.Controlfields.Controlfield("001").Value = linkPost.AbsoluteUri; outRecs.Add(myRec); } this.litRelatedContentContent.Text = outRecs.XsltFile_Transform(sTemplateFileName); } else { this.litRelatedContentContent.Text = ""; } } }
public static DataTable get_PollData(int iPollContentId, out string sQuestion, out int iTotalVoteCount) { iTotalVoteCount = 0; sQuestion = null; DataTable pollData = new DataTable(); DataColumn IDcol = new DataColumn("ID"); IDcol.DataType = System.Type.GetType("System.Int32"); pollData.Columns.Add(IDcol); DataColumn voteCountCol = new DataColumn("VoteCount"); voteCountCol.DataType = System.Type.GetType("System.Int32"); pollData.Columns.Add(voteCountCol); DataColumn ChoiceCol = new DataColumn("Choice"); ChoiceCol.DataType = System.Type.GetType("System.String"); pollData.Columns.Add(ChoiceCol); DataColumn orderCol = new DataColumn("OrderNumber"); orderCol.DataType = System.Type.GetType("System.Int32"); pollData.Columns.Add(orderCol); CRecord pollRecord = new CRecord(); CDatafield Df = new CDatafield(); CSubfield Sf = new CSubfield(); pollRecord.load_Xml(LegoWebSite.Buslgic.MetaContents.get_META_CONTENT_MARCXML(iPollContentId, 0)); pollRecord.Sort(); //get Question First sQuestion = pollRecord.Datafields.Datafield("245").Subfields.Subfield("a").Value; CDatafields ChoiceDfs = pollRecord.Datafields; ChoiceDfs.Filter("650"); for (int i = 0; i < ChoiceDfs.Count; i++) { string sChoice = ""; int iID = 0; int iVoteCount = 0; int iOrderNumber = 0; Df = ChoiceDfs.Datafield(i); if (Df.Subfields.get_Subfield("0", ref Sf)) { iOrderNumber = String.IsNullOrEmpty(Sf.Value)?0:int.Parse(Sf.Value); } if (Df.Subfields.get_Subfield("a", ref Sf)) { sChoice = Sf.Value; iID = int.Parse(Sf.ID); } else { sChoice = "No choice info"; } if (Df.Subfields.get_Subfield("n", ref Sf)) { iTotalVoteCount += int.Parse(Sf.Value); iVoteCount = int.Parse(Sf.Value); } DataRow row = pollData.NewRow(); row["ID"] = iID; row["Choice"] = sChoice; row["VoteCount"] = iVoteCount; row["OrderNumber"] = iOrderNumber; pollData.Rows.Add(row); } pollData.DefaultView.Sort = " OrderNumber ASC"; return(pollData); }