Example #1
0
    protected void MainView()
    {
        if (ContentBlockId > -1)
        {
            ContentAPI capi = new ContentAPI();
            PageBuilder page = (Page as PageBuilder);
            if (ContentBlockId > 0)
            {
                contentBlock.DefaultContentID = ContentBlockId;
                if (page != null && page.CacheInterval > 0)
                {
                    contentBlock.CacheInterval = page.CacheInterval;
                }
                contentBlock.Fill();
                if (contentBlock.EkItem != null)
                {
                    if (contentBlock.EkItem.Title != null)
                        _host.Title = contentBlock.EkItem.Title;
                    if (contentBlock.EkItem.AssetInfo != null && contentBlock.EkItem.AssetInfo.FileExtension != null && contentBlock.EkItem.AssetInfo.FileExtension.ToLower() == "flv")
                    {
                        StringBuilder sbflash = new StringBuilder(); //need object tag here
                        sbflash.Append("<embed id=\"ply\" width=\"" + Width + "\" height=\"" + Height + "\"");
                        sbflash.Append("flashvars=\"file=" + contentBlock.EkItem.AssetInfo.FileName);
                        if (ThumbnailID > 0)
                        {
                            ContentRequest req = new ContentRequest();
                            req.ContentType = EkEnumeration.CMSContentType.AllTypes;
                            req.GetHtml = false;
                            req.Ids = ThumbnailID.ToString();
                            req.MaxNumber = 1;
                            req.RetrieveSummary = false;
                            Ektron.Cms.Common.ContentResult imageresult = capi.LoadContentByIds(ref req, Page);
                            if (imageresult != null && imageresult.Count > 0)
                            {
                                sbflash.Append("&image=" + imageresult.Item[0].AssetInfo.FileName);
                            }
                        }
                        else if (Thumbnail != string.Empty)
                        {
                            sbflash.Append("&image=" + Thumbnail);
                        }
                        sbflash.Append("&autostart=" + AutoStart.ToString().ToLower() + "\"");
                        sbflash.Append("allowscriptaccess=\"always\" allowfullscreen=\"true\" quality=\"high\" bgcolor=\"#CCCCCC\" name=\"ply\" style=\"\"");
                        sbflash.Append("src=\"" + sitePath + "/widgets/Flash/player.swf\" wmode=\"transparent\" type=\"application/x-shockwave-flash\"/>");
                        ltrFlash.Text = sbflash.ToString();
                        Ektron.Cms.API.JS.RegisterJSInclude(this, sitePath + "/widgets/flash/swfobject.js", "widgetFlash.js");
                        contentBlock.Visible = false;
                        ltrFlash.Visible = true;
                    }
                    else
                    {
                        //Ektron.Cms.Controls.ContentBlock contentBlock;
                        if (contentBlock.Text != "")
                        {
                            string html = contentBlock.Text;
                            int startwidth = -1, endwidth = -1, startheight = -1, endheight = -1;
                            startwidth = html.IndexOf("width=\"") + 7;
                            if (startwidth > 0)
                            {
                                endwidth = html.IndexOf("px", startwidth);
                            }
                            startheight = html.IndexOf("height=\"") + 8;
                            if (startheight > 0)
                            {
                                endheight = html.IndexOf("px", startheight);
                            }
                            if (startwidth > 0 && endwidth > startwidth && startheight > 0 && endheight > startheight)
                            {
                                string pixelwidth = html.Substring(startwidth, endwidth - startwidth);
                                string pixelheight = html.Substring(startheight, endheight - startheight);
                                int storedheight = 0;
                                int storedwidth = 0;
                                int.TryParse(Width, out storedwidth);
                                int.TryParse(Height, out storedheight);
                                if (storedheight > 0) html = html.Replace(pixelheight, storedheight.ToString());
                                if (storedwidth > 0) html = html.Replace(pixelwidth, storedwidth.ToString());
                            }
                            ltrFlash.Text = html;

                            contentBlock.Visible = false;
                            ltrFlash.Visible = true;
                        }
                    }
                }
            }
        }
        enableResize = true;
    }