Esempio n. 1
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            try
            {

                // check for new plugins
                var pi = new PluginData(PortalId, true);
                pi.UpdateSystemPlugins();
                pi.CheckforNewSystemConfig();

                #region "load templates"

                var t1 = "backoffice.html";

                // Get Display Body
                var dataTempl = ModCtrl.GetTemplateData(ModSettings, t1, Utils.GetCurrentCulture(), DebugMode);
                // insert page header text
                var headerTempl = NBrightBuyUtils.GetGenXmlTemplate(dataTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                NBrightBuyUtils.IncludePageHeaders(ModCtrl, ModuleId, Page, headerTempl, ModSettings.Settings(), null, DebugMode);

                // remove any DNN modules from the BO page
                var tabInfo = PortalSettings.Current.ActiveTab;
                var modCount = tabInfo.Modules.Count;
                for (int i = 0; i < modCount; i++)
                {
                    tabInfo.Modules.RemoveAt(0);
                }

                var aryTempl = Utils.ParseTemplateText(dataTempl);

                foreach (var s in aryTempl)
                {
                    var htmlDecode = System.Web.HttpUtility.HtmlDecode(s);
                    if (htmlDecode != null)
                    {
                        switch (htmlDecode.ToLower())
                        {
                            case "<tag:menu>":
                                var c1 = LoadControl(ControlPath + "/Menu.ascx");
                                phData.Controls.Add(c1);
                                break;
                            case "<tag:container>":
                                var c2 = LoadControl(ControlPath +  "/Container.ascx");
                                phData.Controls.Add(c2);
                                break;
                            default:
                                var lc = new Literal {Text = s};
                                phData.Controls.Add(lc);
                                break;
                        }
                    }
                }

                #endregion

            }
            catch (Exception exc)
            {
                //display the error on the template (don;t want to log it here, prefer to deal with errors directly.)
                var l = new Literal();
                l.Text = exc.ToString();
                phData.Controls.Add(l);
            }
        }
Esempio n. 2
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            try
            {
                #region "set templates based on entry id (eid) from url"

                _entryid = Utils.RequestQueryStringParam(Context, "eid");

                var pluginTemplate = "";

                if (Utils.IsNumeric(_entryid))
                {
                    _displayentrypage = true;
                    // check if we have bespoke setting that need adding to the template
                    var pluginData = new PluginData(PortalId);
                    var pData = pluginData.GetPlugin(Convert.ToInt32(_entryid));
                    var pluginTemplatePath = pData.GetXmlProperty("genxml/hidden/plugintemplate");
                    if (pluginTemplatePath != "") pluginTemplate = Utils.ReadFile(MapPath(pluginTemplatePath));
                }
                else
                {
                    // check for new plugins
                    var pi = new PluginData(PortalId, true);
                    pi.UpdateSystemPlugins();
                }

                #endregion

                #region "load templates"

                var t1 = "pluginsheader.html";
                var t2 = "pluginsbody.html";
                var t3 = "pluginsfooter.html";

                if (Utils.IsNumeric(_entryid))
                {
                    t1 = "pluginsdetailheader.html";
                    t2 = "pluginsdetail.html";
                    t3 = "pluginsdetailfooter.html";
                }

                // Get Display Header
                var rpDataHTempl = ModCtrl.GetTemplateData(ModSettings, t1, Utils.GetCurrentCulture(), DebugMode);
                rpDataH.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                // Get Display Body
                var rpDataTempl = ModCtrl.GetTemplateData(ModSettings, t2, Utils.GetCurrentCulture(), DebugMode);
                rpDataTempl = rpDataTempl.Replace("[Template:PluginTemplate]", pluginTemplate); // replace special plugin settings
                rpData.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                // Get Display Footer
                var rpDataFTempl = ModCtrl.GetTemplateData(ModSettings, t3, Utils.GetCurrentCulture(), DebugMode);
                rpDataF.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataFTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                #endregion

            }
            catch (Exception exc)
            {
                //display the error on the template (don't want to log it here, prefer to deal with errors directly.)
                var l = new Literal();
                l.Text = exc.ToString();
                phData.Controls.Add(l);
            }
        }
Esempio n. 3
0
        protected override void OnLoad(EventArgs e)
        {
            try
            {
                base.OnLoad(e);
                if (Page.IsPostBack == false)
                {
                    #region "Check for plugins"

                    var pluginData = new PluginData(PortalId, true);
                    pluginData.UpdateSystemPlugins();
                    _systemPlugins = pluginData.GetPluginList();

                    pluginData = new PluginData(PortalId);
                    var portalPlugins = pluginData.GetPluginList();
                    Boolean upd = false;
                    foreach (var p in _systemPlugins)
                    {
                        var ctrllist = from i in portalPlugins where i.GetXmlProperty("genxml/textbox/ctrl") == p.GetXmlProperty("genxml/textbox/ctrl") select i;
                        var nBrightInfos = ctrllist as IList<NBrightInfo> ?? ctrllist.ToList();
                        if (!nBrightInfos.Any())
                        {
                            pluginData.AddPlugin(p);
                            upd = true;
                        }
                    }
                    if (upd) pluginData.Save();

                    #endregion

                    PageLoad();
                }
            }
            catch (Exception exc) //Module failed to load
            {
                //display the error on the template (don;t want to log it here, prefer to deal with errors directly.)
                var l = new Literal();
                l.Text = exc.ToString();
                phData.Controls.Add(l);
            }
        }