Esempio n. 1
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (!Engine.Config.Sections.Management.Organize.UseLegacyControlPanel)
            {
                var cph = new Mvc.Html.ControlPanelExtensions.ControlPanelHelper(Engine, CurrentItem, writer, Page.Items["StateCollection"] as HashSet <string> ?? (Page.Items["StateCollection"] = new HashSet <string>()) as HashSet <string>);
                cph.Render();
                return;
            }

            IDictionary <string, IList <string> > arrays = GetArrays(Page);

            writer.WriteLineNoTabs(@"<script type='text/javascript'>//<!--");
            if (arrays.Count > 0)
            {
                foreach (var pair in arrays)
                {
                    IList <string> array = pair.Value;
                    writer.Write("var " + pair.Key + " = [" + array[0]);
                    for (int i = 1; i < array.Count; i++)
                    {
                        writer.Write("," + array[i]);
                    }
                    writer.WriteLineNoTabs("];");
                }
            }
            if (EnableEditInterfaceIntegration)
            {
                writer.WriteLineNoTabs("if(window.n2ctx){");
                writer.WriteLineNoTabs("n2ctx.select('preview');");
                if (CurrentItem != null)
                {
                    var    adapter       = Engine.GetContentAdapter <NodeAdapter>(CurrentItem);
                    string navigationUrl = Engine.ManagementPaths.GetNavigationUrl(CurrentItem);
                    string previewUrl    = adapter.GetPreviewUrl(CurrentItem);
                    string script        = string.Format(switchScriptFormat,
                                                         CurrentItem.Path,                                         // 0
                                                         previewUrl,                                               // 1
                                                         navigationUrl,                                            // 2
                                                         adapter.GetMaximumPermission(CurrentItem),                // 3
                                                         (Page.Request["refresh"] == "true").ToString().ToLower(), // 4
                                                         GetState(Page.GetEngine()).ToString());
                    writer.WriteLineNoTabs(script);
                }
                writer.WriteLineNoTabs("}");
            }

            writer.Write(@"//--></script>");

            writer.Write("<div class='controlPanel state" + CurrentItem.State.ToString() + "'>");
            base.Render(writer);
            writer.Write("</div>");
        }
Esempio n. 2
0
        protected override void Render(HtmlTextWriter writer)
        {
			if (!Engine.Config.Sections.Management.Organize.UseLegacyControlPanel)
			{
				var cph = new Mvc.Html.ControlPanelExtensions.ControlPanelHelper(Engine, CurrentItem, writer, Page.Items["StateCollection"] as HashSet<string> ?? (Page.Items["StateCollection"] = new HashSet<string>()) as HashSet<string>);
				cph.Render();
                return;
            }

            IDictionary<string, IList<string>> arrays = GetArrays(Page);
            writer.WriteLineNoTabs(@"<script type='text/javascript'>//<!--");
            if (arrays.Count > 0)
            {
                foreach (var pair in arrays)
                {
                    IList<string> array = pair.Value;
                    writer.Write("var " + pair.Key + " = [" + array[0]);
                    for (int i = 1; i < array.Count; i++)
                    {
                        writer.Write("," + array[i]);
                    }
                    writer.WriteLineNoTabs("];");
                }
            }
            if (EnableEditInterfaceIntegration)
            {
                writer.WriteLineNoTabs("if(window.n2ctx){");
                writer.WriteLineNoTabs("n2ctx.select('preview');");
                if (CurrentItem != null)
                {
                    var adapter = Engine.GetContentAdapter<NodeAdapter>(CurrentItem);
                    string navigationUrl = Engine.ManagementPaths.GetNavigationUrl(CurrentItem);
                    string previewUrl = adapter.GetPreviewUrl(CurrentItem);
                    string script = string.Format(switchScriptFormat, 
                        CurrentItem.Path, // 0
                        previewUrl, // 1
                        navigationUrl, // 2
                        adapter.GetMaximumPermission(CurrentItem), // 3
                        (Page.Request["refresh"] == "true").ToString().ToLower(), // 4
                        GetState(Page.GetEngine()).ToString());
                    writer.WriteLineNoTabs(script);
                }
                writer.WriteLineNoTabs("}");
            }

            writer.Write(@"//--></script>");

            writer.Write("<div class='controlPanel state" + CurrentItem.State.ToString() + "'>");
            base.Render(writer);
            writer.Write("</div>");
		}