コード例 #1
0
ファイル: Plugins.ascx.cs プロジェクト: skamphuis/NBrightBuy
        override protected 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.RemoveDeletedSystemPlugins();
                    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);
            }
        }