using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ScrewTurn.Wiki.PluginFramework;
using System.Text;
namespace ScrewTurn.Wiki {
public partial class MasterPageSA : System.Web.UI.MasterPage {
private string currentNamespace = null;
protected void Page_Load(object sender, EventArgs e) {
// Try to detect current namespace
currentNamespace = Tools.DetectCurrentNamespace();
lblStrings.Text = string.Format("",
CphMasterSA.ClientID + "_", Properties.Messages.ConfirmOperation);
string nspace = currentNamespace;
if(string.IsNullOrEmpty(nspace)) nspace = "";
else nspace += ".";
lnkMainPage.NavigateUrl = nspace + "Default.aspx";
if(!Page.IsPostBack) {
string referrer = Request.UrlReferrer != null ? Request.UrlReferrer.ToString() : "";
if(!string.IsNullOrEmpty(referrer)) {
lnkPreviousPage.Visible = true;
lnkPreviousPage.NavigateUrl = referrer;
}
else lnkPreviousPage.Visible = false;
}
PrintHtmlHead();
PrintHeader();
PrintFooter();
}
///
/// Prints the HTML head tag.
///
public void PrintHtmlHead() {
Literal c = new Literal();
c.Text = Tools.GetIncludes(Tools.DetectCurrentNamespace());
Page.Header.Controls.Add(c);
}
///
/// Gets the pseudo-cache item name based on the current namespace.
///
/// The item name.
/// The namespace-qualified item name.
private string GetPseudoCacheItemName(string name) {
if(currentNamespace == null) return name;
else return currentNamespace + "." + name;
}
///
/// Prints the header.
///
public void PrintHeader() {
string h = Content.GetPseudoCacheValue(GetPseudoCacheItemName("Header"));
if(h == null) {
h = FormattingPipeline.FormatWithPhase1And2(Settings.Provider.GetMetaDataItem(MetaDataItem.Header, currentNamespace),
false, FormattingContext.Header, null);
Content.SetPseudoCacheValue(GetPseudoCacheItemName("Header"), h);
}
lblHeaderDiv.Text = FormattingPipeline.FormatWithPhase3(h, FormattingContext.Header, null);
}
///
/// Prints the footer.
///
public void PrintFooter() {
string f = Content.GetPseudoCacheValue(GetPseudoCacheItemName("Footer"));
if(f == null) {
f = FormattingPipeline.FormatWithPhase1And2(Settings.Provider.GetMetaDataItem(MetaDataItem.Footer, currentNamespace),
false, FormattingContext.Footer, null);
Content.SetPseudoCacheValue(GetPseudoCacheItemName("Footer"), f);
}
lblFooterDiv.Text = FormattingPipeline.FormatWithPhase3(f, FormattingContext.Footer, null);
}
}
}