Exemplo n.º 1
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            List <TimeZoneInfo> tzis = TimeZoneInfo.GetSystemTimeZones().ToList();
            DateTime            dt   = DateTime.Now;// Need local time

            bool showDefault = PropData.GetAdditionalAttributeValue("ShowDefault", true);

            List <SelectionItem <string> > list;

            if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows))
            {
                list = (
                    from tzi in tzis orderby tzi.DisplayName
                    orderby tzi.DisplayName
                    select
                    new SelectionItem <string> {
                    Text = tzi.DisplayName,
                    Value = tzi.Id,
                    Tooltip = tzi.IsDaylightSavingTime(dt) ? tzi.DaylightName : tzi.StandardName,
                }).ToList <SelectionItem <string> >();
            }
            else
            {
                try {
                    model = TZConvert.WindowsToIana(model);
                } catch (Exception) {
                    model = null;
                }
                tzis = (from tzi in tzis orderby tzi.BaseUtcOffset, tzi.Id select tzi).ToList();

                list = new List <SelectionItem <string> >();
                foreach (TimeZoneInfo tzi in tzis)
                {
                    TimeSpan ts   = tzi.BaseUtcOffset;
                    int      h    = ts.Hours;
                    string   disp = $"(UTC{(h > 0 ? "+" : "-")}{Math.Abs(h):00}:{ts.Minutes:00}) {tzi.Id}";
                    list.Add(new SelectionItem <string> {
                        Text    = disp,
                        Value   = tzi.Id,
                        Tooltip = tzi.IsDaylightSavingTime(dt) ? tzi.DaylightName : tzi.StandardName,
                    });
                }
            }

            if (showDefault)
            {
                if (string.IsNullOrWhiteSpace(model))
                {
                    model = TimeZoneInfo.Local.Id;
                }
            }
            else
            {
                list.Insert(0, new SelectionItem <string> {
                    Text = __ResStr("select", "(select)"), Value = ""
                });
            }

            return(await DropDownListComponent.RenderDropDownListAsync(this, model, list, "yt_timezone"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            // get all available skins
            SkinAccess skinAccess = new SkinAccess();
            List <SelectionItem <string> > list = (from theme in await skinAccess.GetJQueryThemeListAsync() select new SelectionItem <string>()
            {
                Text = theme.Name,
                Tooltip = theme.Description,
                Value = theme.Name,
            }).ToList();

            bool useDefault = !PropData.GetAdditionalAttributeValue <bool>("NoDefault");

            if (useDefault)
            {
                list.Insert(0, new SelectionItem <string> {
                    Text    = __ResStr("default", "(Site Default)"),
                    Tooltip = __ResStr("defaultTT", "Use the site defined default theme"),
                    Value   = "",
                });
            }
            else if (model == null)
            {
                model = await SkinAccess.GetJQueryUIDefaultSkinAsync();
            }

            // display the skins in a drop down
            return(await DropDownListComponent.RenderDropDownListAsync(this, model, list, "yt_jqueryuiskin"));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(UrlTypeEnum model)
        {
            List <SelectionItem <string> > items = new List <SelectionItem <string> >();

            if ((model & UrlTypeEnum.Local) != 0)
            {
                items.Add(new SelectionItem <string> {
                    Text    = this.__ResStr("selLocal", "Designed Page"),
                    Value   = ((int)UrlTypeEnum.Local).ToString(),
                    Tooltip = this.__ResStr("selLocalTT", "Select for local, designed pages"),
                });
            }
            if ((model & UrlTypeEnum.Remote) != 0)
            {
                items.Add(new SelectionItem <string> {
                    Text    = this.__ResStr("selRemote", "Local/Remote Url"),
                    Value   = ((int)UrlTypeEnum.Remote).ToString(),
                    Tooltip = this.__ResStr("selRemoteTT", "Select to enter a Url (local or remote) - Can contain query string arguments - Local Urls start with /, remote Urls with http:// or https://"),
                });
            }
            if ((model & UrlTypeEnum.New) != 0)
            {
                throw new InternalError("New url not supported by this template");
            }

            return(await DropDownListComponent.RenderDropDownListAsync(this, model.ToString(), items, "yt_urltype"));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(Guid?model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            // dropdown
            List <SelectionItem <string> > list;

            list = (
                from p in await PageDefinition.GetDesignedPagesAsync() orderby p.Url select
                new SelectionItem <string> {
                Text = p.Url,
                Value = p.PageGuid.ToString(),
            }).ToList <SelectionItem <string> >();
            list.Insert(0, new SelectionItem <string> {
                Text = __ResStr("select", "(select)"), Value = null
            });

            string ddList = await DropDownListComponent.RenderDropDownListAsync(this, (model ?? Guid.Empty).ToString(), list, null);

            // link
            YTagBuilder tag = new YTagBuilder("a");

            PageDefinition page = null;

            if (model != null)
            {
                page = await PageDefinition.LoadAsync((Guid)model);
            }

            tag.MergeAttribute("href", (page != null ? page.EvaluatedCanonicalUrl : ""));
            tag.MergeAttribute("target", "_blank");
            tag.MergeAttribute("rel", "nofollow noopener noreferrer");
            tag.Attributes.Add(Basics.CssTooltip, __ResStr("linkTT", "Click to preview the page in a new window - not all pages can be displayed correctly and may require additional parameters"));

            tag.InnerHtml = tag.InnerHtml + ImageHTML.BuildKnownIcon("#PagePreview", sprites: Info.PredefSpriteIcons);
            string linkTag = tag.ToString(YTagRenderMode.Normal);

            hb.Append($@"
<div id='{DivId}' class='yt_pageselection t_edit'>
    <div class='t_select'>
        {ddList.ToString()}
    </div>
    <div class='t_link'>
        {linkTag}
    </div>
    <div class='t_description'>
    </div>
</div>");

            Manager.ScriptManager.AddLast($@"new YetaWF_ComponentsHTML.PageSelectionEditComponent('{DivId}');");

            return(hb.ToString());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            ModuleSkinList modSkins             = GetSiblingProperty <ModuleSkinList>($"{PropertyName}_ModuleSkinList");
            List <SelectionItem <string> > list = (from l in modSkins select new SelectionItem <string>()
            {
                Text = l.Name,
                Tooltip = l.Description,
                Value = l.CssClass,
            }).ToList();

            return(await DropDownListComponent.RenderDropDownListAsync(this, model, list, null));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            // get all available page skins for this collection
            SkinAccess   skinAccess             = new SkinAccess();
            string       collection             = GetSiblingProperty <string>($"{PropertyName}_Collection");
            PageSkinList skinList               = skinAccess.GetAllPageSkins(collection);
            List <SelectionItem <string> > list = (from skin in skinList orderby skin.Description select new SelectionItem <string>()
            {
                Text = skin.Name,
                Tooltip = skin.Description,
                Value = skin.PageViewName,
            }).ToList();

            // display the skins in a drop down
            return(await DropDownListComponent.RenderDropDownListAsync(this, model, list, "yt_skinname"));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            bool includeSiteCountry = PropData.GetAdditionalAttributeValue <bool>("SiteCountry", true);
            List <CountryISO3166.Country> countries = CountryISO3166.GetCountries(IncludeSiteCountry: includeSiteCountry);

            List <SelectionItem <string> > list = (from l in countries select new SelectionItem <string>()
            {
                Text = l.Name,
                Value = l.Id,
            }).ToList();

            list.Insert(0, new SelectionItem <string> {
                Text  = this.__ResStr("default", "(select)"),
                Value = "",
            });
            return(await DropDownListComponent.RenderDropDownListAsync(this, model, list, "yt_countryiso3166id"));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            List <SelectionItem <string> > states = await CAProvince.ReadProvincesListAsync();

            bool useDefault = !PropData.GetAdditionalAttributeValue <bool>("NoDefault");

            if (useDefault)
            {
                states = (from s in states select s).ToList();//copy
                states.Insert(0, new SelectionItem <string> {
                    Text    = __ResStr("default", "(select)"),
                    Tooltip = __ResStr("defaultTT", "Please make a selection"),
                    Value   = "",
                });
            }
            return(await DropDownListComponent.RenderDropDownListAsync(this, model, states, "yt_caprovince"));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            bool includeSiteCurrency = PropData.GetAdditionalAttributeValue <bool>("SiteCurrency", true);

            List <CurrencyISO4217.Currency> currencies = await CurrencyISO4217.GetCurrenciesAsync(IncludeSiteCurrency : includeSiteCurrency);

            List <SelectionItem <string> > list = (from l in currencies select new SelectionItem <string>()
            {
                Text = l.Name,
                Value = l.Id,
            }).ToList();

            list.Insert(0, new SelectionItem <string> {
                Text  = __ResStr("default", "(select)"),
                Value = "",
            });
            return(await DropDownListComponent.RenderDropDownListAsync(this, model, list, "yt_currencyiso4217"));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            List <string> list;

            if (!TryGetSiblingProperty($"{PropertyName}_List", out list))
            {
                list = new List <string>();
            }
            List <SelectionItem <string> > itemList = new List <SelectionItem <string> >();

            foreach (string l in list)
            {
                itemList.Add(new SelectionItem <string> {
                    Text  = l,
                    Value = l,
                });
            }
            return(await DropDownListComponent.RenderDropDownListAsync(this, model, itemList, "yt_paneselection"));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            bool useDefault   = !PropData.GetAdditionalAttributeValue <bool>("NoDefault");
            bool allLanguages = PropData.GetAdditionalAttributeValue <bool>("AllLanguages");

            List <SelectionItem <string> > list;

            if (allLanguages)
            {
                CultureInfo[] ci = CultureInfo.GetCultures(CultureTypes.AllCultures);
                list = (from c in ci orderby c.DisplayName select new SelectionItem <string>()
                {
                    Text = string.Format("{0} - {1}", c.DisplayName, c.Name),
                    Value = c.Name,
                }).ToList();
            }
            else
            {
                list = (from l in MultiString.Languages select new SelectionItem <string>()
                {
                    Text = l.ShortName,
                    Tooltip = l.Description,
                    Value = l.Id,
                }).ToList();
            }
            if (useDefault)
            {
                list.Insert(0, new SelectionItem <string> {
                    Text    = this.__ResStr("default", "(Site Default)"),
                    Tooltip = this.__ResStr("defaultTT", "Use the site defined default language"),
                    Value   = "",
                });
            }
            else
            {
                if (string.IsNullOrWhiteSpace(model))
                {
                    model = MultiString.ActiveLanguage;
                }
            }
            // display the languages in a drop down
            return(await DropDownListComponent.RenderDropDownListAsync(this, model, list, "yt_languageid"));
        }
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(Guid?model)
        {
            model = model ?? Guid.Empty;
            string areaName = await ModuleSelectionModuleNewEditComponent.GetAreaNameFromGuidAsync(false, model);

            List <SelectionItem <string> > list = (
                from module in await DesignedModules.LoadDesignedModulesAsync()
                where module.AreaName == areaName
                orderby module.Name select
                new SelectionItem <string> {
                Text = module.Name,
                Value = module.ModuleGuid.ToString(),
                Tooltip = module.Description,
            }).ToList <SelectionItem <string> >();

            list.Insert(0, new SelectionItem <string> {
                Text = this.__ResStr("none", "(none)"), Value = null
            });
            return(await DropDownListComponent.RenderDropDownListAsync(this, model.ToString(), list, null));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(Guid?model)
        {
            model = model ?? Guid.Empty;
            string areaName = await ModuleSelectionModuleNewEditComponent.GetAreaNameFromGuidAsync(true, model);

            List <SelectionItem <string> > list = (
                from p in InstalledModules.Packages orderby p.Name select
                new SelectionItem <string> {
                Text = this.__ResStr("package", "{0}", p.Name),
                Value = p.AreaName,
                Tooltip = this.__ResStr("packageTT", "{0} - {1}", p.Description.ToString(), p.CompanyDisplayName),
            }).ToList <SelectionItem <string> >();

            list = (from l in list orderby l.Text select l).ToList();
            list.Insert(0, new SelectionItem <string> {
                Text = this.__ResStr("selectPackage", "(select)"), Value = null
            });

            return(await DropDownListComponent.RenderDropDownListAsync(this, areaName, list, null));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            List <string> pages = await PageDefinition.GetDesignedUrlsAsync();

            // get list of desired pages (ignore users that are invalid, they may have been deleted)
            List <SelectionItem <string> > list = new List <SelectionItem <string> >();

            foreach (var page in pages)
            {
                list.Add(new SelectionItem <string> {
                    Text = page,
                    //Tooltip = __ResStr("selPage", "Select page {0}", page),
                    Value = page,
                });
            }
            list = (from l in list orderby l.Text select l).ToList();
            list.Insert(0, new SelectionItem <string> {
                Text = __ResStr("select", "(select)"), Value = ""
            });

            return(await DropDownListComponent.RenderDropDownListAsync(this, model, list, "yt_urldesignedpage"));
        }
Exemplo n.º 15
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            // get all available skins
            SkinAccess skinAccess = new SkinAccess();
            List <SelectionItem <string> > list = (from skinColl in skinAccess.GetAllSkinCollections() orderby skinColl.CollectionDescription select new SelectionItem <string>()
            {
                Text = skinColl.CollectionDescription,
                Value = skinColl.CollectionName,
            }).ToList();
            bool useDefault = !PropData.GetAdditionalAttributeValue("NoDefault", false);

            if (useDefault)
            {
                list.Insert(0, new SelectionItem <string> {
                    Text    = __ResStr("siteDef", "(Site Default)"),
                    Tooltip = __ResStr("siteDefTT", "Use the site defined default skin"),
                    Value   = "",
                });
            }
            // display the skins in a drop down
            return(await DropDownListComponent.RenderDropDownListAsync(this, model, list, "yt_skinselection"));
        }
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(Guid?model)
        {
            string areaName = await GetAreaNameFromGuidAsync(true, model);

            model = model ?? Guid.Empty;
            List <SelectionItem <string> > list = new List <SelectionItem <string> >();

            if (!string.IsNullOrWhiteSpace(areaName))
            {
                list = (
                    from module in InstalledModules.Modules
                    where module.Value.Package.AreaName == areaName
                    orderby module.Value.DisplayName.ToString() select
                    new SelectionItem <string> {
                    Text = module.Value.DisplayName.ToString(),
                    Value = module.Key.ToString(),
                    Tooltip = module.Value.Summary,
                }).ToList <SelectionItem <string> >();
            }
            list.Insert(0, new SelectionItem <string> {
                Text = __ResStr("none", "(none)"), Value = null
            });
            return(await DropDownListComponent.RenderDropDownListAsync(this, model.ToString(), list, null));
        }